5. Geometry module
Gmsh's geometry module provides a simple CAD engine, using a boundary
representation ("BRep") approach: you need to first define points
(using the Point
command: see below), then lines (using
Line
, Circle
, Spline
, ..., commands or by
extruding points), then surfaces (using for example the Plane
Surface
or Ruled Surface
commands, or by extruding lines), and
finally volumes (using the Volume
command or by extruding
surfaces).
These geometrical entities are called "elementary" in Gmsh's jargon, and
are assigned identification numbers when they are created:
- each elementary point must possess a unique identification number;
- each elementary line must possess a unique identification number;
- each elementary surface must possess a unique identification number;
- each elementary volume must possess a unique identification number.
Elementary geometrical entities can then be manipulated in various
ways, for example using the Translate
, Rotate
,
Scale
or Symmetry
commands. They can be deleted with the
Delete
command, provided that no higher-dimension entity
references them.
Compound groups of elementary geometrical entities can also be defined and
are called "physical" entities. These physical entities cannot be modified
by geometry commands: their only purpose is to assemble elementary entities
into larger groups, possibly modifying their orientation, so that they can
be referred to by the mesh module as single entities. As is the case with
elementary entities, each physical point, physical line, physical surface or
physical volume must be assigned a unique identification number. See
6. Mesh module, for more information about how physical entities affect
the way meshes are saved.
5.1 Geometry commands
The next subsections describe all the available geometry commands. These
commands can be used anywhere in a Gmsh script file. Note that the
following general syntax rule is followed for the definition of
geometrical entities: "If an expression defines a new entity, it
is enclosed between parentheses. If an expression refers to a
previously defined entity, it is enclosed between braces."
5.1.1 Points
Point ( expression ) = { expression, expression, expression <, expression > };
-
Creates an elementary point. The expression inside the parentheses
is the point's identification number; the three first
expressions inside the braces on the right hand side give the
three X, Y and Z coordinates of the point in the three-dimensional
Euclidean space; the optional last expression sets the
characteristic mesh length at that point. See 6.2.1 Characteristic lengths, for more information about how this characteristic length
information is used in the meshing process.
Physical Point ( expression | char-expression ) = { expression-list };
-
Creates a physical point. The expression inside the parentheses is
the physical point's identification number (if a char-expression
is given instead, a unique identification number is automatically
created); the expression-list on the right hand side should
contain the identification numbers of all the elementary points that
need to be grouped inside the physical point.
5.1.2 Lines
BSpline ( expression ) = { expression-list };
-
Creates a B-spline curve. The expression inside the parentheses is the
B-spline curve's identification number; the expression-list on the
right hand side should contain the identification numbers of all the
B-spline's control points. Repeating control points has the expected effect.
Circle ( expression ) = { expression, expression, expression };
-
Creates a circle arc (strictly) smaller than Pi. The expression inside
the parentheses is the circle arc's identification number; the first
expression inside the braces on the right hand side gives the
identification number of the start point of the arc; the second
expression gives the identification number of the center of the
circle; the last expression gives the identification number of the end
point of the arc.
CatmullRom ( expression ) = { expression-list };
-
CatmullRom
is a synonym for Spline
.
Ellipse ( expression ) = { expression, expression, expression, expression };
-
Creates an ellipse arc. The expression inside the parentheses is the
ellipse arc's identification number; the first expression inside the
braces on the right hand side gives the identification number of the start
point of the arc; the second expression gives the identification
number of the center of the ellipse; the third expression gives the
identification number of any point located on the major axis of the ellipse;
the last expression gives the identification number of the end point
of the arc.
Line ( expression ) = { expression, expression };
-
Creates a straight line segment. The expression inside the parentheses
is the line segment's identification number; the two expressions
inside the braces on the right hand side give identification numbers of the
start and end points of the segment.
Spline ( expression ) = { expression-list };
-
Creates a spline curve. The expression inside the parentheses is the
spline's identification number; the expression-list on the right hand
side should contain the identification numbers of all the spline's control
points.
Line Loop ( expression ) = { expression-list };
-
Creates an oriented line loop. The expression inside the parentheses
is the line loop's identification number; the expression-list on the
right hand side should contain the identification numbers of all the
elementary lines that constitute the line loop. A line loop must be a closed
loop, and the elementary lines should be ordered and oriented (using
negative identification numbers to specify reverse orientation). If the
orientation is correct, but the ordering is wrong, Gmsh will actually
reorder the list internally to create a consistent loop. Although Gmsh
supports it, it is not recommended to specify multiple line loops (or
subloops) in a single
Line Loop
command. (Line loops are used to
create surfaces: see 5.1.3 Surfaces.)
Physical Line ( expression | char-expression ) = { expression-list };
-
Creates a physical line. The expression inside the parentheses is
the physical line's identification number (if a char-expression is
given instead, a unique identification number is automatically
created); the expression-list on the right hand side should
contain the identification numbers of all the elementary lines that need
to be grouped inside the physical line. Specifying negative
identification numbers in the expression-list will reverse the
orientation of the mesh elements belonging to the corresponding
elementary lines in the saved mesh.
5.1.3 Surfaces
Plane Surface ( expression ) = { expression-list };
-
Creates a plane surface. The expression inside the parentheses is the
plane surface's identification number; the expression-list on the
right hand side should contain the identification numbers of all the line
loops defining the surface. The first line loop defines the exterior
boundary of the surface; all other line loops define holes in the surface.
A line loop defining a hole should not have any lines in common with the
exterior line loop (in which case it is not a hole, and the two surfaces
should be defined separately). Likewise, a line loop defining a hole should
not have any lines in common with another line loop defining a hole in the
same surface (in which case the two line loops should be combined).
Ruled Surface ( expression ) = { expression-list } < In Sphere { expression } >;
-
Creates a ruled surface, i.e., a surface that can be interpolated using
transfinite interpolation. The expression inside the parentheses
is the ruled surface's identification number; the first
expression-list on the right hand side should the identification
number of a line loop composed of either three or four elementary
lines. The optional
In Sphere
argument forces the surface to be a
spherical patch (the extra parameter gives the identification number of
the center of the sphere).
Surface Loop ( expression ) = { expression-list };
-
Creates a surface loop (a shell). The expression inside the
parentheses is the surface loop's identification number; the
expression-list on the right hand side should contain the
identification numbers of all the elementary surfaces that constitute the
surface loop. A surface loop must always represent a closed shell, and the
elementary surfaces should be oriented consistently (using negative
identification numbers to specify reverse orientation). (Surface loops are
used to create volumes: see 5.1.4 Volumes.)
Physical Surface ( expression | char-expression ) = { expression-list };
-
Creates a physical surface. The expression inside the parentheses
is the physical surface's identification number (if a
char-expression is given instead, a unique identification number
is automatically created); the expression-list on the right hand
side should contain the identification numbers of all the elementary
surfaces that need to be grouped inside the physical surface. Specifying
negative identification numbers in the expression-list will
reverse the orientation of the mesh elements belonging to the
corresponding elementary surfaces in the saved mesh.
5.1.4 Volumes
Volume ( expression ) = { expression-list };
-
Creates a volume. The expression inside the parentheses is the
volume's identification number; the expression-list on the right hand
side should contain the identification numbers of all the surface loops
defining the volume. The first surface loop defines the exterior boundary of
the volume; all other surface loops define holes in the volume. A surface
loop defining a hole should not have any surfaces in common with the
exterior surface loop (in which case it is not a hole, and the two volumes
should be defined separately). Likewise, a surface loop defining a hole
should not have any surfaces in common with another surface loop defining a
hole in the same volume (in which case the two surface loops should be
combined).
Physical Volume ( expression | char-expression ) = { expression-list };
-
Creates a physical volume. The expression inside the parentheses
is the physical volume's identification number (if a
char-expression is given instead, a unique identification number
is automatically created); the expression-list on the right hand
side should contain the identification numbers of all the elementary
volumes that need to be grouped inside the physical volume.
5.1.5 Extrusions
Lines, surfaces and volumes can also be created through extrusion of points,
lines and surfaces, respectively. Here is the syntax of the geometrical
extrusion commands (go to 6.2.2 Structured grids, to see how these commands
can be extended in order to also extrude the mesh):
extrude:
Extrude { expression-list } { extrude-list }
-
Extrudes all elementary entities (points, lines or surfaces) in
extrude-list using a translation. The expression-list should
contain three expressions giving the X, Y and Z components of
the translation vector.
Extrude { { expression-list }, { expression-list }, expression } { extrude-list }
-
Extrudes all elementary entities (points, lines or surfaces) in
extrude-list using a rotation. The first expression-list
should contain three expressions giving the X, Y and Z
direction of the rotation axis; the second expression-list should
contain three expressions giving the X, Y and Z components of
any point on this axis; the last expression should contain the
rotation angle (in radians).
Extrude { { expression-list }, { expression-list }, { expression-list }, expression } { extrude-list }
-
Extrudes all elementary entities (points, lines or surfaces) in
extrude-list using a translation combined with a rotation. The
first expression-list should contain three expressions
giving the X, Y and Z components of the translation vector; the second
expression-list should contain three expressions giving
the X, Y and Z direction of the rotation axis; the third
expression-list should contain three expressions giving
the X, Y and Z components of any point on this axis; the last
expression should contain the rotation angle (in radians).
with
| extrude-list:
Point | Line | Surface { expression-list }; ...
|
As explained in 4.2.1 Floating point expressions, extrude can be
used in an expression, in which case it returns a list of identification
numbers. By default, the list contains the "top" of the extruded
entity at index 0 and the extruded entity at index 1, followed by the
"sides" of the extruded entity at indices 2, 3, etc. For example:
| Point(1) = {0,0,0};
Point(2) = {1,0,0};
Line(1) = {1, 2};
out[] = Extrude{0,1,0}{ Line{1}; };
Printf("top line = %g", out[0]);
Printf("surface = %g", out[1]);
Printf("side lines = %g and %g", out[2], out[3]);
|
This behaviour can be changed with the
Geometry.ExtrudeReturnLateralEntities
option (see section B.2 Geometry options list).
5.1.6 Transformations
Geometrical transformations can be applied to elementary entities, or to
copies of elementary entities (using the Duplicata
command: see
below). The syntax of the transformation commands is:
transform:
Dilate { { expression-list }, expression } { transform-list }
-
Scales all elementary entities in transform-list by a factor
expression. The expression-list should contain three
expressions giving the X, Y and Z direction of the homothetic
transformation.
Rotate { { expression-list }, { expression-list }, expression } { transform-list }
-
Rotates all elementary entities in transform-list by an angle of
expression radians. The first expression-list should contain
three expressions giving the X, Y and Z direction of the
rotation axis; the second expression-list should contain three
expressions giving the X, Y and Z components of any point on
this axis.
Symmetry { expression-list } { transform-list }
-
Transforms all elementary entities symmetrically to a plane. The
expression-list should contain four expressions giving
the coefficients of the plane's equation.
Translate { expression-list } { transform-list }
-
Translates all elementary entities in transform-list. The
expression-list should contain three expressions giving
the X, Y and Z components of the translation vector.
Boundary { transform-list }
-
(Not a transformation per-se.) Returns the boundary of the elementary
entities in transform-list.
with
| transform-list:
Point | Line | Surface | Volume { expression-list }; ... |
Duplicata { Point | Line | Surface | Volume { expression-list }; ... } |
transform
|
5.1.7 Miscellaneous
Here is a list of all other geometry commands currently available:
Coherence;
-
Removes all duplicate elementary geometrical entities (e.g., points
having identical coordinates). Note that Gmsh executes the
Coherence
command automatically after each geometrical
transformation, unless Geometry.AutoCoherence
is set to zero
(see section B.2 Geometry options list).
Delete { Point | Line | Surface | Volume { expression-list }; ... }
-
Deletes all elementary entities whose identification numbers are given
in expression-list. If an entity is linked to another entity (for
example, if a point is used as a control point of a curve),
Delete
has no effect (the line will have to be deleted before the
point can).
Hide { Point | Line | Surface | Volume { expression-list }; ... }
-
Hide the entities listed in expression-list, if
General.VisibilityMode
is set to 0
or 1
.
Hide char-expression;
-
Hide the entity char-expression, if
General.VisibilityMode
is
set to 0
or 1
(char-expression can for example be
"*"
).
Show { Point | Line | Surface | Volume { expression-list }; ... }
-
Show the entities listed in expression-list, if
General.VisibilityMode
is set to 0
or 1
.
Show char-expression;
-
Show the entity char-expression, if
General.VisibilityMode
is
set to 0
or 1
(char-expression can for example be
"*"
).
5.2 Geometry options
The list of all the options that control the behavior of geometry
commands, as well as the way geometrical entities are handled in the
GUI, is give in B.2 Geometry options list.
Back to geuz.org/gmsh