Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions examples/sofapython3/BezierTriangularBendingFEMForceField.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
def createScene(rootNode):


rootNode.addObject('RequiredPlugin', name="Shell")
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
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]
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 [IdentityMapping]
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.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.GL.Component.Rendering3D') # Needed to use components [OglModel]
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]
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.Engine.Generate') # Needed to use components [NormalsFromPoints]
rootNode.gravity = [0, -98.1, 0]
rootNode.addObject('AttachBodyButtonSetting', stiffness=0.1)
rootNode.addObject('FreeMotionAnimationLoop')
rootNode.addObject('GenericConstraintSolver', maxIterations=1e3, tolerance=1e-3)

square = rootNode.addChild('Square')
square.addObject('EulerImplicitSolver')
square.addObject('SparseLDLSolver')
square.addObject('GenericConstraintCorrection')
square.addObject('MeshOBJLoader', filename='mesh/square1.obj')
square.addObject('MeshTopology', src=square.MeshOBJLoader.getLinkPath())
square.addObject('MechanicalObject', name="Object", template='Rigid3')
square.addObject('NormalsFromPoints', name='NormalsFrom', position='@Object.position' )
square.addObject('UniformMass', totalMass=0.005)
square.addObject('BoxROI', box=[0, 0.9, -0.1, 1, 1, 0.1], drawBoxes=True)
square.addObject('FixedProjectiveConstraint', indices=square.BoxROI.indices.getLinkPath())
square.addObject('BezierTriangularBendingFEMForceField', youngModulus=1.7e3,
poissonRatio=0.3, thickness=0.01, normals="@NormalsFrom.normals")

visu = square.addChild('Visu')
visu.addObject('OglModel', src=square.MeshTopology.getLinkPath())
visu.addObject('IdentityMapping')

39 changes: 39 additions & 0 deletions examples/sofapython3/CstFEMForceField.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
def createScene(rootNode):

rootNode.addObject('RequiredPlugin', name="Shell")
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
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]
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 [IdentityMapping]
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.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.GL.Component.Rendering3D') # Needed to use components [OglModel]
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]
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.gravity = [0, -98.1, 0]
rootNode.addObject('AttachBodyButtonSetting', stiffness=0.1)
rootNode.addObject('FreeMotionAnimationLoop')
rootNode.addObject('GenericConstraintSolver', maxIterations=1e3, tolerance=1e-3)

square = rootNode.addChild('Square')
square.addObject('EulerImplicitSolver')
square.addObject('SparseLDLSolver')
square.addObject('GenericConstraintCorrection')
square.addObject('MeshOBJLoader', filename='mesh/square1.obj')
square.addObject('MeshTopology', src=square.MeshOBJLoader.getLinkPath())
square.addObject('MechanicalObject')
square.addObject('UniformMass', totalMass=0.005)
square.addObject('BoxROI', box=[0, 0.9, -0.1, 1, 1, 0.1], drawBoxes=True)
square.addObject('FixedProjectiveConstraint', indices=square.BoxROI.indices.getLinkPath())
square.addObject('CstFEMForceField', youngModulus=1.7e3,
poissonRatio=0.3, thickness=0.01)

visu = square.addChild('Visu')
visu.addObject('OglModel', src=square.MeshTopology.getLinkPath())
visu.addObject('IdentityMapping')

14 changes: 13 additions & 1 deletion examples/sofapython3/TriangularBendingFEMForceField.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
def createScene(rootNode):

rootNode.addObject('RequiredPlugin', name="Shell")
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
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]
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 [IdentityMapping]
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.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.GL.Component.Rendering3D') # Needed to use components [OglModel]
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]

rootNode.gravity = [0, -98.1, 0]
rootNode.addObject('AttachBodyButtonSetting', stiffness=0.1)
rootNode.addObject('DefaultAnimationLoop')
Expand All @@ -13,7 +25,7 @@ def createScene(rootNode):
square.addObject('MechanicalObject', template='Rigid3')
square.addObject('UniformMass', totalMass=0.005)
square.addObject('BoxROI', box=[0, 0.9, -0.1, 1, 1, 0.1], drawBoxes=True)
square.addObject('FixedConstraint', indices=square.BoxROI.indices.getLinkPath())
square.addObject('FixedProjectiveConstraint', indices=square.BoxROI.indices.getLinkPath())
square.addObject('TriangularBendingFEMForceField', youngModulus=1.7e3,
poissonRatio=0.3, thickness=0.01)

Expand Down
43 changes: 43 additions & 0 deletions examples/sofapython3/TriangularShellForceField.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
def createScene(rootNode):

rootNode.addObject('RequiredPlugin', name="Shell")
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
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]
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 [IdentityMapping]
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.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.GL.Component.Rendering3D') # Needed to use components [OglModel]
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]
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.gravity = [0, -98.1, 0]
rootNode.addObject('AttachBodyButtonSetting', stiffness=0.1)
rootNode.addObject('DefaultAnimationLoop')
#rootNode.addObject('FreeMotionAnimationLoop')
#rootNode.addObject('GenericConstraintSolver', maxIterations=1e3, tolerance=1e-3)

square = rootNode.addChild('Square')
square.addObject('EulerImplicitSolver')
square.addObject('SparseLDLSolver')
#square.addObject('GenericConstraintCorrection')
square.addObject('MeshOBJLoader', filename='mesh/square1.obj')
square.addObject('MeshTopology', src=square.MeshOBJLoader.getLinkPath())
square.addObject('MechanicalObject', template='Rigid3', showObject=1)
square.addObject('UniformMass', totalMass=0.005)
square.addObject('BoxROI', box=[0, 0.9, -0.1, 1, 1, 0.1], drawBoxes=True)
square.addObject('FixedProjectiveConstraint', indices=square.BoxROI.indices.getLinkPath())
square.addObject('TriangularShellForceField', youngModulus=1.7e3, poissonRatio=0.3,
thickness=0.05, measure="Von Mises stress", arrow_radius="0")

visu = square.addChild('Visu')
visu.addObject('OglModel', src=square.MeshTopology.getLinkPath())
visu.addObject('IdentityMapping')



#pluginList=['SofaEngine', 'SofaLoader', 'SofaSimpleFem','SofaExporter', 'SofaPython3', 'SofaShells']
46 changes: 46 additions & 0 deletions examples/xml/MeshGID.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" ?>
<Node name="root" dt="0.02" gravity="0 0 0">

<Node name="plugins">
<RequiredPlugin name="Shell"/>
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
<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.SceneUtility"/> <!-- Needed to use components [InfoComponent] -->
<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.Visual"/> <!-- Needed to use components [VisualStyle] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
</Node>

<VisualStyle displayFlags ="showBehaviorModels showForceFields showVisualModels"/>
<DefaultAnimationLoop/>
<CollisionPipeline verbose="0"/>
<BruteForceBroadPhase name="N2"/>
<BVHNarrowPhase/>
<CollisionResponse name="Response" response="PenaltyContactForceField"/>
<MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5"/>

<Node name="Meshtest" >
<EulerImplicitSolver />
<CGLinearSolver iterations="100" tolerance="1e-15" threshold="1e-15"/>
<include href="Mesh_test.xml" filename="Mesh_test.xml" src="@tetras" />
<MechanicalObject name="tetras" showIndices="false" showIndicesScale="0.0007"/>
<UniformMass showAxisSizeFactor="0.00001" totalMass="1" />

<TetrahedronFEMForceField name="FEM" youngModulus="2870" poissonRatio="0.45" method="large" drawHeterogeneousTetra="0" />
<Node name="Visual">
<OglModel name="Visual" color="green"/>
<IdentityMapping input="@.." output="@Visual"/>
</Node>
</Node>




</Node>
63 changes: 63 additions & 0 deletions examples/xml/MeshInterpolator.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0"?>
<Node name="root" dt="0.02" gravity="0 0 0">
<Node name="plugins">
<RequiredPlugin name="Shell"/>
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [TriangleSetGeometryAlgorithms,TriangleSetTopologyContainer] -->
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->

</Node>

<VisualStyle displayFlags ="showBehaviorModels showForceFields showVisualModels"/>
<DefaultAnimationLoop/>
<CollisionPipeline verbose="0"/>
<BruteForceBroadPhase name="N2"/>
<BVHNarrowPhase/>
<CollisionResponse name="Response" response="PenaltyContactForceField"/>
<MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5"/>



<Node name="MeshInterpolator">
<!-- Starting mesh -->
<Node name="m1">
<MeshOBJLoader name="m1" filename="../../../Shell/mesh/transform-cube.obj" />
<!-- Visualisation -->
<TriangleSetTopologyContainer src="@m1" />
<MechanicalObject />
<TriangleSetGeometryAlgorithms drawEdges="true" drawColorEdges="0.2 0.2 0.2" />
</Node>

<!-- Final mesh -->
<Node name="m2">
<MeshOBJLoader name="m2" filename="../../../Shell/mesh/transform-sphere.obj" />
<!-- Visualisation -->
<TriangleSetTopologyContainer src="@m2" />
<MechanicalObject />
<TriangleSetGeometryAlgorithms drawEdges="true" drawColorEdges="0.2 0.2 0.2" />
</Node>

<Node name="simluation" >

<MeshInterpolator name="interp" startPosition="@m1/m1.position" endPosition="@m2/m2.position"
listening="true" startTime="0" nbSteps="10" increment="0.01" />

<TriangleSetTopologyContainer triangles="@m1/m1.triangles" position="@interp.position" />
<MechanicalObject position="@interp.position" />

<!-- Visualisation -->
<Node name="Visual">
<OglModel name="Visual" color="green"/>
<IdentityMapping input="@.." output="@Visual"/>
</Node>

</Node>

</Node>
</Node>
Loading
Loading