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.opencascade.geometry.Geometry(characteristic_length_min=None, characteristic_length_max=None)

Bases: pygmsh.built_in.geometry.Geometry

add_ball(*args, **kwargs)
add_box(*args, **kwargs)
add_cone(*args, **kwargs)
add_cylinder(*args, **kwargs)
add_disk(*args, **kwargs)
add_ellipsoid(*args, **kwargs)

Creates an ellipsoid with radii around a given midpoint \(x_0\).

add_rectangle(*args, **kwargs)
add_torus(*args, **kwargs)
add_wedge(*args, **kwargs)
boolean_difference(*args, **kwargs)

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(*args, **kwargs)

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.

get_code()

Returns properly formatted Gmsh code.

Ball

class pygmsh.opencascade.ball.Ball(center, radius, x0=None, x1=None, alpha=None, char_length=None)

Bases: pygmsh.opencascade.volume_base.VolumeBase

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.

Box

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

Bases: pygmsh.opencascade.volume_base.VolumeBase

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.

Cone

class pygmsh.opencascade.cone.Cone(center, axis, radius0, radius1, alpha=None, char_length=None)

Bases: pygmsh.opencascade.volume_base.VolumeBase

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.

alphafloat

Angular opening of the the Cone.

Cylinder

class pygmsh.opencascade.cylinder.Cylinder(x0, axis, radius, angle=None, char_length=None)

Bases: pygmsh.opencascade.volume_base.VolumeBase

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.

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

Disk

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

Bases: pygmsh.opencascade.surface_base.SurfaceBase

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.

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

Rectangle

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

Bases: pygmsh.opencascade.surface_base.SurfaceBase

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.

char_lengthfloat

Characteristic length of the mesh elements of this polygon.

SurfaceBase

class pygmsh.opencascade.surface_base.SurfaceBase(is_list=False, id0=None)

Bases: pygmsh.built_in.surface_base.SurfaceBase

Increments the Surface ID every time a new surface object is created. Inherits from built_in SurfaceBase.

char_length_code(char_length)
dimension = 2

Torus

class pygmsh.opencascade.torus.Torus(center, radius0, radius1, alpha=None, char_length=None)

Bases: pygmsh.opencascade.volume_base.VolumeBase

Creates a torus.

centerarray-like[3]

The 3 coordinates of its center.

radius0float

Inner radius.

radius1float

Outer radius.

alphafloat

Defines the angular opening.

char_lengthfloat

Characteristic length of the mesh elements of this polygon.

VolumeBase

class pygmsh.opencascade.volume_base.VolumeBase(is_list=False, id0=None)

Bases: pygmsh.built_in.volume_base.VolumeBase

Increments the Volume ID every time a new volume object is created. Inherits from built_in VolumeBase.

char_length_code(char_length)
dimension = 3

Wedge

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

Bases: pygmsh.opencascade.volume_base.VolumeBase

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.

char_lengthfloat

Characteristic length of the mesh elements of this polygon.