SEARCH
TOOLBOX
LANGUAGES
TutorialBasicCube

TutorialBasicCube

From SOFAWiki

Jump to: navigation, search
First Tutorial : Basic Cube

Contents

Description

In this tutorial, a deformable cube undergoes internal and external forces. This is one of the simplest scenes we can simulate using Sofa. We use it to introduce the component structure.

The shape is modeled using a MechanicalObject which desribes the particle states, and a Topology which describes how the particles are connected.

The forces are the MeshSpringForceField, which defines springs according to the edges of the mesh (the Topology), and the PlaneForceField which try to prevent the particles to cross planes.

The EulerImplicitSolver contains the algorithm used to update particle positions and velocities at each time step. It uses an auxiliary component, the CGLinearSolver, to solve equation systems.

Try this

Save the XML text in a file and open with SOFA, or open the version given in
examples/Tutorials/Basic/TutorialBasicCube.scn
. Then run the simulation.

Open the scene file in a text editor, modify parameters, save and re-open the scene in SOFA. Alternatively, you can edit the scene using the Sofa modeler program.

Prerequisite

Example Scene

This example is distributed in
examples/Tutorials/Basic/TutorialBasicCube.scn
within SofaSVN and SOFA distributions starting from 1.0 beta 4.

Graph

XML Description

<?xml version="1.0" ?>
<!-- See http://wiki.sofa-framework.org/mediawiki/index.php/TutorialBasicCube -->
<Node name="root" dt="0.01" gravity="0 0 -9.81" showBehavior="1">
 
  <EulerImplicitSolver name="EulerImplicit" />
  <CGLinearSolver name="CG Solver" />
 
  <MechanicalObject name="Particles" template="Vec3"
                    position="0 0 1  1 0 1  0 1 1  1 1 1  0 0 2  1 0 2  0 1 2  1 1 2" />
  <MeshTopology name="Topology" hexas="0 4 6 2 1 5 7 3" />
 
  <UniformMass name="Mass" totalmass="1" />
  <MeshSpringForceField name="Springs" stiffness="100" damping="1" />
 
  <PlaneForceField name="Floor" normal="0 0.2 1" stiffness="100" damping="1" draw="1" />
  <PlaneForceField name="Wall" normal="0 -1 0" d="-4" stiffness="100" damping="1" draw="1" color="1 1 1" />
 
</Node>