From b62e90e6a986fa3ac1557dc79b5d84a8c9b07de7 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 9 Oct 2026 10:20:40 +0200 Subject: [PATCH] [Simulation] Introduce `MappingGraphUser` class --- Sofa/framework/Simulation/Core/CMakeLists.txt | 2 + .../ImplicitIntegrationScheme.cpp | 4 +- .../ImplicitIntegrationScheme.h | 6 +-- .../mappinggraph/MappingGraphUser.cpp | 8 ++++ .../mappinggraph/MappingGraphUser.h | 41 +++++++++++++++++++ 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 Sofa/framework/Simulation/Core/src/sofa/simulation/mappinggraph/MappingGraphUser.cpp create mode 100644 Sofa/framework/Simulation/Core/src/sofa/simulation/mappinggraph/MappingGraphUser.h diff --git a/Sofa/framework/Simulation/Core/CMakeLists.txt b/Sofa/framework/Simulation/Core/CMakeLists.txt index de999627a2f..b6b136c30f2 100644 --- a/Sofa/framework/Simulation/Core/CMakeLists.txt +++ b/Sofa/framework/Simulation/Core/CMakeLists.txt @@ -90,6 +90,7 @@ set(HEADER_FILES ${SRC_ROOT}/mappinggraph/MappingGraphNode.h ${SRC_ROOT}/mappinggraph/MappingGraphVisitor.h ${SRC_ROOT}/mappinggraph/VisitorApplication.h + ${SRC_ROOT}/mappinggraph/MappingGraphUser.h ${SRC_ROOT}/mechanicalvisitor/MechanicalAccFromFVisitor.h ${SRC_ROOT}/mechanicalvisitor/MechanicalAccumulateJacobian.h @@ -243,6 +244,7 @@ set(SOURCE_FILES ${SRC_ROOT}/mappinggraph/ExportDot.cpp ${SRC_ROOT}/mappinggraph/MappingGraphAlgorithms.cpp ${SRC_ROOT}/mappinggraph/MappingGraphVisitor.cpp + ${SRC_ROOT}/mappinggraph/MappingGraphUser.cpp ${SRC_ROOT}/mechanicalvisitor/MechanicalAccFromFVisitor.cpp ${SRC_ROOT}/mechanicalvisitor/MechanicalAccumulateJacobian.cpp diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/integrationscheme/ImplicitIntegrationScheme.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/integrationscheme/ImplicitIntegrationScheme.cpp index 4727a8ebad0..a9e9d947530 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/integrationscheme/ImplicitIntegrationScheme.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/integrationscheme/ImplicitIntegrationScheme.cpp @@ -54,7 +54,7 @@ void ImplicitIntegrationScheme::setupIntegrationStep(const core::ExecParams* par m_xResult = xResult; m_vResult = vResult; - m_mappingGraph.build(this->getContext()); + this->m_mappingGraph.build(this->getContext()); // dx is no longer allocated by default (but it will be deleted automatically by the mechanical objects) @@ -76,4 +76,4 @@ void ImplicitIntegrationScheme::integrate(const core::ExecParams* params, SReal finalizeIntegrationStep(); } -} \ No newline at end of file +} diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/integrationscheme/ImplicitIntegrationScheme.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/integrationscheme/ImplicitIntegrationScheme.h index 6e05453aea3..31926e5646c 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/integrationscheme/ImplicitIntegrationScheme.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/integrationscheme/ImplicitIntegrationScheme.h @@ -29,6 +29,7 @@ #include #include #include +#include namespace sofa::simulation::common { @@ -41,7 +42,8 @@ namespace sofa::simulation::integrationscheme class SOFA_SIMULATION_CORE_API ImplicitIntegrationScheme : public sofa::core::behavior::BaseIntegrationScheme, - public sofa::core::behavior::LinearSolverAccessor + public sofa::core::behavior::LinearSolverAccessor, + public sofa::simulation::MappingGraphUser { public: SOFA_ABSTRACT_CLASS2(ImplicitIntegrationScheme, sofa::core::behavior::BaseIntegrationScheme, sofa::core::behavior::LinearSolverAccessor); @@ -161,8 +163,6 @@ class SOFA_SIMULATION_CORE_API ImplicitIntegrationScheme : std::shared_ptr m_vop; std::unique_ptr m_mop; - - sofa::simulation::MappingGraph m_mappingGraph; }; } // namespace sofa::component::integrationscheme diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/mappinggraph/MappingGraphUser.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/mappinggraph/MappingGraphUser.cpp new file mode 100644 index 00000000000..d771270bd29 --- /dev/null +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/mappinggraph/MappingGraphUser.cpp @@ -0,0 +1,8 @@ +#include + +namespace sofa::simulation +{ + +const MappingGraph& MappingGraphUser::getMappingGraph() const { return m_mappingGraph; } + +} // namespace sofa::simulation diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/mappinggraph/MappingGraphUser.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/mappinggraph/MappingGraphUser.h new file mode 100644 index 00000000000..18e3caf932d --- /dev/null +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/mappinggraph/MappingGraphUser.h @@ -0,0 +1,41 @@ +/****************************************************************************** +* 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 + +namespace sofa::simulation +{ + +class SOFA_SIMULATION_CORE_API MappingGraphUser : virtual public sofa::core::Base +{ +public: + + const MappingGraph& getMappingGraph() const; + +protected: + + MappingGraph m_mappingGraph; +}; + +}