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
10 changes: 5 additions & 5 deletions Sofa/Component/Mass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ project(Sofa.Component.Mass LANGUAGES CXX)
set(SOFACOMPONENTMASS_SOURCE_DIR "src/sofa/component/mass")

set(HEADER_FILES
${SOFACOMPONENTMASS_SOURCE_DIR}/config.h.in
${SOFACOMPONENTMASS_SOURCE_DIR}/init.h
${SOFACOMPONENTMASS_SOURCE_DIR}/AddMToMatrixFunctor.h
${SOFACOMPONENTMASS_SOURCE_DIR}/DiagonalMass.h
${SOFACOMPONENTMASS_SOURCE_DIR}/DiagonalMass.inl
${SOFACOMPONENTMASS_SOURCE_DIR}/ElementFEMMass.h
${SOFACOMPONENTMASS_SOURCE_DIR}/ElementFEMMass.inl
${SOFACOMPONENTMASS_SOURCE_DIR}/FEMMass.h
${SOFACOMPONENTMASS_SOURCE_DIR}/FEMMass.inl
${SOFACOMPONENTMASS_SOURCE_DIR}/MassType.h
${SOFACOMPONENTMASS_SOURCE_DIR}/MeshMatrixMass.h
${SOFACOMPONENTMASS_SOURCE_DIR}/MeshMatrixMass.inl
Expand All @@ -19,12 +17,14 @@ set(HEADER_FILES
${SOFACOMPONENTMASS_SOURCE_DIR}/UniformMass.h
${SOFACOMPONENTMASS_SOURCE_DIR}/UniformMass.inl
${SOFACOMPONENTMASS_SOURCE_DIR}/VecMassType.h
${SOFACOMPONENTMASS_SOURCE_DIR}/config.h.in
${SOFACOMPONENTMASS_SOURCE_DIR}/init.h
)

set(SOURCE_FILES
${SOFACOMPONENTMASS_SOURCE_DIR}/init.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/DiagonalMass.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/ElementFEMMass.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/FEMMass.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/MeshMatrixMass.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/NodalMassDensity.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/UniformMass.cpp
Expand Down
67 changes: 0 additions & 67 deletions Sofa/Component/Mass/src/sofa/component/mass/ElementFEMMass.cpp

This file was deleted.

58 changes: 58 additions & 0 deletions Sofa/Component/Mass/src/sofa/component/mass/FEMMass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#define SOFA_COMPONENT_MASS_FEMMASS_CPP
#include <sofa/component/mass/FEMMass.inl>
#include <sofa/core/ObjectFactory.h>
#include <sofa/defaulttype/VecTypes.h>
#include <sofa/fem/FiniteElement[all].h>

namespace sofa::component::mass
{

template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec1Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Triangle>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Quad>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Quad>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Prism>;

void registerFEMMass(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force)")
.add< FEMMass<sofa::defaulttype::Vec1Types, sofa::geometry::Edge> >()
.add< FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Edge> >()
.add< FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Edge> >()
.add< FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Triangle> >()
.add< FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle> >()
.add< FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Quad> >()
.add< FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Quad> >()
.add< FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron> >()
.add< FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron> >()
.add< FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Prism> >()
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace sofa::component::mass
{

/**
* @class ElementFEMMass
* @class FEMMass
* @brief Computes and stores the mass matrix for a finite element model.
*
* This class calculates the mass matrix for a given set of finite elements based on a nodal mass density field.
Expand All @@ -54,14 +54,14 @@ namespace sofa::component::mass
* @tparam TElementType The type of finite element (e.g., sofa::geometry::Tetrahedron).
*/
template<class TDataTypes, class TElementType>
class ElementFEMMass :
class FEMMass :
public core::behavior::Mass<TDataTypes>,
public virtual sofa::core::behavior::TopologyAccessor
{
public:
using DataTypes = TDataTypes;
using ElementType = TElementType;
SOFA_CLASS2(SOFA_TEMPLATE2(ElementFEMMass, DataTypes, ElementType),
SOFA_CLASS2(SOFA_TEMPLATE2(FEMMass, DataTypes, ElementType),
core::behavior::Mass<TDataTypes>,
sofa::core::behavior::TopologyAccessor);

Expand All @@ -80,31 +80,13 @@ 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.
*
* This component provides the mass density at each node of the mesh.
* It must be present in the context for the mass to be calculated correctly.
*/
sofa::SingleLink<ElementFEMMass, NodalMassDensity,
sofa::SingleLink<FEMMass, NodalMassDensity,
sofa::BaseLink::FLAG_STOREPATH | sofa::BaseLink::FLAG_STRONGLINK> l_nodalMassDensity;

/**
Expand Down Expand Up @@ -211,7 +193,7 @@ class ElementFEMMass :
/**
* @brief Default constructor.
*/
ElementFEMMass();
FEMMass();

/**
* @brief Performs the internal calculation and assembly of the mass matrix.
Expand Down Expand Up @@ -267,17 +249,17 @@ class ElementFEMMass :
GlobalMassMatrixType m_globalMassMatrix;
};

#if !defined(SOFA_COMPONENT_MASS_ELEMENTFEMMASS_CPP)
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec1Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Triangle>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Quad>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Quad>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron>;
template class SOFA_COMPONENT_MASS_API ElementFEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Prism>;
#if !defined(SOFA_COMPONENT_MASS_FEMMASS_CPP)
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec1Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Edge>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Triangle>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Triangle>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec2Types, sofa::geometry::Quad>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Quad>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Tetrahedron>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Hexahedron>;
template class SOFA_COMPONENT_MASS_API FEMMass<sofa::defaulttype::Vec3Types, sofa::geometry::Prism>;
#endif

} // namespace sofa::component::mass
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <sofa/component/mass/ElementFEMMass.h>
#include <sofa/component/mass/FEMMass.h>
#include <sofa/core/behavior/BaseLocalMassMatrix.h>
#include <sofa/helper/IotaView.h>
#include <sofa/helper/ScopedAdvancedTimer.h>
Expand All @@ -29,14 +29,14 @@ namespace sofa::component::mass
{

template <class TDataTypes, class TElementType>
ElementFEMMass<TDataTypes, TElementType>::ElementFEMMass()
FEMMass<TDataTypes, TElementType>::FEMMass()
: l_nodalMassDensity(initLink("nodalMassDensity", "Link to nodal mass density"))
{
}


template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::init()
void FEMMass<TDataTypes, TElementType>::init()
{
TopologyAccessor::init();

Expand All @@ -57,7 +57,7 @@ void ElementFEMMass<TDataTypes, TElementType>::init()
}

template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::validateNodalMassDensity()
void FEMMass<TDataTypes, TElementType>::validateNodalMassDensity()
{
if (l_nodalMassDensity.empty())
{
Expand All @@ -76,7 +76,7 @@ void ElementFEMMass<TDataTypes, TElementType>::validateNodalMassDensity()


template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::elementFEMMass_init()
void FEMMass<TDataTypes, TElementType>::elementFEMMass_init()
{
const auto& elements = FiniteElement::getElementSequence(*this->l_topology);
sofa::type::vector<ElementMassMatrix> elementMassMatrices;
Expand All @@ -89,7 +89,7 @@ void ElementFEMMass<TDataTypes, TElementType>::elementFEMMass_init()
}

template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::calculateElementMassMatrix(
void FEMMass<TDataTypes, TElementType>::calculateElementMassMatrix(
const auto& elements, sofa::type::vector<ElementMassMatrix> &elementMassMatrices)
{
const auto nbElements = elements.size();
Expand Down Expand Up @@ -149,7 +149,7 @@ void ElementFEMMass<TDataTypes, TElementType>::calculateElementMassMatrix(
}

template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::initializeGlobalMassMatrix(
void FEMMass<TDataTypes, TElementType>::initializeGlobalMassMatrix(
const auto& elements, const sofa::type::vector<ElementMassMatrix>& elementMassMatrices)
{
SCOPED_TIMER("elementMassMatrix");
Expand Down Expand Up @@ -183,7 +183,7 @@ void ElementFEMMass<TDataTypes, TElementType>::initializeGlobalMassMatrix(
}

template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::addForce(const core::MechanicalParams* mparams,
void FEMMass<TDataTypes, TElementType>::addForce(const core::MechanicalParams* mparams,
sofa::DataVecDeriv_t<DataTypes>& f,
const sofa::DataVecCoord_t<DataTypes>& x,
const sofa::DataVecDeriv_t<DataTypes>& v)
Expand Down Expand Up @@ -213,7 +213,7 @@ void ElementFEMMass<TDataTypes, TElementType>::addForce(const core::MechanicalPa
}

template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::buildMassMatrix(
void FEMMass<TDataTypes, TElementType>::buildMassMatrix(
sofa::core::behavior::MassMatrixAccumulator* matrices)
{
for (std::size_t xi = 0; xi < m_globalMassMatrix.rowIndex.size(); ++xi)
Expand All @@ -234,7 +234,7 @@ void ElementFEMMass<TDataTypes, TElementType>::buildMassMatrix(
}

template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::addMDx(const core::MechanicalParams* mparams,
void FEMMass<TDataTypes, TElementType>::addMDx(const core::MechanicalParams* mparams,
DataVecDeriv_t<DataTypes>& f,
const DataVecDeriv_t<DataTypes>& dx,
SReal factor)
Expand All @@ -259,7 +259,7 @@ void ElementFEMMass<TDataTypes, TElementType>::addMDx(const core::MechanicalPara
}

template <class TDataTypes, class TElementType>
void ElementFEMMass<TDataTypes, TElementType>::accFromF(const core::MechanicalParams* mparams,
void FEMMass<TDataTypes, TElementType>::accFromF(const core::MechanicalParams* mparams,
DataVecDeriv_t<DataTypes>& a,
const DataVecDeriv_t<DataTypes>& f)
{
Expand All @@ -271,7 +271,7 @@ void ElementFEMMass<TDataTypes, TElementType>::accFromF(const core::MechanicalPa
}

template <class TDataTypes, class TElementType>
SReal ElementFEMMass<TDataTypes, TElementType>::getKineticEnergy(
SReal FEMMass<TDataTypes, TElementType>::getKineticEnergy(
const core::MechanicalParams* mparams,
const DataVecDeriv_t<DataTypes>& v) const
{
Expand All @@ -297,7 +297,7 @@ SReal ElementFEMMass<TDataTypes, TElementType>::getKineticEnergy(
}

template <class TDataTypes, class TElementType>
SReal ElementFEMMass<TDataTypes, TElementType>::getPotentialEnergy(
SReal FEMMass<TDataTypes, TElementType>::getPotentialEnergy(
const core::MechanicalParams* mparams,
const DataVecCoord_t<DataTypes>& x) const
{
Expand Down
Loading
Loading