[Gmsh] Removing duplicates

sebastian.eiser at k-ai.at sebastian.eiser at k-ai.at
Tue Sep 30 10:50:53 CEST 2014


To merge nodes, use the following command:

Geometry.Tolerance = 1e-3; // adjust value here for correct merge result
Coherence Mesh;

By default, the nodes in the surface with lower surface/volume number will survive. If you want the opposite, you can either assign different numbers to them or apply this change which reverses the order. I had to do this once.

Index: Geo/GModel.cpp
===================================================================
--- Geo/GModel.cpp  (revision 18255)
+++ Geo/GModel.cpp  (working copy)
@@ -1556,14 +1556,21 @@
   double eps = lc * tolerance;
   std::vector<GEntity*> entities;
-  getEntities(entities);
+  getEntities(entities); // list of msh groups (tags)
   std::vector<MVertex*> vertices;
-  for(unsigned int i = 0; i < entities.size(); i++)
-    for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++){
-      MVertex *v = entities[i]->mesh_vertices[j];
+  unsigned int esize (entities.size());
+  for(unsigned int i = 0; i < esize; i++) { // using inverse ordering to avoid moving vertices.
+    for(unsigned int j = 0; j < entities[esize-1-i]->mesh_vertices.size(); j++){
+      MVertex *v = entities[esize-1-i]->mesh_vertices[j];
       vertices.push_back(new MVertex(v->x(), v->y(), v->z()));
     }
+  }
   MVertexPositionSet pos(vertices);
   for(unsigned int i = 0; i < vertices.size(); i++)
     pos.find(vertices[i]->x(), vertices[i]->y(), vertices[i]->z(), eps);



From: gmsh [mailto:gmsh-bounces at ace20.montefiore.ulg.ac.be] On Behalf Of Prof. Antonello Uva
Sent: 19 September, 2014 12:37
To: gmsh at geuz.org
Subject: [Gmsh] Removing duplicates


Dear All,
I need to mesh 2 volumes (to be filled with two materials) sharing a surface boundary: "pieno" and "vuoto"
I modeled the geometry in an external CAD and imported them in Gmsh as two .step volumes.
I meshed everything correctly, but I have duplicated nodes (because of duplicate geometry) on the interface (boundary surface).
Is there a way to remove duplicates (which are numerically concident) from script? Either remove duplicates on the geometry or in the mesh will work.
Here I attach my script and step files:

Merge "pieno.step";
Merge "vuoto.step";

Mesh.CharacteristicLengthExtendFromBoundary = 0;
Mesh.CharacteristicLengthFactor = 0.5;
Mesh.CharacteristicLengthMin = 0.4;
Mesh.CharacteristicLengthMax = 20;
Mesh.CharacteristicLengthFromCurvature = 0;
Mesh.CharacteristicLengthFromPoints = 1;

Coherence;

Physical Volume("pieno") = {1};
Physical Volume("vuoto") = {2};


Thank you again for support and for the possibility to use this program.
Regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20140930/0f610858/attachment.html>