Hello

Please find attached a patch to implement the AlternateLeft and AlternateRight 
options in transfinite surfaces.

It would be apparently sufficient to change Gmsh.y and 
Mesh/meshGFaceTransfinite.cpp, but I also updated the related comments in 
Geo/GFace.h and Geo/Geo.h 

The documentation needs updating (also one line?)

The geo files (with very imaginative names!) that I used for testing are 
included. I also played with "demos/transfinite.geo", by not recombining and by 
specifying the orientation and it seems to "do what is says".

Something else that I missed?

Regards

ZP

On Tuesday 09 July 2013, Christophe Geuzaine wrote:
> On 16 May 2013, at 18:40, Jose Paulo Moitinho de Almeida 
<[email protected]> wrote:
> > I wanted to create a triangular Transfinite Surface mesh , but was not
> > able to control the position of the initial triangle created by gmsh
> > (the corners always have only element, as in 1.png).
> > 
> > After looking at the code I swapped the logic in
> > Mesh/meshGFaceTransfinite.cpp from
> > 
> >                ((i % 2 == 0 && j % 2 == 1) ||
> >                
> >                 (i % 2 == 1 && j % 2 == 0)))){
> > 
> > to
> > 
> >                ((i % 2 == 0 && j % 2 == 0) ||
> >                
> >                  (i % 2 == 1 && j % 2 == 1)))){
> > 
> > and managed to obtain the result that I wanted (in 2.png).
> > 
> > Is there an easier way to achieve this?
> > 
> > If there isn't, it would not be too complicated to include an additional
> > option to Transfinite Surface, so that instead of "Left, Right and
> > Alternate" we could opt between  "Left, Right AlternateLeft and
> > AlternateRight", with Alternate still legal and equivalent to the
> > current option.
> > 
> > I should be able to propose a patch (not now...), but before I start
> > opinions are welcome.
> 
> Hi Jose - That's a good idea: send a patch and I will merge it.
> 
> > Regards
> > 
> > ZP
> > 
> > PS: I also considered the idea of adding an additional option, which
> > would create a mesh where both diagonals are always inserted, so that
> > using
> > 
> > Transfinite Line{1,2,3,4} = 2;
> > Transfinite Surface {6} = {1, 2, 3, 4} "OtherNewOption";
> > 
> > in the attached file, would result in 3.png.
> > 
> > I understand that an additional set of vertices is needed, and this is
> > not so immediate. Would it be too complicated to include them in the
> > code?
> > <square.geo><1.png><2.png><3.png>_______________________________________
> > ________ gmsh mailing list
> > [email protected]
> > http://www.geuz.org/mailman/listinfo/gmsh

Index: Geo/GFace.h
===================================================================
--- Geo/GFace.h	(revision 16163)
+++ Geo/GFace.h	(working copy)
@@ -286,7 +286,7 @@
     // corners of the transfinite interpolation
     std::vector<GVertex*> corners;
     // all diagonals of the triangulation are left (-1), right (1) or
-    // alternated (0)
+    // alternated starting at right (2) or left (-2)
     int transfiniteArrangement;
     // do we smooth (transfinite) mesh? (<0 to use default smoothing)
     int transfiniteSmoothing;
Index: Geo/Geo.h
===================================================================
--- Geo/Geo.h	(revision 16163)
+++ Geo/Geo.h	(working copy)
@@ -148,7 +148,7 @@
   char Visible;
   int Method;
   int Recombine;
-  int Recombine_Dir; // -1 is left, +1 is right, 0 is alternated
+  int Recombine_Dir; // -1 is left, +1 is right, -2/2 is alternated left/right
   double RecombineAngle;
   int TransfiniteSmoothing;
   List_T *Generatrices;
Index: Parser/Gmsh.y
===================================================================
--- Parser/Gmsh.y	(revision 16163)
+++ Parser/Gmsh.y	(working copy)
@@ -3455,9 +3455,13 @@
       if(!strcmp($1, "Right"))
         $$ = 1;
       else if(!strcmp($1, "Left"))
-        $$ = -1;
-      else // alternated
-        $$ = 0;
+	$$ = -1;
+      else if(!strcmp($1, "AlternateRight"))
+	$$ = 2;
+      else if(!strcmp($1, "AlternateLeft"))
+	$$ = -2;
+      else // "Alternate" -> "Alternate Right"
+	$$ = 2;
       Free($1);
     }
 ;
Index: Mesh/meshGFaceTransfinite.cpp
===================================================================
--- Mesh/meshGFaceTransfinite.cpp	(revision 16163)
+++ Mesh/meshGFaceTransfinite.cpp	(working copy)
@@ -423,9 +423,13 @@
         if(CTX::instance()->mesh.recombineAll || gf->meshAttributes.recombine)
           gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4));
         else if(gf->meshAttributes.transfiniteArrangement == 1 ||
-                (gf->meshAttributes.transfiniteArrangement == 0 &&
+                (gf->meshAttributes.transfiniteArrangement == 2 &&
                  ((i % 2 == 0 && j % 2 == 1) ||
-                  (i % 2 == 1 && j % 2 == 0)))){
+                  (i % 2 == 1 && j % 2 == 0))) ||
+		(gf->meshAttributes.transfiniteArrangement == -2 &&
+                 ((i % 2 == 0 && j % 2 == 0) ||
+                  (i % 2 == 1 && j % 2 == 1)))
+		){
           gf->triangles.push_back(new MTriangle(v1, v2, v3));
           gf->triangles.push_back(new MTriangle(v3, v4, v1));
         }
@@ -452,9 +456,13 @@
         if(CTX::instance()->mesh.recombineAll || gf->meshAttributes.recombine)
           gf->quadrangles.push_back(new MQuadrangle(v1, v2, v3, v4));
         else if(gf->meshAttributes.transfiniteArrangement == 1 ||
-                (gf->meshAttributes.transfiniteArrangement == 0 &&
+                (gf->meshAttributes.transfiniteArrangement == 2 &&
                  ((i % 2 == 0 && j % 2 == 1) ||
-                  (i % 2 == 1 && j % 2 == 0)))){
+                  (i % 2 == 1 && j % 2 == 0))) ||
+		(gf->meshAttributes.transfiniteArrangement == -2 &&
+                 ((i % 2 == 0 && j % 2 == 0) ||
+                  (i % 2 == 1 && j % 2 == 1)))
+		){
           gf->triangles.push_back(new MTriangle(v1, v2, v3));
           gf->triangles.push_back(new MTriangle(v3, v4, v1));
         }
Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Point(4) = {0, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(5) = {3, 4, 1, 2};
Plane Surface(6) = {5};

Transfinite Line{1,2,3,4} = 3;
Transfinite Surface {6} = {1, 2, 3, 4};

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Point(4) = {0, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(5) = {3, 4, 1, 2};
Plane Surface(6) = {5};

Transfinite Line{1,2,3,4} = 3;
Transfinite Surface {6} = {1, 2, 3, 4} AlternateLeft;

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Point(4) = {0, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(5) = {3, 4, 1, 2};
Plane Surface(6) = {5};

Transfinite Line{1,2,3,4} = 3;
Transfinite Surface {6} = {1, 2, 3, 4} AlternateRight;

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Point(4) = {0, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(5) = {3, 4, 1, 2};
Plane Surface(6) = {5};

Transfinite Line{1,2,3,4} = 3;
Transfinite Surface {6} = {1, 2, 3, 4} Left;

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};},
Point(3) = {1, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 1};
Line Loop(5) = {1, 2, 3};
Plane Surface(6) = {5};

Transfinite Line{1,2,3} = 5;
Transfinite Surface {6} = {2, 3, 1};

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Point(4) = {0, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(5) = {3, 4, 1, 2};
Plane Surface(6) = {5};

Transfinite Line{1,2,3,4} = 3;
Transfinite Surface {6} = {1, 2, 3, 4} Right;

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 1};
Line Loop(5) = {1, 2, 3};
Plane Surface(6) = {5};

Transfinite Line{1,2,3} = 5;
Transfinite Surface {6} = {2, 3, 1} AlternateLeft;

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 1};
Line Loop(5) = {1, 2, 3};
Plane Surface(6) = {5};

Transfinite Line{1,2,3} = 5;
Transfinite Surface {6} = {2, 3, 1} AlternateRight;

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 1};
Line Loop(5) = {1, 2, 3};
Plane Surface(6) = {5};

Transfinite Line{1,2,3} = 5;
Transfinite Surface {6} = {2, 3, 1} Left;

Point(1) = {0, 0, 0, 1};
Point(2) = {1, 0, 0, 1};
Point(3) = {1, 1, 0, 1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 1};
Line Loop(5) = {1, 2, 3};
Plane Surface(6) = {5};

Transfinite Line{1,2,3} = 5;
Transfinite Surface {6} = {2, 3, 1} Right;

_______________________________________________
gmsh mailing list
[email protected]
http://www.geuz.org/mailman/listinfo/gmsh

Reply via email to