[Gmsh] Doubts about Merge files

Christophe Geuzaine cgeuzaine at ulg.ac.be
Fri Apr 5 22:41:06 CEST 2013


On 05 Apr 2013, at 22:31, Bruno Correia da Silva <bcs2 at cin.ufpe.br> wrote:

> Greetings Prof. Geuzaine,
> 
> Thanks for the answer.
> In my case, i wanted fuse the two mesh. My grid needs to be continue.
> About your tips, i did make this change in code and run with same mesh
> send before:
> 
> else if (argc >2){
>    GmshSetOption("General", "Terminal", 1.);
>    GModel *m = new GModel();
>    m->readMSH(argv[1]);//mesh1.msh
>    GmshMergeFile(argv[2]);//mesh2.msh
>    m->removeDuplicateMeshVertices(0.001);
>    m->writeMSH("test.msh", 1.0);
>    delete m;
>  }
> 
> And show me this errors:
> "
> Info    : 76 vertices
> Info    : Vertex numbering is dense
> Info    : 153 elements
> Info    : Reading 'M2.msh'...
> Info    : 76 vertices
> Info    : Vertex numbering is dense
> Info    : 153 elements
> Info    : Done reading 'M2.msh'
> Info    : Removing duplicate mesh vertices...
> Error   : Could not find vertex (0,10,0) (tol 0.0141421)
> Error   : Could not recreate element 12
> Error   : Could not find vertex (0,10,0) (tol 0.0141421)
> Error   : Could not recreate element 13
> Error   : Could not find vertex (0,10,0) (tol 0.0141421)
> Error   : Could not recreate element 63
> Error   : Could not find vertex (0,10,0) (tol 0.0141421)
> Error   : Could not recreate element 64
> Info    : Removed 13 duplicate mesh vertices
> Info    : Done removing duplicate mesh vertices
> 
> I can't understand why this element cannot be found and recreated.
> I don't use tags. This two mesh was generated by GMSH.
> 
> One more question: Doesn't GMSH make this fuse in mesh?
> 

No, in order to fuse the meshes you'll need to have the vertices/elements with different tags in both files. Another solution is to merge "untagged" meshes (e.g. STL).


> Thanks for help,
> 
> Att.
> 
> 
> 2013/4/5 Christophe Geuzaine <cgeuzaine at ulg.ac.be>:
>> 
>> On 26 Mar 2013, at 21:25, Bruno Correia da Silva <bcs2 at cin.ufpe.br> wrote:
>> 
>>> Hi everyone,
>>> 
>>> I am using of GMSH  to make merge in meshes.
>>> I did this cpp:
>>> 
>> 
>> Merge simply adds everything in the same model: in your case this results in an invalid resulting mesh (you can reproduce the same behavior in the GUI). To fuse two grids, you would need to make sure they don't contain entities with clashing tags, then remove the duplicate vertices (m->removeDuplicateMeshVertices()).
>> 
>>> 
>>> #include <stdio.h>
>>> #include "Gmsh.h"
>>> #include "GModel.h"
>>> #include "MElement.h"
>>> 
>>> #include <iostream>
>>> using namespace std;
>>> #include <stdio.h>
>>> #include <string.h>
>>> 
>>> int main(int argc, char **argv)
>>> {
>>> GmshInitialize(argc, argv);
>>> if(argc ==1){
>>>              GmshSetOption("General", "Terminal", 1.);
>>>       char str[80];
>>>       strcpy (str,argv[1]);
>>>       strcat (str,".msh");
>>>              GModel *m = new GModel();
>>>       m->readGEO(argv[1]);
>>>       m->mesh(3);
>>>       m->writeMSH(str, 1.0);
>>>       delete m;
>>> }
>>> else if (argc >2){
>>>   GmshSetOption("General", "Terminal", 1.);
>>>   GModel *m = new GModel();
>>>   m->readMSH(argv[1]);//mesh1.msh
>>>   GmshMergeFile(argv[2]);//mesh2.msh
>>>   m->writeMSH("test.msh", 1.0);
>>>   delete m;
>>> }
>>> GmshFinalize();
>>> }
>>> 
>>> The GMSH show me this error when i try open the test.msh:
>>> Error  Wrong vertex index 0
>>> Error Error loading 'test.msh'
>>> 
>>> The two input files are attached.
>>> 
>>> Some clues to correct this?
>>> 
>>> att.
>>> Bruno Correia
>>> <M1.msh><M2.msh>_______________________________________________
>>> gmsh mailing list
>>> gmsh at geuz.org
>>> http://www.geuz.org/mailman/listinfo/gmsh
>> 
>> --
>> Prof. Christophe Geuzaine
>> University of Liege, Electrical Engineering and Computer Science
>> http://www.montefiore.ulg.ac.be/~geuzaine
>> 
>> 
>> 

-- 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine







More information about the gmsh mailing list