From b98b7cc4b4f21adaaee4bd52a2519a89cfdfd18f Mon Sep 17 00:00:00 2001 From: Frederick ROY Date: Wed, 27 Nov 2024 14:59:13 +0100 Subject: [PATCH 1/8] refresh for latest sofa --- CMakeLists.txt | 8 ++--- src/SofaCaribou/CMakeLists.txt | 4 +-- .../Ode/BackwardEulerODESolver.cpp | 2 +- src/SofaCaribou/Ode/StaticODESolver.cpp | 2 +- src/SofaCaribou/Topology/FictitiousGrid.h | 2 +- unittest/SofaCaribou/CMakeLists.txt | 10 ++++-- .../test_hyperelasticforcefield.cpp | 7 ++--- .../Forcefield/test_tractionforce.cpp | 14 ++++----- .../SofaCaribou/Mass/test_cariboumass.cpp | 8 ++--- .../SofaCaribou/ODE/test_backward_euler.cpp | 9 +++--- unittest/SofaCaribou/ODE/test_static.cpp | 31 ++++++++----------- .../Topology/test_fictitiousgrid.cpp | 8 ++--- 12 files changed, 48 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9eb2b5d2..d5854a2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,8 @@ CMAKE_DEPENDENT_OPTION(CARIBOU_OPTIMIZE_FOR_NATIVE "Build with -march=native to # SOFA option find_package(Threads QUIET) -find_package(SOFA COMPONENTS SofaFramework QUIET) -CMAKE_DEPENDENT_OPTION(CARIBOU_WITH_SOFA "Compile the SofaCaribou library" ON "SOFA_FOUND" OFF) +find_package(SOFA COMPONENTS Sofa.Config QUIET) +CMAKE_DEPENDENT_OPTION(CARIBOU_WITH_SOFA "Compile the SofaCaribou library" ON "Sofa.Config_FOUND" OFF) if (CARIBOU_WITH_SOFA) list(APPEND CMAKE_PREFIX_PATH ${SOFA_MODULE_DIR}) list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH) @@ -122,10 +122,10 @@ endif() # SOFA Python 3 if (CARIBOU_WITH_SOFA) - get_filename_component(SOFA_ROOT_DIR "${SofaFramework_DIR}/../../.." ABSOLUTE) + get_filename_component(SOFA_ROOT_DIR "${Sofa.Framework_DIR}/../../.." ABSOLUTE) message(STATUS "Caribou with SOFA support\n" - " SOFA version: ${SofaFramework_VERSION}\n" + " SOFA version: ${Sofa.Config_VERSION}\n" " SOFA location: ${SOFA_ROOT_DIR}" ) if (CARIBOU_WITH_PYTHON_3) diff --git a/src/SofaCaribou/CMakeLists.txt b/src/SofaCaribou/CMakeLists.txt index 2e516ada..26160f17 100644 --- a/src/SofaCaribou/CMakeLists.txt +++ b/src/SofaCaribou/CMakeLists.txt @@ -146,7 +146,7 @@ if (NOT TARGET Caribou::Algebra) endif() # Sofa's packages -find_package(SOFA COMPONENTS SofaFramework Sofa.Component.LinearSolver.Iterative Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.LinearAlgebra QUIET REQUIRED) +find_package(SOFA COMPONENTS Sofa.Config Sofa.Component.LinearSolver.Iterative Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.LinearAlgebra QUIET REQUIRED) # Optional packages find_package(Eigen3 QUIET REQUIRED) @@ -159,7 +159,7 @@ endif() add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${TEMPLATE_FILES} ${HEADER_FILES}) add_library(Caribou::Plugin ALIAS ${PROJECT_NAME}) -target_link_libraries(${PROJECT_NAME} PUBLIC SofaCore Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.Component.LinearSolver.Iterative Sofa.LinearAlgebra) +target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Core Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.Component.LinearSolver.Iterative Sofa.LinearAlgebra) target_link_libraries(${PROJECT_NAME} PUBLIC Caribou::Algebra Caribou::Geometry Caribou::Topology Caribou::Mechanics) target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) diff --git a/src/SofaCaribou/Ode/BackwardEulerODESolver.cpp b/src/SofaCaribou/Ode/BackwardEulerODESolver.cpp index 74784133..31c8aa12 100644 --- a/src/SofaCaribou/Ode/BackwardEulerODESolver.cpp +++ b/src/SofaCaribou/Ode/BackwardEulerODESolver.cpp @@ -97,7 +97,7 @@ void BackwardEulerODESolver::assemble_rhs_vector(const MechanicalParams & mec // NOTE: This correspond to the force terms dependant on the displacement, i.e. : // - f_0 = (-Ku + F) MechanicalComputeForceVisitor(&mechanical_parameters, f_id, - true /* accumulate (to mapped node) */, true /*neglectingCompliance*/) + true /* accumulate (to mapped node) */) .execute(this->getContext()); // 3. Go down in the current context tree calling `addMBKdx` on every force field components, diff --git a/src/SofaCaribou/Ode/StaticODESolver.cpp b/src/SofaCaribou/Ode/StaticODESolver.cpp index 3cbf2ee8..cddc1c03 100644 --- a/src/SofaCaribou/Ode/StaticODESolver.cpp +++ b/src/SofaCaribou/Ode/StaticODESolver.cpp @@ -44,7 +44,7 @@ void StaticODESolver::assemble_rhs_vector(const sofa::core::MechanicalParams &me // 2. Go down in the current context tree calling `addForce` on every force field components, // then go up from the leaves calling `applyJT` on every mechanical mappings MechanicalComputeForceVisitor(&mechanical_parameters, f_id, - true /* accumulate (to mapped node) */, true /*neglectingCompliance*/) + true /* accumulate (to mapped node) */) .execute(this->getContext()); // 3. Calls the "projectResponse" method of every `BaseProjectiveConstraintSet` objects found in the current diff --git a/src/SofaCaribou/Topology/FictitiousGrid.h b/src/SofaCaribou/Topology/FictitiousGrid.h index e5919fd1..6cff76af 100644 --- a/src/SofaCaribou/Topology/FictitiousGrid.h +++ b/src/SofaCaribou/Topology/FictitiousGrid.h @@ -273,7 +273,7 @@ class FictitiousGrid : public virtual BaseObject this->f_bbox.setValue(sofa::type::TBoundingBox(min, max)); } else { this->f_bbox.setValue(sofa::type::TBoundingBox( - d_min.getValue().array(),d_max.getValue().array())); + d_min.getValue().data() ,d_max.getValue().data())); } } diff --git a/unittest/SofaCaribou/CMakeLists.txt b/unittest/SofaCaribou/CMakeLists.txt index 0ab493de..bd402e5f 100644 --- a/unittest/SofaCaribou/CMakeLists.txt +++ b/unittest/SofaCaribou/CMakeLists.txt @@ -15,7 +15,10 @@ set(SOURCE_FILES enable_testing() -find_package(SOFA COMPONENTS SofaFramework Sofa.Simulation.Graph Sofa.Component.StateContainer Sofa.Component.Mass Sofa.Component.SceneUtility Sofa.Component.LinearSolver.Iterative Sofa.Component.Mass Sofa.Component.SolidMechanics.FEM.Elastic QUIET REQUIRED) +find_package(Sofa.Config REQUIRED) +find_package(Sofa.Component REQUIRED) +find_package(Sofa.Testing REQUIRED) +find_package(Sofa.SimpleApi REQUIRED) find_package(Caribou COMPONENTS Topology REQUIRED) find_package(Threads REQUIRED) @@ -31,11 +34,12 @@ endif() target_link_libraries(${PROJECT_NAME} PUBLIC gtest) target_link_libraries(${PROJECT_NAME} PUBLIC SofaCaribou) -target_link_libraries(${PROJECT_NAME} PUBLIC SofaHelper Sofa.Component.StateContainer Sofa.Component.Mass Sofa.Component.SceneUtility Sofa.Component.LinearSolver.Iterative Sofa.Component.SolidMechanics.FEM.Elastic) +target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Helper Sofa.Component.StateContainer Sofa.Component.Mass Sofa.Component.SceneUtility Sofa.Component.LinearSolver.Iterative Sofa.Component.SolidMechanics.FEM.Elastic ) +target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Testing Sofa.SimpleApi) target_link_libraries(${PROJECT_NAME} PUBLIC $<$,$,8.0>>:stdc++fs> $<$,$,9.0>>:c++fs>) -if (${SofaFramework_VERSION} VERSION_LESS "22.06.99") +if (${Sofa.Config_VERSION} VERSION_LESS "22.06.99") target_link_libraries(${PROJECT_NAME} PUBLIC SofaSimulationGraph) else() target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Graph) diff --git a/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp b/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp index 525b6149..f88bd77a 100644 --- a/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp +++ b/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp @@ -5,7 +5,7 @@ DISABLE_ALL_WARNINGS_BEGIN #include #include #include -#include +#include #include DISABLE_ALL_WARNINGS_END @@ -22,7 +22,6 @@ TEST(HyperelasticForcefield, Hexahedron_from_SOFA) { MessageDispatcher::addHandler( MainGtestMessageHandler::getInstance() ) ; EXPECT_MSG_NOEMIT(Error); - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "DefaultAnimationLoop"); createObject(root, "DefaultVisualManagerLoop"); @@ -55,7 +54,7 @@ TEST(HyperelasticForcefield, Hexahedron_from_SOFA) { createObject(meca, "QuadSetTopologyContainer", {{"name", "traction_container"}, {"quads", "@top_roi.quadInROI"}}); createObject(meca, "TractionForcefield", {{"traction", "0 -30 0"}, {"slope", "0.2"}, {"topology", "@traction_container"}}); - getSimulation()->init(root.get()); + sofa::simulation::node::init(root.get()); EXPECT_EQ(ff->number_of_elements(), 32); -} \ No newline at end of file +} diff --git a/unittest/SofaCaribou/Forcefield/test_tractionforce.cpp b/unittest/SofaCaribou/Forcefield/test_tractionforce.cpp index d008793b..39aa0807 100644 --- a/unittest/SofaCaribou/Forcefield/test_tractionforce.cpp +++ b/unittest/SofaCaribou/Forcefield/test_tractionforce.cpp @@ -6,7 +6,7 @@ DISABLE_ALL_WARNINGS_BEGIN #include #include #include -#include +#include #include DISABLE_ALL_WARNINGS_END @@ -19,12 +19,10 @@ using namespace sofa::testing; class TractionForcefield : public BaseTest { void SetUp() override { - setSimulation(new sofa::simulation::graph::DAGSimulation()) ; root = getSimulation()->createNewNode("TractionForce"); } void TearDown() override { root.reset(); - setSimulation(nullptr); } protected: @@ -43,10 +41,10 @@ TEST_F(TractionForcefield, Triangle) { EXPECT_NE(traction, nullptr); - getSimulation()->init(root.get()); + sofa::simulation::node::init(root.get()); auto total_load = dynamic_cast *>(traction->findData("total_load")); for (unsigned int step = 1; step <= 5; ++step) { - getSimulation()->animate(root.get(), 1); + sofa::simulation::node::animate(root.get(), 1); EXPECT_DOUBLE_EQ(total_load->getValue(), 4*step) << "Total load at time step " << step << " is incorrect."; } } @@ -59,10 +57,10 @@ TEST_F(TractionForcefield, Quad) { createObject(root, "QuadSetTopologyContainer", {{"quads", "8 7 3 5 6 8 5 2 0 4 8 6 4 1 7 8"}}); auto traction = createObject(root, "TractionForcefield", {{"traction", "0 5 0"}, {"slope", std::to_string(1/5.)}}); - getSimulation()->init(root.get()); + sofa::simulation::node::init(root.get()); auto total_load = dynamic_cast *>(traction->findData("total_load")); for (unsigned int step = 1; step <= 5; ++step) { - getSimulation()->animate(root.get(), 1); + sofa::simulation::node::animate(root.get(), 1); EXPECT_DOUBLE_EQ(total_load->getValue(), 4*step) << "Total load at time step " << step << " is incorrect."; } -} \ No newline at end of file +} diff --git a/unittest/SofaCaribou/Mass/test_cariboumass.cpp b/unittest/SofaCaribou/Mass/test_cariboumass.cpp index 2c11b0bc..8ea78318 100644 --- a/unittest/SofaCaribou/Mass/test_cariboumass.cpp +++ b/unittest/SofaCaribou/Mass/test_cariboumass.cpp @@ -6,7 +6,7 @@ DISABLE_ALL_WARNINGS_BEGIN #include #include #include -#include +#include #include #include DISABLE_ALL_WARNINGS_END @@ -29,7 +29,6 @@ TEST(CaribouMass, LinearTetrahedron) { MessageDispatcher::addHandler( MainGtestMessageHandler::getInstance() ) ; EXPECT_MSG_NOEMIT(Error); - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Mapping"}}); @@ -57,7 +56,7 @@ TEST(CaribouMass, LinearTetrahedron) { auto sofa_mass_diagonal = dynamic_cast *> ( createObject(root, "MeshMatrixMass", {{"name", "sofa_mass_diagonal"}, {"topology", "@topology"}, {"massDensity", "2"}, {"lumping", "true"}}).get() ); - getSimulation()->init(root.get()); + sofa::simulation::node::init(root.get()); // Get M from caribou const Eigen::SparseMatrix M = caribou_mass->M(); @@ -137,7 +136,6 @@ TEST(CaribouMass, LinearHexahedron) { MessageDispatcher::addHandler( MainGtestMessageHandler::getInstance() ) ; EXPECT_MSG_NOEMIT(Error); - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Mapping"}}); @@ -161,7 +159,7 @@ TEST(CaribouMass, LinearHexahedron) { createObject(root, "MeshMatrixMass", {{"name", "sofa_mass"}, {"topology", "@topology"}, {"massDensity", "2"}}).get() ); - getSimulation()->init(root.get()); + sofa::simulation::node::init(root.get()); // Get M from caribou const Eigen::SparseMatrix M = caribou_mass->M(); diff --git a/unittest/SofaCaribou/ODE/test_backward_euler.cpp b/unittest/SofaCaribou/ODE/test_backward_euler.cpp index 5cfbf249..d3ad95dc 100644 --- a/unittest/SofaCaribou/ODE/test_backward_euler.cpp +++ b/unittest/SofaCaribou/ODE/test_backward_euler.cpp @@ -7,7 +7,7 @@ DISABLE_ALL_WARNINGS_BEGIN #include #include #include -#include +#include #include DISABLE_ALL_WARNINGS_END @@ -21,7 +21,6 @@ TEST(BackwardEulerODESolver, Beam) { MessageDispatcher::addHandler( MainGtestMessageHandler::getInstance() ) ; EXPECT_MSG_NOEMIT(Error); - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Constraint.Projective"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); @@ -124,10 +123,10 @@ TEST(BackwardEulerODESolver, Beam) { {1.647607571061131E-15, -2.710271984455126E+01, 7.464181417401340E+01} }}; - getSimulation()->init(root.get()); + sofa::simulation::node::init(root.get()); for (unsigned int step_id = 0; step_id < force_residuals.size(); ++step_id) { - getSimulation()->animate(root.get(), 1); + sofa::simulation::node::animate(root.get(), 1); // @todo uncomment the following when we have time to debug why fenics converges faster... // EXPECT_EQ(solver->squared_residuals().size(), force_residuals[step_id].size()) << "Time step # "<< step_id; @@ -151,5 +150,5 @@ TEST(BackwardEulerODESolver, Beam) { EXPECT_LE(rel_err, 0.005); } - getSimulation()->unload(root); + sofa::simulation::node::unload(root); } diff --git a/unittest/SofaCaribou/ODE/test_static.cpp b/unittest/SofaCaribou/ODE/test_static.cpp index c05499cc..1523f3f1 100644 --- a/unittest/SofaCaribou/ODE/test_static.cpp +++ b/unittest/SofaCaribou/ODE/test_static.cpp @@ -7,7 +7,7 @@ DISABLE_ALL_WARNINGS_BEGIN #include #include #include -#include +#include #include DISABLE_ALL_WARNINGS_END @@ -21,13 +21,12 @@ TEST(StaticODESolver, InitWithoutSolver) { MessageDispatcher::addHandler( MainGtestMessageHandler::getInstance() ) ; EXPECT_MSG_EMIT(Error) ; - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "DefaultAnimationLoop"); createObject(root, "DefaultVisualManagerLoop"); createObject(root, "StaticODESolver", {{"printLog", "true"}}); - getSimulation()->init(root.get()); - getSimulation()->unload(root); + sofa::simulation::node::init(root.get()); + sofa::simulation::node::unload(root); } /** Initialization without any compatible linear solver (expecting an error) */ @@ -35,7 +34,6 @@ TEST(StaticODESolver, InitSofaSolver) { MessageDispatcher::addHandler( MainGtestMessageHandler::getInstance() ) ; EXPECT_MSG_EMIT(Error) ; - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.LinearSolver.Iterative"}}); createObject(root, "DefaultAnimationLoop"); @@ -43,8 +41,8 @@ TEST(StaticODESolver, InitSofaSolver) { createObject(root, "StaticODESolver", {{"printLog", "true"}}); createObject(root, "CGLinearSolver", {{"iterations", "25"}, {"tolerance", "1e-05"}, {"threshold", "1e-05"}}); createObject(root, "CGLinearSolver", {{"iterations", "25"}, {"tolerance", "1e-05"}, {"threshold", "1e-05"}}); - getSimulation()->init(root.get()); - getSimulation()->unload(root); + sofa::simulation::node::init(root.get()); + sofa::simulation::node::unload(root); } /** Initialization with both a Caribou linear solver and a SOFA solver (should inform the user of the choice made) */ @@ -53,7 +51,6 @@ TEST(StaticODESolver, InitCaribouSolver) { EXPECT_MSG_NOEMIT(Warning, Error); EXPECT_MSG_EMIT(Info) ; - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.LinearSolver.Iterative"}}); createObject(root, "DefaultAnimationLoop"); @@ -61,8 +58,8 @@ TEST(StaticODESolver, InitCaribouSolver) { createObject(root, "StaticODESolver", {{"printLog", "true"}}); createObject(root, "CGLinearSolver", {{"iterations", "25"}, {"tolerance", "1e-05"}, {"threshold", "1e-05"}}); createObject(root, "LDLTSolver"); - getSimulation()->init(root.get()); - getSimulation()->unload(root); + sofa::simulation::node::init(root.get()); + sofa::simulation::node::unload(root); } /** Initialization with two Caribou linear solvers (should warn the user of the choice made) */ @@ -71,15 +68,14 @@ TEST(StaticODESolver, InitMultipleCaribouSolver) { EXPECT_MSG_NOEMIT(Info, Error); EXPECT_MSG_EMIT(Warning); - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "DefaultAnimationLoop"); createObject(root, "DefaultVisualManagerLoop"); createObject(root, "StaticODESolver", {{"printLog", "true"}}); createObject(root, "LDLTSolver", {{"name", "first_solver"}}); createObject(root, "LDLTSolver", {{"name", "second_solver"}}); - getSimulation()->init(root.get()); - getSimulation()->unload(root); + sofa::simulation::node::init(root.get()); + sofa::simulation::node::unload(root); } /** Make sure residual norms at each newton steps remains the same */ @@ -87,7 +83,6 @@ TEST(StaticODESolver, Beam) { MessageDispatcher::addHandler( MainGtestMessageHandler::getInstance() ) ; EXPECT_MSG_NOEMIT(Error); - setSimulation(new sofa::simulation::graph::DAGSimulation()); auto root = getSimulation()->createNewNode("root"); createObject(root, "DefaultAnimationLoop"); createObject(root, "DefaultVisualManagerLoop"); @@ -130,10 +125,10 @@ TEST(StaticODESolver, Beam) { {1.000000000000000e+00, 3.526942203674829e-03, 8.307813177405512e-04, 4.667215114394798e-05, 1.646730071539153e-07} // Step 5 }}; - getSimulation()->init(root.get()); + sofa::simulation::node::init(root.get()); for (unsigned int step_id = 0; step_id < force_residuals.size(); ++step_id) { - getSimulation()->animate(root.get(), 1); + sofa::simulation::node::animate(root.get(), 1); EXPECT_EQ(solver->squared_residuals().size(), force_residuals[step_id].size()); for (unsigned int newton_step_id = 0; newton_step_id < solver->squared_residuals().size(); ++newton_step_id) { double residual = solver->squared_residuals()[newton_step_id] / solver->squared_residuals()[0]; @@ -148,5 +143,5 @@ TEST(StaticODESolver, Beam) { EXPECT_NEAR(middle_point[1], -21.016, 1e-3); // y EXPECT_NEAR(middle_point[2], 76.190, 1e-3); // z - getSimulation()->unload(root); -} \ No newline at end of file + sofa::simulation::node::unload(root); +} diff --git a/unittest/SofaCaribou/Topology/test_fictitiousgrid.cpp b/unittest/SofaCaribou/Topology/test_fictitiousgrid.cpp index 0585e12d..aa535d19 100644 --- a/unittest/SofaCaribou/Topology/test_fictitiousgrid.cpp +++ b/unittest/SofaCaribou/Topology/test_fictitiousgrid.cpp @@ -5,7 +5,7 @@ DISABLE_ALL_WARNINGS_BEGIN #include #include #include -#include +#include #include DISABLE_ALL_WARNINGS_END @@ -18,7 +18,6 @@ using namespace sofa::testing; class FictitiousGrid : public BaseTest { void SetUp() override { - setSimulation(new sofa::simulation::graph::DAGSimulation()) ; root = getSimulation()->createNewNode("root"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.IO.Mesh"}}); createObject(root, "DefaultAnimationLoop"); @@ -26,7 +25,6 @@ class FictitiousGrid : public BaseTest { } void TearDown() override { root.reset(); - setSimulation(nullptr); } protected: @@ -44,7 +42,7 @@ TEST_F(FictitiousGrid, Liver) { {"surface_triangles", "@./loader.triangles"} }).get()); - getSimulation()->init(root.get()); + sofa::simulation::node::init(root.get()); // Get the volume FLOATING_POINT_TYPE volume = 0.; @@ -56,4 +54,4 @@ TEST_F(FictitiousGrid, Liver) { } EXPECT_NEAR(volume, 3414171, 5); -} \ No newline at end of file +} From a51576cb0fbaa17560270792dcec070b704ddf41 Mon Sep 17 00:00:00 2001 From: Frederick ROY Date: Thu, 28 Nov 2024 10:24:01 +0100 Subject: [PATCH 2/8] fix unit test compilation --- unittest/SofaCaribou/Mass/test_cariboumass.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unittest/SofaCaribou/Mass/test_cariboumass.cpp b/unittest/SofaCaribou/Mass/test_cariboumass.cpp index 8ea78318..bbb08a1f 100644 --- a/unittest/SofaCaribou/Mass/test_cariboumass.cpp +++ b/unittest/SofaCaribou/Mass/test_cariboumass.cpp @@ -71,7 +71,7 @@ TEST(CaribouMass, LinearTetrahedron) { accessor.setupMatrices(); sofa::core::MechanicalParams mechanical_parameters; mechanical_parameters.setMFactor(1); - caribou_mass->addMToMatrix(&mechanical_parameters, &accessor); + caribou_mass->Mass::addMToMatrix(&mechanical_parameters, &accessor); M2.compress(); EXPECT_DOUBLE_EQ(M.sum(), M2.matrix().sum()); @@ -90,7 +90,7 @@ TEST(CaribouMass, LinearTetrahedron) { SofaCaribou::Algebra::EigenMatrix> SofaM; SofaM.resize((signed) mo->getSize()*3, (signed) mo->getSize()*3); accessor.setGlobalMatrix(&SofaM); - sofa_mass->addMToMatrix(&mechanical_parameters, &accessor); + sofa_mass->Mass::addMToMatrix(&mechanical_parameters, &accessor); SofaM.compress(); EXPECT_DOUBLE_EQ(M.sum(), SofaM.matrix().sum()); @@ -99,7 +99,7 @@ TEST(CaribouMass, LinearTetrahedron) { SofaCaribou::Algebra::EigenMatrix> SofaM_diagonal; SofaM_diagonal.resize((signed) mo->getSize()*3, (signed) mo->getSize()*3); accessor.setGlobalMatrix(&SofaM_diagonal); - sofa_mass_diagonal->addMToMatrix(&mechanical_parameters, &accessor); + sofa_mass_diagonal->Mass::addMToMatrix(&mechanical_parameters, &accessor); SofaM_diagonal.compress(); EXPECT_DOUBLE_EQ(M_diag.diagonal().sum(), SofaM_diagonal.matrix().sum()); @@ -173,7 +173,7 @@ TEST(CaribouMass, LinearHexahedron) { accessor.setupMatrices(); sofa::core::MechanicalParams mechanical_parameters; mechanical_parameters.setMFactor(1); - sofa_mass->addMToMatrix(&mechanical_parameters, &accessor); + sofa_mass->Mass::addMToMatrix(&mechanical_parameters, &accessor); SofaM.compress(); EXPECT_DOUBLE_EQ(M.sum(), SofaM.matrix().sum()); From fb11b9f700e9bc1970c6fb3b400888310eda1059 Mon Sep 17 00:00:00 2001 From: Frederick ROY Date: Thu, 28 Nov 2024 11:49:56 +0100 Subject: [PATCH 3/8] Squashed commit of the following: commit f9ca1aed6ec89e4521b74382484ace41d6ffcd2f Author: Jean-Nicolas Brunet Date: Tue Aug 8 09:17:42 2023 -0400 Windows compatibility commit 385403bf1a6ae69ca728c90fa6265954d11c9bd0 Author: Jean-Nicolas Brunet Date: Tue Aug 8 08:55:55 2023 -0400 Windows compatibility commit 6339704fe4f893d98fadedb1a43fe5bc48a3e6cf Author: Jean-Nicolas Brunet Date: Mon Aug 7 21:50:23 2023 -0400 Windows compatibility commit a1ab1d95a4bd7abbb22ebcff695c7a2a25536a53 Author: Jean-Nicolas Brunet Date: Mon Aug 7 20:02:54 2023 -0400 Windows compatibility commit 34dbe28ad82bbb53335d43d702c77aa6cb647a02 Author: Jean-Nicolas Brunet Date: Thu Aug 3 22:15:26 2023 -0400 Windows compatibility commit 8984c380e3571166ae13616865b60a0585a1ffeb Author: Jean-Nicolas Brunet Date: Thu Aug 3 22:02:25 2023 -0400 Windows compatibility commit 90ce4cedffb7cf4a6dac5f9881a8dfab50c82b19 Merge: 15f9b91 2aa665c Author: Jean-Nicolas Brunet Date: Tue Jun 27 19:41:58 2023 -0400 Merge remote-tracking branch 'origin/master' into windows_workflow # Conflicts: # .github/workflows/macos.yml # .github/workflows/ubuntu.yml # src/SofaCaribou/Algebra/EigenMatrix.h # src/SofaCaribou/Algebra/EigenVector.h # unittest/SofaCaribou/Mass/test_cariboumass.cpp commit 15f9b91cfc4af41e5a92eefb845c40c6589938c6 Author: Jean-Nicolas Brunet Date: Wed Jun 22 21:11:33 2022 -0400 temp commit 6d9d0b8ce3e88ed66199787ad87e138d85dff0fc Author: Jean-Nicolas Brunet Date: Fri May 27 22:07:23 2022 -0400 [wip] Windows workflow commit 01ee3db8241288d6e12242fb3002942323fe9d85 Author: Jean-Nicolas Brunet Date: Fri May 27 21:30:24 2022 -0400 [wip] Windows workflow commit c31d85b062e0bf51f6325379fbb43bc408f1a166 Author: Jean-Nicolas Brunet Date: Sat May 7 14:27:22 2022 -0400 [wip] Windows workflow commit 5fbb7043a015edde8b12a8d99b5daed9a55c94bb Author: Jean-Nicolas Brunet Date: Sat May 7 13:47:16 2022 -0400 [wip] Windows workflow commit 1e61133d878697ddde908082f0aaeb49a33230cf Author: Jean-Nicolas Brunet Date: Fri May 6 20:48:42 2022 -0400 [wip] Windows workflow commit c1eaeb7fda492dadbf844360c30d311c0c833499 Author: Jean-Nicolas Brunet Date: Thu May 5 11:41:52 2022 -0400 [wip] Windows workflow commit 6957494d3ee28b967e366cb0f57eb50e838fae10 Author: Jean-Nicolas Brunet Date: Thu Mar 31 10:22:13 2022 -0400 [wip] Windows workflow commit 57deb1d9f40f9f710ecc48b7ff0afcd351494a1c Author: Jean-Nicolas Brunet Date: Sat Sep 18 09:58:16 2021 -0400 [wip] Windows workflow --- .github/workflows/ubuntu.yml | 2 +- .github/workflows/windows.yml | 251 ++++++++++++++++++ CMakeLists.txt | 23 +- cmake/FindSOFA.cmake | 15 +- src/SofaCaribou/Algebra/EigenMatrix.h | 17 +- src/SofaCaribou/CMakeLists.txt | 14 +- unittest/Caribou/Geometry/CMakeLists.txt | 2 + unittest/SofaCaribou/CMakeLists.txt | 6 +- .../test_hyperelasticforcefield.cpp | 1 + 9 files changed, 292 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index fca4b794..3e0cf6ec 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -37,7 +37,7 @@ jobs: git config --global user.email "caribou@github.com" git config --global user.name "Caribou Github" git fetch origin - git rebase origin/master + git merge origin/master - name: Install pybind11 if: ${{ matrix.PYBIND11_VERSION != '2.4' }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..6240fccc --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,251 @@ +name: Windows + +on: + pull_request: + branches: + - master + schedule: + # Runs every day at 23:15 + - cron: '15 23 * * *' + +jobs: + build: + name: Building with ${{ matrix.sofa_version }} + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + sofa_version: [ master ] + include: + - sofa_version: master + PYTHON_VERSION: 3.8 + EIGEN_VERSION: 3.4 + PYBIND11_VERSION: 2.4.3 +# - sofa_version: v21.12.00 +# PYTHON_VERSION: 3.7 +# EIGEN_VERSION: 3.3.7 +# PYBIND11_VERSION: 2.4.3 + env: + SOFA_VERSION: ${{ matrix.sofa_version }} + SOFA_ROOT: ${{ format('{0}/sofa', github.workspace) }} + PYBIND11_ROOT: ${{ format('{0}/pybind11', github.workspace) }} + PYBIND11_VERSION: ${{ matrix.PYBIND11_VERSION }} + QT_ROOT: ${{ format('{0}/qt', github.workspace) }} + PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} + BOOST_ROOT: ${{ format('{0}/boost', github.workspace) }} + EIGEN_ROOT: ${{ format('{0}/eigen', github.workspace) }} + EIGEN_VERSION: ${{ matrix.EIGEN_VERSION }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - run: | + git config --global user.email "caribou@github.com" + git config --global user.name "Caribou Github" + git fetch origin + git merge origin/master + +# Python + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.PYTHON_VERSION }} + +# Eigen3 + - name: cache eigen + uses: actions/cache@v2 + id: cache-eigen + with: + path: ${{ github.workspace }}/eigen + key: eigen-${{ matrix.EIGEN_VERSION }}-windows + - name: Install Eigen + if: steps.cache-eigen.outputs.cache-hit != 'true' + shell: bash + run: | + git clone --depth 1 -b $EIGEN_VERSION https://gitlab.com/libeigen/eigen.git eigen_src + cmake -S eigen_src -B eigen_src/build -DCMAKE_BUILD_TYPE=Release -DEIGEN_BUILD_DOC=OFF -DCMAKE_INSTALL_PREFIX="$EIGEN_ROOT" + cmake --build eigen_src/build --target install + +# PYBIND11 + - name: Install pybind11 + shell: bash + run: | + git clone --depth 1 -b v$PYBIND11_VERSION https://github.com/pybind/pybind11.git pybind11_src + cmake -S pybind11_src -B pybind11_src/build -DPYBIND11_TEST=OFF -DCMAKE_BUILD_TYPE=Release -DPYBIND11_FINDPYTHON=ON + cmake --install pybind11_src/build --prefix $PYBIND11_ROOT + rm -rf pybind11_src + +# BOOST + - name: Cache Boost + id: cache-Boost + uses: actions/cache@v1 + with: + path: ${{ format('{0}/boost', github.workspace) }} + key: boost-1.69.0-windows + + - name: Install Boost + if: steps.cache-Boost.outputs.cache-hit != 'true' + run: | + $BOOST_MAJOR = 1 + $BOOST_MINOR = 69 + $BOOST_PATCH = 0 + Invoke-WebRequest "https://boost.teeks99.com/bin/$($BOOST_MAJOR).$($BOOST_MINOR).$($BOOST_PATCH)/boost_$($BOOST_MAJOR)_$($BOOST_MINOR)_$($BOOST_PATCH)-msvc-14.1-64.exe" -OutFile boostinstaller.exe + ./boostinstaller.exe /NORESTART /VERYSILENT /DIR="$($BOOST_ROOT)" | Out-Null + rm -Force boostinstaller.exe + +# SOFA + - name: Download SOFA Release + shell: bash + run: | + if [ "$SOFA_VERSION" = "master" ]; then + curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=master,CI_SCOPE=standard/lastSuccessfulBuild/artifact/Windows/*zip*/Windows.zip" + unzip sofa.zip -d temp + mv temp/Windows/`ls temp/Windows` sofa.zip + rm -rf temp + unzip sofa.zip -d temp + mv temp/`ls temp` $SOFA_ROOT + rm -rf temp + else + curl --output sofa.zip -L "https://github.com/sofa-framework/sofa/releases/download/$SOFA_VERSION/SOFA_"$SOFA_VERSION"_Win64.zip" + unzip sofa.zip -d temp + mv temp/`ls temp` $SOFA_ROOT + fi + + # Patch SP3 absolute path + sed -i 's/C:\/pybind11\/[0-9].[0-9].[0-9]\/install\/include;//' $SOFA_ROOT/plugins/SofaPython3/lib/cmake/SofaPython3/PluginTargets.cmake + +# SOFA DEPENDENCY PACK + - name: Download SOFA Dependency pack + shell: bash + run: | + curl --output sofa_dependency.zip -L "https://www.sofa-framework.org/download/WinDepPack/VS-2017/latest" + unzip sofa_dependency.zip -d temp + mv temp/`ls temp` $SOFA_ROOT/windows_dependency + rm -rf temp + +# QT + - name: Cache Qt + id: cache-qt + uses: actions/cache@v1 + with: + path: ${{ format('{0}/qt', github.workspace) }} + key: qt-5.12.6-windows + + - name: Install Qt + uses: jurplel/install-qt-action@v2 + with: + version: '5.12.6' + dir: ${{ format('{0}/qt', github.workspace) }} + cached: ${{ steps.cache-qt.outputs.cache-hit }} + modules: 'qtcharts qtwebengine' + +# CARIBOU + - name: Build caribou + shell: bash + run: + cmake -DCMAKE_BUILD_TYPE=Release + -Dpybind11_DIR=$PYBIND11_ROOT + -DEigen3_ROOT=$EIGEN_ROOT + -DCMAKE_INCLUDE_PATH=$SOFA_ROOT/windows_dependency/include + -DCMAKE_LIBRARY_PATH=$SOFA_ROOT/windows_dependency/lib/win64 + -DQt5_ROOT=$QT_ROOT\5.12.5\msvc2017_64 + -DCMAKE_INSTALL_PREFIX=$SOFA_ROOT/plugins/SofaCaribou + -DCARIBOU_WITH_PYTHON_3=OFF + . + && cmake --build . --config Release + && cmake --install . + +# ZIP + - name: Zip production + run: Compress-Archive -LiteralPath "$($env:SOFA_ROOT)/plugins/SofaCaribou" -DestinationPath SofaCaribou.zip + +# ARCHIVE + - name: Archive production + uses: actions/upload-artifact@v2 + with: + name: caribou_win64_${{ matrix.sofa_version }} + path: SofaCaribou.zip + + test: + name: Testing with ${{ matrix.sofa_version }} + needs: [build] + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + sofa_version: [ master ] + include: + - sofa_version: master + PYTHON_VERSION: 3.8.10 +# - sofa_version: v21.12.00 +# PYTHON_VERSION: 3.7 + env: + SOFA_VERSION: ${{ matrix.sofa_version }} + SOFA_ROOT: ${{ format('{0}\sofa', github.workspace) }} + CARIBOU_ROOT: ${{ format('{0}\sofa\plugins\SofaCaribou', github.workspace) }} + + steps: +# Python + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.PYTHON_VERSION }} + +# PATH + - run: echo "${$env:SOFA_ROOT}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + +# SOFA + - name: Download SOFA Release + shell: bash + run: | + if [ "$SOFA_VERSION" = "master" ]; then + curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=master,CI_SCOPE=standard/lastSuccessfulBuild/artifact/Windows/*zip*/Windows.zip" + unzip sofa.zip -d temp + mv temp/Windows/`ls temp/Windows` sofa.zip + rm -rf temp + unzip sofa.zip -d temp + mv temp/`ls temp` $SOFA_ROOT + rm -rf temp + else + curl --output sofa.zip -L "https://github.com/sofa-framework/sofa/releases/download/$SOFA_VERSION/SOFA_"$SOFA_VERSION"_Win64.zip" + unzip sofa.zip -d temp + mv temp/`ls temp` $SOFA_ROOT + fi + +# CARIBOU + - name: Download caribou + uses: actions/download-artifact@v2 + with: + name: caribou_win64_${{ matrix.sofa_version }} + - name: Install caribou + run: Expand-Archive -Path SofaCaribou.zip -DestinationPath "${$env:SOFA_ROOT}\plugins" + + - name: Caribou.unittests.Geometry + if: ${{ always() }} + shell: bash + run: | + export PATH="$SOFA_ROOT/bin:$PATH" + $CARIBOU_ROOT/bin/Caribou.unittests.Geometry.exe + + - name: Caribou.unittests.Topology + if: ${{ always() }} + shell: bash + run: | + export PATH="$SOFA_ROOT/bin:$PATH" + $CARIBOU_ROOT/bin/Caribou.unittests.Topology.exe + + - name: Caribou.unittests.Mechanics + if: ${{ always() }} + shell: bash + run: | + export PATH="$SOFA_ROOT/bin:$PATH" + $CARIBOU_ROOT/bin/Caribou.unittests.Mechanics.exe + + - name: Caribou.unittests.SofaCaribou + if: ${{ always() }} + shell: bash + run: | + export PATH="$SOFA_ROOT/bin:$PATH" + $CARIBOU_ROOT/bin/Caribou.unittests.SofaCaribou.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index 9eb2b5d2..28bf2764 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,16 +50,19 @@ CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE) # OPTIONS option(CARIBOU_USE_FLOAT "Use float precision for floating point values." OFF) +option(CARIBOU_WITH_PYTHON_3 "Compile the plugin with python 3 support" OFF) CMAKE_DEPENDENT_OPTION(CARIBOU_OPTIMIZE_FOR_NATIVE "Build with -march=native to allow msse support" ON "COMPILER_SUPPORTS_MARCH_NATIVE" OFF) # SOFA option find_package(Threads QUIET) -find_package(SOFA COMPONENTS SofaFramework QUIET) +find_package(SOFA COMPONENTS Sofa.Framework QUIET) CMAKE_DEPENDENT_OPTION(CARIBOU_WITH_SOFA "Compile the SofaCaribou library" ON "SOFA_FOUND" OFF) if (CARIBOU_WITH_SOFA) list(APPEND CMAKE_PREFIX_PATH ${SOFA_MODULE_DIR}) list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH) - find_package(SofaPython3 QUIET) # We need to do this first to setup the exact python version required + if (CARIBOU_WITH_PYTHON_3) + find_package(SofaPython3 QUIET) # We need to do this first to setup the exact python version required + endif() endif() # Tests @@ -94,21 +97,27 @@ else() endif() # Python 3 option -if (CARIBOU_WITH_SOFA) +if (CARIBOU_WITH_SOFA AND CARIBOU_WITH_PYTHON_3) sofa_find_package(SofaPython3 QUIET) endif() set(CMAKE_CXX_STANDARD 17) set(PYBIND11_FINDPYTHON ON) set(PYBIND11_PYTHON_VERSION 3) set(Python_FIND_FRAMEWORK LAST) -find_package(SofaPython3 QUIET) +if (CARIBOU_WITH_SOFA AND CARIBOU_WITH_PYTHON_3) + find_package(SofaPython3 QUIET) +endif() if (SofaPython3_FOUND) set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) set(PYBIND11_PYTHON_VERSION ${PYTHON_VERSION}) endif() find_package(Python ${PYBIND11_PYTHON_VERSION} COMPONENTS Interpreter Development QUIET) find_package(pybind11 CONFIG QUIET) -CMAKE_DEPENDENT_OPTION(CARIBOU_WITH_PYTHON_3 "Compile the plugin with python 3 support" ON "Python_FOUND;pybind11_FOUND" OFF) +if (CARIBOU_WITH_PYTHON_3 AND (NOT Python_FOUND OR NOT pybind11_FOUND)) + SET(CARIBOU_WITH_PYTHON_3 OFF) + message(ERROR "Caribou is set to be compiled with python support, but pybind11 cannot be resolved.") +endif() + if (CARIBOU_WITH_PYTHON_3) message(STATUS "Caribou with Python support: Version: ${Python_VERSION} @@ -122,10 +131,10 @@ endif() # SOFA Python 3 if (CARIBOU_WITH_SOFA) - get_filename_component(SOFA_ROOT_DIR "${SofaFramework_DIR}/../../.." ABSOLUTE) + get_filename_component(SOFA_ROOT_DIR "${Sofa.Framework_DIR}/../../.." ABSOLUTE) message(STATUS "Caribou with SOFA support\n" - " SOFA version: ${SofaFramework_VERSION}\n" + " SOFA version: ${Sofa.Framework_VERSION}\n" " SOFA location: ${SOFA_ROOT_DIR}" ) if (CARIBOU_WITH_PYTHON_3) diff --git a/cmake/FindSOFA.cmake b/cmake/FindSOFA.cmake index 1f0db7b0..f282629d 100644 --- a/cmake/FindSOFA.cmake +++ b/cmake/FindSOFA.cmake @@ -15,8 +15,11 @@ # endif() ################################################################################ +# In cases quotes were added to the SOFA_ROOT env variable +STRING(REPLACE "\"" "" SOFA_ROOT_ENV $ENV{SOFA_ROOT}) + # Try to find SOFA's cmake module directory -find_package(SofaFramework CONFIG QUIET) # This defines SOFA_ROOT if SofaFrameworkConfig.cmake is found +find_package(Sofa.Framework CONFIG QUIET) # This defines SOFA_ROOT if SofaFrameworkConfig.cmake is found find_path ( SOFA_MODULE_DIR SofaFramework/SofaFrameworkConfig.cmake PATHS @@ -24,10 +27,10 @@ find_path ( ${SOFA_ROOT}/install/lib/cmake ${SOFA_ROOT}/build/install/lib/cmake ${SOFA_ROOT}/build/master/install/lib/cmake - $ENV{SOFA_ROOT}/lib/cmake - $ENV{SOFA_ROOT}/install/lib/cmake - $ENV{SOFA_ROOT}/build/install/lib/cmake - $ENV{SOFA_ROOT}/build/master/install/lib/cmake + ${SOFA_ROOT_ENV}/lib/cmake + ${SOFA_ROOT_ENV}/install/lib/cmake + ${SOFA_ROOT_ENV}/build/install/lib/cmake + ${SOFA_ROOT_ENV}/build/master/install/lib/cmake ) if (SOFA_MODULE_DIR) @@ -63,7 +66,7 @@ if (NOT SOFA_FIND_COMPONENTS) endif() # Compatibility layer -set(SOFA_VERSION ${SofaFramework_VERSION}) +set(SOFA_VERSION ${Sofa.Framework_VERSION}) foreach(component ${SOFA_FIND_COMPONENTS}) if (SOFA_VERSION VERSION_LESS "22.06.99") string(REGEX REPLACE "Sofa.Simulation.*" "SofaSimulation" component ${component}) diff --git a/src/SofaCaribou/Algebra/EigenMatrix.h b/src/SofaCaribou/Algebra/EigenMatrix.h index 9e7a18dd..547f3a89 100644 --- a/src/SofaCaribou/Algebra/EigenMatrix.h +++ b/src/SofaCaribou/Algebra/EigenMatrix.h @@ -5,23 +5,8 @@ DISABLE_ALL_WARNINGS_BEGIN #include -#include DISABLE_ALL_WARNINGS_END - -#if (defined(SOFA_VERSION) && SOFA_VERSION < 201200) -namespace sofa { using Size = unsigned int; } -#endif - -#if (defined(SOFA_VERSION) && SOFA_VERSION < 210600) -namespace sofa::type { -using Mat3x3d = ::sofa::defaulttype::Mat3x3d; -using Mat3x3f = ::sofa::defaulttype::Mat3x3f; -using Mat2x2d = ::sofa::defaulttype::Mat2x2d; -using Mat2x2f = ::sofa::defaulttype::Mat2x2f; -template -using Mat = ::sofa::defaulttype::Mat; -} -#endif +#include #include diff --git a/src/SofaCaribou/CMakeLists.txt b/src/SofaCaribou/CMakeLists.txt index 2e516ada..9b352e96 100644 --- a/src/SofaCaribou/CMakeLists.txt +++ b/src/SofaCaribou/CMakeLists.txt @@ -146,7 +146,7 @@ if (NOT TARGET Caribou::Algebra) endif() # Sofa's packages -find_package(SOFA COMPONENTS SofaFramework Sofa.Component.LinearSolver.Iterative Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.LinearAlgebra QUIET REQUIRED) +find_package(SOFA COMPONENTS Sofa.Framework Sofa.Component.LinearSolver.Iterative Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.LinearAlgebra QUIET REQUIRED) # Optional packages find_package(Eigen3 QUIET REQUIRED) @@ -159,7 +159,7 @@ endif() add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${TEMPLATE_FILES} ${HEADER_FILES}) add_library(Caribou::Plugin ALIAS ${PROJECT_NAME}) -target_link_libraries(${PROJECT_NAME} PUBLIC SofaCore Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.Component.LinearSolver.Iterative Sofa.LinearAlgebra) +target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Topology.Container.Grid Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Dynamic Sofa.Component.LinearSolver.Iterative Sofa.LinearAlgebra) target_link_libraries(${PROJECT_NAME} PUBLIC Caribou::Algebra Caribou::Geometry Caribou::Topology Caribou::Mechanics) target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) @@ -215,10 +215,12 @@ caribou_add_target_to_component ( HEADER_SRC_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.." ) -find_package(SofaPython3 QUIET) -if (CARIBOU_WITH_SOFA AND SofaPython3_FOUND AND CARIBOU_WITH_PYTHON_3) - add_subdirectory(Python) - set(CARIBOU_WITH_SP3 ON) +if (CARIBOU_WITH_PYTHON_3) + find_package(SofaPython3 QUIET) + if (CARIBOU_WITH_SOFA AND SofaPython3_FOUND) + add_subdirectory(Python) + set(CARIBOU_WITH_SP3 ON) + endif() endif() install ( diff --git a/unittest/Caribou/Geometry/CMakeLists.txt b/unittest/Caribou/Geometry/CMakeLists.txt index 4dc11839..b7012d6e 100644 --- a/unittest/Caribou/Geometry/CMakeLists.txt +++ b/unittest/Caribou/Geometry/CMakeLists.txt @@ -16,6 +16,8 @@ target_link_libraries(${PROJECT_NAME} Caribou::Geometry Caribou::Config) if (NOT WIN32) target_link_libraries(${PROJECT_NAME} pthread) +elseif(MSVC) + target_compile_options(${PROJECT_NAME} PRIVATE /bigobj) endif() list(APPEND target_rpath diff --git a/unittest/SofaCaribou/CMakeLists.txt b/unittest/SofaCaribou/CMakeLists.txt index 0ab493de..a0b1ea38 100644 --- a/unittest/SofaCaribou/CMakeLists.txt +++ b/unittest/SofaCaribou/CMakeLists.txt @@ -15,7 +15,7 @@ set(SOURCE_FILES enable_testing() -find_package(SOFA COMPONENTS SofaFramework Sofa.Simulation.Graph Sofa.Component.StateContainer Sofa.Component.Mass Sofa.Component.SceneUtility Sofa.Component.LinearSolver.Iterative Sofa.Component.Mass Sofa.Component.SolidMechanics.FEM.Elastic QUIET REQUIRED) +find_package(SOFA COMPONENTS Sofa.Framework Sofa.Simulation.Graph Sofa.Component.StateContainer Sofa.Component.Mass Sofa.Component.SceneUtility Sofa.Component.LinearSolver.Iterative Sofa.Component.Mass Sofa.Component.SolidMechanics.FEM.Elastic QUIET REQUIRED) find_package(Caribou COMPONENTS Topology REQUIRED) find_package(Threads REQUIRED) @@ -31,11 +31,11 @@ endif() target_link_libraries(${PROJECT_NAME} PUBLIC gtest) target_link_libraries(${PROJECT_NAME} PUBLIC SofaCaribou) -target_link_libraries(${PROJECT_NAME} PUBLIC SofaHelper Sofa.Component.StateContainer Sofa.Component.Mass Sofa.Component.SceneUtility Sofa.Component.LinearSolver.Iterative Sofa.Component.SolidMechanics.FEM.Elastic) +target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Helper Sofa.Component.StateContainer Sofa.Component.Mass Sofa.Component.SceneUtility Sofa.Component.LinearSolver.Iterative Sofa.Component.SolidMechanics.FEM.Elastic) target_link_libraries(${PROJECT_NAME} PUBLIC $<$,$,8.0>>:stdc++fs> $<$,$,9.0>>:c++fs>) -if (${SofaFramework_VERSION} VERSION_LESS "22.06.99") +if (${Sofa.Framework_VERSION} VERSION_LESS "22.06.99") target_link_libraries(${PROJECT_NAME} PUBLIC SofaSimulationGraph) else() target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Graph) diff --git a/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp b/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp index 525b6149..c82b3ecf 100644 --- a/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp +++ b/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp @@ -29,6 +29,7 @@ TEST(HyperelasticForcefield, Hexahedron_from_SOFA) { createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Constraint.Projective"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Grid"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Dynamic"}}); createObject(root, "RegularGridTopology", {{"name", "grid"}, {"min", "-7.5 -7.5 0"}, {"max", "7.5 7.5 80"}, {"n", "3 3 9"}}); auto meca = createChild(root, "meca"); From 71497b06a27863e3ca3a2e55d400f45aa266a676 Mon Sep 17 00:00:00 2001 From: Frederick ROY Date: Thu, 28 Nov 2024 14:25:56 +0100 Subject: [PATCH 4/8] remove ccache compilation --- .github/workflows/ubuntu.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 527fd48c..4983a414 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -86,13 +86,9 @@ jobs: PYTHONEXE: ${{ format('/usr/bin/python{0}', matrix.PYTHON_VERSION) }} run: export CCACHE_BASEDIR=$GITHUB_WORKSPACE && - export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache && - ccache -z && cmake -GNinja -DPYTHON_EXECUTABLE=$PYTHONEXE - -DCMAKE_C_COMPILER_LAUNCHER=ccache - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCARIBOU_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=SofaCaribou @@ -100,8 +96,6 @@ jobs: . && cmake --build . && cmake --install . && tar czvf SofaCaribou.tar.gz SofaCaribou - && echo ${CCACHE_BASEDIR} - && ccache -s - name: Archive production uses: actions/upload-artifact@v4.4.0 From 40a5a386868279859f46397d0b8cf11a72efd84a Mon Sep 17 00:00:00 2001 From: Frederick ROY Date: Thu, 28 Nov 2024 14:43:49 +0100 Subject: [PATCH 5/8] use sofa action --- .github/workflows/ubuntu.yml | 215 +++++++++++------------------------ 1 file changed, 65 insertions(+), 150 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 4983a414..720aa823 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -10,204 +10,119 @@ on: jobs: build: - name: Building with ${{ matrix.sofa_version }} - runs-on: ubuntu-24.04 - container: ${{ matrix.CONTAINER }} + name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }} + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - sofa_version: [ master ] - include: - - sofa_version: master - SOFA_VERSION_I: 999999 - CONTAINER: jnbrunet/caribou-ubuntu-2004-builder:latest - PYTHON_VERSION: 3.8 - PYBIND11_VERSION: 2.6 - env: - SOFA_VERSION: ${{ matrix.sofa_version }} - SOFA_ROOT: /opt/sofa - PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} + os: [ubuntu-22.04] + sofa_branch: [master] steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - run: | - git config --global user.email "caribou@github.com" - git config --global user.name "Caribou Github" - git fetch origin - git merge origin/master - - - name: Install pybind11 - if: ${{ matrix.PYBIND11_VERSION != '2.4' }} - run: | - git clone --depth 1 -b v${{ matrix.PYBIND11_VERSION }} https://github.com/pybind/pybind11.git /tmp/pybind11 - cmake -GNinja -S/tmp/pybind11 -B/tmp/pybind11/build -DPYBIND11_TEST=OFF -DCMAKE_BUILD_TYPE=Release - cmake --install /tmp/pybind11/build - rm -rf /tmp/pybind11 - - - name: Download SOFA Release - run: | - if [ "$SOFA_VERSION" = "master" ]; then - curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastStableBuild/CI_BRANCH=master,CI_SCOPE=standard/artifact/Linux/*zip*/Linux.zip" - unzip sofa.zip -d temp - mv temp/Linux/`ls temp/Linux` sofa.zip - rm -rf temp - unzip sofa.zip -d temp - mv temp/`ls temp` $SOFA_ROOT - else - curl --output sofa.zip -L "https://github.com/sofa-framework/sofa/releases/download/$SOFA_VERSION/SOFA_"$SOFA_VERSION"_Linux.zip" - unzip sofa.zip -d temp - mv temp/`ls temp` $SOFA_ROOT - fi - - - name: Get Time - id: time - uses: nanzm/get-time-action@v1.0 + - name: Setup SOFA and environment + id: sofa + uses: sofa-framework/sofa-setup-action@v5 with: - timeZone: 8 - format: 'YYYY-MM-DD-HH-mm-ss' - - - name: ccache cache files - uses: actions/cache@v2 - if: ${{ always() }} + sofa_root: ${{ github.workspace }}/sofa + sofa_version: ${{ matrix.sofa_branch }} + sofa_scope: 'standard' + - name: Checkout source code + uses: actions/checkout@v2 with: - path: .ccache - key: ubuntu-ccache-${{ steps.time.outputs.time }} - restore-keys: | - ubuntu-ccache- + path: ${{ env.WORKSPACE_SRC_PATH }} - name: Build caribou - env: - CCACHE_COMPRESS: true - CCACHE_COMPRESSLEVEL: 6 - CCACHE_MAXSIZE: "500M" - PYTHONEXE: ${{ format('/usr/bin/python{0}', matrix.PYTHON_VERSION) }} - run: - export CCACHE_BASEDIR=$GITHUB_WORKSPACE && - cmake - -GNinja - -DPYTHON_EXECUTABLE=$PYTHONEXE - -DCARIBOU_BUILD_TESTS=ON - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX=SofaCaribou - -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake - . - && cmake --build . && cmake --install . - && tar czvf SofaCaribou.tar.gz SofaCaribou - - - name: Archive production - uses: actions/upload-artifact@v4.4.0 - with: - name: caribou_${{ matrix.sofa_version }} - path: SofaCaribou.tar.gz - - test: - name: Testing with ${{ matrix.sofa_version }} - needs: [build] - runs-on: ubuntu-20.04 - container: ubuntu:20.04 - strategy: - fail-fast: false - matrix: - sofa_version: [ master ] - include: - - sofa_version: master - PYTHON_VERSION: 3.8 - sofa_version_int: 211200 - env: - SOFA_VERSION: ${{ matrix.sofa_version }} - SOFA_ROOT: /opt/sofa - CARIBOU_ROOT: /opt/sofa/plugins/SofaCaribou - - steps: - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.PYTHON_VERSION }} - - - name: Install dependencies run: | - apt-get update - apt-get -qq --no-install-recommends install \ - libgl1-mesa-glx libglib2.0-0 libglx0 libopengl0 libharfbuzz0b libgomp1 curl ca-certificates unzip - python -m pip install numpy meshio scipy - - - name: Install SOFA + sudo apt install libeigen3-dev + cd "$WORKSPACE_BUILD_PATH" + cmake \ + -GNinja \ + -DCARIBOU_BUILD_TESTS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \ + -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \ + ../src + cmake --build . && cmake --install . + + - name: Sanitize artifact name + id: sanitize + # This step removes special characters from the artifact name to ensure compatibility with upload-artifact + # Characters removed: " : < > | * ? \r \n \ / + # Spaces are replaced with underscores + # This sanitization prevents errors in artifact creation and retrieval + shell: pwsh run: | - if [ "$SOFA_VERSION" = "master" ]; then - curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastStableBuild/CI_BRANCH=master,CI_SCOPE=standard/artifact/Linux/*zip*/Linux.zip" - unzip sofa.zip -d temp - mv temp/Linux/`ls temp/Linux` sofa.zip - rm -rf temp - unzip sofa.zip -d temp - mv temp/`ls temp` $SOFA_ROOT - else - curl --output sofa.zip -L "https://github.com/sofa-framework/sofa/releases/download/$SOFA_VERSION/SOFA_"$SOFA_VERSION"_Linux.zip" - unzip sofa.zip -d temp - mv temp/`ls temp` $SOFA_ROOT - fi + $originalName = "Caribou_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}" + $artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_' + echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT + + - name: Create artifact + uses: actions/upload-artifact@v4.4.0 + with: + name: ${{ steps.sanitize.outputs.artifact_name }} + path: ${{ env.WORKSPACE_INSTALL_PATH }} - - name: Download caribou + - name: Install artifact uses: actions/download-artifact@v4.1.7 with: - name: caribou_${{ matrix.sofa_version }} - path: /tmp + name: ${{ steps.sanitize.outputs.artifact_name }} + path: ${{ env.WORKSPACE_ARTIFACT_PATH }} - - name: Unpack caribou - run: tar xzf /tmp/SofaCaribou.tar.gz -C /opt/sofa/plugins + - name: Set env vars for tests + shell: bash + run: | + echo "LD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaPython3/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV + # export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages - name: Caribou.unittests.Geometry if: ${{ always() }} run: | - export LD_LIBRARY_PATH="$SOFA_ROOT/lib:$LD_LIBRARY_PATH" - $CARIBOU_ROOT/bin/Caribou.unittests.Geometry + cd $WORKSPACE_BUILD_PATH + ./bin/Caribou.unittests.Geometry - name: Caribou.Geometry.PyTest if: ${{ always() }} run: | - export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages - python $CARIBOU_ROOT/bin/pytest/Caribou_Geometry_Test.py - + export PYTHONPATH=$PYTHONPATH:$WORKSPACE_INSTALL_PATH/lib/python3/site-packages:$WORKSPACE_INSTALL_PATH/plugins/SofaPython3/lib/python3/site-packages + cd "$WORKSPACE_BUILD_PATH"/../src + python3 src/Caribou/Python/Geometry/pytest/Caribou_Geometry_Test.py - name: Caribou.unittests.Topology if: ${{ always() }} run: | - [ "$SOFA_VERSION" = "v20.06.01" ] && export LD_LIBRARY_PATH="$SOFA_ROOT/lib:$LD_LIBRARY_PATH" - $CARIBOU_ROOT/bin/Caribou.unittests.Topology + cd $WORKSPACE_BUILD_PATH + ./bin/Caribou.unittests.Topology - name: Caribou.Topology.PyTest if: ${{ always() }} run: | - export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages - python $CARIBOU_ROOT/bin/pytest/Caribou_Topology_Test.py + cd $${{ env.WORKSPACE_SRC_PATH }} + python3 src/Caribou/Python/Topology/pytest/Caribou_Topology_Test.py - name: Caribou.unittests.Mechanics if: ${{ always() }} run: | - export LD_LIBRARY_PATH="$SOFA_ROOT/lib:$LD_LIBRARY_PATH" - $CARIBOU_ROOT/bin/Caribou.unittests.Mechanics + cd $WORKSPACE_BUILD_PATH + ./bin/Caribou.unittests.Mechanics - name: Caribou.unittests.SofaCaribou if: ${{ always() }} run: | - [ "$SOFA_VERSION" = "v20.06.01" ] && export LD_LIBRARY_PATH="$SOFA_ROOT/lib:$LD_LIBRARY_PATH" - export LD_LIBRARY_PATH="$SOFA_ROOT/collections/SofaBaseMechanics/lib:$LD_LIBRARY_PATH" - export LD_LIBRARY_PATH="$SOFA_ROOT/collections/SofaBaseUtils/lib:$LD_LIBRARY_PATH" - $CARIBOU_ROOT/bin/Caribou.unittests.SofaCaribou + cd $WORKSPACE_BUILD_PATH + ./bin/Caribou.unittests.SofaCaribou - name: SofaCaribou.PyTest - if: ${{ matrix.sofa_version_int >= '201200' }} + if: ${{ always() }} run: | + cd $WORKSPACE_BUILD_PATH export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages:$SOFA_ROOT/plugins/SofaPython3/lib/python3/site-packages - python $CARIBOU_ROOT/bin/pytest/SofaCaribou_Forcefield_HyperelasticForcefield.py + python3 src/SofaCaribou/Python/pytest/SofaCaribou_Forcefield_HyperelasticForcefield.py deploy: name: Deploy ${{ matrix.sofa_version }} - needs: [test] + needs: [build] runs-on: ubuntu-20.04 if: github.event_name == 'schedule' strategy: From 30f6113781e9de6cc9963bca4dde250eda772bba Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 29 Nov 2024 12:27:52 +0100 Subject: [PATCH 6/8] define SOFA_TARGET in SofaCaribou --- src/SofaCaribou/config.h.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SofaCaribou/config.h.in b/src/SofaCaribou/config.h.in index fd43f279..c74ca0f1 100644 --- a/src/SofaCaribou/config.h.in +++ b/src/SofaCaribou/config.h.in @@ -5,6 +5,7 @@ #ifdef CARIBOU_BUILD_SOFACARIBOU # define CARIBOU_TARGET SofaCaribou +# define SOFA_TARGET SofaCaribou # define CARIBOU_API SOFA_EXPORT_DYNAMIC_LIBRARY #else # define CARIBOU_API SOFA_IMPORT_DYNAMIC_LIBRARY From c2e9e7c799e4ecfbec164b2a77a11b3dd6da1d3a Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 29 Nov 2024 15:30:33 +0100 Subject: [PATCH 7/8] fix missing plugins --- unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp | 1 + unittest/SofaCaribou/Mass/test_cariboumass.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp b/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp index 074b26d7..8ee58840 100644 --- a/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp +++ b/unittest/SofaCaribou/Forcefield/test_hyperelasticforcefield.cpp @@ -25,6 +25,7 @@ TEST(HyperelasticForcefield, Hexahedron_from_SOFA) { auto root = getSimulation()->createNewNode("root"); createObject(root, "DefaultAnimationLoop"); createObject(root, "DefaultVisualManagerLoop"); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.StateContainer"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Constraint.Projective"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Grid"}}); diff --git a/unittest/SofaCaribou/Mass/test_cariboumass.cpp b/unittest/SofaCaribou/Mass/test_cariboumass.cpp index bbb08a1f..9f73b1a0 100644 --- a/unittest/SofaCaribou/Mass/test_cariboumass.cpp +++ b/unittest/SofaCaribou/Mass/test_cariboumass.cpp @@ -30,7 +30,9 @@ TEST(CaribouMass, LinearTetrahedron) { EXPECT_MSG_NOEMIT(Error); auto root = getSimulation()->createNewNode("root"); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Mass"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Grid"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Mapping"}}); // Some component to avoid warnings From fd2e3f521bc559289976360d00e1319d630191fc Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 29 Nov 2024 16:59:48 +0100 Subject: [PATCH 8/8] fix again missing plugins --- unittest/SofaCaribou/Forcefield/test_tractionforce.cpp | 4 ++++ unittest/SofaCaribou/Mass/test_cariboumass.cpp | 6 ++++++ unittest/SofaCaribou/ODE/test_backward_euler.cpp | 4 ++++ unittest/SofaCaribou/ODE/test_static.cpp | 6 +++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/unittest/SofaCaribou/Forcefield/test_tractionforce.cpp b/unittest/SofaCaribou/Forcefield/test_tractionforce.cpp index 39aa0807..a910a7e3 100644 --- a/unittest/SofaCaribou/Forcefield/test_tractionforce.cpp +++ b/unittest/SofaCaribou/Forcefield/test_tractionforce.cpp @@ -31,6 +31,8 @@ class TractionForcefield : public BaseTest { TEST_F(TractionForcefield, Triangle) { EXPECT_MSG_NOEMIT(Error, Warning) ; + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.StateContainer"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Dynamic"}}); createObject(root, "DefaultAnimationLoop"); createObject(root, "DefaultVisualManagerLoop"); createObject(root, "MechanicalObject", {{"position", "-1 0 1 1 0 1 -1 0 -1 1 0 -1 0 0 1 0 0 -1 -1 0 0 1 0 0 0 0 0"}}); @@ -51,6 +53,8 @@ TEST_F(TractionForcefield, Triangle) { TEST_F(TractionForcefield, Quad) { EXPECT_MSG_NOEMIT(Error, Warning) ; + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.StateContainer"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Dynamic"}}); createObject(root, "DefaultAnimationLoop"); createObject(root, "DefaultVisualManagerLoop"); createObject(root, "MechanicalObject", {{"position", "-1 0 1 1 0 1 -1 0 -1 1 0 -1 0 0 1 0 0 -1 -1 0 0 1 0 0 0 0 0"}}); diff --git a/unittest/SofaCaribou/Mass/test_cariboumass.cpp b/unittest/SofaCaribou/Mass/test_cariboumass.cpp index 9f73b1a0..8d57ef9b 100644 --- a/unittest/SofaCaribou/Mass/test_cariboumass.cpp +++ b/unittest/SofaCaribou/Mass/test_cariboumass.cpp @@ -34,6 +34,8 @@ TEST(CaribouMass, LinearTetrahedron) { createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Grid"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Mapping"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.StateContainer"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Dynamic"}}); // Some component to avoid warnings createObject(root, "DefaultAnimationLoop"); @@ -141,6 +143,10 @@ TEST(CaribouMass, LinearHexahedron) { auto root = getSimulation()->createNewNode("root"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Mapping"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.StateContainer"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Dynamic"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Grid"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Mass"}}); // Some component to avoid warnings createObject(root, "DefaultAnimationLoop"); diff --git a/unittest/SofaCaribou/ODE/test_backward_euler.cpp b/unittest/SofaCaribou/ODE/test_backward_euler.cpp index d3ad95dc..b04cbfdc 100644 --- a/unittest/SofaCaribou/ODE/test_backward_euler.cpp +++ b/unittest/SofaCaribou/ODE/test_backward_euler.cpp @@ -24,6 +24,10 @@ TEST(BackwardEulerODESolver, Beam) { auto root = getSimulation()->createNewNode("root"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Constraint.Projective"}}); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Mass"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.StateContainer"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Dynamic"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Grid"}}); // Some component to avoid warnings createObject(root, "DefaultAnimationLoop"); diff --git a/unittest/SofaCaribou/ODE/test_static.cpp b/unittest/SofaCaribou/ODE/test_static.cpp index 1523f3f1..bf47fd2b 100644 --- a/unittest/SofaCaribou/ODE/test_static.cpp +++ b/unittest/SofaCaribou/ODE/test_static.cpp @@ -87,6 +87,10 @@ TEST(StaticODESolver, Beam) { createObject(root, "DefaultAnimationLoop"); createObject(root, "DefaultVisualManagerLoop"); createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Engine.Select"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Grid"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Topology.Container.Dynamic"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.StateContainer"}}); + createObject(root, "RequiredPlugin", {{"pluginName", "Sofa.Component.Constraint.Projective"}}); createObject(root, "RegularGridTopology", {{"name", "grid"}, {"min", "-7.5 -7.5 0"}, {"max", "7.5 7.5 80"}, {"n", "3 3 9"}}); auto meca = createChild(root, "meca"); @@ -108,7 +112,7 @@ TEST(StaticODESolver, Beam) { // Fix the left side of the beam createObject(meca, "BoxROI", {{"name", "fixed_roi"}, {"quad", "@surface_topology.quad"}, {"box", "-7.5 -7.5 -0.9 7.5 7.5 0.1"}}); - createObject(meca, "FixedConstraint", {{"indices", "@fixed_roi.indices"}}); + createObject(meca, "FixedProjectiveConstraint", {{"indices", "@fixed_roi.indices"}}); // Apply traction on the right side of the beam createObject(meca, "BoxROI", {{"name", "top_roi"}, {"quad", "@surface_topology.quad"}, {"box", "-7.5 -7.5 79.9 7.5 7.5 80.1"}});