Skip to content
Snippets Groups Projects
Commit 5af72b66 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

new syntax for physicals

  Physical Point|Line|Surface|Volume ( "char" , expr ) = ...

allows to specify both a string label and a physical id by hand.
parent 062fa784
Branches
Tags
No related merge requests found
This diff is collapsed.
...@@ -1307,6 +1307,11 @@ PhysicalId0 : ...@@ -1307,6 +1307,11 @@ PhysicalId0 :
(std::string($1), 0, ++GModel::current()->getGEOInternals()->MaxPhysicalNum); (std::string($1), 0, ++GModel::current()->getGEOInternals()->MaxPhysicalNum);
Free($1); Free($1);
} }
| StringExpr ',' FExpr
{
$$ = GModel::current()->setPhysicalName(std::string($1), 0, $3);
Free($1);
}
; ;
PhysicalId1 : PhysicalId1 :
...@@ -1320,6 +1325,11 @@ PhysicalId1 : ...@@ -1320,6 +1325,11 @@ PhysicalId1 :
(std::string($1), 1, ++GModel::current()->getGEOInternals()->MaxPhysicalNum); (std::string($1), 1, ++GModel::current()->getGEOInternals()->MaxPhysicalNum);
Free($1); Free($1);
} }
| StringExpr ',' FExpr
{
$$ = GModel::current()->setPhysicalName(std::string($1), 1, $3);
Free($1);
}
; ;
PhysicalId2 : PhysicalId2 :
...@@ -1333,6 +1343,11 @@ PhysicalId2 : ...@@ -1333,6 +1343,11 @@ PhysicalId2 :
(std::string($1), 2, ++GModel::current()->getGEOInternals()->MaxPhysicalNum); (std::string($1), 2, ++GModel::current()->getGEOInternals()->MaxPhysicalNum);
Free($1); Free($1);
} }
| StringExpr ',' FExpr
{
$$ = GModel::current()->setPhysicalName(std::string($1), 2, $3);
Free($1);
}
; ;
PhysicalId3 : PhysicalId3 :
...@@ -1346,6 +1361,11 @@ PhysicalId3 : ...@@ -1346,6 +1361,11 @@ PhysicalId3 :
(std::string($1), 3, ++GModel::current()->getGEOInternals()->MaxPhysicalNum); (std::string($1), 3, ++GModel::current()->getGEOInternals()->MaxPhysicalNum);
Free($1); Free($1);
} }
| StringExpr ',' FExpr
{
$$ = GModel::current()->setPhysicalName(std::string($1), 3, $3);
Free($1);
}
; ;
InSphereCenter : InSphereCenter :
......
...@@ -1941,13 +1941,16 @@ mesh element size at that point. See @ref{Specifying mesh element ...@@ -1941,13 +1941,16 @@ mesh element size at that point. See @ref{Specifying mesh element
sizes}, for more information about how this value is used in the meshing sizes}, for more information about how this value is used in the meshing
process. process.
@item Physical Point ( @var{expression} | @var{char-expression} ) <+>= @{ @var{expression-list} @}; @item Physical Point ( @var{expression} | @var{char-expression} <, @var{expression}> ) <+>= @{ @var{expression-list} @};
Creates a physical point. The @var{expression} inside the parentheses is Creates a physical point. The @var{expression} inside the parentheses is
the physical point's identification number (if a @var{char-expression} the physical point's identification number; the @var{expression-list} on
is given instead, a unique identification number is automatically the right hand side should contain the identification numbers of all the
created); the @var{expression-list} on the right hand side should elementary points that need to be grouped inside the physical point. If
contain the identification numbers of all the elementary points that a @var{char-expression} is given instead instead of @var{expression}
need to be grouped inside the physical point. inside the parentheses, a string label is associated with the physical
identification number, which can be either provided explicitly (after
the comma) or not (in which case a unique identification number is
automatically created).
@end ftable @end ftable
...@@ -2043,16 +2046,19 @@ number of the elementary lines that should be reparametrized as a single ...@@ -2043,16 +2046,19 @@ number of the elementary lines that should be reparametrized as a single
line. See @code{Compound Surface} for additional information on compound line. See @code{Compound Surface} for additional information on compound
entities. entities.
@item Physical Line ( @var{expression} | @var{char-expression} ) <+>= @{ @var{expression-list} @}; @item Physical Line ( @var{expression} | @var{char-expression} <, @var{expression}> ) <+>= @{ @var{expression-list} @};
Creates a physical line. The @var{expression} inside the parentheses is Creates a physical line. The @var{expression} inside the parentheses is
the physical line's identification number (if a @var{char-expression} is the physical line's identification number; the @var{expression-list} on
given instead, a unique identification number is automatically the right hand side should contain the identification numbers of all the
created); the @var{expression-list} on the right hand side should elementary lines that need to be grouped inside the physical line. If a
contain the identification numbers of all the elementary lines that need @var{char-expression} is given instead instead of @var{expression}
to be grouped inside the physical line. Specifying negative inside the parentheses, a string label is associated with the physical
identification numbers in the @var{expression-list} will reverse the identification number, which can be either provided explicitly (after
orientation of the mesh elements belonging to the corresponding the comma) or not (in which case a unique identification number is
elementary lines in the saved mesh. automatically created). Specifying negative identification numbers in
the @var{expression-list} will reverse the orientation of the mesh
elements belonging to the corresponding elementary lines in the saved
mesh.
@end ftable @end ftable
...@@ -2115,15 +2121,18 @@ surface's identification number; the mandatory @var{expression-list} on ...@@ -2115,15 +2121,18 @@ surface's identification number; the mandatory @var{expression-list} on
the right hand side contains the identification number of the elementary the right hand side contains the identification number of the elementary
surfaces that should be reparametrized as a single surface. surfaces that should be reparametrized as a single surface.
@item Physical Surface ( @var{expression} | @var{char-expression} ) <+>= @{ @var{expression-list} @}; @item Physical Surface ( @var{expression} | @var{char-expression} <, @var{expression}> ) <+>= @{ @var{expression-list} @};
Creates a physical surface. The @var{expression} inside the parentheses Creates a physical surface. The @var{expression} inside the parentheses
is the physical surface's identification number (if a is the physical surface's identification number; the
@var{char-expression} is given instead, a unique identification number @var{expression-list} on the right hand side should contain the
is automatically created); the @var{expression-list} on the right hand identification numbers of all the elementary surfaces that need to be
side should contain the identification numbers of all the elementary grouped inside the physical surface. If a @var{char-expression} is
surfaces that need to be grouped inside the physical surface. Specifying given instead instead of @var{expression} inside the parentheses, a
negative identification numbers in the @var{expression-list} will string label is associated with the physical identification number,
reverse the orientation of the mesh elements belonging to the which can be either provided explicitly (after the comma) or not (in
which case a unique identification number is automatically created).
Specifying negative identification numbers in the @var{expression-list}
will reverse the orientation of the mesh elements belonging to the
corresponding elementary surfaces in the saved mesh. corresponding elementary surfaces in the saved mesh.
@end ftable @end ftable
...@@ -2164,13 +2173,16 @@ number of the elementary volumes that should be reparametrized as a ...@@ -2164,13 +2173,16 @@ number of the elementary volumes that should be reparametrized as a
single volume. See @code{Compound Surface} for additional information on single volume. See @code{Compound Surface} for additional information on
compound entities. compound entities.
@item Physical Volume ( @var{expression} | @var{char-expression} ) <+>= @{ @var{expression-list} @}; @item Physical Volume ( @var{expression} | @var{char-expression} <, @var{expression}> ) <+>= @{ @var{expression-list} @};
Creates a physical volume. The @var{expression} inside the parentheses Creates a physical volume. The @var{expression} inside the parentheses
is the physical volume's identification number (if a is the physical volume's identification number; the
@var{char-expression} is given instead, a unique identification number @var{expression-list} on the right hand side should contain the
is automatically created); the @var{expression-list} on the right hand identification numbers of all the elementary volumes that need to be
side should contain the identification numbers of all the elementary grouped inside the physical volume. If a @var{char-expression} is given
volumes that need to be grouped inside the physical volume. instead instead of @var{expression} inside the parentheses, a string
label is associated with the physical identification number, which can
be either provided explicitly (after the comma) or not (in which case a
unique identification number is automatically created).
@end ftable @end ftable
......
...@@ -13,22 +13,22 @@ ...@@ -13,22 +13,22 @@
lc = 1e-2; lc = 1e-2;
// This variable can then be used in the definition of Gmsh's simplest // This variable can then be used in the definition of Gmsh's simplest
// `elementary entity', a `Point'. A Point is defined by a list of // `elementary entity', a `Point'. A Point is defined by a list of four numbers:
// four numbers: three coordinates (X, Y and Z), and a characteristic // three coordinates (X, Y and Z), and a characteristic length (lc) that sets
// length (lc) that sets the target element size at the point: // the target element size at the point:
Point(1) = {0, 0, 0, lc}; Point(1) = {0, 0, 0, lc};
// The distribution of the mesh element sizes is then obtained by // The distribution of the mesh element sizes is then obtained by interpolation
// interpolation of these characteristic lengths throughout the // of these characteristic lengths throughout the geometry. Another method to
// geometry. Another method to specify characteristic lengths is to // specify characteristic lengths is to use a background mesh (see `t7.geo' and
// use a background mesh (see `t7.geo' and `bgmesh.pos'). // `bgmesh.pos').
// We can then define some additional points as well as our first // We can then define some additional points as well as our first curve. Curves
// curve. Curves are Gmsh's second type of elementery entities, and, // are Gmsh's second type of elementery entities, and, amongst curves, straight
// amongst curves, straight lines are the simplest. A straight line is // lines are the simplest. A straight line is defined by a list of point
// defined by a list of point numbers. In the commands below, for // numbers. In the commands below, for example, the line 1 starts at point 1 and
// example, the line 1 starts at point 1 and ends at point 2: // ends at point 2:
Point(2) = {.1, 0, 0, lc} ; Point(2) = {.1, 0, 0, lc} ;
Point(3) = {.1, .3, 0, lc} ; Point(3) = {.1, .3, 0, lc} ;
...@@ -39,48 +39,48 @@ Line(2) = {3,2} ; ...@@ -39,48 +39,48 @@ Line(2) = {3,2} ;
Line(3) = {3,4} ; Line(3) = {3,4} ;
Line(4) = {4,1} ; Line(4) = {4,1} ;
// The third elementary entity is the surface. In order to define a // The third elementary entity is the surface. In order to define a simple
// simple rectangular surface from the four lines defined above, a // rectangular surface from the four lines defined above, a line loop has first
// line loop has first to be defined. A line loop is a list of // to be defined. A line loop is a list of connected lines, a sign being
// connected lines, a sign being associated with each line (depending // associated with each line (depending on the orientation of the line):
// on the orientation of the line):
Line Loop(5) = {4,1,-2,3} ; Line Loop(5) = {4,1,-2,3} ;
// We can then define the surface as a list of line loops (only one // We can then define the surface as a list of line loops (only one here, since
// here, since there are no holes--see `t4.geo'): // there are no holes--see `t4.geo'):
Plane Surface(6) = {5} ; Plane Surface(6) = {5} ;
// At this level, Gmsh knows everything to display the rectangular // At this level, Gmsh knows everything to display the rectangular surface 6 and
// surface 6 and to mesh it. An optional step is needed if we want to // to mesh it. An optional step is needed if we want to associate specific
// associate specific region numbers to the various elements in the // region numbers to the various elements in the mesh (e.g. to the line segments
// mesh (e.g. to the line segments discretizing lines 1 to 4 or to the // discretizing lines 1 to 4 or to the triangles discretizing surface 6). This
// triangles discretizing surface 6). This is achieved by the // is achieved by the definition of `physical entities'. Physical entities will
// definition of `physical entities'. Physical entities will group // group elements belonging to several elementary entities by giving them a
// elements belonging to several elementary entities by giving them a
// common number (a region number). // common number (a region number).
// We can for example group the points 1 and 2 into the physical // We can for example group the points 1 and 2 into the physical entity 1:
// entity 1:
Physical Point(1) = {1,2} ; Physical Point(1) = {1,2} ;
// Consequently, two punctual elements will be saved in the output // Consequently, two punctual elements will be saved in the output mesh file,
// mesh file, both with the region number 1. The mechanism is // both with the region number 1. The mechanism is identical for line or surface
// identical for line or surface elements: // elements:
MyLine = 99; MY_FIRST_LINE = 99;
Physical Line(MyLine) = {1,2,4} ; Physical Line(MY_FIRST_LINE) = {1,2} ;
Physical Line("My second line (auto physical id)") = {3} ;
Physical Surface("My fancy surface label") = {6} ; Physical Line("My third line (physical id 199)", 199) = {4} ;
Physical Surface("My surface") = {6} ;
// All the line elements created during the meshing of lines 1, 2 and
// 4 will be saved in the output mesh file with the region number 99; // All the line elements created during the meshing of lines 1 and 2 will be
// and all the triangular elements resulting from the discretization // saved in the output mesh file with the physical id 99. The elements from line
// of surface 6 will be given an automatic region number (100, // 3 will be saved in the output mesh file with an automatic physical id,
// associated with the label "My fancy surface label"). // associated with the label "My second line (auto physical id)". The elements
// from line 4 will be saved with physical id 199, associated with the label "My
// Note that if no physical entities are defined, then all the // third line (physical id 199)". And finally, all the triangular elements
// elements in the mesh will be saved "as is", with their default // resulting from the discretization of surface 6 will be given an automatic
// orientation. // physical id associated with the label "My surface").
// Note that if no physical entities are defined, then all the elements in the
// mesh will be saved "as is", with their default orientation.
...@@ -20,21 +20,19 @@ Line(1) = {1,2}; Line(2) = {2,3}; Line(3) = {3,4}; Line(4) = {4,1}; ...@@ -20,21 +20,19 @@ Line(1) = {1,2}; Line(2) = {2,3}; Line(3) = {3,4}; Line(4) = {4,1};
Line Loop(5) = {1,2,3,4}; Plane Surface(6) = {5}; Line Loop(5) = {1,2,3,4}; Plane Surface(6) = {5};
// Say we would like to obtain mesh elements with size lc/30 near line // Say we would like to obtain mesh elements with size lc/30 near line 1 and
// 1 and point 5, and size lc elsewhere. To achieve this, we can use // point 5, and size lc elsewhere. To achieve this, we can use two fields:
// two fields: "Attractor", and "Threshold". We first define an // "Attractor", and "Threshold". We first define an Attractor field (Field[1])
// Attractor field (Field[1]) on points 5 and on line 1. This field // on points 5 and on line 1. This field returns the distance to point 5 and to
// returns the distance to point 5 and to (100 equidistant points on) // (100 equidistant points on) line 1.
// line 1.
Field[1] = Attractor; Field[1] = Attractor;
Field[1].NodesList = {5}; Field[1].NodesList = {5};
Field[1].NNodesByEdge = 100; Field[1].NNodesByEdge = 100;
Field[1].EdgesList = {2}; Field[1].EdgesList = {2};
// We then define a Threshold field, which uses the return value of // We then define a Threshold field, which uses the return value of the
// the Attractor Field[1] in order to define a simple change in // Attractor Field[1] in order to define a simple change in element size around
// element size around the attractors (i.e., around point 5 and line // the attractors (i.e., around point 5 and line 1)
// 1)
// //
// LcMax - /------------------ // LcMax - /------------------
// / // /
...@@ -50,26 +48,24 @@ Field[2].LcMax = lc; ...@@ -50,26 +48,24 @@ Field[2].LcMax = lc;
Field[2].DistMin = 0.15; Field[2].DistMin = 0.15;
Field[2].DistMax = 0.5; Field[2].DistMax = 0.5;
// Say we want to modulate the mesh element sizes using a mathematical // Say we want to modulate the mesh element sizes using a mathematical function
// function of the spatial coordinates. We can do this with the // of the spatial coordinates. We can do this with the MathEval field:
// MathEval field:
Field[3] = MathEval; Field[3] = MathEval;
Field[3].F = "Cos(4*3.14*x) * Sin(4*3.14*y) / 10 + 0.101"; Field[3].F = "Cos(4*3.14*x) * Sin(4*3.14*y) / 10 + 0.101";
// We could also combine MathEval with values coming from other // We could also combine MathEval with values coming from other fields. For
// fields. For example, let's define an Attractor around point 1 // example, let's define an Attractor around point 1
Field[4] = Attractor; Field[4] = Attractor;
Field[4].NodesList = {1}; Field[4].NodesList = {1};
// We can then create a MathEval field with a function that depends on // We can then create a MathEval field with a function that depends on the
// the return value of the Attractr Field[4], i.e., depending on the // return value of the Attractr Field[4], i.e., depending on the distance to
// distance to point 1 (here using a cubic law, with minumum element // point 1 (here using a cubic law, with minumum element size = lc / 100)
// size = lc / 100)
Field[5] = MathEval; Field[5] = MathEval;
Field[5].F = Sprintf("F4^3 + %g", lc / 100); Field[5].F = Sprintf("F4^3 + %g", lc / 100);
// We could also use a Box field to impose a step change in element // We could also use a Box field to impose a step change in element sizes inside
// sizes inside a box // a box
Field[6] = Box; Field[6] = Box;
Field[6].VIn = lc / 15; Field[6].VIn = lc / 15;
Field[6].VOut = lc; Field[6].VOut = lc;
...@@ -78,13 +74,11 @@ Field[6].XMax = 0.6; ...@@ -78,13 +74,11 @@ Field[6].XMax = 0.6;
Field[6].YMin = 0.3; Field[6].YMin = 0.3;
Field[6].YMax = 0.6; Field[6].YMax = 0.6;
// Many other types of fields are available: see the reference manual // Many other types of fields are available: see the reference manual for a
// for a complete list. You can also create fields directly in the // complete list. You can also create fields directly in the graphical user
// graphical user interface by selecting Define->Fields in the Mesh // interface by selecting Define->Fields in the Mesh module.
// module.
// Finally, let's use the minimum of all the fields as the background // Finally, let's use the minimum of all the fields as the background mesh field
// mesh field
Field[7] = Min; Field[7] = Min;
Field[7].FieldsList = {2, 3, 5, 6}; Field[7].FieldsList = {2, 3, 5, 6};
Background Field = 7; Background Field = 7;
......
...@@ -6,11 +6,10 @@ ...@@ -6,11 +6,10 @@
* *
*********************************************************************/ *********************************************************************/
// We have seen in tutorials t3 and t6 that extruded and transfinite // We have seen in tutorials t3 and t6 that extruded and transfinite meshes can
// meshes can be "recombined" into quads/prisms/hexahedra by using the // be "recombined" into quads/prisms/hexahedra by using the "Recombine"
// "Recombine" keyword. Unstructured meshes can be recombined in the // keyword. Unstructured meshes can be recombined in the same way. Let's define
// same way. Let's define a simple geometry with an analytical mesh // a simple geometry with an analytical mesh size field:
// size field:
Point(1) = {-1.25, -.5, 0}; Point(2) = {1.25, -.5, 0}; Point(1) = {-1.25, -.5, 0}; Point(2) = {1.25, -.5, 0};
Point(3) = {1.25, 1.25, 0}; Point(4) = {-1.25, 1.25, 0}; Point(3) = {1.25, 1.25, 0}; Point(4) = {-1.25, 1.25, 0};
...@@ -27,21 +26,19 @@ Background Field = 1; ...@@ -27,21 +26,19 @@ Background Field = 1;
// To generate quadrangles instead of triangles, we can simply add // To generate quadrangles instead of triangles, we can simply add
Recombine Surface{100}; Recombine Surface{100};
// If we'd had several surfaces, we could have used 'Recombine Surface // If we'd had several surfaces, we could have used 'Recombine Surface "*";'.
// "*";'. Yet another way would be to specify the global option // Yet another way would be to specify the global option "Mesh.RecombineAll =
// "Mesh.RecombineAll = 1;". // 1;".
// The default recombination algorithm is called "Blossom": it uses a // The default recombination algorithm is called "Blossom": it uses a minimum
// minimum cost perfect matching algorithm to generate fully // cost perfect matching algorithm to generate fully quadrilateral meshes from
// quadrilateral meshes from triangulations. More details about the // triangulations. More details about the algorithm can be found in the
// algorithm can be found in the following paper: J.-F. Remacle, // following paper: J.-F. Remacle, J. Lambrechts, B. Seny, E. Marchandise,
// J. Lambrechts, B. Seny, E. Marchandise, A. Johnen and C. Geuzaine, // A. Johnen and C. Geuzaine, "Blossom-Quad: a non-uniform quadrilateral mesh
// "Blossom-Quad: a non-uniform quadrilateral mesh generator using a // generator using a minimum cost perfect matching algorithm", International
// minimum cost perfect matching algorithm", International Journal for // Journal for Numerical Methods in Engineering, 2011 (in press).
// Numerical Methods in Engineering, 2011 (in press).
// For even better quadrilateral meshes, you can try the experimental "Delaunay
// For even better quadrilateral meshes, you can try the experimental // for quads" (DelQuad) meshing algorithm: DelQuad is a triangulation algorithm
// "Delaunay for quads" (DelQuad) meshing algorithm: DelQuad is a // that enables to create right triangles almost everywhere. Uncomment the
// triangulation algorithm that enables to create right triangles // following line to try DelQuad: Mesh.Algorithm = 8;
// almost everywhere. Uncomment the following line to try DelQuad:
// Mesh.Algorithm = 8;
...@@ -6,10 +6,9 @@ ...@@ -6,10 +6,9 @@
* *
*********************************************************************/ *********************************************************************/
// Compound geometrical entities can be defined to compute a new // Compound geometrical entities can be defined to compute a new parametrization
// parametrization of groups of elementary geometrical entities. This // of groups of elementary geometrical entities. This parametrization can then
// parametrization can then be used for remeshing the compound as if // be used for remeshing the compound as if it were a single CAD entity.
// it were a single CAD entity.
lc = 0.1; lc = 0.1;
...@@ -41,21 +40,19 @@ DefineConstant[ hide = {Geometry.HideCompounds, Choices{0,1}, ...@@ -41,21 +40,19 @@ DefineConstant[ hide = {Geometry.HideCompounds, Choices{0,1},
Name "Hide compound sub-entities", GmshOption "Geometry.HideCompounds", Name "Hide compound sub-entities", GmshOption "Geometry.HideCompounds",
AutoCheck 0} ]; AutoCheck 0} ];
// More details about the reparametrization technique can be found in // More details about the reparametrization technique can be found in the
// the following papers: // following papers:
// //
// * J.-F. Remacle, C. Geuzaine, G. Compère and E. Marchandise, // * J.-F. Remacle, C. Geuzaine, G. Compère and E. Marchandise, "High-Quality
// "High-Quality Surface Remeshing Using Harmonic Maps", // Surface Remeshing Using Harmonic Maps", International Journal for Numerical
// International Journal for Numerical Methods in Engineering, // Methods in Engineering, 83 (4), pp. 403-425, 2010.
// 83 (4), pp. 403-425, 2010.
// //
// * E. Marchandise, G. Compère, M. Willemet, G. Bricteux, C. Geuzaine // * E. Marchandise, G. Compère, M. Willemet, G. Bricteux, C. Geuzaine and J-F
// and J-F Remacle, "Quality meshing based on STL triangulations for // Remacle, "Quality meshing based on STL triangulations for biomedical
// biomedical simulations", International Journal for Numerical // simulations", International Journal for Numerical Methods in Biomedical
// Methods in Biomedical Engineering", 26 (7), pp. 876-889, 2010. // Engineering", 26 (7), pp. 876-889, 2010.
// //
// * E. Marchandise, C. Carton de Wiart, W. G. Vos, C. Geuzaine and // * E. Marchandise, C. Carton de Wiart, W. G. Vos, C. Geuzaine and
// J.-F. Remacle, "High Quality Surface Remeshing Using Harmonic // J.-F. Remacle, "High Quality Surface Remeshing Using Harmonic Maps. Part
// Maps. Part II: Surfaces with High Genus and of Large Aspect // II: Surfaces with High Genus and of Large Aspect Ratio", International
// Ratio", International Journal for Numerical Methods in // Journal for Numerical Methods in Engineering, 86 (11), pp. 1303-1321, 2011.
// Engineering, 86 (11), pp. 1303-1321, 2011.
...@@ -6,14 +6,13 @@ ...@@ -6,14 +6,13 @@
* *
*********************************************************************/ *********************************************************************/
// Since compound geometrical compute a new parametrization, one can // Since compound geometrical compute a new parametrization, one can also use
// also use them to remesh STL files, even if in this case there's // them to remesh STL files, even if in this case there's usually only a single
// usually only a single elementary geometrical entity per compound. // elementary geometrical entity per compound.
// Let's merge the mesh that we would like to remesh. This mesh was // Let's merge the mesh that we would like to remesh. This mesh was reclassified
// reclassified ("colored") from an initial STL triangulation using // ("colored") from an initial STL triangulation using the "Reclassify 2D" tool
// the "Reclassify 2D" tool in Gmsh, so that we could split it along // in Gmsh, so that we could split it along sharp geometrical features.
// sharp geometrical features.
Merge "t13_data.msh"; Merge "t13_data.msh";
// Since the original mesh is a bit coarse, we refine it once // Since the original mesh is a bit coarse, we refine it once
...@@ -22,8 +21,8 @@ RefineMesh; ...@@ -22,8 +21,8 @@ RefineMesh;
// Create the topology of the discrete model // Create the topology of the discrete model
CreateTopology; CreateTopology;
// We can now define a compound line (resp. surface) for each discrete // We can now define a compound line (resp. surface) for each discrete line
// line (resp. surface) in the model // (resp. surface) in the model
ll[] = Line "*"; ll[] = Line "*";
For j In {0 : #ll[]-1} For j In {0 : #ll[]-1}
Compound Line(newl) = ll[j]; Compound Line(newl) = ll[j];
......
...@@ -6,10 +6,9 @@ ...@@ -6,10 +6,9 @@
* *
*********************************************************************/ *********************************************************************/
// Homology computation in Gmsh finds representative chains of // Homology computation in Gmsh finds representative chains of (relative)
// (relative) (co)homology space bases using a mesh of a model. // (co)homology space bases using a mesh of a model. The representative basis
// The representative basis chains are stored in the mesh as // chains are stored in the mesh as physical groups of Gmsh, one for each chain.
// physical groups of Gmsh, one for each chain.
// Create an example geometry // Create an example geometry
...@@ -56,18 +55,16 @@ Physical Surface(80) = bnd[]; ...@@ -56,18 +55,16 @@ Physical Surface(80) = bnd[];
bnd[] -= {36, 44, 52, 60}; bnd[] -= {36, 44, 52, 60};
Physical Surface(75) = bnd[]; Physical Surface(75) = bnd[];
// Find bases for relative homology spaces of // Find bases for relative homology spaces of the domain modulo the four
// the domain modulo the four terminals. // terminals.
Homology {{1}, {70, 71, 72, 73}}; Homology {{1}, {70, 71, 72, 73}};
// Find homology space bases isomorphic to the previous bases: // Find homology space bases isomorphic to the previous bases: homology spaces
// homology spaces modulo the non-terminal domain surface, // modulo the non-terminal domain surface, a.k.a the thin cuts.
// a.k.a the thin cuts.
Homology {{1}, {75}}; Homology {{1}, {75}};
// Find cohomology space bases isomorphic to the previous bases: // Find cohomology space bases isomorphic to the previous bases: cohomology
// cohomology spaces of the domain modulo the four terminals, // spaces of the domain modulo the four terminals, a.k.a the thick cuts.
// a.k.a the thick cuts.
Cohomology {{1}, {70, 71, 72, 73}}; Cohomology {{1}, {70, 71, 72, 73}};
// More examples: // More examples:
......
...@@ -7,64 +7,60 @@ ...@@ -7,64 +7,60 @@
* *
*********************************************************************/ *********************************************************************/
// We first include the previous tutorial file, in order to use it as // We first include the previous tutorial file, in order to use it as a basis
// a basis for this one: // for this one:
Include "t1.geo"; Include "t1.geo";
// We can then add new points and lines in the same way as we did in // We can then add new points and lines in the same way as we did in `t1.geo':
// `t1.geo':
Point(5) = {0, .4, 0, lc}; Point(5) = {0, .4, 0, lc};
Line(5) = {4, 5}; Line(5) = {4, 5};
// But Gmsh also provides tools to tranform (translate, rotate, etc.) // But Gmsh also provides tools to tranform (translate, rotate, etc.)
// elementary entities or copies of elementary entities. For example, // elementary entities or copies of elementary entities. For example, the point
// the point 3 can be moved by 0.05 units to the left with: // 3 can be moved by 0.05 units to the left with:
Translate {-0.05, 0, 0} { Point{3}; } Translate {-0.05, 0, 0} { Point{3}; }
// The resulting point can also be duplicated and translated by 0.1 // The resulting point can also be duplicated and translated by 0.1 along the y
// along the y axis: // axis:
Translate {0, 0.1, 0} { Duplicata{ Point{3}; } } Translate {0, 0.1, 0} { Duplicata{ Point{3}; } }
// This command created a new point with an automatically assigned // This command created a new point with an automatically assigned id. This id
// id. This id can be obtained using the graphical user interface by // can be obtained using the graphical user interface by hovering the mouse over
// hovering the mouse over it and looking at the bottom of the graphic // it and looking at the bottom of the graphic window: in this case, the new
// window: in this case, the new point has id "6". Point 6 can then be // point has id "6". Point 6 can then be used to create new entities, e.g.:
// used to create new entities, e.g.:
Line(7) = {3, 6}; Line(7) = {3, 6};
Line(8) = {6, 5}; Line(8) = {6, 5};
Line Loop(10) = {5,-8,-7,3}; Line Loop(10) = {5,-8,-7,3};
Plane Surface(11) = {10}; Plane Surface(11) = {10};
// Using the graphical user interface to obtain the ids of newly // Using the graphical user interface to obtain the ids of newly created
// created entities can sometimes be cumbersome. It can then be // entities can sometimes be cumbersome. It can then be advantageous to use the
// advantageous to use the return value of the transformation commands // return value of the transformation commands directly. For example, the
// directly. For example, the Translate command returns a list // Translate command returns a list containing the ids of the translated
// containing the ids of the translated entities. For example, we can // entities. For example, we can translate copies of the two surfaces 6 and 11
// translate copies of the two surfaces 6 and 11 to the right with the // to the right with the following command:
// following command:
my_new_surfs[] = Translate {0.12, 0, 0} { Duplicata{ Surface{6, 11}; } }; my_new_surfs[] = Translate {0.12, 0, 0} { Duplicata{ Surface{6, 11}; } };
// my_new_surfs[] (note the square brackets) denotes a list, which in // my_new_surfs[] (note the square brackets) denotes a list, which in this case
// this case contains the ids of the two new surfaces (check // contains the ids of the two new surfaces (check `Tools->Message console' to
// `Tools->Message console' to see the message): // see the message):
Printf("New surfaces '%g' and '%g'", my_new_surfs[0], my_new_surfs[1]); Printf("New surfaces '%g' and '%g'", my_new_surfs[0], my_new_surfs[1]);
// In Gmsh lists use square brackets for their definition (mylist[] = // In Gmsh lists use square brackets for their definition (mylist[] = {1,2,3};)
// {1,2,3};) as well as to access their elements (myotherlist[] = // as well as to access their elements (myotherlist[] = {mylist[0],
// {mylist[0], mylist[2]};). Note that list indexing starts at 0. // mylist[2]};). Note that list indexing starts at 0.
// Volumes are the fourth type of elementary entities in Gmsh. In the // Volumes are the fourth type of elementary entities in Gmsh. In the same way
// same way one defines line loops to build surfaces, one has to // one defines line loops to build surfaces, one has to define surface loops
// define surface loops (i.e. `shells') to build volumes. The // (i.e. `shells') to build volumes. The following volume does not have holes
// following volume does not have holes and thus consists of a single // and thus consists of a single surface loop:
// surface loop:
Point(100) = {0., 0.3, 0.13, lc}; Point(101) = {0.08, 0.3, 0.1, lc}; Point(100) = {0., 0.3, 0.13, lc}; Point(101) = {0.08, 0.3, 0.1, lc};
Point(102) = {0.08, 0.4, 0.1, lc}; Point(103) = {0., 0.4, 0.13, lc}; Point(102) = {0.08, 0.4, 0.1, lc}; Point(103) = {0., 0.4, 0.13, lc};
...@@ -83,32 +79,29 @@ Line Loop(126) = {115, 116, 117, 114}; Plane Surface(127) = {126}; ...@@ -83,32 +79,29 @@ Line Loop(126) = {115, 116, 117, 114}; Plane Surface(127) = {126};
Surface Loop(128) = {127, 119, 121, 123, 125, 11}; Surface Loop(128) = {127, 119, 121, 123, 125, 11};
Volume(129) = {128}; Volume(129) = {128};
// When a volume can be extruded from a surface, it is usually easier // When a volume can be extruded from a surface, it is usually easier to use the
// to use the Extrude command directly instead of creating all the // Extrude command directly instead of creating all the points, lines and
// points, lines and surfaces by hand. For example, the following // surfaces by hand. For example, the following command extrudes the surface 11
// command extrudes the surface 11 along the z axis and automatically // along the z axis and automatically creates a new volume (as well as all the
// creates a new volume (as well as all the needed points, lines and // needed points, lines and surfaces):
// surfaces):
Extrude {0, 0, 0.12} { Surface{my_new_surfs[1]}; } Extrude {0, 0, 0.12} { Surface{my_new_surfs[1]}; }
// The following command permits to manually assign a characteristic // The following command permits to manually assign a characteristic length to
// length to some of the new points: // some of the new points:
Characteristic Length {103, 105, 109, 102, 28, 24, 6, 5} = lc * 3; Characteristic Length {103, 105, 109, 102, 28, 24, 6, 5} = lc * 3;
// Note that, if the transformation tools are handy to create complex // Note that, if the transformation tools are handy to create complex
// geometries, it is also sometimes useful to generate the `flat' // geometries, it is also sometimes useful to generate the `flat' geometry, with
// geometry, with an explicit list of all elementary entities. This // an explicit list of all elementary entities. This can be achieved by
// can be achieved by selecting the `File->Save as->Gmsh unrolled // selecting the `File->Save as->Gmsh unrolled geometry' menu or by typing
// geometry' menu or by typing
// //
// > gmsh t2.geo -0 // > gmsh t2.geo -0
// //
// on the command line. // on the command line.
// To save all the tetrahedra discretizing the volumes 129 and 130 // To save all the tetrahedra discretizing the volumes 129 and 130 with a common
// with a common region number, we finally define a physical // region number, we finally define a physical volume:
// volume:
Physical Volume (1) = {129,130}; Physical Volume (1) = {129,130};
...@@ -10,12 +10,11 @@ ...@@ -10,12 +10,11 @@
Include "t1.geo"; Include "t1.geo";
// As in `t2.geo', we plan to perform an extrusion along the z axis. // As in `t2.geo', we plan to perform an extrusion along the z axis. But here,
// But here, instead of only extruding the geometry, we also want to // instead of only extruding the geometry, we also want to extrude the 2D
// extrude the 2D mesh. This is done with the same `Extrude' command, // mesh. This is done with the same `Extrude' command, but by specifying element
// but by specifying element 'Layers' (2 layers in this case, the // 'Layers' (2 layers in this case, the first one with 8 subdivisions and the
// first one with 8 subdivisions and the second one with 2 // second one with 2 subdivisions, both with a height of h/2):
// subdivisions, both with a height of h/2):
h = 0.1; h = 0.1;
...@@ -23,21 +22,20 @@ Extrude {0,0,h} { ...@@ -23,21 +22,20 @@ Extrude {0,0,h} {
Surface{6}; Layers{ {8,2}, {0.5,1} }; Surface{6}; Layers{ {8,2}, {0.5,1} };
} }
// The extrusion can also be performed with a rotation instead of a // The extrusion can also be performed with a rotation instead of a translation,
// translation, and the resulting mesh can be recombined into prisms // and the resulting mesh can be recombined into prisms (we use only one layer
// (we use only one layer here, with 7 subdivisions). All rotations // here, with 7 subdivisions). All rotations are specified by an axis direction
// are specified by an axis direction ({0,1,0}), an axis point // ({0,1,0}), an axis point ({-0.1,0,0.1}) and a rotation angle (-Pi/2):
// ({-0.1,0,0.1}) and a rotation angle (-Pi/2):
Extrude { {0,1,0} , {-0.1,0,0.1} , -Pi/2 } { Extrude { {0,1,0} , {-0.1,0,0.1} , -Pi/2 } {
Surface{122}; Layers{7}; Recombine; Surface{122}; Layers{7}; Recombine;
} }
// Note that a translation ({-2*h,0,0}) and a rotation ({1,0,0}, // Note that a translation ({-2*h,0,0}) and a rotation ({1,0,0}, {0,0.15,0.25},
// {0,0.15,0.25}, Pi/2) can also be combined. Here the angle is // Pi/2) can also be combined. Here the angle is specified as a 'parameter',
// specified as a 'parameter', using the 'DefineConstant' syntax. // using the 'DefineConstant' syntax. This parameter can be modified
// This parameter can be modified insteractively in the GUI, and // insteractively in the GUI, and can be exchanged with other codes using the
// can be exchanged with other codes using the ONELAB framework: // ONELAB framework:
DefineConstant[ angle = {90, Min 0, Max 120, Step 1, DefineConstant[ angle = {90, Min 0, Max 120, Step 1,
Name "Parameters/Twisting angle"} ]; Name "Parameters/Twisting angle"} ];
...@@ -46,14 +44,13 @@ out[] = Extrude { {-2*h,0,0}, {1,0,0} , {0,0.15,0.25} , angle * Pi / 180 } { ...@@ -46,14 +44,13 @@ out[] = Extrude { {-2*h,0,0}, {1,0,0} , {0,0.15,0.25} , angle * Pi / 180 } {
Surface{144}; Layers{10}; Recombine; Surface{144}; Layers{10}; Recombine;
}; };
// In this last extrusion command we retrieved the volume number // In this last extrusion command we retrieved the volume number programatically
// programatically by using the return value (a list) of the Extrude // by using the return value (a list) of the Extrude command. This list contains
// command. This list contains the "top" of the extruded surface (in // the "top" of the extruded surface (in out[0]), the newly created volume (in
// out[0]), the newly created volume (in out[1]) and the ids of the // out[1]) and the ids of the lateral surfaces (in out[2], out[3], ...)
// lateral surfaces (in out[2], out[3], ...)
// We can then define a new physical volume to save all the tetrahedra // We can then define a new physical volume to save all the tetrahedra with a
// with a common region number (101): // common region number (101):
Physical Volume(101) = {1, 2, out[1]}; Physical Volume(101) = {1, 2, out[1]};
...@@ -67,17 +64,15 @@ General.Color.Text = White; ...@@ -67,17 +64,15 @@ General.Color.Text = White;
Mesh.Color.Points = {255,0,0}; Mesh.Color.Points = {255,0,0};
// Note that all colors can be defined literally or numerically, i.e. // Note that all colors can be defined literally or numerically, i.e.
// `Mesh.Color.Points = Red' is equivalent to `Mesh.Color.Points = // `Mesh.Color.Points = Red' is equivalent to `Mesh.Color.Points = {255,0,0}';
// {255,0,0}'; and also note that, as with user-defined variables, the // and also note that, as with user-defined variables, the options can be used
// options can be used either as right or left hand sides, so that the // either as right or left hand sides, so that the following command will set
// following command will set the surface color to the same color as // the surface color to the same color as the points:
// the points:
Geometry.Color.Surfaces = Geometry.Color.Points; Geometry.Color.Surfaces = Geometry.Color.Points;
// You can use the `Help->Current options' menu to see the current // You can use the `Help->Current options' menu to see the current values of all
// values of all options. To save all the options in a file, use // options. To save all the options in a file, use `File->Save as->Gmsh
// `File->Save as->Gmsh options'. To associate the current options // options'. To associate the current options with the current file use
// with the current file use `File->Save Options->For Current // `File->Save Options->For Current File'. To save the current options for all
// File'. To save the current options for all future Gmsh sessions use // future Gmsh sessions use `File->Save Options->As default'.
// `File->Save Options->As default'.
...@@ -15,9 +15,8 @@ R1 = 1 * cm; R2 = 1.5 * cm; r = 1 * cm; ...@@ -15,9 +15,8 @@ R1 = 1 * cm; R2 = 1.5 * cm; r = 1 * cm;
Lc1 = 0.01; Lc1 = 0.01;
Lc2 = 0.003; Lc2 = 0.003;
// We can use all the usual mathematical functions (note the // We can use all the usual mathematical functions (note the capitalized first
// capitalized first letters), plus some useful functions like // letters), plus some useful functions like Hypot(a, b) := Sqrt(a^2 + b^2):
// Hypot(a, b) := Sqrt(a^2 + b^2):
ccos = (-h5*R1 + e2 * Hypot(h5, Hypot(e2, R1))) / (h5^2 + e2^2); ccos = (-h5*R1 + e2 * Hypot(h5, Hypot(e2, R1))) / (h5^2 + e2^2);
ssin = Sqrt(1 - ccos^2); ssin = Sqrt(1 - ccos^2);
...@@ -46,16 +45,14 @@ Point(24)= { 0, h1+h3+h4+R2, 0, Lc2}; Point(25)= { 0, h1+h3-R2, 0, Lc2}; ...@@ -46,16 +45,14 @@ Point(24)= { 0, h1+h3+h4+R2, 0, Lc2}; Point(25)= { 0, h1+h3-R2, 0, Lc2};
Line(1) = {1 , 17}; Line(1) = {1 , 17};
Line(2) = {17, 16}; Line(2) = {17, 16};
// Gmsh provides other curve primitives than stright lines: splines, // Gmsh provides other curve primitives than stright lines: splines, B-splines,
// B-splines, circle arcs, ellipse arcs, etc. Here we define a new // circle arcs, ellipse arcs, etc. Here we define a new circle arc, starting at
// circle arc, starting at point 14 and ending at point 16, with the // point 14 and ending at point 16, with the circle's center being the point 15:
// circle's center being the point 15:
Circle(3) = {14,15,16}; Circle(3) = {14,15,16};
// Note that, in Gmsh, circle arcs should always be smaller than // Note that, in Gmsh, circle arcs should always be smaller than Pi. We can then
// Pi. We can then define additional lines and circles, as well as a // define additional lines and circles, as well as a new surface:
// new surface:
Line(4) = {14,13}; Line(5) = {13,12}; Line(6) = {12,11}; Line(4) = {14,13}; Line(5) = {13,12}; Line(6) = {12,11};
Line(7) = {11,10}; Circle(8) = {8,9,10}; Line(9) = {8,7}; Line(7) = {11,10}; Circle(8) = {8,9,10}; Line(9) = {8,7};
...@@ -68,28 +65,27 @@ Line(20) = {21,22}; ...@@ -68,28 +65,27 @@ Line(20) = {21,22};
Line Loop(21) = {17,-15,18,19,-20,16}; Line Loop(21) = {17,-15,18,19,-20,16};
Plane Surface(22) = {21}; Plane Surface(22) = {21};
// But we still need to define the exterior surface. Since this // But we still need to define the exterior surface. Since this surface has a
// surface has a hole, its definition now requires two lines loops: // hole, its definition now requires two lines loops:
Line Loop(23) = {11,-12,13,14,1,2,-3,4,5,6,7,-8,9,10}; Line Loop(23) = {11,-12,13,14,1,2,-3,4,5,6,7,-8,9,10};
Plane Surface(24) = {23,21}; Plane Surface(24) = {23,21};
// As a general rule, if a surface has N holes, it is defined by N+1 // As a general rule, if a surface has N holes, it is defined by N+1 line loops:
// line loops: the first loop defines the exterior boundary; the other // the first loop defines the exterior boundary; the other loops define the
// loops define the boundaries of the holes. // boundaries of the holes.
// Finally, we can add some comments by embedding a post-processing // Finally, we can add some comments by embedding a post-processing view
// view containing some strings, and change the color of some mesh // containing some strings, and change the color of some mesh entities:
// entities:
View "comments" { View "comments" {
// Add a text string in window coordinates, 10 pixels from the left // Add a text string in window coordinates, 10 pixels from the left and 10
// and 10 pixels from the bottom: // pixels from the bottom:
T2(10, -10, 0){ "Copyright (C) My Company" }; T2(10, -10, 0){ "Copyright (C) My Company" };
// Add another text string in window coordinates, 10 pixels from the // Add another text string in window coordinates, 10 pixels from the left and
// left and 15 pixels from the top, using the StrCat() function to // 15 pixels from the top, using the StrCat() function to concatenate a string
// concatenate a string with the current date: // with the current date:
T2(10, 15, 0){ StrCat("File created on ", Today) }; T2(10, 15, 0){ StrCat("File created on ", Today) };
// Add a text string in model coordinates at (X,Y,Z) = (0, 0.11, 0): // Add a text string in model coordinates at (X,Y,Z) = (0, 0.11, 0):
......
...@@ -12,25 +12,23 @@ lcar1 = .1; ...@@ -12,25 +12,23 @@ lcar1 = .1;
lcar2 = .0005; lcar2 = .0005;
lcar3 = .055; lcar3 = .055;
// If we wanted to change these mesh sizes globally (without changing // If we wanted to change these mesh sizes globally (without changing the above
// the above definitions), we could give a global scaling factor for // definitions), we could give a global scaling factor for all characteristic
// all characteristic lengths on the command line with the `-clscale' // lengths on the command line with the `-clscale' option (or with
// option (or with `Mesh.CharacteristicLengthFactor' in an option // `Mesh.CharacteristicLengthFactor' in an option file). For example, with:
// file). For example, with:
// //
// > gmsh t5.geo -clscale 1 // > gmsh t5.geo -clscale 1
// //
// this input file produces a mesh of approximately 1,300 nodes and // this input file produces a mesh of approximately 1,300 nodes and 11,000
// 11,000 tetrahedra. With // tetrahedra. With
// //
// > gmsh t5.geo -clscale 0.2 // > gmsh t5.geo -clscale 0.2
// //
// the mesh counts approximately 350,000 nodes and 2.1 million // the mesh counts approximately 350,000 nodes and 2.1 million tetrahedra. You
// tetrahedra. You can check mesh statistics in the graphical user // can check mesh statistics in the graphical user interface with the
// interface with the `Tools->Statistics' menu. // `Tools->Statistics' menu.
// We proceed by defining some elementary entities describing a // We proceed by defining some elementary entities describing a truncated cube:
// truncated cube:
Point(1) = {0.5,0.5,0.5,lcar2}; Point(2) = {0.5,0.5,0,lcar1}; Point(1) = {0.5,0.5,0.5,lcar2}; Point(2) = {0.5,0.5,0,lcar1};
Point(3) = {0,0.5,0.5,lcar1}; Point(4) = {0,0,0.5,lcar1}; Point(3) = {0,0.5,0.5,lcar1}; Point(4) = {0,0,0.5,lcar1};
...@@ -58,18 +56,17 @@ Line Loop(34) = {7,3,8,9}; Plane Surface(35) = {34}; ...@@ -58,18 +56,17 @@ Line Loop(34) = {7,3,8,9}; Plane Surface(35) = {34};
Line Loop(36) = {-10,18,-16,-20,4,-8}; Plane Surface(37) = {36}; Line Loop(36) = {-10,18,-16,-20,4,-8}; Plane Surface(37) = {36};
Line Loop(38) = {-14,-13,-12,19}; Plane Surface(39) = {38}; Line Loop(38) = {-14,-13,-12,19}; Plane Surface(39) = {38};
// Instead of using included files, we now use a user-defined function // Instead of using included files, we now use a user-defined function in order
// in order to carve some holes in the cube: // to carve some holes in the cube:
Function CheeseHole Function CheeseHole
// In the following commands we use the reserved variable name // In the following commands we use the reserved variable name `newp', which
// `newp', which automatically selects a new point number. This // automatically selects a new point number. This number is chosen as the
// number is chosen as the highest current point number, plus // highest current point number, plus one. (Note that, analogously to `newp',
// one. (Note that, analogously to `newp', the variables `newl', // the variables `newl', `news', `newv' and `newreg' select the highest number
// `news', `newv' and `newreg' select the highest number amongst // amongst currently defined curves, surfaces, volumes and `any entities other
// currently defined curves, surfaces, volumes and `any entities // than points', respectively.)
// other than points', respectively.)
p1 = newp; Point(p1) = {x, y, z, lcar3} ; p1 = newp; Point(p1) = {x, y, z, lcar3} ;
p2 = newp; Point(p2) = {x+r,y, z, lcar3} ; p2 = newp; Point(p2) = {x+r,y, z, lcar3} ;
...@@ -86,8 +83,8 @@ Function CheeseHole ...@@ -86,8 +83,8 @@ Function CheeseHole
c9 = newreg; Circle(c9) = {p7,p1,p3}; c10 = newreg; Circle(c10) = {p3,p1,p4}; c9 = newreg; Circle(c9) = {p7,p1,p3}; c10 = newreg; Circle(c10) = {p3,p1,p4};
c11 = newreg; Circle(c11) = {p4,p1,p6}; c12 = newreg; Circle(c12) = {p6,p1,p7}; c11 = newreg; Circle(c11) = {p4,p1,p6}; c12 = newreg; Circle(c12) = {p6,p1,p7};
// We need non-plane surfaces to define the spherical holes. Here we // We need non-plane surfaces to define the spherical holes. Here we use ruled
// use ruled surfaces, which can have 3 or 4 sides: // surfaces, which can have 3 or 4 sides:
l1 = newreg; Line Loop(l1) = {c5,c10,c4}; Ruled Surface(newreg) = {l1}; l1 = newreg; Line Loop(l1) = {c5,c10,c4}; Ruled Surface(newreg) = {l1};
l2 = newreg; Line Loop(l2) = {c9,-c5,c1}; Ruled Surface(newreg) = {l2}; l2 = newreg; Line Loop(l2) = {c9,-c5,c1}; Ruled Surface(newreg) = {l2};
...@@ -98,9 +95,8 @@ Function CheeseHole ...@@ -98,9 +95,8 @@ Function CheeseHole
l7 = newreg; Line Loop(l7) = {-c2,-c7,-c12};Ruled Surface(newreg) = {l7}; l7 = newreg; Line Loop(l7) = {-c2,-c7,-c12};Ruled Surface(newreg) = {l7};
l8 = newreg; Line Loop(l8) = {-c6,-c9,c2}; Ruled Surface(newreg) = {l8}; l8 = newreg; Line Loop(l8) = {-c6,-c9,c2}; Ruled Surface(newreg) = {l8};
// We then store the surface loops identification numbers in a list // We then store the surface loops identification numbers in a list for later
// for later reference (we will need these to define the final // reference (we will need these to define the final volume):
// volume):
theloops[t] = newreg ; theloops[t] = newreg ;
...@@ -128,34 +124,32 @@ For t In {1:5} ...@@ -128,34 +124,32 @@ For t In {1:5}
Physical Volume (t) = thehole ; Physical Volume (t) = thehole ;
// We also print some variables on the terminal (note that, since // We also print some variables on the terminal (note that, since all
// all variables are treated internally as floating point numbers, // variables are treated internally as floating point numbers, the format
// the format string should only contain valid floating point format // string should only contain valid floating point format specifiers like
// specifiers like `%g', `%f', '%e', etc.): // `%g', `%f', '%e', etc.):
Printf("Hole %g (center = {%g,%g,%g}, radius = %g) has number %g!", Printf("Hole %g (center = {%g,%g,%g}, radius = %g) has number %g!",
t, x, y, z, r, thehole) ; t, x, y, z, r, thehole) ;
EndFor EndFor
// We can then define the surface loop for the exterior surface of the // We can then define the surface loop for the exterior surface of the cube:
// cube:
theloops[0] = newreg ; theloops[0] = newreg ;
Surface Loop(theloops[0]) = {35,31,29,37,33,23,39,25,27} ; Surface Loop(theloops[0]) = {35,31,29,37,33,23,39,25,27} ;
// The volume of the cube, without the 5 holes, is now defined by 6 // The volume of the cube, without the 5 holes, is now defined by 6 surface
// surface loops: the first surface loop defines the exterior surface; // loops: the first surface loop defines the exterior surface; the surface loops
// the surface loops other than the first one define holes. (Again, // other than the first one define holes. (Again, to reference an array of
// to reference an array of variables, its identifier is followed by // variables, its identifier is followed by square brackets):
// square brackets):
Volume(186) = {theloops[]} ; Volume(186) = {theloops[]} ;
// We finally define a physical volume for the elements discretizing // We finally define a physical volume for the elements discretizing the cube,
// the cube, without the holes (whose elements were already tagged // without the holes (whose elements were already tagged with numbers 1 to 5 in
// with numbers 1 to 5 in the `For' loop): // the `For' loop):
Physical Volume (10) = 186 ; Physical Volume (10) = 186 ;
......
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
* *
*********************************************************************/ *********************************************************************/
// Let's use the geometry from the first tutorial as a basis for this // Let's use the geometry from the first tutorial as a basis for this one
// one
Include "t1.geo"; Include "t1.geo";
// Delete the left line and create replace it with 3 new ones // Delete the left line and create replace it with 3 new ones
...@@ -27,26 +26,25 @@ Plane Surface(1) = {-1}; ...@@ -27,26 +26,25 @@ Plane Surface(1) = {-1};
// Put 20 points with a refinement toward the extremities on curve 2 // Put 20 points with a refinement toward the extremities on curve 2
Transfinite Line{2} = 20 Using Bump 0.05; Transfinite Line{2} = 20 Using Bump 0.05;
// Put 20 points total on combination of curves l1, l2 and l3 (beware // Put 20 points total on combination of curves l1, l2 and l3 (beware that the
// that the points p1 and p2 are shared by the curves, so we do not // points p1 and p2 are shared by the curves, so we do not create 6 + 6 + 10 =
// create 6 + 6 + 10 = 22 points, but 20!) // 22 points, but 20!)
Transfinite Line{l1} = 6; Transfinite Line{l1} = 6;
Transfinite Line{l2} = 6; Transfinite Line{l2} = 6;
Transfinite Line{l3} = 10; Transfinite Line{l3} = 10;
// Put 30 points following a geometric progression on curve 1 // Put 30 points following a geometric progression on curve 1 (reversed) and on
// (reversed) and on curve 3 // curve 3
Transfinite Line{-1,3} = 30 Using Progression 1.2; Transfinite Line{-1,3} = 30 Using Progression 1.2;
// Define the Surface as transfinite, by specifying the four corners // Define the Surface as transfinite, by specifying the four corners of the
// of the transfinite interpolation // transfinite interpolation
Transfinite Surface{1} = {1,2,3,4}; Transfinite Surface{1} = {1,2,3,4};
// (Note that the list on the right hand side refers to points, not // (Note that the list on the right hand side refers to points, not curves. When
// curves. When the surface has only 3 or 4 points on its boundary the // the surface has only 3 or 4 points on its boundary the list can be
// list can be omitted. The way triangles are generated can be // omitted. The way triangles are generated can be controlled by appending
// controlled by appending "Left", "Right" or "Alternate" after the // "Left", "Right" or "Alternate" after the list.)
// list.)
// Recombine the triangles into quads // Recombine the triangles into quads
Recombine Surface{1}; Recombine Surface{1};
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* *
*********************************************************************/ *********************************************************************/
// Characteristic lengths can be specified very accuractely by // Characteristic lengths can be specified very accuractely by providing a
// providing a background mesh, i.e., a post-processing view that // background mesh, i.e., a post-processing view that contains the target mesh
// contains the target mesh sizes. // sizes.
// Merge the first tutorial // Merge the first tutorial
Merge "t1.geo"; Merge "t1.geo";
......
...@@ -53,10 +53,9 @@ View[v2].Height = 130; ...@@ -53,10 +53,9 @@ View[v2].Height = 130;
View[v3].Visible = 0; View[v3].Visible = 0;
// We then loop from 1 to 3 with a step of 1. (To use a different // We then loop from 1 to 3 with a step of 1. (To use a different step, just add
// step, just add a third argument in the list. For example, `For num // a third argument in the list. For example, `For num In {0.5:1.5:0.1}' would
// In {0.5:1.5:0.1}' would increment num from 0.5 to 1.5 with a step // increment num from 0.5 to 1.5 with a step of 0.1.)
// of 0.1.)
t = 0; t = 0;
...@@ -92,8 +91,8 @@ For num In {1:3} ...@@ -92,8 +91,8 @@ For num In {1:3}
// clipping) // clipping)
If (num == 3) If (num == 3)
// The `Print' command saves the graphical window; the `Sprintf' // The `Print' command saves the graphical window; the `Sprintf' function
// function permits to create the file names on the fly: // permits to create the file names on the fly:
/* /*
Print Sprintf("t8-%02g.gif", num2); Print Sprintf("t8-%02g.gif", num2);
Print Sprintf("t8-%02g.ppm", num2); Print Sprintf("t8-%02g.ppm", num2);
......
...@@ -6,12 +6,11 @@ ...@@ -6,12 +6,11 @@
* *
*********************************************************************/ *********************************************************************/
// Plugins can be added to Gmsh in order to extend its // Plugins can be added to Gmsh in order to extend its capabilities. For
// capabilities. For example, post-processing plugins can modify a // example, post-processing plugins can modify a view, or create a new view
// view, or create a new view based on previously loaded // based on previously loaded views. Several default plugins are statically
// views. Several default plugins are statically linked with Gmsh, // linked with Gmsh, e.g. Isosurface, CutPlane, CutSphere, Skin, Transform or
// e.g. Isosurface, CutPlane, CutSphere, Skin, Transform or Smooth. // Smooth. Plugins can be controlled in the same way as other options: either
// Plugins can be controlled in the same way as other options: either
// from the graphical interface (right click on the view button, then // from the graphical interface (right click on the view button, then
// `Plugins'), or from the command file. // `Plugins'), or from the command file.
...@@ -19,16 +18,15 @@ ...@@ -19,16 +18,15 @@
Include "view3.pos" ; Include "view3.pos" ;
// We then set some options for the `Isosurface' plugin (which // We then set some options for the `Isosurface' plugin (which extracts an
// extracts an isosurface from a 3D scalar view), and run it: // isosurface from a 3D scalar view), and run it:
Plugin(Isosurface).Value = 0.67 ; // iso-value level Plugin(Isosurface).Value = 0.67 ; // iso-value level
Plugin(Isosurface).View = 0 ; // source view is View[0] Plugin(Isosurface).View = 0 ; // source view is View[0]
Plugin(Isosurface).Run ; // run the plugin! Plugin(Isosurface).Run ; // run the plugin!
// We also set some options for the `CutPlane' plugin (which computes // We also set some options for the `CutPlane' plugin (which computes a section
// a section of a 3D view using the plane A*x+B*y+C*z+D=0), and then // of a 3D view using the plane A*x+B*y+C*z+D=0), and then run it:
// run it:
Plugin(CutPlane).A = 0 ; Plugin(CutPlane).A = 0 ;
Plugin(CutPlane).B = 0.2 ; Plugin(CutPlane).B = 0.2 ;
...@@ -37,10 +35,9 @@ Plugin(CutPlane).D = 0 ; ...@@ -37,10 +35,9 @@ Plugin(CutPlane).D = 0 ;
Plugin(CutPlane).View = 0 ; Plugin(CutPlane).View = 0 ;
Plugin(CutPlane).Run ; Plugin(CutPlane).Run ;
// Add a title (By convention, for window coordinates a value greater // Add a title (By convention, for window coordinates a value greater than 99999
// than 99999 represents the center. We could also use // represents the center. We could also use `General.GraphicsWidth / 2', but
// `General.GraphicsWidth / 2', but that would only center the string // that would only center the string for the current window size.):
// for the current window size.):
Plugin(Annotate).Text = "A nice title" ; Plugin(Annotate).Text = "A nice title" ;
Plugin(Annotate).X = 1.e5; Plugin(Annotate).X = 1.e5;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment