Skip to content

mesh generation

GeneratesMeshMixin

Role mixin for components that generate auxiliary mesh cells.

Use this mixin when a component needs to create its own mesh representation after the ordinary model geometry already exists. This is common for advanced interfaces that derive extra elements from the assembled mesh rather than from a simple pre-assembly meshpart.

In practice, components using this mixin usually:

  1. subscribe to a lifecycle event such as POST_ASSEMBLE
  2. inspect the assembled mesh or nearby geometry
  3. build an internal interface mesh
  4. merge or attach that mesh into the model-owned assembled mesh

The two hook methods separate those responsibilities:

  • build_mesh() creates the component's internal mesh description
  • integrate_mesh() inserts that mesh into the assembled model
Example
class MyInterface(GeneratesMeshMixin):
    def build_mesh(self, assembled_mesh, **kwargs):
        self.interface_mesh = assembled_mesh.extract_surface()

    def integrate_mesh(self, assembled_mesh, **kwargs):
        assembled_mesh.merge(self.interface_mesh, inplace=True)
Tip

Use this mixin when the component is responsible for cells or an actual interface mesh. If the component only creates standalone points, GeneratesNodesMixin is the better fit.

Methods:

build_mesh

build_mesh(**kwargs) -> None

Construct the component-owned auxiliary mesh.

Subclasses implement this hook to derive the interface mesh they need from runtime context such as the assembled mesh, nearby cells, or component-specific geometry.

Parameters:

Name Type Description Default
**kwargs

Arbitrary keyword arguments passed from the build context.

{}

Raises:

Type Description
NotImplementedError

If the subclass does not implement this method.

integrate_mesh

integrate_mesh(assembled_mesh, **kwargs) -> None

Integrate the generated mesh into the model-owned assembled mesh.

This hook runs after build_mesh() has created the component's auxiliary mesh. Subclasses use it to merge, attach, or otherwise register that geometry with the global assembled mesh.

Parameters:

Name Type Description Default
assembled_mesh

The global assembled mesh object to which the interface mesh cells will be attached.

required
**kwargs

Arbitrary keyword arguments passed from the integration context.

{}