Home › Forum › SOFA › Programming with SOFA › Doubts about how ForceField and mapping interact
Tagged: 64_bits, Forcefield, Linux_other, mapping, Plugin_other, SOFA_2006
 This topic has 3 replies, 2 voices, and was last updated 3 years, 7 months ago by Hugo.

AuthorPosts

6 October 2020 at 14:26 #17294jjcasmarBlocked
I am implementing a Mapping that, given my degress of freedom, computes the deformation gradient. Then I have an energy that depends on the deformation gradient. With this scheme, I have some doubts.
First of all, the math for this scheme would be
u = DoF F = g(u) // Deformation gradient is a function of the DoF E = e(F) // Energy is a function of the deformation gradient dE/du = dE/dF * dF/du d2E/du2 = (dF/du)^T * d2E/dF2 * dF/du + dE/dF * d2F/du2
I am not sure how all this happens in SOFA. I have a ForceField which I am going to use with a ConjugateGradient solver, so I have implemented
addForce
andaddDForce
functions. If I understand SOFA correctly,addForce
has to computedE/dF
andaddDForce
has to computed2E/dF2
.First question I have is how I can compute
d2E/dF2
if hessian depends onF
. In this case I only receive what I believe isdx = dF/du * du
The second question is how the force is actually computed. According to the math i wrote, it is
dE/du = dE/dF * dF/du
andaddForce
receives what I believe isx = F = g(u)
. When is thedF/du
done?Finally, what happens if my mapping is not linear and therefore I need the second derivative of the deformation gradient wrt the DoF?
10 October 2020 at 00:03 #17342HugoKeymasterHi @jjcasmar
Thank you for your question.
I see you are doing things in a similar way than what was developed in the Flexible plugin.You perfectly understood the definition of
addForce
andaddDForce
.I am just not sure to see how your scene is created. Could you please describe it (including your mapping)?
Hugo
10 October 2020 at 16:17 #17351jjcasmarBlockedSorry, cant share the scene description right now. Ill do it ASAP.
One thing I normally dont have clear if is I have to add the kFactor or dt on the computations and also the sign of the result.
For example, if used in a EulerImplicit solver, the force is multiplied by the dt and the hessian is multiplied by dt+beta value (or something like that, I dont have the details right infront of me). It would be nice to add in the documentation if we need to multiply our force and hessian by these quantities.
Also, the force is the
dE/du
, but I always have to double check if the solver is assuming Im returning the force or the derivative of the energy. It would be nice to specify all this in the documentation clearly.30 October 2020 at 14:19 #17487HugoKeymasterOla @jjcasmar
Sorry for keeping you waiting last two weeks.
kFactor is indeed not straightforward to understand. It’s a good point.
kFactor is defined in the MechanicalParams. These are set by the ODESolver (integration scheme) when writing:matrix = MechanicalMatrix(mFactor, bFactor, kFactor);
For instance, for EulerImplicitSolver we have:
matrix = MechanicalMatrix(1+tr*h*f_rayleighMass.getValue(),tr*h,tr*h*(h+f_rayleighStiffness.getValue()));
In this case:
kFactor = tr * h * (h+f_rayleighStiffness.getValue())
whereh=dt
This kFactor is therefore used in implicit schemes, and it must be applied in the addDForce and addKToMatrix, when the implicit part of forces are applied.
Could reformulate your last point?
I am not sure to get where lies the lack of clarity.Finally, I profit from this post to thank you directly for your strong activity around SOFA! Good to have you.
Hugo
PS: it would great to hear from your work at the SOFA Symposium in 3 weeks!

AuthorPosts
 You must be logged in to reply to this topic.