Common

Common functions shared between the geo and the occ kernels.

Geometry

class pygmsh.common.geometry.CommonGeometry(env, init_argv=None)

Bases: object

Geometry base class containing all methods that can be shared between built-in and occ.

add_boundary_layer(*args, **kwargs)
add_bspline(*args, **kwargs)
add_circle_arc(*args, **kwargs)
add_curve_loop(*args, **kwargs)
add_ellipse_arc(*args, **kwargs)
add_line(*args, **kwargs)
add_physical(entities, label: Optional[str] = None)
add_plane_surface(*args, **kwargs)
add_point(*args, **kwargs)
add_polygon(*args, **kwargs)
add_spline(*args, **kwargs)
add_surface(*args, **kwargs)
add_surface_loop(*args, **kwargs)
add_volume(*args, **kwargs)
copy(obj)
dilate(obj, x0: Tuple[float, float, float], abc: Tuple[float, float, float])
extrude(input_entity, translation_axis: Tuple[float, float, float], num_layers: Union[int, List[int], None] = None, heights: Optional[List[float]] = None, recombine: bool = False)

Extrusion of any entity along a given translation_axis.

generate_mesh(dim: int = 3, order: Optional[int] = None, algorithm: Optional[int] = None, verbose: bool = False)

Return a meshio.Mesh, storing the mesh points, cells, and data, generated by Gmsh from the self.

in_surface(input_entity, surface)

Embed the point(s) or curve(s) in the given surface. The surface mesh will conform to the mesh of the point(s) or curves(s).

in_volume(input_entity, volume)

Embed the point(s)/curve(s)/surface(s) in the given volume. The volume mesh will conform to the mesh of the input entities.

mirror(obj, abcd: Tuple[float, float, float, float])
remove(obj, recursive: bool = False)
rotate(obj, point: Tuple[float, float, float], angle: float, axis: Tuple[float, float, float])
Rotate input_entity around a given point with a given angle.
Rotation axis has to be specified.

Changes the input object.

save_geometry(filename: str)
set_background_mesh(*args, **kwargs)
set_mesh_size_callback(fun, ignore_other_mesh_sizes=True)
set_recombined_surfaces(surfaces)
set_transfinite_curve(curve, num_nodes: int, mesh_type: str, coeff: float)
set_transfinite_surface(surface, arrangement: str, corner_pts)
set_transfinite_volume(volume, corner_pts)
symmetrize(obj, coefficients: Tuple[float, float, float, float])

Transforms all elementary entities symmetrically to a plane. The vector should contain four expressions giving the coefficients of the plane’s equation.

synchronize()
translate(obj, vector: Tuple[float, float, float])

Translates input_entity itself by vector.

Changes the input object.

Bspline

class pygmsh.common.bspline.BSpline(env, control_points)

Bases: pygmsh.common.line_base.LineBase

Creates a B-spline.

Parameters:control_points (List[Point]) – Contains the identification numbers of the control points.

CircleArc

class pygmsh.common.circle_arc.CircleArc(env, start, center, end)

Bases: pygmsh.common.line_base.LineBase

Creates a circle arc.

Parameters:
  • start (Point) – Coordinates of start point needed to construct circle-arc.
  • center (Point) – Coordinates of center point needed to construct circle-arc.
  • end (Point) – Coordinates of end point needed to construct circle-arc.

EllipseArc

class pygmsh.common.ellipse_arc.EllipseArc(env, start, center, point_on_major_axis, end)

Bases: pygmsh.common.line_base.LineBase

Creates an ellipse arc.

Parameters:
  • start (Point) – Coordinates of start point needed to construct elliptic arc.
  • center (Point) – Coordinates of center point needed to construct elliptic arc.
  • point_on_major_axis (Point) – Point on the center axis of ellipse.
  • end (Point) – Coordinates of end point needed to construct elliptic arc.

LineBase

class pygmsh.common.line_base.LineBase(id0, points)

Bases: object

Parameters:
  • id0 (int) –
  • points (list of int) –
dim = 1

CurveLoop

class pygmsh.common.curve_loop.CurveLoop(env, curves)

Bases: object

Increments 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.

dim = 1

Line

class pygmsh.common.line.Line(env, p0, p1)

Bases: pygmsh.common.line_base.LineBase

Creates 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.

dim = 1

Point

class pygmsh.common.point.Point(env, x, mesh_size=None)

Bases: object

Creates an elementary point.

x : array-like[3]
Give the three X, Y and Z coordinates of the point in the three-dimensional Euclidean space.
mesh_size : float
The prescribed mesh element size at this point.
dim = 0

Spline

class pygmsh.common.spline.Spline(env, points)

Bases: pygmsh.common.line_base.LineBase

With the built-in geometry kernel this constructs a Catmull-Rom spline.

Parameters:points (list) – List containing Point objects

SurfaceLoop

class pygmsh.common.surface_loop.SurfaceLoop(env, surfaces)

Bases: object

Creates a surface loop (a shell).

Parameters: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).

dim = 2

Surface

class pygmsh.common.surface.Surface(env, curve_loop)

Bases: object

Generates a Surface from a CurveLoop.

Parameters:curve_loop (Object) – CurveLoop object that contains all the Line objects for the loop construction.

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).

dim = 2

Volume

class pygmsh.common.volume.Volume(env, surface_loop, holes=None)

Bases: object

Creates 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).

dim = 3