Home › Forum › SOFA › Programming with SOFA › [SOLVED] Forcefields, collisions and integration
Tagged: 64_bits, Linux_ubuntu, SOFA_1512
 This topic has 4 replies, 2 voices, and was last updated 8 years, 1 month ago by Hugo.

AuthorPosts

18 February 2016 at 10:24 #5822jjcasmarBlocked
Hello everyone,
I have some generic questions about forcefields, integration step and collision responde models
I have been looking at the ForceField interface and I see that there is a “addForce” and a “addDForce”. The first one computes the forces in the current state and the second one computes the force derivative in the current state. As explained in Baraff et Witkin (siggraph ’98), for an implicit solver the derivative must be taken for the positions and for the velocities in order to compute the stiffnes matrix and the damping matrix. How is SOFA taking into account the damping forces? Does it only allow rayleigh (\alpha*M + \beta*K) model?
Also, for the forcefield, I dont understand the addKtoMatrix, addSubKToMatrix, addBToMatrix, addSubBToMatrix and addToMatrix methods. How do they work? I suppose it creates a matrix for the object that later can be retrieved when the solver do the time step, isn’t it?
If it’s like that, in the EulerImplicitSolver classmatrix = MechanicalMatrix::K * (tr*h*(h+f_rayleighStiffness.getValue())) + MechanicalMatrix::B * (tr*h) + MechanicalMatrix::M * (1+tr*h*f_rayleighMass.getValue());
What is the MechanicalMatrix class and how does it retrieve each simulated object matrix? Also, related with the damping model question, how is B computed?
I’m also interested in the collision response model. The default response model is a penalty method Is it possible to change this to the lagrange multiplier method with unequalities constraints? is it possible to use different response models for different collision resolution between different pair of objects? Imagine I have a floor and I want to apply a strong constraint (with lagrange multiplier method) so objects stays over the surface (position.y > 0, for example). But, at the same time, I have two objects in space that I want to solve that collision using weak constraints (penalty forces). Finally, talking about constraint, if I want to add a strange constraint (I dont know, that the velocity is twice the height of the object, to say something), I will have to define a ConstraintSet, isnt it?
And lastly (for today) does the Modeler has bugs in the git repository? I have tried to launch some examples from the tutorial and they don’t, and also when I add a component, it’s duplicated.Thanks everybody
18 February 2016 at 13:17 #5830HugoKeymasterDear Juan Jo,
You understood perfectly the way the addForce and addDForce are working. By default, SOFA indeed proposes only the Rayleigh model (\alpha*M + \beta*K). However, you can implement a custom damping using the addForce and addDForce as it is done in DiagonalVelocityDampingForceField.inl.
The addDForce is used to the implicit term (which accumulates in the Left Hand Side) related to the force derivative. The addDForce is only called if the matrix A (of the linear system Ax=b) is not assembled, i.e. addDForce is only called for iterative linear solvers (e.g. CGLinearSolver). If you use a direct solver (e.g. LU, LDL etc.), the function addKToMatrix will be used instead. Therefore, this does not depend on the integration scheme (Euler or other).
In the integration, as you mentioned, the MechanicalMatrix appears. This is an implicit way of describing how the matrix A of the linear system (Ax=b) will be computed. Behind this, visitors are sent to go through the right functions. If the solver is iterative: addDForce, addMBKv functions are called. If the solver is direct: addKtoMatrix, addBToMatrix are called.
The matrix B is added into the one matrix A (of the linear system Ax=b). Either B is not assembled (iterative solver) and a visitor launches the addMBKv function or B is assembled (direct solver) and a visitor launches the addBToMatrix function.
About the constraints, I am no expert. In SOFA you can use either an approach based on Lagrange multipliers or on penalty. Those are two different approaches:
 Lagrange: this is splitting the computation into several steps: solve the free motion, compute the constraints only on the considered DOFs (not the entire system) and then applying the constraint. This constraint uses a FreeAnimationLoop, a ConstraintSolver and your Constraint. This is suitable if you have few constraints compared to the number of DOFs of your objects. One example is the examples/Components/constraint/BilateralInteractionConstraint.scn
 Penalty method: this constraints couples the objects. If you define this constraint between two objects, the system solved includes the two objects and the constraints. This is therefore suitable if you have objects with few DOFs (i.e. the constrained system remains reasonably small). You can find a simple example : examples/Tutorials/Collision/MultipleObjectsTwoCubes.scn.
In your case, I would maybe use the Lagrange approach (Bileteral between my objects) and add a PlaneForceField “simulating” a floor (examples/Components/forcefield/PlaneForceField.scn).
Last, yes the Modeler still includes some bugs that have been reported. The improvement of this Modeler is one of the tasks to do in the future in order to make the introduction to SOFA easier.
Hope this helps. Next time, do not hesitate to open one thread per “topic”. But this is really nice to see people with a highlevel of understanding in SOFA as you have.
Best regards,
Hugo
29 February 2016 at 10:16 #5983HugoKeymasterHi Juan Jo,
Did this help you in any way?
Do you need further info?Cheers,
Hugo
16 March 2016 at 15:05 #6336jjcasmarBlockedHi Hugo,
the information was really useful, but I’m still trying to understand it completely. I am going to open new threads for the different topics that we are talking about.
16 March 2016 at 15:22 #6337HugoKeymasterNice to hear !
thank you Juan and do not hesitate to contribute to the forum as well 😉 
AuthorPosts
 You must be logged in to reply to this topic.