Home › Forum › SOFA › Using SOFA › MeshSpringForceField on Rigid3d
Tagged: Compliant, force field
- This topic has 4 replies, 2 voices, and was last updated 7 years, 1 month ago by Hugo.
-
AuthorPosts
-
23 October 2017 at 18:29 #10082mmabroukBlocked
Hello,
I had an Vec3d atom model pulled together using a MeshSpringForceField. I wish to add the 3dof of rotation to the springs. How can I do that. My model right now looks like this:
cn.createObject("MechanicalObject", name="atom_frames", template="Rigid3d", position=config) cn = parent_node.createChild("mesh") cn.createObject("MechanicalObject", template="Vec3d", name="meshframes", position=stools.arrayToString(config[:, :3])) cn.createObject("SkinningMapping", template="Rigid3d,Vec3d", name="mapsframetohullpoints", input="@../ca_frames", output="@./meshframes") cn.createObject("MeshTopology", name="topology", edges=txt_edges) cn.createObject("MeshSpringForceField", name="springs", template="Vec3d", stiffness=springs_stiffness, damping=springs_damping) cn.createObject("UniformMass", name="mass", totalmass=totalmass)
I want to substitute the MeshSpringForceField to a force field that takes account of the rotations.
I tried using the FrameSpringForceField without avail.
Thank you!
Yours,
Mahmoudp.s. By the way, is there a resource with more information about the different mappings and force field.
23 October 2017 at 18:47 #10083HugoKeymasterHi Mahmoud,
Have you checked the GearSpringForceField ? it’s defining a spring with torque support.
NB: For your notice, this code should be refactorized soon with the JointSpringForceFields.
HTH
Hugo
24 October 2017 at 14:03 #10084mmabroukBlockedHello Hugo,
Thanks for your quick answer. I am struggling a bit working with the GearSpringForceField, especially the spring definition. Here are my issues:
1)I tried copying some stuff from the example, but it seems things are different since I am using the compliant solver:
subnode.createObject('CompliantImplicitSolver', name="timestep integration scheme", stabilization=0, warm_start=0, neglecting_compliance_forces_in_geometric_stiffness="0", constraint_forces="propagate")
For some reason, I cannot use the RigidRigidMapping with the compliant solver, but have to use the AssembledRigidRigidMapping. I am assuming they do the same thing?
2) I am not sure what is the correct Spring formatting. I looked into the code, and my understanding that it is:
BEGIN_SPRING mass_frame1 index_frame1 mass_frame2 index_frame2 AXIS unknown unknow ENDSPRING
I am not sure how to define the axis.. Is the rest of my understanding correct?3) Currently I neither see the springs in the GUI, nor do they extert any force, in fact, as soon as I move any atom/frame in my model, my model explodes.
Below is my code:
cn = parent_node.createChild("mesh") cn.createObject("MechanicalObject", template="Rigid3d", name="dofs", position=stools.dummyDofs(config.shape[0], "Rigid3d"), showObject="1", showObjectScale="2") source = "" for c in range(config.shape[0]): x = [0, 0, 0] source += "%s %s %s %s 0 0 0 0\n" % (c, x[0], x[1], x[2]) cn.createObject("AssembledRigidRigidMapping", template="Rigid3d,Rigid3d", name="mapscatomesh", source=source[:-1]) springs = " ".join(["BEGIN_SPRING 4 %s 5 %s AXIS 0 1 END_SPRING\n" % (i, i+1) for i in range(30)]) cn.createObject("GearSpringForceField", template="Rigid3d", name="spring", spring=springs)
Thanks for your help!
Yours,
Mahmoud24 October 2017 at 14:16 #10089mmabroukBlockedIt seems my model works when I use the EulerImplicitSolver and CGLinearSolver instead of the CompliantImplicitSolver.
But other parts of my model are dependent on the Compliant module (I use for example DistanceMapping and UniformCompliance).
Is there a solution for this problem?30 October 2017 at 15:10 #10101HugoKeymasterHi @mmabrouk
I am sorry, I am not rock-solid about Rigid simulations and about the Compliant plugin (which has a specific API).
1) Yes they are doing the same, just the Compliant case is assembling (building) the matrices (even for mapping)
2) Looking from the code it seems that the format is : BEGIN_SPRING index_frame1 mass_frame1 index_frame2 mass_frame2 ENDSPRING (and additional info can be added about stiffness etc ex: KS_R 2000000 2000000 KD 1 RATIO 2.166667)
What you mention in your last post makes me think about a potential hint. The CompliantImplicitSolver implements a Newmark-beta implicit solver for constrained dynamics using assembly. Which means the system matrix A (from Ax=b system) will be built. With such direct approach, the functions that are called in the ForceField API are:
addForce
: for explicit forces stored in b vectoraddKToMatrix
: for implicit forces stored in A
The CGLinearSolver is an iterative solver, in such cases, the function
addDForce
is called instead ofaddKToMatrix
. This is why it works in one case and not the other one, I would guess. A solution would be to implement the sameaddKToMatrix
in GearSpringForceField. I really hope this helps. Cheers,Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.