Home › Forum › SOFA › Programming with SOFA › [SOLVED] Extracting tetrahedron forcefield indices
Tagged: 64_bits, c++, CGAL, Forcefields, Linux_ubuntu, SOFA_1906
- This topic has 7 replies, 2 voices, and was last updated 4 years, 10 months ago by Lekan.
-
AuthorPosts
-
21 January 2020 at 23:02 #15127LekanBlocked
Hi everyone,
I have a forcefield which I have written in the framework of the native TatrahedronHyperelasticityFEMForceField. My addForce and addDForce implementations are quite different from the native ones.
What I would love to do is to apply internal pressurization to each tetrahedron index from my main SOFA C++ loop. I have the scene file similar to the following gist
https://gist.github.com/lakehanne/eb13b29b17e833112b0b83f40529851b
In my C++ file, I am accessing the dome ring node as follows:
auto dome_ring = root->getChild("DomeRingNode"); // auto dome_ring_tetras = dome_ring->getObject("dofs"); using MechanicalObject = sofa::component::container::MechanicalObject<Vec3Types>; typename MechanicalObject::SPtr dome_ring_dofs = dome_ring->get<MechanicalObject>(groot->SearchDown); auto dome_ring_pos_ = dome_ring_dofs.get()->read(sofa::core::ConstVecCoordId::position()); sofa::helper::ReadAccessor<Data<Vec3Types::VecCoord>>dr_pos_vecs(dome_ring_dofs.get()->read(sofa::core::ConstVecCoordId::position()));
What I am not sure of is if
dr_pos_vecs
contain thedofs
for the tetras only or for just the Vec3d templated mechanical object. It appears that the size of this vector is different from that of the ones I created with CGAL. Would appreciate your help.22 January 2020 at 15:48 #15129HugoKeymasterDear @lakehanne
Your variable
dr_pos_vecs
will contain the field ‘position’ of your Vec3 MechanicalObject. It will therefore be a vector with a size corresponding to the number of nodes in your mesh, with 3 reals (x,y,z) for each node.
How many points does your mesh include?
What is the size returned by the MechanicalObject position vector?Best wishes,
Hugo
PS: short question, why not using Python to script interactive features in your simulation?
22 January 2020 at 18:03 #15130LekanBlockedThanks @Hugo. I think the error came from me. I was confusing the number of points with the total number of cells. My question is now moot, sorry.
Thanks for your SOFAPython interactive simulation suggestion. I wasn’t sure if I had to write the python bindings for my new
TetrahedronMooneyRivlinFEMForceField
class. I wouldn’t, would I?22 January 2020 at 19:22 #15131LekanBlockedSpecifically, can I just load my XML scene in python without having to explicitly rewrite my whole python scene in pyscn?
22 January 2020 at 22:46 #15132HugoKeymasterDear @lakehanne
Yes the new SOFAPython plugin (using Python3 instead of Python2) allows such an implementation, you can see an example for a forcefield here.
You might have to rewrite the entire scene. We had a script translating a *.scn into a *.py (see scn2python.py script) but this was compatible for Python2.
Best,
Hugo
23 January 2020 at 04:55 #1513323 January 2020 at 09:24 #15134HugoKeymasterHi @lakehanne
I’m glad if it helped. Can we close the topic?
Anyway, keep us posted from your progress (papers, video, pull-requests etc.)!Best,
Hugo
19 February 2020 at 00:36 #15213LekanBlockedThanks again, I’ve only just now had a chance to test the python2 scene generator. Thank you to you and the whole Sofa team for all the awesome work that you do.
-
AuthorPosts
- You must be logged in to reply to this topic.