Skip to content

DistanceMultiMapping

Mapping point positions from several mechanical states to distances (in distance unit).

Rigid3d,Vec1d

Templates:

  • Rigid3d,Vec1d

Target: Sofa.Component.Mapping.NonLinear

namespace: sofa::component::mapping::nonlinear

parents:

  • MultiMapping

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
mapForces Are forces mapped ? 1
mapConstraints Are constraints mapped ? 1
mapMasses Are masses mapped ? 1
mapMatrices Are matrix explicit mapped? 0
applyRestPosition set to true to apply this mapping to restPosition at init 0
geometricStiffness Method used to compute the geometric stiffness: -None: geometric stiffness is not computed -Exact: the exact geometric stiffness is computed -Stabilized: the exact geometric stiffness is approximated in order to improve stability Stabilized
computeDistance if 'computeDistance = true', then rest length of each element equal 0, otherwise rest length is the initial length of each of them 0
restLengths Rest lengths of the connections
indexPairs list of couples (parent index + index in the parent)
Visualization
showObjectScale Scale for object display 0
showColor Color for object display. (default=[1.0,1.0,0.0,1.0]) 1 1 0 1
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
input Input Object(s) State<Rigid3d>
output Output Object(s) State<Vec1d>
topology link to the topology container BaseMeshTopology

Vec3d,Vec1d

Templates:

  • Vec3d,Vec1d

Target: Sofa.Component.Mapping.NonLinear

namespace: sofa::component::mapping::nonlinear

parents:

  • MultiMapping

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
mapForces Are forces mapped ? 1
mapConstraints Are constraints mapped ? 1
mapMasses Are masses mapped ? 1
mapMatrices Are matrix explicit mapped? 0
applyRestPosition set to true to apply this mapping to restPosition at init 0
geometricStiffness Method used to compute the geometric stiffness: -None: geometric stiffness is not computed -Exact: the exact geometric stiffness is computed -Stabilized: the exact geometric stiffness is approximated in order to improve stability Stabilized
computeDistance if 'computeDistance = true', then rest length of each element equal 0, otherwise rest length is the initial length of each of them 0
restLengths Rest lengths of the connections
indexPairs list of couples (parent index + index in the parent)
Visualization
showObjectScale Scale for object display 0
showColor Color for object display. (default=[1.0,1.0,0.0,1.0]) 1 1 0 1
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
input Input Object(s) State<Vec3d>
output Output Object(s) State<Vec1d>
topology link to the topology container BaseMeshTopology

Examples

DistanceMultiMapping.scn

<?xml version="1.0"?>
<Node name="Root" gravity="0 -10 0" time="0" animate="0"  dt="0.01">

    <Node name="plugins">
        <RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedProjectiveConstraint] -->
        <RequiredPlugin name="Sofa.Component.Engine.Transform"/> <!-- Needed to use components [TransformEngine] -->
        <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [StringMeshCreator] -->
        <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
        <RequiredPlugin name="Sofa.Component.Mapping.NonLinear"/> <!-- Needed to use components [DistanceMapping DistanceMultiMapping] -->
        <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [DiagonalMass] -->
        <RequiredPlugin name="Sofa.Component.MechanicalLoad"/> <!-- Needed to use components [UniformVelocityDampingForceField] -->
        <RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
        <RequiredPlugin name="Sofa.Component.SolidMechanics.Spring"/> <!-- Needed to use components [RestShapeSpringsForceField] -->
        <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
        <RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [EdgeSetGeometryAlgorithms EdgeSetTopologyContainer] -->
        <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    </Node>

    <DefaultVisualManagerLoop/>
    <VisualStyle displayFlags="showVisualModels showBehaviorModels showMappings showForceFields showMechanicalMappings" />

    <DefaultAnimationLoop/>
    <StringMeshCreator name="loader" resolution="20" />

    <EulerImplicitSolver rayleighStiffness="0.1" rayleighMass="0.1"/>
    <CGLinearSolver iterations="2500" name="linear solver" tolerance="1.0e-9" threshold="1.0e-9" />

    <Node  name="springs0" >
        <TransformEngine name="translate" input_position="@../loader.position" translation="0 0 0" />

        <EdgeSetTopologyContainer name="topology" position="@translate.output_position" edges="@../loader.edges" />
        <MechanicalObject name="defoDOF" template="Vec3" />
        <EdgeSetGeometryAlgorithms drawEdges="true" />
        <FixedProjectiveConstraint indices="0" />
        <DiagonalMass  name="mass" totalMass="1e-2"/>
        <UniformVelocityDampingForceField template="Vec3" name="uniformVelocityDampingFF0" implicit="true" dampingCoefficient="0.005"/>
        <Node name="extensionsNode" >
            <MechanicalObject template="Vec1" name="extensionsDOF" />
            <DistanceMapping name="distanceMapping" topology="@../topology" input="@../defoDOF" output="@extensionsDOF" geometricStiffness="0" applyRestPosition="true" computeDistance="true"/>
            <RestShapeSpringsForceField template="Vec1" stiffness="1000"/>
        </Node>
    </Node>

    <Node  name="springs1" >
        <TransformEngine name="translate" input_position="@../loader.position" translation="1.2 0 0" />

        <EdgeSetTopologyContainer name="topology" position="@translate.output_position" edges="@../loader.edges" />
        <MechanicalObject name="defoDOF" template="Vec3" />
        <EdgeSetGeometryAlgorithms drawEdges="true" />
        <FixedProjectiveConstraint indices="19" />
        <DiagonalMass  name="mass" totalMass="1e-2"/>
        <UniformVelocityDampingForceField template="Vec3" name="uniformVelocityDampingFF0" implicit="true" dampingCoefficient="0.005"/>
        <Node name="extensionsNode" >
            <MechanicalObject template="Vec1" name="extensionsDOF" />
            <DistanceMapping name="distanceMapping" topology="@../topology" input="@../defoDOF" output="@extensionsDOF" geometricStiffness="0" applyRestPosition="true" computeDistance="true"/>
            <RestShapeSpringsForceField template="Vec1" stiffness="1000"/>
        </Node>
    </Node>

    <Node name="connection">
        <MechanicalObject template="Vec1" name="connectionDOF" />
        <EdgeSetTopologyContainer edges="0 1"/>
        <DistanceMultiMapping template="Vec3,Vec1" input="@../springs0 @../springs1" output="@connectionDOF" indexPairs="0 19 1 0" restLengths="1" geometricStiffness="0" applyRestPosition="true" computeDistance="true"/>
        <RestShapeSpringsForceField template="Vec1" stiffness="1"/>
    </Node>

</Node>
def createScene(root_node):

   root = root_node.addChild('Root', gravity="0 -10 0", time="0", animate="0", dt="0.01")

   plugins = Root.addChild('plugins')

   plugins.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Projective")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Engine.Transform")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Mapping.NonLinear")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Mass")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.MechanicalLoad")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.SolidMechanics.Spring")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Dynamic")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Visual")

   root.addObject('DefaultVisualManagerLoop', )
   root.addObject('VisualStyle', displayFlags="showVisualModels showBehaviorModels showMappings showForceFields showMechanicalMappings")
   root.addObject('DefaultAnimationLoop', )
   root.addObject('StringMeshCreator', name="loader", resolution="20")
   root.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
   root.addObject('CGLinearSolver', iterations="2500", name="linear solver", tolerance="1.0e-9", threshold="1.0e-9")

   springs0 = Root.addChild('springs0')

   springs0.addObject('TransformEngine', name="translate", input_position="@../loader.position", translation="0 0 0")
   springs0.addObject('EdgeSetTopologyContainer', name="topology", position="@translate.output_position", edges="@../loader.edges")
   springs0.addObject('MechanicalObject', name="defoDOF", template="Vec3")
   springs0.addObject('EdgeSetGeometryAlgorithms', drawEdges="true")
   springs0.addObject('FixedProjectiveConstraint', indices="0")
   springs0.addObject('DiagonalMass', name="mass", totalMass="1e-2")
   springs0.addObject('UniformVelocityDampingForceField', template="Vec3", name="uniformVelocityDampingFF0", implicit="true", dampingCoefficient="0.005")

   extensions_node = springs0.addChild('extensionsNode')

   extensions_node.addObject('MechanicalObject', template="Vec1", name="extensionsDOF")
   extensions_node.addObject('DistanceMapping', name="distanceMapping", topology="@../topology", input="@../defoDOF", output="@extensionsDOF", geometricStiffness="0", applyRestPosition="true", computeDistance="true")
   extensions_node.addObject('RestShapeSpringsForceField', template="Vec1", stiffness="1000")

   springs1 = Root.addChild('springs1')

   springs1.addObject('TransformEngine', name="translate", input_position="@../loader.position", translation="1.2 0 0")
   springs1.addObject('EdgeSetTopologyContainer', name="topology", position="@translate.output_position", edges="@../loader.edges")
   springs1.addObject('MechanicalObject', name="defoDOF", template="Vec3")
   springs1.addObject('EdgeSetGeometryAlgorithms', drawEdges="true")
   springs1.addObject('FixedProjectiveConstraint', indices="19")
   springs1.addObject('DiagonalMass', name="mass", totalMass="1e-2")
   springs1.addObject('UniformVelocityDampingForceField', template="Vec3", name="uniformVelocityDampingFF0", implicit="true", dampingCoefficient="0.005")

   extensions_node = springs1.addChild('extensionsNode')

   extensions_node.addObject('MechanicalObject', template="Vec1", name="extensionsDOF")
   extensions_node.addObject('DistanceMapping', name="distanceMapping", topology="@../topology", input="@../defoDOF", output="@extensionsDOF", geometricStiffness="0", applyRestPosition="true", computeDistance="true")
   extensions_node.addObject('RestShapeSpringsForceField', template="Vec1", stiffness="1000")

   connection = Root.addChild('connection')

   connection.addObject('MechanicalObject', template="Vec1", name="connectionDOF")
   connection.addObject('EdgeSetTopologyContainer', edges="0 1")
   connection.addObject('DistanceMultiMapping', template="Vec3,Vec1", input="@../springs0 @../springs1", output="@connectionDOF", indexPairs="0 19 1 0", restLengths="1", geometricStiffness="0", applyRestPosition="true", computeDistance="true")
   connection.addObject('RestShapeSpringsForceField', template="Vec1", stiffness="1")