[Gmsh] Extruded meshes

mb mi.benham at free.fr
Tue May 1 10:10:41 CEST 2007


Hello,

I needed to mesh to mesh a 3D volume by surface extrusion, unfortunatly
it failed because of swapping algorithm. So i made a few modifications
in the code so that extrusion will always work without recombining.
The modifications are made in Mesh/meshGRegionExtuded.cpp, in the method
named phase1. Here is the new code (added also in attachment):

void phase1(GRegion *gr,
	    std::set<MVertex*, MVertexLessThanLexicographic> &pos,
	    std::set<std::pair<MVertex*, MVertex*> > &edges)
{
  ExtrudeParams *ep = gr->meshAttributes.extrude;
  GFace *from = gr->model()->faceByTag(std::abs(ep->geo.Source));
  if(!from) return;
  for(unsigned int i = 0; i < from->triangles.size(); i++){
    for(int j = 0; j < ep->mesh.NbLayer; j++) {
      for(int k = 0; k < ep->mesh.NbElmLayer[j]; k++) {
	   std::vector<MVertex*> v;
// modification_mb
	   if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, v) == 6){
       int v0 = 0;
       int l;
       for(l = 1; l < 6; l++){
        if(v[l] < v[v0]) v0 = l;
       }
       v0 = (v0 + 2) % 3;
       int vn[6];
       for(l = 0; l < 3; l++){
         vn[l] = (v0 + l) % 3;
         vn[l + 3] = vn[l] + 3;
       }
//       Msg(STATUS2, "v[vn[0,1,2] %d %d %d ", v[vn[0]], v[vn[1]],
v[vn[2]]);
	  if(!edgeExists(v[vn[0]], v[vn[4]], edges))
	    createEdge(v[vn[1]], v[vn[3]], edges);
//        Msg(STATUS2, " 1 1-3 v[vn[1]], v[vn[3]] %d %d  ", v[vn[1]],
v[vn[3]]);
	  if(!edgeExists(v[vn[4]], v[vn[2]], edges))
	    createEdge(v[vn[1]], v[vn[5]], edges);
      if(v[vn[0]] < v[vn[3]]){
	   if(!edgeExists(v[vn[3]], v[vn[2]], edges))
	    createEdge(v[vn[0]], v[vn[5]], edges);
//       Msg(STATUS2, " 2 0-5 v[vn[0]], v[vn[5]] %d %d  ", v[vn[0]],
v[vn[5]]);
      }
      else{
	   if(!edgeExists(v[vn[0]], v[vn[5]], edges))
	     createEdge(v[vn[3]], v[vn[2]], edges);
//     Msg(STATUS2, " 2 3-2 v[vn[3]], v[vn[2]] %d %d  ", v[vn[3]],
v[vn[2]]);
      }
	}
//end modification_mb
      }
    }
  }
}

The idea is simply adding classical lowest index ordering. I hope it
will help other users.

Thanks for your great work.

Michel Benhamou, Paris.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: meshGRegionExtruded.cpp
Type: text/x-c++src
Size: 16657 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20070501/0970170a/attachment.cpp>