constraint generation
GeneratesConstraintsMixin
Role mixin for components that build runtime constraints.
Use this mixin when a component must create multi-point or single-point constraints only after it has discovered geometry relationships at runtime. This is common for embedded or coupling interfaces where the paired nodes are not fully known until the assembled mesh has been inspected.
The two hook methods deliberately separate:
build_constraints(): decide what constraints should existregister_constraints(): push those constraints into the owning model
Example
class CouplingInterface(GeneratesConstraintsMixin):
def build_constraints(self, assembled_mesh, **kwargs):
self.constraints = [("equal_dof", 10, 25, [1, 2, 3])]
def register_constraints(self):
for _, master, slave, dofs in self.constraints:
self._owner._mesh_maker.constraint.mp.equal_dof(master, [slave], dofs)
Note
This mixin is about lifecycle-dependent constraint creation. If a constraint can be created directly up front, it usually does not need to be routed through the event system.
Methods:
build_constraints
Construct the component-owned constraint description.
Subclasses implement this hook after geometry pairing, node lookup, or post-assembly inspection has revealed what constraints are required.
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. |