Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mass] Fix point topological changes for UniformMass #2853

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Sofa/Component/Mass/src/sofa/component/mass/UniformMass.inl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,22 @@ void UniformMass<DataTypes>::initDefaultImpl()
msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'";

d_indices.createTopologyHandler(meshTopology);
d_indices.addTopologyEventCallBack(sofa::core::topology::TopologyChangeType::ENDING_EVENT, [this](const core::topology::TopologyChange* eventTopo) {
d_indices.supportNewTopologyElements(true);

// Need to create a call back to assign index of new point into the topologySubsetData. Deletion is automatically handle.
d_indices.setCreationCallback([this](Index dataIndex, Index& valueIndex,
const core::topology::BaseMeshTopology::Point& point,
const sofa::type::vector< Index >& ancestors,
const sofa::type::vector< SReal >& coefs)
{
SOFA_UNUSED(point);
SOFA_UNUSED(ancestors);
SOFA_UNUSED(coefs);
valueIndex = dataIndex;
});

d_indices.addTopologyEventCallBack(sofa::core::topology::TopologyChangeType::ENDING_EVENT, [this](const core::topology::TopologyChange* eventTopo)
{
updateMassOnResize(d_indices.getValue().size());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class BeamFEMForceField_test : public BaseTest
createObject(m_root, "EdgeSetGeometryAlgorithms", { {"template","Rigid3d"} });

createObject(m_root, "BeamFEMForceField", { {"Name","Beam"}, {"template", "Rigid3d"}, {"radius", str(radius)}, {"youngModulus", str(youngModulus)}, {"poissonRatio", str(poissonRatio)} });
createObject(m_root, "UniformMass", { {"name","mass"}, {"totalMass","1.0"}, {"handleTopologicalChanges", "1" } });
createObject(m_root, "UniformMass", { {"name","mass"}, {"totalMass","1.0"} });
createObject(m_root, "FixedConstraint", { {"name","fix"}, {"indices","0"} });

/// Init simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SOFA_CORE_API TopologySubsetIndices : public sofa::core::topology::Topolog
void createTopologyHandler(sofa::core::topology::BaseMeshTopology* _topology) override;

SOFA_ATTRIBUTE_DISABLED("v21.12 (PR#2393)", "v21.12 (PR#2393)", "This method has been removed, TopologyHandler is now created internally. Method createTopologyHandler(BaseMeshTopology*) should be used.")
void createTopologyHandler(sofa::core::topology::BaseMeshTopology* _topology, sofa::core::topology::TopologyDataHandler < core::topology::BaseMeshTopology::Point, type::vector<Index> >* topoEngine) = delete;
void createTopologyHandler(sofa::core::topology::BaseMeshTopology* _topology, sofa::core::topology::TopologyDataHandler < core::topology::BaseMeshTopology::Point, type::vector<Index> >* topoEngine) override = delete;

protected:
void swapPostProcess(Index i1, Index i2) override;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Node >
<Node bbox="0 0 0 20 20 20">
<RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
<RequiredPlugin name="Sofa.Component.SolidMechanics.FEM.Elastic"/> <!-- Needed to use components [TriangularFEMForceField] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
Expand Down