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
7 changes: 7 additions & 0 deletions Sofa/Component/Mass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ set(HEADER_FILES
${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}/MassType.h
${SOFACOMPONENTMASS_SOURCE_DIR}/MeshMatrixMass.h
${SOFACOMPONENTMASS_SOURCE_DIR}/MeshMatrixMass.inl
${SOFACOMPONENTMASS_SOURCE_DIR}/NodalMassDensity.h
${SOFACOMPONENTMASS_SOURCE_DIR}/RigidMassType.h
${SOFACOMPONENTMASS_SOURCE_DIR}/UniformMass.h
${SOFACOMPONENTMASS_SOURCE_DIR}/UniformMass.inl
Expand All @@ -21,14 +24,18 @@ set(HEADER_FILES
set(SOURCE_FILES
${SOFACOMPONENTMASS_SOURCE_DIR}/init.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/DiagonalMass.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/ElementFEMMass.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/MeshMatrixMass.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/NodalMassDensity.cpp
${SOFACOMPONENTMASS_SOURCE_DIR}/UniformMass.cpp
)

sofa_find_package(Sofa.FEM REQUIRED)
sofa_find_package(Sofa.Simulation.Core REQUIRED)
sofa_find_package(Sofa.Component.Topology.Container.Dynamic REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.FEM)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Topology.Container.Dynamic)

Expand Down
1 change: 1 addition & 0 deletions Sofa/Component/Mass/Sofa.Component.MassConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@PACKAGE_INIT@

find_package(Sofa.Config QUIET REQUIRED)
sofa_find_package(Sofa.FEM QUIET REQUIRED)
sofa_find_package(Sofa.Simulation.Core QUIET REQUIRED)
sofa_find_package(Sofa.Component.Topology.Container.Dynamic QUIET REQUIRED)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct Mass_test : public sofa::testing::BaseSimulationTest, public sofa::testin

// v * Mv should be the 2 * kinetic energy
EXPECT_LT(std::abs(vMv - 2 * ke), (SReal)(m_errorMax * this->epsilon()))
<< "Kinetic energy inconsistent with addMDx";
<< "Kinetic energy inconsistent with addMDx (vMv = " << vMv << ", kinetic energy = " << (Real)ke << ")";
}
/**
* @brief Given positions and velocities, checks mass methods.
Expand Down
64 changes: 64 additions & 0 deletions Sofa/Component/Mass/src/sofa/component/mass/ElementFEMMass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/******************************************************************************
* 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_ELEMENTFEMMASS_CPP
#include <sofa/component/mass/ElementFEMMass.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 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>;

void registerFEMMass(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Finite-element mass (inertia and body force) defined on edges")
.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::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::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));

}

}
Loading
Loading