21 January 2020 at 23 h 02 min #15127
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
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
dofsfor 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 h 48 min #15129
dr_pos_vecswill 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?
PS: short question, why not using Python to script interactive features in your simulation?22 January 2020 at 18 h 03 min #15130
Thanks @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
TetrahedronMooneyRivlinFEMForceFieldclass. I wouldn’t, would I?22 January 2020 at 19 h 22 min #15131
Specifically, 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 h 46 min #15132
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.
Hugo23 January 2020 at 4 h 55 min #1513323 January 2020 at 9 h 24 min #15134
I’m glad if it helped. Can we close the topic?
Anyway, keep us posted from your progress (papers, video, pull-requests etc.)!
Hugo19 February 2020 at 0 h 36 min #15213
Thanks 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.
- You must be logged in to reply to this topic.