PreconditionedConjugateResidual
A Constraint Solver using the Linear Complementarity Problem formulation to solve Constraint based components using a Projected Jacobi iterative method
Target: Sofa.Component.Constraint.Lagrangian.Solver
namespace: sofa::component::constraint::lagrangian::solver
parents:
- BuiltConstraintSolver
Data
| Name | Description | Default value |
|---|---|---|
| name | object name | unnamed |
| printLog | if true, emits extra messages at runtime. | 0 |
| tags | list of the subsets the object belongs to | |
| bbox | this object bounding box | |
| componentState | The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). | Undefined |
| listening | if true, handle the events, otherwise ignore the events | 0 |
| maxIterations | maximal number of iterations of iterative algorithm | 1000 |
| tolerance | residual error threshold for termination of the Gauss-Seidel algorithm | 0.001 |
| sor | Successive Over Relaxation parameter (0-2) | 1 |
| regularizationTerm | Add regularization factor times the identity matrix to the compliance W when solving constraints | 0 |
| scaleTolerance | Scale the error tolerance with the number of constraints | 1 |
| allVerified | All constraints must be verified (each constraint's error < tolerance) | 0 |
| computeGraphs | Compute graphs of errors and forces during resolution | 0 |
| constraintForces | OUTPUT: constraint forces (stored only if computeConstraintForces=True) | |
| computeConstraintForces | enable the storage of the constraintForces. | 0 |
| nbThreads | If not yet initialized, the main task scheduler is initialized with this number of threads. 0 corresponds to the number of available cores on the CPU. -n (minus) corresponds to the number of available cores on the CPU minus the provided number. | 0 |
| taskSchedulerType | Type of task scheduler to use. | _default |
| multithreading | Build compliances concurrently | 0 |
| useSVDForRegularization | Use SVD decomposiiton of the compliance matrix to project singular values smaller than regularization to the regularization term. Only works with built | 0 |
| svdSingularValueNullSpaceCriteriaFactor | Fraction of the highest singular value bellow which a singular value will be supposed to belong to the nullspace | 0.01 |
| svdSingularVectorNullSpaceCriteriaFactor | Absolute value bellow which a component of a normalized base vector will be considered null | 0.001 |
| Graph | ||
| graphErrors | Sum of the constraints' errors at each iteration | |
| graphConstraints | Graph of each constraint's error at the end of the resolution | |
| Graph2 | ||
| graphForces | Graph of each constraint's force at each step of the resolution | |
| graphViolations | Graph of each constraint's violation at each step of the resolution | |
| Stats | ||
| currentNumConstraints | OUTPUT: current number of constraints | 0 |
| currentNumConstraintGroups | OUTPUT: current number of constraints | 0 |
| currentIterations | OUTPUT: current number of constraint groups | 0 |
| currentError | OUTPUT: current error | 0 |
Links
| Name | Description | Destination type name |
|---|---|---|
| context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) | BaseContext |
| slaves | Sub-objects used internally by this object | BaseComponent |
| master | nullptr for regular objects, or master object for which this object is one sub-objects | BaseComponent |
| constraintCorrections | List of constraint corrections handled by this constraint solver | BaseConstraintCorrection |
Examples
PreconditionedConjugateResidual.scn
<?xml version="1.0"?>
<Node name="root" dt="0.01" gravity="0 0 -0.981">
<RequiredPlugin name="Sofa.Component.AnimationLoop"/> <!-- Needed to use components [FreeMotionAnimationLoop] -->
<RequiredPlugin name="Sofa.Component.Collision.Geometry"/> <!-- Needed to use components [TriangleCollisionModel] -->
<RequiredPlugin name="Sofa.Component.Constraint.Lagrangian.Correction"/> <!-- Needed to use components [LinearSolverConstraintCorrection] -->
<RequiredPlugin name="Sofa.Component.Constraint.Lagrangian.Model"/> <!-- Needed to use components [FixedLagrangianConstraint] -->
<RequiredPlugin name="Sofa.Component.Constraint.Lagrangian.Solver"/> <!-- Needed to use components [GenericConstraintSolver] -->
<RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [BoxROI] -->
<RequiredPlugin name="Sofa.Component.LinearSolver.Direct"/> <!-- Needed to use components [SparseLDLSolver] -->
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
<RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
<RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
<RequiredPlugin name="Sofa.Component.SolidMechanics.FEM.Elastic"/> <!-- Needed to use components [TetrahedronFEMForceField] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [TetrahedronSetTopologyContainer TetrahedronSetTopologyModifier TriangleSetTopologyContainer TriangleSetTopologyModifier] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
<RequiredPlugin name="Sofa.Component.Topology.Mapping"/> <!-- Needed to use components [Hexa2TetraTopologicalMapping Tetra2TriangleTopologicalMapping] -->
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<RequiredPlugin name="Sofa.GUI.Component"/> <!-- Needed to use components [ConstraintAttachButtonSetting] -->
<VisualStyle displayFlags="showForceFields"/>
<ConstraintAttachButtonSetting /> <!-- The presence of this component sets the mouse interaction to Lagrangian-based constraints at the GUI launch -->
<FreeMotionAnimationLoop />
<PreconditionedConjugateResidual maxIterations="30" tolerance="1e-9" regularizationTerm="0"/>
<!-- $$$$$$$$$$$$$$$$$$$$$$ TOPOLOGY 1 $$$$$$$$$$$$$$$$$$$$$$ -->
<Node name="BEAMVOLUME">
<RegularGridTopology name="HexaTop" n="25 5 5" min="0 0 0" max="0.5 0.1 0.1"/>
<TetrahedronSetTopologyContainer name="Container" position="@HexaTop.position"/>
<TetrahedronSetTopologyModifier name="Modifier"/>
<Hexa2TetraTopologicalMapping input="@HexaTop" output="@Container" swapping="true"/>
</Node>
<Node name="FEM">
<EulerImplicitSolver firstOrder="false" rayleighMass="0.1" rayleighStiffness="0.1"/>
<SparseLDLSolver name="precond" template="CompressedRowSparseMatrixMat3x3" parallelInverseProduct="true" />
<TetrahedronSetTopologyContainer name="Container" position="@../BEAMVOLUME/HexaTop.position" tetrahedra="@../BEAMVOLUME/Container.tetrahedra"/>
<TetrahedronSetTopologyModifier name="Modifier"/>
<MechanicalObject name="mstate" template="Vec3d" src="@Container"/>
<TetrahedronFEMForceField name="forceField" listening="true" youngModulus="6e4" poissonRatio="0.40" />
<UniformMass totalMass="1"/>
<BoxROI name="box" box="-0.01 -0.01 -0.01 0.0001 0.11 0.11"/>
<FixedLagrangianConstraint indices="@box.indices"/>
<Node name="Surface">
<TriangleSetTopologyContainer name="Container"/>
<TriangleSetTopologyModifier name="Modifier"/>
<Tetra2TriangleTopologicalMapping input="@../Container" output="@Container" flipNormals="false"/>
<MechanicalObject name="dofs" rest_position="@../mstate.rest_position"/>
<TriangleCollisionModel name="Torus8CMT" contactDistance="0.001" contactStiffness="20" color="0.94117647058824 0.93725490196078 0.89411764705882" />
<Node name="Visual" activated="1">
<TriangleSetTopologyContainer name="Container" src="@../Container"/>
<OglModel color="1.0 0.1 0.2 1.0" name="visualModel"/>
<IdentityMapping name="VisualMapping"/>
</Node>
<IdentityMapping name="SurfaceMapping"/>
</Node>
<LinearSolverConstraintCorrection linearSolver="@precond"/>
</Node>
</Node>
def createScene(root_node):
root = root_node.addChild('root', dt="0.01", gravity="0 0 -0.981")
root.addObject('RequiredPlugin', name="Sofa.Component.AnimationLoop")
root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Geometry")
root.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Lagrangian.Correction")
root.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Lagrangian.Model")
root.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Lagrangian.Solver")
root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Select")
root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Direct")
root.addObject('RequiredPlugin', name="Sofa.Component.Mapping.Linear")
root.addObject('RequiredPlugin', name="Sofa.Component.Mass")
root.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
root.addObject('RequiredPlugin', name="Sofa.Component.SolidMechanics.FEM.Elastic")
root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Dynamic")
root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Grid")
root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Mapping")
root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
root.addObject('RequiredPlugin', name="Sofa.GUI.Component")
root.addObject('VisualStyle', displayFlags="showForceFields")
root.addObject('ConstraintAttachButtonSetting', )
root.addObject('FreeMotionAnimationLoop', )
root.addObject('PreconditionedConjugateResidual', maxIterations="30", tolerance="1e-9", regularizationTerm="0")
beamvolume = root.addChild('BEAMVOLUME')
beamvolume.addObject('RegularGridTopology', name="HexaTop", n="25 5 5", min="0 0 0", max="0.5 0.1 0.1")
beamvolume.addObject('TetrahedronSetTopologyContainer', name="Container", position="@HexaTop.position")
beamvolume.addObject('TetrahedronSetTopologyModifier', name="Modifier")
beamvolume.addObject('Hexa2TetraTopologicalMapping', input="@HexaTop", output="@Container", swapping="true")
fem = root.addChild('FEM')
fem.addObject('EulerImplicitSolver', firstOrder="false", rayleighMass="0.1", rayleighStiffness="0.1")
fem.addObject('SparseLDLSolver', name="precond", template="CompressedRowSparseMatrixMat3x3", parallelInverseProduct="true")
fem.addObject('TetrahedronSetTopologyContainer', name="Container", position="@../BEAMVOLUME/HexaTop.position", tetrahedra="@../BEAMVOLUME/Container.tetrahedra")
fem.addObject('TetrahedronSetTopologyModifier', name="Modifier")
fem.addObject('MechanicalObject', name="mstate", template="Vec3d", src="@Container")
fem.addObject('TetrahedronFEMForceField', name="forceField", listening="true", youngModulus="6e4", poissonRatio="0.40")
fem.addObject('UniformMass', totalMass="1")
fem.addObject('BoxROI', name="box", box="-0.01 -0.01 -0.01 0.0001 0.11 0.11")
fem.addObject('FixedLagrangianConstraint', indices="@box.indices")
surface = FEM.addChild('Surface')
surface.addObject('TriangleSetTopologyContainer', name="Container")
surface.addObject('TriangleSetTopologyModifier', name="Modifier")
surface.addObject('Tetra2TriangleTopologicalMapping', input="@../Container", output="@Container", flipNormals="false")
surface.addObject('MechanicalObject', name="dofs", rest_position="@../mstate.rest_position")
surface.addObject('TriangleCollisionModel', name="Torus8CMT", contactDistance="0.001", contactStiffness="20", color="0.94117647058824 0.93725490196078 0.89411764705882")
visual = Surface.addChild('Visual', activated="1")
visual.addObject('TriangleSetTopologyContainer', name="Container", src="@../Container")
visual.addObject('OglModel', color="1.0 0.1 0.2 1.0", name="visualModel")
visual.addObject('IdentityMapping', name="VisualMapping")
surface.addObject('IdentityMapping', name="SurfaceMapping")
fem.addObject('LinearSolverConstraintCorrection', linearSolver="@precond")