Skip to content

ParallelCGLinearSolver

Linear system solver using the conjugate gradient iterative algorithm in parallel

ParallelCompressedRowSparseMatrixMat3x3d

Templates:

  • ParallelCompressedRowSparseMatrixMat3x3d

Target: MultiThreading

namespace: multithreading::component::linearsolver::iterative

parents:

  • CGLinearSolver
  • Base

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
parallelInverseProduct Parallelize the computation of the product J*M^{-1}*J^T where M is the matrix of the linear system and J is any matrix with compatible dimensions 0
iterations Maximum number of iterations after which the iterative descent of the Conjugate Gradient must stop 25
tolerance Desired accuracy of the Conjugate Gradient solution evaluating: |r|²/|b|² (ratio of current residual norm over initial residual norm) 1e-05
threshold Minimum value of the denominator (pT A p)^ in the conjugate Gradient solution 1e-05
warmStart Use previous solution as initial solution, which may improve the initial guess if your system is evolving smoothly 0
graph Graph of residuals at each iteration
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
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 BaseObject
master nullptr for regular objects, or master object for which this object is one sub-objects BaseObject
linearSystem The linear system to solve TypedMatrixLinearSystem<ParallelCompressedRowSparseMatrixMat3x3d>

ParallelCompressedRowSparseMatrixd

Templates:

  • ParallelCompressedRowSparseMatrixd

Target: MultiThreading

namespace: multithreading::component::linearsolver::iterative

parents:

  • CGLinearSolver
  • Base

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
parallelInverseProduct Parallelize the computation of the product J*M^{-1}*J^T where M is the matrix of the linear system and J is any matrix with compatible dimensions 0
iterations Maximum number of iterations after which the iterative descent of the Conjugate Gradient must stop 25
tolerance Desired accuracy of the Conjugate Gradient solution evaluating: |r|²/|b|² (ratio of current residual norm over initial residual norm) 1e-05
threshold Minimum value of the denominator (pT A p)^ in the conjugate Gradient solution 1e-05
warmStart Use previous solution as initial solution, which may improve the initial guess if your system is evolving smoothly 0
graph Graph of residuals at each iteration
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
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 BaseObject
master nullptr for regular objects, or master object for which this object is one sub-objects BaseObject
linearSystem The linear system to solve TypedMatrixLinearSystem<ParallelCompressedRowSparseMatrixd>

Examples

ParallelCGLinearSolver.scn

<?xml version="1.0"?>
<Node name="root" dt="0.02" gravity="0 -10 0">
    <Node name="plugins">
        <RequiredPlugin name="MultiThreading"/> <!-- Needed to use components [ParallelCGLinearSolver] -->
        <RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedProjectiveConstraint] -->
        <RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [BoxROI] -->
        <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
        <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 [HexahedronFEMForceField] -->
        <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
        <RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
        <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    </Node>

    <VisualStyle displayFlags="showBehaviorModels showForceFields" />
    <DefaultAnimationLoop/>

    <Node>
        <EulerImplicitSolver name="eulerimplicit_odesolver" printLog="false"  rayleighStiffness="0.1" rayleighMass="0.1" />
        <ParallelCGLinearSolver template="ParallelCompressedRowSparseMatrixMat3x3d" iterations="100" tolerance="1e-20" threshold="1e-20" warmStart="1" />
        <MechanicalObject />
        <UniformMass name="mass" totalMass="320" />
        <RegularGridTopology name="grid" nx="8" ny="8" nz="40" xmin="-9" xmax="-6" ymin="0" ymax="3" zmin="0" zmax="19" />
        <BoxROI name="box" box="-10 -1 -0.0001  -5 4 0.0001"/>
        <FixedProjectiveConstraint indices="@box.indices" />
        <ParallelHexahedronFEMForceField name="FEM" youngModulus="4000" poissonRatio="0.3" method="large" />
    </Node>
</Node>
def createScene(root_node):

   root = root_node.addChild('root', dt="0.02", gravity="0 -10 0")

   plugins = root.addChild('plugins')

   plugins.addObject('RequiredPlugin', name="MultiThreading")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Projective")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Engine.Select")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Mass")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.SolidMechanics.FEM.Elastic")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Grid")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Visual")

   root.addObject('VisualStyle', displayFlags="showBehaviorModels showForceFields")
   root.addObject('DefaultAnimationLoop', )

   node = root.addChild('node')

   node.addObject('EulerImplicitSolver', name="eulerimplicit_odesolver", printLog="false", rayleighStiffness="0.1", rayleighMass="0.1")
   node.addObject('ParallelCGLinearSolver', template="ParallelCompressedRowSparseMatrixMat3x3d", iterations="100", tolerance="1e-20", threshold="1e-20", warmStart="1")
   node.addObject('MechanicalObject', )
   node.addObject('UniformMass', name="mass", totalMass="320")
   node.addObject('RegularGridTopology', name="grid", nx="8", ny="8", nz="40", xmin="-9", xmax="-6", ymin="0", ymax="3", zmin="0", zmax="19")
   node.addObject('BoxROI', name="box", box="-10 -1 -0.0001  -5 4 0.0001")
   node.addObject('FixedProjectiveConstraint', indices="@box.indices")
   node.addObject('ParallelHexahedronFEMForceField', name="FEM", youngModulus="4000", poissonRatio="0.3", method="large")