Skip to content

VariationalSymplecticSolver

Implicit time integrator which conserves linear momentum and mechanical energy.

Target: Sofa.Component.ODESolver.Backward

namespace: sofa::component::odesolver::backward

parents:

  • OdeSolver
  • LinearSolverAccessor

Data

Name Description Default value
name object name unnamed
printLog if true, emits extra messages at runtime. 0
tags list of the subsets the objet 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
newtonError Error tolerance for Newton iterations 0.01
steps Maximum number of Newton steps 5
rayleighStiffness Rayleigh damping coefficient related to stiffness, > 0 0
rayleighMass Rayleigh damping coefficient related to mass, > 0 0
saveEnergyInFile If kinetic and potential energies should be dumped in a CSV file at each iteration 0
explicitIntegration Use explicit integration scheme 0
file File name where kinetic and potential energies are saved in a CSV file
computeHamiltonian Compute hamiltonian 1
hamiltonianEnergy hamiltonian energy 0
useIncrementalPotentialEnergy use real potential energy, if false use approximate potential energy 1
threadSafeVisitor If true, do not use realloc and free visitors in fwdInteractionForceField. 0
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
linearSolver Linear solver used by this component LinearSolver

Examples

VariationalSymplecticSolver.scn

<Node name="root" dt="0.02">
    <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 [VariationalSymplecticSolver] -->
    <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.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <DefaultAnimationLoop/>

    <VisualStyle displayFlags="showBehaviorModels showForceFields" />
    <Node name="Single">
    <VariationalSymplecticSolver name="default0"  tags="meca" rayleighStiffness="0" rayleighMass="0" newtonError="1e-12" steps="4" file="energy.txt" saveEnergyInFile ="true"/>
        <CGLinearSolver template="GraphScattered" name="cGLinearSolver1" iterations="300"  tolerance="1e-09"  threshold="1e-9"/>
        <Node name="M1">
            <MechanicalObject />
            <UniformMass vertexMass="1" />
            <RegularGridTopology nx="4" ny="4" nz="28" xmin="-9" xmax="-6" ymin="0" ymax="3" zmin="0" zmax="27" />
            <BoxConstraint box="-9.1 -0.1 -0.1 -5.9 3.1 0.1" />
            <!--<BoxConstraint box="-9.1 -0.1 26.9 -5.9 3.1 27.1" />-->
            <TetrahedronFEMForceField name="FEM" youngModulus="100000" poissonRatio="0.3" />
        </Node>
    </Node>
</Node>
def createScene(root_node):

   root = root_node.addChild('root', dt="0.02")

   root.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Projective")
   root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Select")
   root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
   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.Grid")
   root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
   root.addObject('DefaultAnimationLoop', )
   root.addObject('VisualStyle', displayFlags="showBehaviorModels showForceFields")

   single = root.addChild('Single')

   single.addObject('VariationalSymplecticSolver', name="default0", tags="meca", rayleighStiffness="0", rayleighMass="0", newtonError="1e-12", steps="4", file="energy.txt", saveEnergyInFile="true")
   single.addObject('CGLinearSolver', template="GraphScattered", name="cGLinearSolver1", iterations="300", tolerance="1e-09", threshold="1e-9")

   m1 = Single.addChild('M1')

   m1.addObject('MechanicalObject', )
   m1.addObject('UniformMass', vertexMass="1")
   m1.addObject('RegularGridTopology', nx="4", ny="4", nz="28", xmin="-9", xmax="-6", ymin="0", ymax="3", zmin="0", zmax="27")
   m1.addObject('BoxConstraint', box="-9.1 -0.1 -0.1 -5.9 3.1 0.1")
   m1.addObject('TetrahedronFEMForceField', name="FEM", youngModulus="100000", poissonRatio="0.3")