Skip to content
Open
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
25 changes: 8 additions & 17 deletions Sofa/Component/Mass/src/sofa/component/mass/ElementFEMMass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,18 @@ template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec3Typ

void registerFEMMass(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force) defined on edges")
factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force)")
.add< ElementFEMMass<sofa::defaulttype::Vec1Types, sofa::geometry::Edge> >()
.add< ElementFEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Edge> >()
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Edge> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force) defined on triangles")
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Edge> >()
.add< ElementFEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Triangle> >()
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force) defined on quads")
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle> >()
.add< ElementFEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Quad> >()
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Quad> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force) defined on tetrahedra")
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force) defined on hexahedra")
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force) defined on prisms")
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Prism> >(true));
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Quad> >()
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron> >()
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron> >()
.add< ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Prism> >()
);
}

}
18 changes: 0 additions & 18 deletions Sofa/Component/Mass/src/sofa/component/mass/ElementFEMMass.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,6 @@ class ElementFEMMass :

public:

/**
* @brief Gets the class name according to the provided template parameters.
*
* For example, `ElementFEMMass<Vec3Types, sofa::geometry::Edge>` will return "EdgeFEMMass".
*
* @return A string representing the class name.
*/
static const std::string GetCustomClassName()
{
return std::string(sofa::geometry::elementTypeToString(ElementType::Element_type)) + "FEMMass";
}

/**
* @brief Gets the template name based on the data types.
* @return A string representing the template name (e.g., "Vec3d").
*/
static const std::string GetCustomTemplateName() { return DataTypes::Name(); }

/**
* @brief Link to the nodal mass density component.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,18 @@ namespace sofa::component::solidmechanics::fem::elastic

void registerElementCorotationalFEMForceField(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear beams using the corotational approach")
factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law using the corotational approach")
// .add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec1Types, sofa::geometry::Edge> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec2Types, sofa::geometry::Edge> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Edge> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear triangles using the corotational approach")
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Edge> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec2Types, sofa::geometry::Triangle> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear quads using the corotational approach")
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec2Types, sofa::geometry::Quad> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Quad> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear tetrahedra using the corotational approach")
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear hexahedra using the corotational approach")
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear prisms using the corotational approach")
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Prism> >(true));
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Quad> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron> >()
.add< ElementCorotationalFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Prism> >()
);
}

// template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API ElementCorotationalFEMForceField<sofa::defaulttype::Vec1Types, sofa::geometry::Edge>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,6 @@ class ElementCorotationalFEMForceField :
SOFA_TEMPLATE2(BaseElementLinearFEMForceField, DataTypes, ElementType),
SOFA_TEMPLATE2(FEMForceField, DataTypes, ElementType));

/**
* The purpose of this function is to register the name of this class according to the provided
* pattern.
*
* Example: ElementCorotationalFEMForceField<Vec3Types, sofa::geometry::Edge> will produce
* the class name "EdgeCorotationalFEMForceField".
*/
static const std::string GetCustomClassName()
{
return std::string(sofa::geometry::elementTypeToString(ElementType::Element_type)) +
"CorotationalFEMForceField";
}

static const std::string GetCustomTemplateName() { return DataTypes::Name(); }

private:
using trait = sofa::component::solidmechanics::fem::elastic::trait<DataTypes, ElementType>;
using ElementForce = typename trait::ElementForce;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,18 @@ namespace sofa::component::solidmechanics::fem::elastic

void registerElementLinearSmallStrainFEMForceField(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear beams assuming small strain")
factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law assuming small strain")
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec1Types, sofa::geometry::Edge> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec2Types, sofa::geometry::Edge> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Edge> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear triangles assuming small strain")
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Edge> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec2Types, sofa::geometry::Triangle> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear quads assuming small strain")
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec2Types, sofa::geometry::Quad> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Quad> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear tetrahedra assuming small strain")
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear hexahedra assuming small strain")
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron> >(true));

factory->registerObjects(sofa::core::ObjectRegistrationData("Hooke's law on linear prisms assuming small strain")
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Prism> >(true));
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Quad> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron> >()
.add< ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec3Types, sofa::geometry::Prism> >()
);
}

template class SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_API ElementLinearSmallStrainFEMForceField<sofa::defaulttype::Vec1Types, sofa::geometry::Edge>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,8 @@ class ElementLinearSmallStrainFEMForceField :
SOFA_TEMPLATE2(BaseElementLinearFEMForceField, DataTypes, ElementType),
SOFA_TEMPLATE2(FEMForceField, DataTypes, ElementType));

/**
* The purpose of this function is to register the name of this class according to the provided
* pattern.
*
* Example: ElementLinearSmallStrainFEMForceField<Vec3Types, sofa::geometry::Edge> will produce
* the class name "EdgeLinearSmallStrainFEMForceField".
*/
static const std::string GetCustomClassName()
{
return std::string(sofa::geometry::elementTypeToString(ElementType::Element_type)) +
"LinearSmallStrainFEMForceField";
}

static const std::string GetCustomTemplateName() { return DataTypes::Name(); }

private:
using trait = sofa::component::solidmechanics::fem::elastic::trait<DataTypes, ElementType>;
using trait = typename FEMForceField<DataTypes, ElementType>::trait;
using ElementStiffness = typename trait::ElementStiffness;
using ElementDisplacement = typename trait::ElementDisplacement;
using StrainDisplacement = typename trait::StrainDisplacement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FEMForceField :
sofa::core::behavior::TopologyAccessor,
sofa::simulation::TaskSchedulerUser);

private:
protected:
using trait = sofa::component::solidmechanics::fem::elastic::trait<DataTypes, ElementType>;
using ElementForce = typename trait::ElementForce;

Expand Down Expand Up @@ -106,6 +106,8 @@ class FEMForceField :
sofa::type::vector<ElementForce>& df,
const sofa::VecDeriv_t<DataTypes>& dx);

virtual void beforeElementForceDeriv(const sofa::core::MechanicalParams* mparams) {}
Comment thread
alxbilger marked this conversation as resolved.

virtual void computeElementsForcesDeriv(
const sofa::simulation::Range<std::size_t>& range,
const sofa::core::MechanicalParams* mparams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ void FEMForceField<DataTypes, ElementType>::computeElementsForcesDeriv(
const sofa::VecDeriv_t<DataTypes>& dx)
{
SCOPED_TIMER("ElementForcesDeriv");
beforeElementForceDeriv(mparams);

const auto& elements = trait::FiniteElement::getElementSequence(*this->l_topology);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
rotationMethod="polar" computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>

<NodalMassDensity property="1100"/>
<PrismFEMMass/>
<ElementFEMMass template="Vec3,Prism"/>

<VisualMesh position="@../state.position" topology="@prism_topology" enable="true"/>
</Node>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<NaturalOrderingMethod/>
<SparseLDLSolver name="linear_solver" template="CompressedRowSparseMatrix"/>

<HexahedronCorotationalFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>
<ElementCorotationalFEMForceField name="FEM" template="Vec3,Hexahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

<CGLinearSolver iterations="250" name="linear_solver" tolerance="1.0e-12" threshold="1.0e-12" />

<HexahedronCorotationalFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>
<ElementCorotationalFEMForceField name="FEM" template="Vec3,Hexahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<NaturalOrderingMethod/>
<SparseLDLSolver name="linear_solver" template="CompressedRowSparseMatrix"/>

<HexahedronCorotationalFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>
<ElementCorotationalFEMForceField name="FEM" template="Vec3,Hexahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

<CGLinearSolver iterations="250" name="linear_solver" tolerance="1.0e-12" threshold="1.0e-12" />

<HexahedronCorotationalFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>
<ElementCorotationalFEMForceField name="FEM" template="Vec3,Hexahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<NaturalOrderingMethod/>
<SparseLDLSolver name="linear_solver" template="CompressedRowSparseMatrix"/>

<HexahedronLinearSmallStrainFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>
<ElementLinearSmallStrainFEMForceField name="FEM" template="Vec3,Hexahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

<CGLinearSolver iterations="250" name="linear_solver" tolerance="1.0e-12" threshold="1.0e-12" />

<HexahedronLinearSmallStrainFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>
<ElementLinearSmallStrainFEMForceField name="FEM" template="Vec3,Hexahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<NaturalOrderingMethod/>
<SparseLDLSolver name="linear_solver" template="CompressedRowSparseMatrix"/>

<HexahedronLinearSmallStrainFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>
<ElementLinearSmallStrainFEMForceField name="FEM" template="Vec3,Hexahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

<CGLinearSolver iterations="250" name="linear_solver" tolerance="1.0e-12" threshold="1.0e-12" />

<HexahedronLinearSmallStrainFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>
<ElementLinearSmallStrainFEMForceField name="FEM" template="Vec3,Hexahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@grid"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<TetrahedronSetGeometryAlgorithms template="Vec3" name="GeomAlgo" drawTetrahedra="false"/>
<Hexa2TetraTopologicalMapping input="@grid" output="@Tetra_topo" swapping="true"/>

<TetrahedronCorotationalFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@Tetra_topo"
<ElementCorotationalFEMForceField name="FEM" template="Vec3,Tetrahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@Tetra_topo"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>
</Node>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
<TetrahedronSetGeometryAlgorithms template="Vec3" name="GeomAlgo" drawTetrahedra="false"/>
<Hexa2TetraTopologicalMapping input="@grid" output="@Tetra_topo" swapping="true"/>

<TetrahedronCorotationalFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@Tetra_topo"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>
<ElementCorotationalFEMForceField name="FEM" template="Vec3,Tetrahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@Tetra_topo"
computeForceStrategy="parallel" computeForceDerivStrategy="parallel"/>
</Node>

</Node>
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
<TetrahedronSetGeometryAlgorithms template="Vec3" name="GeomAlgo" drawTetrahedra="false"/>
<Hexa2TetraTopologicalMapping input="@grid" output="@Tetra_topo" swapping="true"/>

<TetrahedronCorotationalFEMForceField name="FEM" youngModulus="2e6" poissonRatio="0.45" topology="@Tetra_topo"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>
<ElementCorotationalFEMForceField name="FEM" template="Vec3,Tetrahedron"
youngModulus="2e6" poissonRatio="0.45" topology="@Tetra_topo"
computeForceStrategy="sequenced" computeForceDerivStrategy="sequenced"/>
</Node>


Expand Down
Loading
Loading