From fe8aacbe63694d34a2e997ae82f39f19962f747c Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Fri, 3 Jul 2026 13:18:40 +0900 Subject: [PATCH 1/2] add instanciations and registration for nodalmass density (explicit double and float) --- .../Mass/src/sofa/component/mass/NodalMassDensity.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sofa/Component/Mass/src/sofa/component/mass/NodalMassDensity.cpp b/Sofa/Component/Mass/src/sofa/component/mass/NodalMassDensity.cpp index cb5f531971c..5697e159e75 100644 --- a/Sofa/Component/Mass/src/sofa/component/mass/NodalMassDensity.cpp +++ b/Sofa/Component/Mass/src/sofa/component/mass/NodalMassDensity.cpp @@ -25,12 +25,14 @@ namespace sofa::component::mass { -template class SOFA_COMPONENT_MASS_API NodalMassDensity; +template class SOFA_COMPONENT_MASS_API NodalMassDensity; +template class SOFA_COMPONENT_MASS_API NodalMassDensity; void registerNodalMassDensity(sofa::core::ObjectFactory* factory) { factory->registerObjects(core::ObjectRegistrationData("Definition of a nodal mass density (one value per dof).") - .add< NodalMassDensity >() + .add< NodalMassDensity >() + .add< NodalMassDensity >() ); } From 1d175db32ef0f7416f70c7b304265a783582ab9f Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Fri, 3 Jul 2026 13:45:47 +0900 Subject: [PATCH 2/2] SofaCUDA: add instanciations and registrations for FEMMass --- .../plugins/SofaCUDA/Component/CMakeLists.txt | 4 +- .../Component/src/SofaCUDA/component/init.cpp | 2 + .../SofaCUDA/component/mass/CudaFEMMass.cpp | 85 +++++++++++++++++++ .../src/SofaCUDA/component/mass/CudaFEMMass.h | 52 ++++++++++++ 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/mass/CudaFEMMass.cpp create mode 100644 applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/mass/CudaFEMMass.h diff --git a/applications/plugins/SofaCUDA/Component/CMakeLists.txt b/applications/plugins/SofaCUDA/Component/CMakeLists.txt index effab0275a9..e30a18bc29d 100644 --- a/applications/plugins/SofaCUDA/Component/CMakeLists.txt +++ b/applications/plugins/SofaCUDA/Component/CMakeLists.txt @@ -36,7 +36,8 @@ set(HEADER_FILES ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/mass/CudaMeshMatrixMass.inl ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/mass/CudaUniformMass.h ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/mass/CudaUniformMass.inl - + ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/mass/CudaFEMMass.h + ### solidmechanics ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/solidmechanics/fem/elastic/CudaFEMKernelUtils.cuh @@ -114,6 +115,7 @@ set(SOURCE_FILES ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/mass/CudaDiagonalMass.cpp ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/mass/CudaMeshMatrixMass.cpp ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/mass/CudaUniformMass.cpp + ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/mass/CudaFEMMass.cpp ### Solidmechanics ${SOFACUDA_COMPONENT_SOURCE_DIR}/SofaCUDA/component/solidmechanics/fem/elastic/CudaCorotationalFEMForceField.cpp diff --git a/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/init.cpp b/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/init.cpp index 968cd603fb6..794b720ae7f 100644 --- a/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/init.cpp +++ b/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/init.cpp @@ -81,6 +81,7 @@ extern void registerRigidMapping(sofa::core::ObjectFactory* factory); extern void registerDiagonalMass(sofa::core::ObjectFactory* factory); extern void registerMeshMatrixMass(sofa::core::ObjectFactory* factory); extern void registerUniformMass(sofa::core::ObjectFactory* factory); +extern void registerFEMMass(sofa::core::ObjectFactory* factory); // component::mechanicalload extern void registerConstantForceField(sofa::core::ObjectFactory* factory); @@ -221,6 +222,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) registerDiagonalMass(factory); registerMeshMatrixMass(factory); registerUniformMass(factory); + registerFEMMass(factory); registerConstantForceField(factory); registerEllipsoidForceField(factory); registerLinearForceField(factory); diff --git a/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/mass/CudaFEMMass.cpp b/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/mass/CudaFEMMass.cpp new file mode 100644 index 00000000000..71487b3f72d --- /dev/null +++ b/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/mass/CudaFEMMass.cpp @@ -0,0 +1,85 @@ +/****************************************************************************** +* 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 . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#define SOFA_GPU_CUDA_CUDAFEMMASS_CPP + +#include + +#include +#include +#include +#include +#include +#include + +namespace sofa::component::mass +{ + +using namespace sofa::gpu::cuda; + +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; + +#ifdef SOFA_GPU_CUDA_DOUBLE +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +template class SOFACUDA_COMPONENT_API FEMMass; +#endif + +} // namespace sofa::component::mass + +namespace sofa::gpu::cuda +{ + +void registerFEMMass(sofa::core::ObjectFactory* factory) +{ + using namespace sofa::component::mass; + + factory->registerObjects(sofa::core::ObjectRegistrationData("Supports GPU-side computations using CUDA for FEMMass") + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() +#ifdef SOFA_GPU_CUDA_DOUBLE + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() + .add< FEMMass >() +#endif + ); +} + +} // namespace sofa::gpu::cuda diff --git a/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/mass/CudaFEMMass.h b/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/mass/CudaFEMMass.h new file mode 100644 index 00000000000..bb847a6f167 --- /dev/null +++ b/applications/plugins/SofaCUDA/Component/src/SofaCUDA/component/mass/CudaFEMMass.h @@ -0,0 +1,52 @@ +/****************************************************************************** +* 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 . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#pragma once + +#include + +#include +#include + +namespace sofa::component::mass +{ + +#ifndef SOFA_GPU_CUDA_CUDAFEMMASS_CPP +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; + +#ifdef SOFA_GPU_CUDA_DOUBLE +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +extern template class SOFACUDA_COMPONENT_API FEMMass; +#endif +#endif + +} // namespace sofa::component::mass