In the following labs, we will use the Sofa-framework to perform the FE simulations. You can download and install the software on this page. Then you will need to build Sofa with additional plugins:
Additionally, you will need to add the path of the build directory in your environment in order to run Sofa from any location. For this purpose add the following variables in the file ~/.bashrc
Where SOFA is the build directory (for instance /home/sofa/work/sofa/build-src-Desktop-Release).
Installation and visualization
Launch the command runSofa from any location in the terminal. Sofa starts with a default example:
Note that you can run Sofa with a double-click on SOFA/bin/runSofa. However, running Sofa via the graphical interface prevents visualizing errors. In this lab, we will launch the software from the terminal. Check in the terminal the warnings and eventual errors that are given when Sofa starts.
You can move around the scene using the wheel to move forward/backward. Right-click allows going up / down and left click to rotate the scene. Click Animate to start the simulation and see the collisions and deformations. With Shift + Left Shift, you can apply external forces on the deformable model to pull and deform it.
The View tab allows you to change the view mode. For example, you can visualize the mechanical mesh or collision. Display the mechanical mesh by clicking on Force Fields, a set of hexahedra appears to represent the elements on which the mechanical behavior is calculated. You can also display the collision mesh. For that click on Collision Model then disable the Visual Models. The displayed meshes are simpler meshes that are used for the computation of collisions. Finally, you can view other information such as contacts (Interactions) or wireframe mode.
Sofa is based on a component graph system. Each component is specialized for a specific task in the simulation (solver, visualization, topology, …). The principle is then to describe a simulation with a hierarchy of components that will interact with each other to form the simulation.
This Root node contains the main parameters of the simulations (such as gravity). Sub nodes contain a list of components that will constitute the simulation. Each of these components accepts several parameters (sometimes called attributes or data). You can edit the values of data by double-clicking on the components. A second window opens and you can edit the values and click on the update button.
Although almost any data can be edited online, some of them does not have any influence when the simulation is already loaded (this is the case for precomputed parameters for instance) or it may have a lot of side effect. It is therefore always better to save the desired value of data in a file. The scene files describe the components in a format similar to XML which is called a scene file (.scn) in the Sofa nomination.
In practice, the scene hierarchy is described and stored in a scene file. Scene files can simply be edited with a text editor. Open the modified scene file in a text editor (for instance kate).
The hierarchical structure is done opening the <Node> tag. This tag is open in the first line by <Node> and closed to the last line by </ Node> which represents the Root node of the scene .
Sub nodes and components are then declared to define the simulation. Inside, each component there is a declarative list of attributes that represents the parameters of the component with name = “value” . In order to know the name of data that can be specified for each component you can either use the Modeler, or directly open the component in Sofa and edit the value in the .scn file.
Edit the gravity of the scene from the text editor. Save the file and restart Sofa.