Built-in Engine¶
The default Gmsh kernel with basic geometry construction functions. For advanced geometries it is recommended to use the openCASCADE kernel.
Geometry¶
-
class
pygmsh.built_in.geometry.Geometry(gmsh_major_version=None)¶ Bases:
object-
class
Polygon(points, lines, line_loop, surface, lcar=None)¶ Bases:
object
-
add_ball(x0, radius, **kwargs)¶
-
add_boundary_layer(edges_list=None, faces_list=None, nodes_list=None, anisomax=None, hfar=None, hwall_n=None, ratio=None, thickness=None)¶
-
add_box(x0, x1, y0, y1, z0, z1, lcar=None, with_volume=True, holes=None)¶
-
add_bspline(*args, **kwargs)¶
-
add_circle(x0, radius, lcar=None, R=None, compound=False, num_sections=3, holes=None, make_surface=True)¶ Add circle in the \(x\)-\(y\)-plane.
-
add_circle_arc(*args, **kwargs)¶
-
add_comment(string)¶
-
add_compound_line(*args, **kwargs)¶
-
add_compound_surface(*args, **kwargs)¶
-
add_compound_volume(*args, **kwargs)¶
-
add_ellipse_arc(*args, **kwargs)¶
-
add_ellipsoid(x0, radii, lcar=None, with_volume=True, holes=None)¶ Creates an ellipsoid with radii around a given midpoint \(x_0\).
-
add_line(*args, **kwargs)¶
-
add_line_loop(*args, **kwargs)¶
-
add_physical(entities, label=None)¶
-
add_physical_line(lines, label=None)¶
-
add_physical_point(points, label=None)¶
-
add_physical_surface(surfaces, label=None)¶
-
add_physical_volume(volumes, label=None)¶
-
add_pipe(outer_radius, inner_radius, length, R=array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]), x0=array([0., 0., 0.]), lcar=None, variant='rectangle_rotation')¶
-
add_plane_surface(*args, **kwargs)¶
-
add_point(*args, **kwargs)¶
-
add_polygon(X, lcar=None, holes=None, make_surface=True)¶
-
add_raw_code(string_or_list)¶ Add raw Gmsh code.
-
add_rectangle(xmin, xmax, ymin, ymax, z, lcar=None, holes=None, make_surface=True)¶
-
add_spline(*args, **kwargs)¶
-
add_surface(*args, **kwargs)¶
-
add_surface_loop(*args, **kwargs)¶
-
add_torus(irad, orad, lcar=None, R=array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]), x0=array([0., 0., 0.]), variant='extrude_lines')¶
-
add_volume(*args, **kwargs)¶
-
define_constant(*args, **kwargs)¶
-
extrude(input_entity, translation_axis=None, rotation_axis=None, point_on_axis=None, angle=None, num_layers=None, recombine=False)¶ Extrusion (translation + rotation) of any entity along a given translation_axis, around a given rotation_axis, about a given angle. If one of the entities is not provided, this method will produce only translation or rotation.
-
get_code()¶ Returns properly formatted Gmsh code.
-
in_surface(input_entity, surface)¶
-
rotate(input_entity, point, angle, axis)¶ - Rotate input_entity around a given point with a give angle.
Rotation axis has to be specified.
Changes the input object.
-
set_boundary_layers(fields)¶
-
set_recombined_surfaces(surfaces)¶
-
set_transfinite_lines(lines, size, progression=None, bump=None)¶
-
set_transfinite_surface(surface, size=None, orientation=None)¶
-
symmetry(input_entity, coefficients, duplicate=True)¶ Transforms all elementary entities symmetrically to a plane. The vector should contain four expressions giving the coefficients of the plane’s equation.
-
translate(input_entity, vector)¶ Translates input_entity itself by vector.
Changes the input object.
-
class
Bspline¶
-
class
pygmsh.built_in.bspline.Bspline(control_points)¶ Bases:
pygmsh.built_in.line_base.LineBaseCreates a BSpline.
- Parameters
control_points (List[Point]) – Contains the identification numbers of the control points.
CircleArc¶
-
class
pygmsh.built_in.circle_arc.CircleArc(start, center, end)¶ Bases:
pygmsh.built_in.line_base.LineBaseCreates a circle arc.
CompoundLine¶
-
class
pygmsh.built_in.compound_line.CompoundLine(lines)¶ Bases:
pygmsh.built_in.line_base.LineBaseCreates a compound line from several elementary lines. When meshed, a compound line will be reparametrized as a single line, whose mesh can thus cross internal boundaries.
- Parameters
lines (array-like[N]) – Contains the identification number of the elementary lines that should be reparametrized as a single line.
CompoundSurface¶
-
class
pygmsh.built_in.compound_surface.CompoundSurface(surfaces)¶ Bases:
pygmsh.built_in.surface_base.SurfaceBaseGenerates the Compound Surface Gmsh function. Creates a compound surface from several elementary surfaces. When meshed, a compound surface will be reparametrized as a single surface, whose mesh can thus cross internal boundaries. Compound surfaces are mostly useful for remeshing discrete models.
- Parameters
surfaces (array-like[N]) – Contains the identification number of the elementary surfaces that should be reparametrized as a single surface.
CompoundVolume¶
-
class
pygmsh.built_in.compound_volume.CompoundVolume(volumes)¶ Bases:
objectCreates a compound volume from several elementary volumes. When meshed, a compound volume will be reparametrized as a single volume, whose mesh can thus cross internal boundaries.
- Parameters
volumes (array-like[N]) – Contains the identification number of the elementary volumes that should be reparametrized as a single volume.
EllipseArc¶
-
class
pygmsh.built_in.ellipse_arc.EllipseArc(start, center, point_on_major_axis, end)¶ Bases:
pygmsh.built_in.line_base.LineBaseCreates an ellipse arc.
- Parameters
LineBase¶
LineLoop¶
-
class
pygmsh.built_in.line_loop.LineLoop(lines)¶ Bases:
objectIncrements the Line ID every time a new object is created that inherits from LineBase.
- Parameters
id0 (str) – If no unique ID is given, the object global is incremented.
lines (list) – Containing the lines defining the shape.
Notes
A line loop must be a closed loop, and the elementary lines should be ordered and oriented (negating 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.
-
dimension= 1¶
Line¶
-
class
pygmsh.built_in.line.Line(p0, p1)¶ Bases:
pygmsh.built_in.line_base.LineBaseCreates a straight line segment.
- Parameters
p0 (Object) – Point object that represents the start of the line.
p1 (Object) – Point object that represents the end of the line.
- Variables
points (array-like[1][2]) – List containing the begin and end points of the line.
-
dimension= 1¶
PlaneSurface¶
-
class
pygmsh.built_in.plane_surface.PlaneSurface(line_loop, holes=None)¶ Bases:
pygmsh.built_in.surface_base.SurfaceBaseCreates a plane surface.
- Parameters
line_loop (Object) – Each unique line in the line loop will be used for the surface construction.
holes (list) – List of line loops that represents polygon holes.
Notes
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).
Point¶
-
class
pygmsh.built_in.point.Point(x, lcar=None)¶ Bases:
pygmsh.built_in.point_base.PointBaseCreates an elementary point.
- xarray-like[3]
Give the three X, Y and Z coordinates of the point in the three-dimensional Euclidean space.
- lcarfloat
The prescribed mesh element size at this point.
Spline¶
-
class
pygmsh.built_in.spline.Spline(points)¶ Bases:
pygmsh.built_in.line_base.LineBaseWith the built-in geometry kernel this constructs a Catmull-Rom spline.
- Parameters
points (list) – List containing Point objects
SurfaceBase¶
SurfaceLoop¶
-
class
pygmsh.built_in.surface_loop.SurfaceLoop(surfaces)¶ Bases:
objectCreates a surface loop (a shell). Increments the Line ID every time a new object is created that inherits from LineBase.
- Parameters
id0 (str) – The surface loop’s identification number. If None then the object’s global ID is incremented.
surfaces (list) – Contain the identification numbers of all the elementary surfaces that constitute the surface loop.
Notes
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).
-
dimension= 2¶
Surface¶
-
class
pygmsh.built_in.surface.Surface(line_loop, api_level=2)¶ Bases:
objectGenerates a Surface or Rules Surfaces.
- Parameters
line_loop (Object) – LineLoop object that contains all the Line objects for the loop construction.
api_level (integer) – If larger than 2 a Surface will be constructed, otherwise a Ruled Surface will be constructed instead.
Notes
With the built-in kernel, the first line loop should be composed of either three or four elementary lines.
With the built-in kernel, 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).
-
dimension= 2¶
-
num_edges= 0¶
VolumeBase¶
Volume¶
-
class
pygmsh.built_in.volume.Volume(surface_loop, holes=None)¶ Bases:
pygmsh.built_in.volume_base.VolumeBaseCreates a volume.
- Parameters
surface_loop (list) – Contain the identification numbers of all the surface loops defining the volume.
holes (list) – List containing surface loop objects that represents polygon holes.
Notes
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).