openCASCADE Engine

Using the openCASCADE kernel instead of the built-in geometry kernel. Models can be built using constructive solid geometry, allowing for 2D and 3D polygon boolean operations.

Geometry

class pygmsh.occ.geometry.Geometry(init_argv=None)

Bases: pygmsh.common.geometry.CommonGeometry

add_ball(*args, mesh_size=None, **kwargs)
add_box(*args, mesh_size=None, **kwargs)
add_cone(*args, mesh_size=None, **kwargs)
add_cylinder(*args, mesh_size=None, **kwargs)
add_disk(*args, mesh_size=None, **kwargs)
add_ellipsoid(center, radii, mesh_size=None)
add_rectangle(*args, mesh_size=None, **kwargs)
add_torus(*args, mesh_size=None, **kwargs)
add_wedge(*args, mesh_size=None, **kwargs)
boolean_difference(d0, d1, delete_first=True, delete_other=True)

Boolean difference, see https://gmsh.info/doc/texinfo/gmsh.html#Boolean-operations input_entity and tool_entity are called object and tool in gmsh documentation.

boolean_fragments(d0, d1, delete_first=True, delete_other=True)

Boolean fragments, see https://gmsh.info/doc/texinfo/gmsh.html#Boolean-operations input_entity and tool_entity are called object and tool in gmsh documentation.

boolean_intersection(entities, delete_first=True, delete_other=True)

Boolean intersection, see https://gmsh.info/doc/texinfo/gmsh.html#Boolean-operations input_entity and tool_entity are called object and tool in gmsh documentation.

boolean_union(entities, delete_first=True, delete_other=True)

Boolean union, see https://gmsh.info/doc/texinfo/gmsh.html#Boolean-operations input_entity and tool_entity are called object and tool in gmsh documentation.

property characteristic_length_max
property characteristic_length_min
force_outward_normals(tag)
import_shapes(filename)
revolve(*args, **kwargs)

Ball

class pygmsh.occ.ball.Ball(center, radius, angle1=- 1.5707963267948966, angle2=1.5707963267948966, angle3=6.283185307179586)

Bases: object

Creates a sphere.

Parameters
  • center (array-like[3]) – Center of the ball.

  • radius (float) – Radius of the ball.

  • x0 (float) – If specified and x0 > -1, the ball is cut off at x0*radius parallel to the y-z plane.

  • x1 (float) – If specified and x1 < +1, the ball is cut off at x1*radius parallel to the y-z plane.

  • alpha (float) – If specified and alpha < 2*pi, the points between alpha and 2*pi w.r.t. to the x-y plane are not part of the object.

  • char_length (float) – If specified, sets the Characteristic Length property.

dim = 3

Box

class pygmsh.occ.box.Box(x0, extents, char_length=None)

Bases: object

Creates a box.

Parameters
  • x0 (array-like[3]) – List containing the x, y, z values of the start point.

  • extends (array-like[3]) – List of the 3 extents of the box edges.

  • char_length (float) – Characteristic length of the mesh elements of this polygon.

dim = 3

Cone

class pygmsh.occ.cone.Cone(center, axis, radius0, radius1, angle=6.283185307179586)

Bases: object

Creates a cone.

centerarray-like[3]

The 3 coordinates of the center of the first circular face.

axisarray-like[3]

The 3 components of the vector defining its axis.

radius0float

Radius of the first circle.

radius1float

Radius of the second circle.

anglefloat

Angular opening of the the Cone.

dim = 3

Cylinder

class pygmsh.occ.cylinder.Cylinder(x0, axis, radius, angle=6.283185307179586)

Bases: object

Creates a cylinder.

Parameters
  • x0 (array-like[3]) – The 3 coordinates of the center of the first circular face.

  • axis (array-like[3]) – The 3 components of the vector defining its axis.

  • radius (float) – Radius value of the cylinder.

  • angle (float) – Angular opening of the cylinder.

dim = 3

Disk

class pygmsh.occ.disk.Disk(x0, radius0, radius1=None)

Bases: object

Creates a disk.

Parameters
  • x0 (array-like[3]) – The 3 coordinates of the center of the disk face.

  • radius0 (float) – Radius value of the disk.

  • radius1 (float) – Radius along Y, leading to an ellipse.

dim = 2

Rectangle

class pygmsh.occ.rectangle.Rectangle(x0, a, b, corner_radius=None)

Bases: object

Creates a rectangle.

x0array-like[3]

The 3 first expressions define the lower-left corner.

afloat

Rectangle width.

bfloat

Rectangle height.

corner_radiusfloat

Defines a radius to round the rectangle corners.

dim = 2

Torus

class pygmsh.occ.torus.Torus(center, radius0, radius1, alpha=6.283185307179586)

Bases: object

Creates a torus.

centerarray-like[3]

The 3 coordinates of its center.

radius0float

Inner radius.

radius1float

Outer radius.

alphafloat

Defines the angular opening.

dim = 3

Wedge

class pygmsh.occ.wedge.Wedge(x0, extents, top_extent=None)

Bases: object

Creates a right angular wedge.

x0array-like[3]

The 3 coordinates of the right-angle point.

extendsarray-like[3]

List of the 3 extends of the box edges.

top_extendfloat

Defines the top X extent.

dim = 3