diff --git a/examples/.scene-tests b/examples/.scene-tests new file mode 100644 index 00000000..cbd91a2b --- /dev/null +++ b/examples/.scene-tests @@ -0,0 +1,25 @@ +# Scenes to reduce are too heavy and slow to be simulated, so compute only a few iterations + +# Organs +iterations "organs/liver/liverFine.pyscn" "10" +timeout "organs/liver/liverFine.pyscn" "120" + +iterations "organs/liver/liverFineHyperElastic.pyscn" "10" +timeout "organs/liver/liverFineHyperElastic.pyscn" "120" + + + +# Others +iterations "others/caduceus/SphereOnAPlane.softSphereFalling.pyscn" "10" +timeout "others/caduceus/SphereOnAPlane.softSphereFalling.pyscn" "120" + +iterations "others/caduceus/caduceusNG.pyscn" "10" +timeout "others/caduceus/caduceusNG.pyscn" "120" + + +# SoftRobot +iterations "softRobots/multiGait/multiGait.py" "20" +timeout "softRobots/multiGait/multiGait.py" "120" + +ignore "softRobots/multiGait/reducedMultiGait-softRobot.pyscn" # TODO fix: MechanicalMatrixMapperMOR is missing +ignore "softRobots/multiGait/reduced/debug/debug_scene.py" # TODO fix: ODE solver is not copied during reduction process \ No newline at end of file diff --git a/examples/organs/liver/liverFine.pyscn b/examples/organs/liver/liverFine.pyscn index 30f5a8c5..ea2d4364 100644 --- a/examples/organs/liver/liverFine.pyscn +++ b/examples/organs/liver/liverFine.pyscn @@ -8,10 +8,26 @@ def createScene(rootNode): rootNode.addObject('RequiredPlugin', name='ModelOrderReduction', pluginName='ModelOrderReduction') rootNode.addObject('RequiredPlugin', name='SofaPython3', pluginName='SofaPython3') + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader,MeshVTKLoader] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [BarycentricMapping] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.Spring') # Needed to use components [RestShapeSpringsForceField] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Dynamic') # Needed to use components [TetrahedronSetTopologyContainer] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle] + rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel] + rootNode.addObject('VisualStyle', displayFlags='showCollision showVisualModels showForceFields showInteractionForceFields hideCollisionModels hideBoundingCollisionModels hideWireframe') rootNode.findData('dt').value=0.01 rootNode.findData('gravity').value=[0, -981, 0] + + rootNode.addObject('DefaultAnimationLoop') + liver = rootNode.addChild('liver') liver.addObject('EulerImplicitSolver', rayleighStiffness = 0.0, rayleighMass = 0.0) liver.addObject('SparseLDLSolver',template="CompressedRowSparseMatrixMat3x3d") diff --git a/examples/organs/liver/liverFineHyperElastic.pyscn b/examples/organs/liver/liverFineHyperElastic.pyscn index 42ff73c8..f09f8c19 100644 --- a/examples/organs/liver/liverFineHyperElastic.pyscn +++ b/examples/organs/liver/liverFineHyperElastic.pyscn @@ -9,10 +9,25 @@ def createScene(rootNode): rootNode.addObject('RequiredPlugin', name='ModelOrderReduction', pluginName='ModelOrderReduction') rootNode.addObject('RequiredPlugin', name='SofaPython3', pluginName='SofaPython3') + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader,MeshVTKLoader] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [BarycentricMapping] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.HyperElastic') # Needed to use components [TetrahedronHyperelasticityFEMForceField] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.Spring') # Needed to use components [RestShapeSpringsForceField] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Dynamic') # Needed to use components [TetrahedronSetTopologyContainer] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle] + rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel] + rootNode.addObject('VisualStyle', displayFlags='showCollision showVisualModels showForceFields showInteractionForceFields hideCollisionModels hideBoundingCollisionModels hideWireframe') rootNode.findData('dt').value=0.01 rootNode.findData('gravity').value=[0, -981, 0] + rootNode.addObject('DefaultAnimationLoop') + liver = rootNode.addChild('liver') liver.addObject('EulerImplicitSolver', rayleighStiffness = 0.0, rayleighMass = 0.0) liver.addObject('SparseLDLSolver',template="CompressedRowSparseMatrixMat3x3d") diff --git a/examples/others/SphereOnAPlane/softSphereFalling.pyscn b/examples/others/SphereOnAPlane/softSphereFalling.pyscn index 91844901..f265514d 100644 --- a/examples/others/SphereOnAPlane/softSphereFalling.pyscn +++ b/examples/others/SphereOnAPlane/softSphereFalling.pyscn @@ -7,103 +7,114 @@ pathMesh = os.path.dirname(os.path.abspath(__file__))+'/' def createScene(rootNode): - rootNode.addObject('RequiredPlugin', name='SoftRobots', pluginName='SoftRobots') - rootNode.addObject('RequiredPlugin', name='SofaPython', pluginName='SofaPython') - rootNode.addObject('RequiredPlugin', name='ModelOrderReduction', pluginName='ModelOrderReduction') - rootNode.findData('dt').value=0.005 - - rootNode.findData('gravity').value='0 -9810 0'; - #rootNode.findData('gravity').value='0 0 0'; - rootNode.addObject('VisualStyle', displayFlags='showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels showForceFields showInteractionForceFields hideWireframe') - - reductionOn = True - lambdaModes = "lambdaModesSphereFine6.txt" - lambdaCoeffs = "lambdaCoeffsSphereFine6.txt" - - rootNode.addObject('FreeMotionAnimationLoop') - #rootNode.addObject('GenericConstraintSolver', printLog=True, tolerance="1e-6", maxIterations="500", storeLambdas=True) - if reductionOn: - rootNode.addObject('GenericConstraintSolver', name='GSSolver', maxIterations='10000', tolerance='1e-15') - else: - #rootNode.addObject('GenericConstraintSolver', name='GSSolver', maxIterations='10000', tolerance='1e-15',storeLambdas=True, lambdaPath="lambdaStored.txt",computeConstraintForces=True) - rootNode.addObject('GenericConstraintSolver', name='GSSolver', maxIterations='10000', tolerance='1e-15',computeConstraintForces=True) - rootNode.addObject('PythonScriptController', filename="lambdaDumper.py", classname="storeLambda", variables="Zetest.txt") - - - rootNode.addObject('CollisionPipeline', verbose="0") - rootNode.addObject('BruteForceBroadPhase', name="N2") - rootNode.addObject('BVHNarrowPhase') - #rootNode.addObject('CollisionResponse', response="StickContactConstraint", responseParams="mu=0.5") - if not reductionOn: - rootNode.addObject('CollisionResponse', response="FrictionContact", responseParams="mu=0.0") - else: - rootNode.addObject('CollisionResponse', response="MORFrictionContact", responseParams="mu=0.0?lambdaModesPath="+lambdaModes+"?lambdaModesCoeffsPath="+lambdaCoeffs) - #rootNode.addObject('CollisionResponse', response="MORFrictionContact", responseParams="mu=0.0", name='Colcol') - #rootNode.addObject('CollisionResponse', response="MORFrictionContact", responseParams="mu=0.0?lambdaModesPath=lambdaModesVLONG7.txt?lambdaModesCoeffsPath=lambdaCoeffsVLONG7.txt") - - rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance="1.0", contactDistance="0.5", angleCone="0.01") - - solverNode = rootNode.addChild('solverNode') - solverNode.addObject('EulerImplicitSolver', name='odesolver',firstOrder="false", rayleighStiffness='0.1', rayleighMass='0.1', printLog="0",verbose="0") - solverNode.addObject('SparseLDLSolver', name="preconditioner", template="CompressedRowSparseMatrixMat3x3d") - solverNode.addObject('GenericConstraintCorrection', solverName='preconditioner',printLog=True, name='ResReso') - - - ########################################## - # FEM Model # - ########################################## - - sphereTranslation = [0,7,0] - model = solverNode.addChild('model') - model.addObject('MeshVTKLoader', name='loader', filename=pathMesh+'sphere.vtk', translation=sphereTranslation) - model.addObject('Mesh',src = '@loader') - model.addObject('MechanicalObject', name='tetras', template='Vec3d', showIndices='false', showIndicesScale='4e-5', rx='0',printLog="0") - model.addObject('UniformMass', totalMass='0.1', printLog='0') - model.addObject('TetrahedronFEMForceField', template='Vec3d',youngModulus=30) - - - - - modelCollis = model.addChild('modelCollis') - #modelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphere.stl', rotation="0 0 0", translation=sphereTranslation) - modelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphereFine.stl', rotation="0 0 0", translation=sphereTranslation) - modelCollis.addObject('TriangleSetTopologyContainer', src='@loader', name='container') - modelCollis.addObject('MechanicalObject', name='collisMO', template='Vec3d') - #modelCollis.addObject('TriangleCollisionModel',group="0") - #modelCollis.addObject('LineCollisionModel',group="0") - #modelCollis.addObject('PointCollisionModel',group="0") - modelCollis.addObject('BarycentricMapping') - - subModelCollis = modelCollis.addChild('subModelCollis') - #subModelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphere.stl', rotation="0 0 0", translation=sphereTranslation) - subModelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphereFine.stl', rotation="0 0 0", translation=sphereTranslation) - subModelCollis.addObject('TriangleSetTopologyContainer', src='@loader', name='container') - subModelCollis.addObject('MechanicalObject', name='subModelCollisMO', template='Vec3d') - #subModelCollis.addObject('TriangleCollisionModel',group="0",name='TriSPhere') - #subModelCollis.addObject('LineCollisionModel',group="0",name='LineSPhere') - if reductionOn: - subModelCollis.addObject('MORPoint',group="0",name='PointSphere',computeNormals=True, lambdaModesPath=lambdaModes,lambdaModesCoeffsPath=lambdaCoeffs ,displayContactModes=True) - else: - subModelCollis.addObject('PointCollisionModel',group="0",name='PointSphere', displayContactModes=False,computeNormals=True) - #subModelCollis.addObject('MORContactMapping',modesPath='lambdaModes.txt',contactIndicesPath = 'lambdaCoeffs.txt',storeLambda=True) - ##subModelCollis.addObject('IdentityMapping') - if not reductionOn: - subModelCollis.addObject('MORContactMapping',lambdaIndicesPath="lambdaIndices.txt",storeLambda=True) - else: - subModelCollis.addObject('IdentityMapping') - - - - rotation=[20,0,0] - #rotation=[30,0,0] - planeNode = rootNode.addChild('Plane') - planeNode.addObject('MeshOBJLoader', name='loader', filename="mesh/floorFlat.obj", triangulate="true",rotation=rotation) - planeNode.addObject('Mesh', src="@loader") - planeNode.addObject('MechanicalObject', src="@loader", rotation="0 0 0", translation="0 0 0", scale="1") - planeNode.addObject('TriangleCollisionModel',simulated="0", moving="0",group="1",name='TriPlane') - #planeNode.addObject('LineCollisionModel',simulated="0", moving="0",group="1") - #planeNode.addObject('PointCollisionModel',simulated="0", moving="0",group="1") - #planeNode.addObject('OglModel',name="Visual", fileMesh="mesh/floorFlat.obj", color="1 0 0 1",rotation=rotation, translation="0 0 0", scale="1") - planeNode.addObject('UncoupledConstraintCorrection') - - return rootNode + rootNode.addObject('RequiredPlugin', name='SoftRobots', pluginName='SoftRobots') + rootNode.addObject('RequiredPlugin', name='SofaPython3', pluginName='SofaPython3') + rootNode.addObject('RequiredPlugin', name='ModelOrderReduction', pluginName='ModelOrderReduction') + rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Algorithm') # Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Intersection') # Needed to use components [LocalMinDistance] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Response.Contact') # Needed to use components [CollisionResponse] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] + + + rootNode.findData('dt').value=0.005 + + rootNode.findData('gravity').value=[0, -9810, 0] + #rootNode.findData('gravity').value='0 0 0'; + rootNode.addObject('VisualStyle', displayFlags='showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels showForceFields showInteractionForceFields hideWireframe') + + reductionOn = True + lambdaModes = "lambdaModesSphereFine6.txt" + lambdaCoeffs = "lambdaCoeffsSphereFine6.txt" + + rootNode.addObject('FreeMotionAnimationLoop') + #rootNode.addObject('GenericConstraintSolver', printLog=True, tolerance="1e-6", maxIterations="500", storeLambdas=True) + if reductionOn: + rootNode.addObject('GenericConstraintSolver', name='GSSolver', maxIterations='10000', tolerance='1e-15') + else: + #rootNode.addObject('GenericConstraintSolver', name='GSSolver', maxIterations='10000', tolerance='1e-15',storeLambdas=True, lambdaPath="lambdaStored.txt",computeConstraintForces=True) + rootNode.addObject('GenericConstraintSolver', name='GSSolver', maxIterations='10000', tolerance='1e-15',computeConstraintForces=True) + rootNode.addObject('PythonScriptController', filename="lambdaDumper.py", classname="storeLambda", variables="Zetest.txt") + + + rootNode.addObject('CollisionPipeline', verbose="0") + rootNode.addObject('BruteForceBroadPhase', name="N2") + rootNode.addObject('BVHNarrowPhase') + #rootNode.addObject('CollisionResponse', response="StickContactConstraint", responseParams="mu=0.5") + if not reductionOn: + rootNode.addObject('CollisionResponse', response="FrictionContact", responseParams="mu=0.0") + else: + rootNode.addObject('CollisionResponse', response="MORFrictionContact", responseParams="mu=0.0?lambdaModesPath="+lambdaModes+"?lambdaModesCoeffsPath="+lambdaCoeffs) + #rootNode.addObject('CollisionResponse', response="MORFrictionContact", responseParams="mu=0.0", name='Colcol') + #rootNode.addObject('CollisionResponse', response="MORFrictionContact", responseParams="mu=0.0?lambdaModesPath=lambdaModesVLONG7.txt?lambdaModesCoeffsPath=lambdaCoeffsVLONG7.txt") + + rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance="1.0", contactDistance="0.5", angleCone="0.01") + + solverNode = rootNode.addChild('solverNode') + solverNode.addObject('EulerImplicitSolver', name='odesolver',firstOrder="false", rayleighStiffness='0.1', rayleighMass='0.1', printLog="0") + solverNode.addObject('SparseLDLSolver', name="preconditioner", template="CompressedRowSparseMatrixMat3x3d") + solverNode.addObject('GenericConstraintCorrection', printLog=True, name='ResReso') + + + ########################################## + # FEM Model # + ########################################## + + sphereTranslation = [0,7,0] + model = solverNode.addChild('model') + model.addObject('MeshVTKLoader', name='loader', filename=pathMesh+'sphere.vtk', translation=sphereTranslation) + model.addObject('Mesh',src = '@loader') + model.addObject('MechanicalObject', name='tetras', template='Vec3d', showIndices='false', showIndicesScale='4e-5', rx='0',printLog="0") + model.addObject('UniformMass', totalMass='0.1', printLog='0') + model.addObject('TetrahedronFEMForceField', template='Vec3d',youngModulus=30) + + + + + modelCollis = model.addChild('modelCollis') + #modelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphere.stl', rotation="0 0 0", translation=sphereTranslation) + modelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphereFine.stl', rotation="0 0 0", translation=sphereTranslation) + modelCollis.addObject('TriangleSetTopologyContainer', src='@loader', name='container') + modelCollis.addObject('MechanicalObject', name='collisMO', template='Vec3d') + #modelCollis.addObject('TriangleCollisionModel',group="0") + #modelCollis.addObject('LineCollisionModel',group="0") + #modelCollis.addObject('PointCollisionModel',group="0") + modelCollis.addObject('BarycentricMapping') + + subModelCollis = modelCollis.addChild('subModelCollis') + #subModelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphere.stl', rotation="0 0 0", translation=sphereTranslation) + subModelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphereFine.stl', rotation="0 0 0", translation=sphereTranslation) + subModelCollis.addObject('TriangleSetTopologyContainer', src='@loader', name='container') + subModelCollis.addObject('MechanicalObject', name='subModelCollisMO', template='Vec3d') + #subModelCollis.addObject('TriangleCollisionModel',group="0",name='TriSPhere') + #subModelCollis.addObject('LineCollisionModel',group="0",name='LineSPhere') + if reductionOn: + subModelCollis.addObject('MORPoint',group="0",name='PointSphere',computeNormals=True, lambdaModesPath=lambdaModes,lambdaModesCoeffsPath=lambdaCoeffs ,displayContactModes=True) + else: + subModelCollis.addObject('PointCollisionModel',group="0",name='PointSphere', displayContactModes=False,computeNormals=True) + #subModelCollis.addObject('MORContactMapping',modesPath='lambdaModes.txt',contactIndicesPath = 'lambdaCoeffs.txt',storeLambda=True) + ##subModelCollis.addObject('IdentityMapping') + if not reductionOn: + subModelCollis.addObject('MORContactMapping',lambdaIndicesPath="lambdaIndices.txt",storeLambda=True) + else: + subModelCollis.addObject('IdentityMapping') + + + + rotation=[20,0,0] + #rotation=[30,0,0] + planeNode = rootNode.addChild('Plane') + planeNode.addObject('MeshOBJLoader', name='loader', filename="mesh/floorFlat.obj", triangulate="true",rotation=rotation) + planeNode.addObject('Mesh', src="@loader") + planeNode.addObject('MechanicalObject', src="@loader", rotation="0 0 0", translation="0 0 0", scale="1") + planeNode.addObject('TriangleCollisionModel',simulated="0", moving="0",group="1",name='TriPlane') + #planeNode.addObject('LineCollisionModel',simulated="0", moving="0",group="1") + #planeNode.addObject('PointCollisionModel',simulated="0", moving="0",group="1") + #planeNode.addObject('OglModel',name="Visual", fileMesh="mesh/floorFlat.obj", color="1 0 0 1",rotation=rotation, translation="0 0 0", scale="1") + planeNode.addObject('UncoupledConstraintCorrection') + + return rootNode diff --git a/examples/others/caduceus/caduceusNG.pyscn b/examples/others/caduceus/caduceusNG.pyscn index 4fac9874..4976c57e 100644 --- a/examples/others/caduceus/caduceusNG.pyscn +++ b/examples/others/caduceus/caduceusNG.pyscn @@ -9,8 +9,29 @@ def createScene(rootNode): rootNode.findData('dt').value=0.02 rootNode.findData('gravity').value=[0, -981.0, 0] rootNode.addObject('VisualStyle', displayFlags='showBehaviorModels showForceFields') - rootNode.addObject('RequiredPlugin', pluginName='ModelOrderReduction') - rootNode.addObject('RequiredPlugin', pluginName='SoftRobots') + + rootNode.addObject('RequiredPlugin', name='ModelOrderReduction') + rootNode.addObject('RequiredPlugin', name='SoftRobots') + rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Algorithm') # Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Intersection') # Needed to use components [LocalMinDistance] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Geometry') # Needed to use components [LineCollisionModel,PointCollisionModel,TriangleCollisionModel] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Response.Contact') # Needed to use components [CollisionResponse] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader,MeshVTKLoader] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [BarycentricMapping] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Dynamic') # Needed to use components [TetrahedronSetTopologyContainer] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [Camera,VisualStyle] + rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel] + rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Shader') # Needed to use components [LightManager,SpotLight] + rootNode.addObject('FreeMotionAnimationLoop') @@ -47,7 +68,7 @@ def createScene(rootNode): collis = Snake.addChild('collis') collis.addObject('MeshOBJLoader', name='loader', filename=meshPath+"meca_snake_900tri.obj",translation=[0,5,0]) - collis.addObject('Mesh', src='@loader', name='topo') + collis.addObject('MeshTopology', src='@loader', name='topo') collis.addObject('MechanicalObject', name='CollisModel') collis.addObject('TriangleCollisionModel', selfCollision=False) collis.addObject('LineCollisionModel', selfCollision=False) @@ -73,14 +94,14 @@ def createScene(rootNode): stick = base.addChild("stick") stick.addObject('MeshOBJLoader',name="loader", filename="mesh/collision_batons.obj") - stick.addObject('Mesh', src='@loader', name='topo') + stick.addObject('MeshTopology', src='@loader', name='topo') stick.addObject('MechanicalObject', name='stickCollisModel') stick.addObject('LineCollisionModel',simulated="false", moving="false") stick.addObject('PointCollisionModel',simulated="false", moving="false") blobs = base.addChild("blobs") blobs.addObject('MeshOBJLoader',name="loader", filename="mesh/collision_boules_V3.obj") - blobs.addObject('Mesh', src='@loader', name='topo') + blobs.addObject('MeshTopology', src='@loader', name='topo') blobs.addObject('MechanicalObject', name='blobsCollisModel') blobs.addObject('TriangleCollisionModel',simulated="false", moving="false") blobs.addObject('LineCollisionModel',simulated="false", moving="false") @@ -88,7 +109,7 @@ def createScene(rootNode): foot = base.addChild("foot") foot.addObject('MeshOBJLoader',name="loader", filename="mesh/collision_pied.obj") - foot.addObject('Mesh', src='@loader', name='topo') + foot.addObject('MeshTopology', src='@loader', name='topo') foot.addObject('MechanicalObject', name='footCollisModel') foot.addObject('TriangleCollisionModel',simulated="false", moving="false") foot.addObject('LineCollisionModel',simulated="false", moving="false") diff --git a/examples/others/hexaBeam/hexaBeam.pyscn b/examples/others/hexaBeam/hexaBeam.pyscn index 01392b21..e4d89cb2 100644 --- a/examples/others/hexaBeam/hexaBeam.pyscn +++ b/examples/others/hexaBeam/hexaBeam.pyscn @@ -9,8 +9,21 @@ def createScene(rootNode): rootNode.findData('dt').value=0.02 rootNode.findData('gravity').value=[0, -9810, 0] rootNode.addObject('VisualStyle', displayFlags='showBehaviorModels showForceFields') - rootNode.addObject('RequiredPlugin', pluginName='ModelOrderReduction') - rootNode.addObject('RequiredPlugin', pluginName='SoftRobots') + rootNode.addObject('RequiredPlugin', name='ModelOrderReduction') + rootNode.addObject('RequiredPlugin', name='SoftRobots') + rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [BarycentricMapping] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [HexahedronFEMForceField] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.Spring') # Needed to use components [RestShapeSpringsForceField] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Grid') # Needed to use components [RegularGridTopology] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle] + rootNode.addObject('FreeMotionAnimationLoop') rootNode.addObject('GenericConstraintSolver', tolerance="1e-12", maxIterations="10000") @@ -20,7 +33,7 @@ def createScene(rootNode): M1.addObject('SparseLDLSolver',name='preconditioner') M1.addObject('MechanicalObject') M1.addObject('UniformMass', totalMass="0.1") - M1.addObject('RegularGrid', nx="4", ny="4", nz="20", xmin="-9", xmax="-6", ymin="0", ymax="3", zmin="0", zmax="19") + M1.addObject('RegularGridTopology', nx="4", ny="4", nz="20", xmin="-9", xmax="-6", ymin="0", ymax="3", zmin="0", zmax="19") M1.addObject('RestShapeSpringsForceField', points="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15", stiffness=1e12) M1.addObject('HexahedronFEMForceField', name="FEM", youngModulus="4000", poissonRatio="0.3", method="large") M1.addObject('GenericConstraintCorrection') diff --git a/examples/softRobots/finger/finger.pyscn b/examples/softRobots/finger/finger.pyscn index 4ccbb8d2..e3ffe3a4 100644 --- a/examples/softRobots/finger/finger.pyscn +++ b/examples/softRobots/finger/finger.pyscn @@ -13,7 +13,24 @@ from stlib3.visuals import VisualModel def createScene(rootNode): rootNode.addObject("RequiredPlugin", - pluginName=["SoftRobots", 'SofaConstraint', 'SofaEngine', 'SofaLoader', 'SofaDeformable', 'ModelOrderReduction']) + pluginName=["SoftRobots", + 'Sofa.Component.AnimationLoop', + 'Sofa.Component.Constraint.Lagrangian.Correction', + 'Sofa.Component.Constraint.Lagrangian.Solver', + 'Sofa.Component.Engine.Select', + 'Sofa.Component.IO.Mesh', + 'Sofa.Component.LinearSolver.Direct', + 'Sofa.Component.Mapping.Linear', + 'Sofa.Component.Mass', + 'Sofa.Component.ODESolver.Backward', + 'Sofa.Component.SolidMechanics.FEM.Elastic', + 'Sofa.Component.SolidMechanics.Spring', + 'Sofa.Component.StateContainer', + 'Sofa.Component.Topology.Container.Dynamic', + 'Sofa.Component.Visual', + 'ModelOrderReduction']) + + scene = Scene(rootNode, gravity=[0.0, -9810.0, 0.0], dt=0.01) scene.VisualStyle.displayFlags='showBehavior' @@ -30,7 +47,7 @@ def createScene(rootNode): finger.addObject('EulerImplicitSolver', rayleighStiffness = 0.0, rayleighMass = 0.0) finger.addObject('SparseLDLSolver',template="CompressedRowSparseMatrixMat3x3d") finger.addObject('MeshVTKLoader', name="loader", filename=path+'finger.vtk') - finger.addObject('TetrahedronSetTopologyContainer', src="@loader") + finger.addObject('TetrahedronSetTopologyContainer', position="@loader.position", tetrahedra="@loader.tetrahedra") finger.addObject('MechanicalObject') finger.addObject('UniformMass', totalMass=0.05) finger.addObject('TetrahedronFEMForceField', poissonRatio="0.45", youngModulus="600") diff --git a/examples/softRobots/finger/reduced/reduced_finger.py b/examples/softRobots/finger/reduced/reduced_finger.py index d6518faf..d9656009 100644 --- a/examples/softRobots/finger/reduced/reduced_finger.py +++ b/examples/softRobots/finger/reduced/reduced_finger.py @@ -72,7 +72,7 @@ def Reduced_test( finger = finger_MOR.addChild('finger') finger.addObject('MeshVTKLoader' , name = 'loader', filename = pathMesh + r'/mesh/finger.vtk', translation = add(translation,[0.0, 0.0, 0.0]), rotation = add(rotation,[0.0, 0.0, 0.0]), scale3d = multiply(scale,[1.0, 1.0, 1.0])) - finger.addObject('TetrahedronSetTopologyContainer' , src = '@loader') + finger.addObject('TetrahedronSetTopologyContainer' , position = '@loader.position', tetrahedra = '@loader.tetrahedra') finger.addObject('MechanicalObject') finger.addObject('UniformMass' , totalMass = 0.05) finger.addObject('HyperReducedTetrahedronFEMForceField' , poissonRatio = '0.45', youngModulus = '600', name = 'reducedFF_finger_0', nbModes = nbrOfModes, performECSW = hyperReduction, modesPath = path + r'/data/modes.txt', RIDPath = path + r'/data/reducedFF_finger_0_RID.txt', weightsPath = path + r'/data/reducedFF_finger_0_weight.txt') diff --git a/examples/softRobots/multiGait/multiGait.py b/examples/softRobots/multiGait/multiGait.py index be661696..ce3e18fc 100644 --- a/examples/softRobots/multiGait/multiGait.py +++ b/examples/softRobots/multiGait/multiGait.py @@ -8,9 +8,32 @@ # Units: mm, kg, s. Pressure in kPa = k (kg/(m.s^2)) = k (g/(mm.s^2) = kg/(mm.s^2) def createScene(rootNode): - rootNode.addObject('RequiredPlugin', pluginName='SoftRobots') + rootNode.addObject('RequiredPlugin', name='SoftRobots') # rootNode.addObject('RequiredPlugin', pluginName='SofaPython3') - rootNode.addObject('RequiredPlugin', pluginName='ModelOrderReduction') + rootNode.addObject('RequiredPlugin', name='ModelOrderReduction') + rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Algorithm') # Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Intersection') # Needed to use components [LocalMinDistance] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Geometry') # Needed to use components [LineCollisionModel,PointCollisionModel,TriangleCollisionModel] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Response.Contact') # Needed to use components [CollisionResponse,RuleBasedContactManager] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection,UncoupledConstraintCorrection] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader,MeshSTLLoader,MeshVTKLoader] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [BarycentricMapping] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Setting') # Needed to use components [BackgroundSetting] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField,TriangleFEMForceField] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Dynamic') # Needed to use components [TetrahedronSetTopologyContainer,TriangleSetTopologyContainer] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle] + rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel,OglSceneFrame] + + + rootNode.gravity = [0, 0, -9810] rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels hideCollisionModels hideBoundingCollisionModels showForceFields showInteractionForceFields hideWireframe') @@ -52,7 +75,7 @@ def createScene(rootNode): print(model) model.addObject('MeshVTKLoader', name='loader', filename=path + quadrupedMesh) - model.addObject('TetrahedronSetTopologyContainer', src='@loader', name='container') + model.addObject('TetrahedronSetTopologyContainer', position='@loader.position', tetrahedra='@loader.tetrahedra', name='container') model.addObject('MechanicalObject', name='tetras', template='Vec3d', showIndices='false', showIndicesScale='4e-5', rx='0') model.addObject('UniformMass', totalMass='0.035') @@ -69,7 +92,7 @@ def createScene(rootNode): modelSubTopo = model.addChild('modelSubTopo') modelSubTopo.addObject('TriangleSetTopologyContainer', position='@../membraneROISubTopo.pointsInROI', - triangles='@../membraneROISubTopo.trianglesInROI', name='container') + triangles='@../membraneROISubTopo.trianglesInROI', edges='@../membraneROISubTopo.edgesInROI', name='container_modelSubTopo') modelSubTopo.addObject('TriangleFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio='0.49', youngModulus='5000') @@ -77,7 +100,7 @@ def createScene(rootNode): # Constraint centerCavity = model.addChild('centerCavity') centerCavity.addObject('MeshSTLLoader', name='loader', filename=path + centerCavityMesh) - centerCavity.addObject('Mesh', src='@loader', name='topo') + centerCavity.addObject('MeshTopology', src='@loader', name='topo') centerCavity.addObject('MechanicalObject', name='centerCavity') centerCavity.addObject('SurfacePressureConstraint', name="SurfacePressureConstraint", template='Vec3d', value="0.00", triangles='@topo.triangles', drawPressure='0', drawScale='0.0002', @@ -86,7 +109,7 @@ def createScene(rootNode): rearLeftCavity = model.addChild('rearLeftCavity') rearLeftCavity.addObject('MeshSTLLoader', name='loader', filename=path + rearLeftCavityMesh) - rearLeftCavity.addObject('Mesh', src='@loader', name='topo') + rearLeftCavity.addObject('MeshTopology', src='@loader', name='topo') rearLeftCavity.addObject('MechanicalObject', name='rearLeftCavity') rearLeftCavity.addObject('SurfacePressureConstraint', name="SurfacePressureConstraint", template='Vec3d', valueType="volumeGrowth", value="0.000", triangles='@topo.triangles', drawPressure='0', @@ -95,7 +118,7 @@ def createScene(rootNode): rearRightCavity = model.addChild('rearRightCavity') rearRightCavity.addObject('MeshSTLLoader', name='loader', filename=path + rearRightCavityMesh) - rearRightCavity.addObject('Mesh', src='@loader', name='topo') + rearRightCavity.addObject('MeshTopology', src='@loader', name='topo') rearRightCavity.addObject('MechanicalObject', name='rearRightCavity') rearRightCavity.addObject('SurfacePressureConstraint', name="SurfacePressureConstraint", template='Vec3d', value="0.00", triangles='@topo.triangles', drawPressure='0', drawScale='0.0002', @@ -104,7 +127,7 @@ def createScene(rootNode): frontLeftCavity = model.addChild('frontLeftCavity') frontLeftCavity.addObject('MeshSTLLoader', name='loader', filename=path + frontLeftCavityMesh) - frontLeftCavity.addObject('Mesh', src='@loader', name='topo') + frontLeftCavity.addObject('MeshTopology', src='@loader', name='topo') frontLeftCavity.addObject('MechanicalObject', name='frontLeftCavity') frontLeftCavity.addObject('SurfacePressureConstraint', name="SurfacePressureConstraint", template='Vec3d', value="0.000", triangles='@topo.triangles', drawPressure='0', drawScale='0.0002', @@ -113,7 +136,7 @@ def createScene(rootNode): frontRightCavity = model.addChild('frontRightCavity') frontRightCavity.addObject('MeshSTLLoader', name='loader', filename=path + frontRightCavityMesh) - frontRightCavity.addObject('Mesh', src='@loader', name='topo') + frontRightCavity.addObject('MeshTopology', src='@loader', name='topo') frontRightCavity.addObject('MechanicalObject', name='frontRightCavity') frontRightCavity.addObject('SurfacePressureConstraint', name="SurfacePressureConstraint", template='Vec3d', value="0.000", triangles='@topo.triangles', drawPressure='0', drawScale='0.0002', @@ -123,7 +146,7 @@ def createScene(rootNode): modelCollis = model.addChild('modelCollis') modelCollis.addObject('MeshSTLLoader', name='loader', filename=path + 'quadriped_collision.stl', rotation="0 0 0", translation="0 0 0") - modelCollis.addObject('TriangleSetTopologyContainer', src='@loader', name='container') + modelCollis.addObject('TriangleSetTopologyContainer', position='@loader.position', triangles='@loader.triangles', name='container_quadriped') modelCollis.addObject('MechanicalObject', name='collisMO', template='Vec3d') modelCollis.addObject('TriangleCollisionModel', group="0") modelCollis.addObject('LineCollisionModel', group="0") @@ -144,7 +167,7 @@ def createScene(rootNode): planeNode = rootNode.addChild('Plane') planeNode.addObject('MeshOBJLoader', name='loader', filename="mesh/floorFlat.obj", triangulate="true") - planeNode.addObject('Mesh', src="@loader") + planeNode.addObject('MeshTopology', src="@loader") planeNode.addObject('MechanicalObject', src="@loader", rotation="90 0 0", translation="0 35 -1", scale="15") planeNode.addObject('TriangleCollisionModel', simulated="0", moving="0", group="1") planeNode.addObject('LineCollisionModel', simulated="0", moving="0", group="1") diff --git a/examples/softRobots/multiGait/reduced/reduced_multiGait.py b/examples/softRobots/multiGait/reduced/reduced_multiGait.py index 6f5b50f8..551d0d0f 100644 --- a/examples/softRobots/multiGait/reduced/reduced_multiGait.py +++ b/examples/softRobots/multiGait/reduced/reduced_multiGait.py @@ -64,6 +64,7 @@ def Reduced_test( modelRoot = attachedTo.addChild(name) model_MOR = modelRoot.addChild('model_MOR') + model_MOR.addObject('EulerImplicitSolver', name='odesolver', rayleighStiffness='0.1', rayleighMass='0.1') model_MOR.addObject('SparseLDLSolver' , name = 'preconditioner', template = 'CompressedRowSparseMatrixMat3x3d') model_MOR.addObject('GenericConstraintCorrection' , linearSolver = '@preconditioner') model_MOR.addObject('MechanicalObject' , template = 'Vec1d', position = [0]*nbrOfModes) @@ -71,7 +72,7 @@ def Reduced_test( model = model_MOR.addChild('model') model.addObject('MeshVTKLoader' , name = 'loader', filename = pathMesh + r'/mesh/full_quadriped_SMALL.vtk', translation = add(translation,[0.0, 0.0, 0.0]), rotation = add(rotation,[0.0, 0.0, 0.0]), scale3d = multiply(scale,[1.0, 1.0, 1.0])) - model.addObject('TetrahedronSetTopologyContainer' , src = '@loader', name = 'container') + model.addObject('TetrahedronSetTopologyContainer' , position = '@loader.position', tetrahedra = '@loader.tetrahedra', name = 'container') model.addObject('MechanicalObject' , name = 'tetras', template = 'Vec3d', showIndices = 'false', showIndicesScale = '4e-5', rx = '0') model.addObject('UniformMass' , totalMass = '0.035') model.addObject('HyperReducedTetrahedronFEMForceField' , template = 'Vec3d', name = 'reducedFF_model_0', method = 'large', poissonRatio = '0.05', youngModulus = '70', nbModes = nbrOfModes, performECSW = hyperReduction, modesPath = path + r'/data/modes.txt', RIDPath = path + r'/data/reducedFF_model_0_RID.txt', weightsPath = path + r'/data/reducedFF_model_0_weight.txt') @@ -87,7 +88,7 @@ def Reduced_test( centerCavity = model.addChild('centerCavity') centerCavity.addObject('MeshSTLLoader' , name = 'loader', filename = pathMesh + r'/mesh/quadriped_Center-cavityREMESHEDlighter.stl', translation = add(translation,[0.0, 0.0, 0.0]), rotation = add(rotation,[0.0, 0.0, 0.0]), scale3d = multiply(scale,[1.0, 1.0, 1.0])) - centerCavity.addObject('Mesh' , src = '@loader', name = 'topo') + centerCavity.addObject('MeshTopology' , src = '@loader', name = 'topo') centerCavity.addObject('MechanicalObject' , name = 'centerCavity') centerCavity.addObject('SurfacePressureConstraint' , name = 'SurfacePressureConstraint', template = 'Vec3d', value = '0.00', triangles = '@topo.triangles', drawPressure = '0', drawScale = '0.0002', valueType = 'volumeGrowth') centerCavity.addObject('BarycentricMapping' , name = 'mapping', mapForces = 'false', mapMasses = 'false') @@ -95,7 +96,7 @@ def Reduced_test( rearLeftCavity = model.addChild('rearLeftCavity') rearLeftCavity.addObject('MeshSTLLoader' , name = 'loader', filename = pathMesh + r'/mesh/quadriped_Rear-Left-cavity_collis.stl', translation = add(translation,[0.0, 0.0, 0.0]), rotation = add(rotation,[0.0, 0.0, 0.0]), scale3d = multiply(scale,[1.0, 1.0, 1.0])) - rearLeftCavity.addObject('Mesh' , src = '@loader', name = 'topo') + rearLeftCavity.addObject('MeshTopology' , src = '@loader', name = 'topo') rearLeftCavity.addObject('MechanicalObject' , name = 'rearLeftCavity') rearLeftCavity.addObject('SurfacePressureConstraint' , name = 'SurfacePressureConstraint', template = 'Vec3d', valueType = 'volumeGrowth', value = '0.000', triangles = '@topo.triangles', drawPressure = '0', drawScale = '0.0002') rearLeftCavity.addObject('BarycentricMapping' , name = 'mapping', mapForces = 'false', mapMasses = 'false') @@ -103,7 +104,7 @@ def Reduced_test( rearRightCavity = model.addChild('rearRightCavity') rearRightCavity.addObject('MeshSTLLoader' , name = 'loader', filename = pathMesh + r'/mesh/quadriped_Rear-Right-cavity_collis.stl', translation = add(translation,[0.0, 0.0, 0.0]), rotation = add(rotation,[0.0, 0.0, 0.0]), scale3d = multiply(scale,[1.0, 1.0, 1.0])) - rearRightCavity.addObject('Mesh' , src = '@loader', name = 'topo') + rearRightCavity.addObject('MeshTopology' , src = '@loader', name = 'topo') rearRightCavity.addObject('MechanicalObject' , name = 'rearRightCavity') rearRightCavity.addObject('SurfacePressureConstraint' , name = 'SurfacePressureConstraint', template = 'Vec3d', value = '0.00', triangles = '@topo.triangles', drawPressure = '0', drawScale = '0.0002', valueType = 'volumeGrowth') rearRightCavity.addObject('BarycentricMapping' , name = 'mapping', mapForces = 'false', mapMasses = 'false') @@ -111,7 +112,7 @@ def Reduced_test( frontLeftCavity = model.addChild('frontLeftCavity') frontLeftCavity.addObject('MeshSTLLoader' , name = 'loader', filename = pathMesh + r'/mesh/quadriped_Front-Left-cavity_collis.stl', translation = add(translation,[0.0, 0.0, 0.0]), rotation = add(rotation,[0.0, 0.0, 0.0]), scale3d = multiply(scale,[1.0, 1.0, 1.0])) - frontLeftCavity.addObject('Mesh' , src = '@loader', name = 'topo') + frontLeftCavity.addObject('MeshTopology' , src = '@loader', name = 'topo') frontLeftCavity.addObject('MechanicalObject' , name = 'frontLeftCavity') frontLeftCavity.addObject('SurfacePressureConstraint' , name = 'SurfacePressureConstraint', template = 'Vec3d', value = '0.000', triangles = '@topo.triangles', drawPressure = '0', drawScale = '0.0002', valueType = 'volumeGrowth') frontLeftCavity.addObject('BarycentricMapping' , name = 'mapping', mapForces = 'false', mapMasses = 'false') @@ -119,7 +120,7 @@ def Reduced_test( frontRightCavity = model.addChild('frontRightCavity') frontRightCavity.addObject('MeshSTLLoader' , name = 'loader', filename = pathMesh + r'/mesh/quadriped_Front-Right-cavity_collis.stl', translation = add(translation,[0.0, 0.0, 0.0]), rotation = add(rotation,[0.0, 0.0, 0.0]), scale3d = multiply(scale,[1.0, 1.0, 1.0])) - frontRightCavity.addObject('Mesh' , src = '@loader', name = 'topo') + frontRightCavity.addObject('MeshTopology' , src = '@loader', name = 'topo') frontRightCavity.addObject('MechanicalObject' , name = 'frontRightCavity') frontRightCavity.addObject('SurfacePressureConstraint' , name = 'SurfacePressureConstraint', template = 'Vec3d', value = '0.000', triangles = '@topo.triangles', drawPressure = '0', drawScale = '0.0002', valueType = 'volumeGrowth') frontRightCavity.addObject('BarycentricMapping' , name = 'mapping', mapForces = 'false', mapMasses = 'false') @@ -127,7 +128,7 @@ def Reduced_test( modelCollis = model.addChild('modelCollis') modelCollis.addObject('MeshSTLLoader' , name = 'loader', filename = pathMesh + r'/mesh/quadriped_collision.stl', rotation = '0 0 0', translation = '0 0 0', scale3d = multiply(scale,[1.0, 1.0, 1.0])) - modelCollis.addObject('TriangleSetTopologyContainer' , src = '@loader', name = 'container') + modelCollis.addObject('TriangleSetTopologyContainer' , position = '@loader.position', triangles = '@loader.triangles', name = 'container') modelCollis.addObject('MechanicalObject' , name = 'collisMO', template = 'Vec3d') modelCollis.addObject('TriangleCollisionModel' , group = '0') modelCollis.addObject('LineCollisionModel' , group = '0') @@ -148,11 +149,27 @@ def Reduced_test( def createScene(rootNode): surfaceMeshFileName = False - MainHeader(rootNode,plugins=["SoftRobots","ModelOrderReduction"], + MainHeader(rootNode,plugins=['SoftRobots', + 'ModelOrderReduction', + 'Sofa.Component.Collision.Geometry', + 'Sofa.Component.Constraint.Lagrangian.Correction', + 'Sofa.Component.Engine.Select', + 'Sofa.Component.IO.Mesh', + 'Sofa.Component.LinearSolver.Direct', + 'Sofa.Component.Mapping.Linear', + 'Sofa.Component.Mass', + 'Sofa.Component.StateContainer', + 'Sofa.Component.Topology.Container.Constant', + 'Sofa.Component.Topology.Container.Dynamic', + 'Sofa.Component.Visual', + 'Sofa.GL.Component.Rendering3D'], + dt=0.01, gravity=[0.0, -9.81, 0.0]) rootNode.VisualStyle.displayFlags="showForceFields" + + Reduced_test(rootNode, name="Reduced_test", surfaceMeshFileName=surfaceMeshFileName) diff --git a/examples/softRobots/multiGait/reducedMultiGait-softRobot.pyscn b/examples/softRobots/multiGait/reducedMultiGait-softRobot.pyscn index deed0746..991cf3a7 100644 --- a/examples/softRobots/multiGait/reducedMultiGait-softRobot.pyscn +++ b/examples/softRobots/multiGait/reducedMultiGait-softRobot.pyscn @@ -202,6 +202,17 @@ class waveController(Sofa.Core.Controller): def createScene(rootNode): rootNode.addObject('RequiredPlugin', name='SoftRobots', pluginName='SoftRobots') rootNode.addObject('RequiredPlugin', name='ModelOrderReduction', pluginName='ModelOrderReduction') + rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Algorithm') # Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,BruteForceDetection,CollisionPipeline] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Intersection') # Needed to use components [LocalMinDistance] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Response.Contact') # Needed to use components [CollisionResponse] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Setting') # Needed to use components [BackgroundSetting] + rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle] + rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglSceneFrame] rootNode.dt.value = 0.05 rootNode.gravity.value=[0, 0, -9810] @@ -210,15 +221,16 @@ def createScene(rootNode): rootNode.addObject('FreeMotionAnimationLoop') rootNode.addObject('GenericConstraintSolver', printLog=False, tolerance="1e-4", maxIterations="1000") rootNode.addObject('CollisionPipeline') - rootNode.addObject('BruteForceDetection', name="N2") - rootNode.addObject('CollisionResponse', response="FrictionContact", responseParams="mu=0.7") + rootNode.addObject('BruteForceBroadPhase', name="N2") + rootNode.addObject('BVHNarrowPhase') + rootNode.addObject('CollisionResponse', response="FrictionContactConstraint", responseParams="mu=0.7") rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance="2.5", contactDistance="0.5", angleCone="0.01") rootNode.addObject('BackgroundSetting', color='0 0.168627 0.211765') rootNode.addObject('OglSceneFrame', style="Arrows", alignment="TopRight") solverNode = rootNode.addChild('solverNode') solverNode.addObject('EulerImplicitSolver', name='odesolver',firstOrder="false", rayleighStiffness='0.01', rayleighMass='0.01', printLog=False) solverNode.addObject('SparseLDLSolver', name="preconditioner", template="CompressedRowSparseMatrixMat3x3d") - solverNode.addObject('GenericConstraintCorrection', solverName='preconditioner') + solverNode.addObject('GenericConstraintCorrection', linearSolver='@preconditioner') solverNode.addObject('MechanicalMatrixMapperMOR', template='Vec1d,Vec1d', object1='@./reducedModel/alpha', object2='@./reducedModel/alpha', nodeToParse='@./reducedModel/model', performECSW=performECSWBoolMappedMatrix, listActiveNodesPath=listActiveNodesFile,timeInvariantMapping1 = True,timeInvariantMapping2 = True, saveReducedMass=False, usePrecomputedMass=False, precomputedMassPath='ROM_data/quadrupedMass_reduced63modes.txt', fastMatrixProduct=False, printLog=False)