Skip to content

Commit

Permalink
r2563/sofa-dev : DOC: implementing task 2432. Small How To, and will …
Browse files Browse the repository at this point in the history
…be continued
  • Loading branch information
falipou committed Jun 18, 2008
1 parent 618dfb7 commit 22791a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion doc/HowTo/forcefield.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@

\section{How To create a new Force Field}
to come...

In SOFA, the Force Field already existing are located in the namespace sofa::component::forcefield. They derive from the core class sofa::core::componentmodel::behavior::ForceField. It is templated by the type of elements you want to model. It can be a deformable object of 1,2,3 or 6 dimensions, or rigid bodies of 2 and 3 dimensions.\\
The simplest way to implement your own ForceField is :
\begin{enumerate}
\item make it derive from sofa::core::componentmodel::behavior::ForceField
\item implements the following virtual fonctions: addForce, getPotentialEnery. Others virtual functions exist like addDForce, addDForceV (if you want to make dynamics), and you should read the doxigen documentation about ForceField.
\item as all the others component you might create, you have to add it to the project. Edit \$SOFA\_DIR/modules/sofa/component/component.pro, and add the path to new files in the section HEADERS and SOURCES.
\item Edit \$SOFA\_DIR/modules/sofa/simulation/common/init.cpp and add your new forcefield to the list. This step is compulsory for Windows system, and does the linking of a new component to the factory. If you forget it, your component won't be created at initialization time.
\end{enumerate}

The method addForce computes and accumulates the forces given the positions and velocities of its associated mechanical state.\\
If the ForceField can be represented as a matrix, this method computes
$$ f += B v + K x $$
This method is usually called by the generic ForceField::addForce() method.
Binary file modified doc/sofaDocumentation/sofadocumentation.pdf
Binary file not shown.

0 comments on commit 22791a8

Please sign in to comment.