Skip to content

Commit

Permalink
[MeshMatrixMass] Fix massDensity vector update when adding new elemen…
Browse files Browse the repository at this point in the history
…ts. Add method to compute the good element density using ancestors and coefs values (#2257)
  • Loading branch information
epernod authored Jul 28, 2021
1 parent a6e74b8 commit c9d7bb0
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 133 deletions.
114 changes: 59 additions & 55 deletions modules/SofaMiscForceField/src/SofaMiscForceField/MeshMatrixMass.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ class MeshMatrixMass : public core::behavior::Mass<DataTypes>
virtual void setMassDensity(sofa::type::vector< Real > massDensity);
virtual void setMassDensity(Real massDensityValue);
virtual void setTotalMass(Real totalMass);

virtual void addMassDensity(const sofa::type::vector< Index >& indices,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);
/// @}


Expand Down Expand Up @@ -253,73 +257,73 @@ class MeshMatrixMass : public core::behavior::Mass<DataTypes>

/// Mass coefficient Creation/Destruction functions for Triangular Mesh:
/// Vertex coefficient of mass matrix creation function to handle creation of new triangles
void applyTriangleCreation(const sofa::type::vector< Index >& /*indices*/,
const sofa::type::vector< core::topology::BaseMeshTopology::Triangle >& /*elems*/,
const sofa::type::vector< sofa::type::vector< Index > >& /*ancestors*/,
const sofa::type::vector< sofa::type::vector< double > >& /*coefs*/);
void applyTriangleCreation(const sofa::type::vector< Index >& triangleAdded,
const sofa::type::vector< core::topology::BaseMeshTopology::Triangle >& elems,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);

/// Vertex coefficient of mass matrix destruction function to handle creation of new triangles
void applyTriangleDestruction(const sofa::type::vector<Index> & /*indices*/);
void applyTriangleDestruction(const sofa::type::vector<Index> & triangleRemoved);

using topology::TopologyDataHandler<core::topology::BaseMeshTopology::Point,MassVector>::ApplyTopologyChange;
/// Callback to add triangles elements.
void ApplyTopologyChange(const core::topology::TrianglesAdded* /*event*/);
void ApplyTopologyChange(const core::topology::TrianglesAdded* topoEvent);
/// Callback to remove triangles elements.
void ApplyTopologyChange(const core::topology::TrianglesRemoved* /*event*/);
void ApplyTopologyChange(const core::topology::TrianglesRemoved* topoEvent);


///////////////////////// Functions on Quads //////////////////////////////////////

/// Mass coefficient Creation/Destruction functions for Quad Mesh:
/// Vertex coefficient of mass matrix creation function to handle creation of new quads
void applyQuadCreation(const sofa::type::vector< Index >& /*indices*/,
const sofa::type::vector< core::topology::BaseMeshTopology::Quad >& /*elems*/,
const sofa::type::vector< sofa::type::vector< Index > >& /*ancestors*/,
const sofa::type::vector< sofa::type::vector< double > >& /*coefs*/);
void applyQuadCreation(const sofa::type::vector< Index >& quadAdded,
const sofa::type::vector< core::topology::BaseMeshTopology::Quad >& elems,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);

/// Vertex coefficient of mass matrix destruction function to handle creation of new quads
void applyQuadDestruction(const sofa::type::vector<Index> & /*indices*/);
void applyQuadDestruction(const sofa::type::vector<Index> & quadRemoved);

/// Callback to add quads elements.
void ApplyTopologyChange(const core::topology::QuadsAdded* /*event*/);
void ApplyTopologyChange(const core::topology::QuadsAdded* topoEvent);
/// Callback to remove quads elements.
void ApplyTopologyChange(const core::topology::QuadsRemoved* /*event*/);
void ApplyTopologyChange(const core::topology::QuadsRemoved* topoEvent);


///////////////////////// Functions on Tetrahedron //////////////////////////////////////

/// Mass coefficient Creation/Destruction functions for Tetrahedral Mesh:
/// Vertex coefficient of mass matrix creation function to handle creation of new tetrahedra
void applyTetrahedronCreation(const sofa::type::vector< Index >& /*indices*/,
const sofa::type::vector< core::topology::BaseMeshTopology::Tetrahedron >& /*elems*/,
const sofa::type::vector< sofa::type::vector< Index > >& /*ancestors*/,
const sofa::type::vector< sofa::type::vector< double > >& /*coefs*/);
void applyTetrahedronCreation(const sofa::type::vector< Index >& tetrahedronAdded,
const sofa::type::vector< core::topology::BaseMeshTopology::Tetrahedron >& elems,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);

/// Vertex coefficient of mass matrix destruction function to handle creation of new tetrahedra
void applyTetrahedronDestruction(const sofa::type::vector<Index> & /*indices*/);
void applyTetrahedronDestruction(const sofa::type::vector<Index> & tetrahedronRemoved);

/// Callback to add tetrahedron elements.
void ApplyTopologyChange(const core::topology::TetrahedraAdded* /*event*/);
void ApplyTopologyChange(const core::topology::TetrahedraAdded* topoEvent);
/// Callback to remove tetrahedron elements.
void ApplyTopologyChange(const core::topology::TetrahedraRemoved* /*event*/);
void ApplyTopologyChange(const core::topology::TetrahedraRemoved* topoEvent);


///////////////////////// Functions on Hexahedron //////////////////////////////////////

/// Mass coefficient Creation/Destruction functions for Hexahedral Mesh:
/// Vertex coefficient of mass matrix creation function to handle creation of new hexahedra
void applyHexahedronCreation(const sofa::type::vector< Index >& /*indices*/,
const sofa::type::vector< core::topology::BaseMeshTopology::Hexahedron >& /*elems*/,
const sofa::type::vector< sofa::type::vector< Index > >& /*ancestors*/,
const sofa::type::vector< sofa::type::vector< double > >& /*coefs*/);
void applyHexahedronCreation(const sofa::type::vector< Index >& hexahedronAdded,
const sofa::type::vector< core::topology::BaseMeshTopology::Hexahedron >& elems,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);

/// Vertex coefficient of mass matrix destruction function to handle creation of new hexahedra
void applyHexahedronDestruction(const sofa::type::vector<Index> & /*indices*/);
void applyHexahedronDestruction(const sofa::type::vector<Index> & hexahedronRemoved);

/// Callback to add hexahedron elements.
virtual void ApplyTopologyChange(const core::topology::HexahedraAdded* /*event*/);
virtual void ApplyTopologyChange(const core::topology::HexahedraAdded* topoEvent);
/// Callback to remove hexahedron elements.
virtual void ApplyTopologyChange(const core::topology::HexahedraRemoved* /*event*/);
virtual void ApplyTopologyChange(const core::topology::HexahedraRemoved* topoEvent);

protected:
MeshMatrixMass<DataTypes,TMassType>* m;
Expand All @@ -345,69 +349,69 @@ class MeshMatrixMass : public core::behavior::Mass<DataTypes>
///////////////////////// Functions on Triangles //////////////////////////////////////

/// Edge coefficient of mass matrix creation function to handle creation of new triangles
void applyTriangleCreation(const sofa::type::vector< Index >& /*indices*/,
const sofa::type::vector< core::topology::BaseMeshTopology::Triangle >& /*elems*/,
const sofa::type::vector< sofa::type::vector< Index > >& /*ancestors*/,
const sofa::type::vector< sofa::type::vector< double > >& /*coefs*/);
void applyTriangleCreation(const sofa::type::vector< Index >& triangleAdded,
const sofa::type::vector< core::topology::BaseMeshTopology::Triangle >& elems,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);

/// Edge coefficient of mass matrix destruction function to handle creation of new triangles
void applyTriangleDestruction(const sofa::type::vector<Index> & /*indices*/);
void applyTriangleDestruction(const sofa::type::vector<Index> & triangleRemoved);

/// Callback to add triangles elements.
void ApplyTopologyChange(const core::topology::TrianglesAdded* /*event*/);
void ApplyTopologyChange(const core::topology::TrianglesAdded* topoEvent);
/// Callback to remove triangles elements.
void ApplyTopologyChange(const core::topology::TrianglesRemoved* /*event*/);
void ApplyTopologyChange(const core::topology::TrianglesRemoved* topoEvent);


///////////////////////// Functions on Quads //////////////////////////////////////

/// Edge coefficient of mass matrix creation function to handle creation of new quads
void applyQuadCreation(const sofa::type::vector< Index >& /*indices*/,
const sofa::type::vector< core::topology::BaseMeshTopology::Quad >& /*elems*/,
const sofa::type::vector< sofa::type::vector< Index > >& /*ancestors*/,
const sofa::type::vector< sofa::type::vector< double > >& /*coefs*/);
void applyQuadCreation(const sofa::type::vector< Index >& quadAdded,
const sofa::type::vector< core::topology::BaseMeshTopology::Quad >& elems,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);

/// Edge coefficient of mass matrix destruction function to handle creation of new quads
void applyQuadDestruction(const sofa::type::vector<Index> & /*indices*/);
void applyQuadDestruction(const sofa::type::vector<Index> & quadRemoved);

/// Callback to add quads elements.
void ApplyTopologyChange(const core::topology::QuadsAdded* /*event*/);
void ApplyTopologyChange(const core::topology::QuadsAdded* topoEvent);
/// Callback to remove quads elements.
void ApplyTopologyChange(const core::topology::QuadsRemoved* /*event*/);
void ApplyTopologyChange(const core::topology::QuadsRemoved* topoEvent);


///////////////////////// Functions on Tetrahedron //////////////////////////////////////

/// Edge coefficient of mass matrix creation function to handle creation of new tetrahedra
void applyTetrahedronCreation(const sofa::type::vector< Index >& /*indices*/,
const sofa::type::vector< core::topology::BaseMeshTopology::Tetrahedron >& /*elems*/,
const sofa::type::vector< sofa::type::vector< Index > >& /*ancestors*/,
const sofa::type::vector< sofa::type::vector< double > >& /*coefs*/);
void applyTetrahedronCreation(const sofa::type::vector< Index >& tetrahedronAdded,
const sofa::type::vector< core::topology::BaseMeshTopology::Tetrahedron >& elems,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);

/// Edge coefficient of mass matrix destruction function to handle creation of new tetrahedra
void applyTetrahedronDestruction(const sofa::type::vector<Index> & /*indices*/);
void applyTetrahedronDestruction(const sofa::type::vector<Index> & tetrahedronRemoved);

/// Callback to add tetrahedron elements.
void ApplyTopologyChange(const core::topology::TetrahedraAdded* /*event*/);
void ApplyTopologyChange(const core::topology::TetrahedraAdded* topoEvent);
/// Callback to remove tetrahedron elements.
void ApplyTopologyChange(const core::topology::TetrahedraRemoved* /*event*/);
void ApplyTopologyChange(const core::topology::TetrahedraRemoved* topoEvent);


///////////////////////// Functions on Hexahedron //////////////////////////////////////

/// Edge coefficient of mass matrix creation function to handle creation of new hexahedra
void applyHexahedronCreation(const sofa::type::vector< Index >& /*indices*/,
const sofa::type::vector< core::topology::BaseMeshTopology::Hexahedron >& /*elems*/,
const sofa::type::vector< sofa::type::vector< Index > >& /*ancestors*/,
const sofa::type::vector< sofa::type::vector< double > >& /*coefs*/);
void applyHexahedronCreation(const sofa::type::vector< Index >& hexahedronAdded,
const sofa::type::vector< core::topology::BaseMeshTopology::Hexahedron >& elems,
const sofa::type::vector< sofa::type::vector< Index > >& ancestors,
const sofa::type::vector< sofa::type::vector< double > >& coefs);

/// Edge coefficient of mass matrix destruction function to handle creation of new hexahedra
void applyHexahedronDestruction(const sofa::type::vector<Index> & /*indices*/);

/// Callback to add hexahedron elements.
void ApplyTopologyChange(const core::topology::HexahedraAdded* /*event*/);
void ApplyTopologyChange(const core::topology::HexahedraAdded* topoEvent);
/// Callback to remove hexahedron elements.
void ApplyTopologyChange(const core::topology::HexahedraRemoved* /*event*/);
void ApplyTopologyChange(const core::topology::HexahedraRemoved* topoEvent);

protected:
MeshMatrixMass<DataTypes,TMassType>* m;
Expand Down
Loading

0 comments on commit c9d7bb0

Please sign in to comment.