From a90fe6471a44772bf7f3fddfa7e04ef3939e006d Mon Sep 17 00:00:00 2001 From: Jean-Nicolas Brunet Date: Thu, 30 May 2024 17:02:19 -0400 Subject: [PATCH] Compatibility with SOFA 23.12 --- CMakeLists.txt | 2 +- cmake/FindSOFA.cmake | 6 +++--- src/SofaCaribou/CMakeLists.txt | 4 ++-- src/SofaCaribou/Ode/BackwardEulerODESolver.cpp | 4 ++-- src/SofaCaribou/Ode/LegacyStaticODESolver.cpp | 2 +- src/SofaCaribou/Ode/StaticODESolver.cpp | 2 +- unittest/SofaCaribou/CMakeLists.txt | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9eb2b5d2..4a63b663 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ CMAKE_DEPENDENT_OPTION(CARIBOU_OPTIMIZE_FOR_NATIVE "Build with -march=native to # SOFA option find_package(Threads QUIET) -find_package(SOFA COMPONENTS SofaFramework QUIET) +find_package(SOFA COMPONENTS Sofa.Config 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}) diff --git a/cmake/FindSOFA.cmake b/cmake/FindSOFA.cmake index 1f0db7b0..f916a5c0 100644 --- a/cmake/FindSOFA.cmake +++ b/cmake/FindSOFA.cmake @@ -16,9 +16,9 @@ ################################################################################ # 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.Config CONFIG QUIET) # This defines SOFA_ROOT if Sofa.Config.cmake is found find_path ( - SOFA_MODULE_DIR SofaFramework/SofaFrameworkConfig.cmake + SOFA_MODULE_DIR Sofa.Config/Sofa.ConfigConfig.cmake PATHS ${SOFA_ROOT}/lib/cmake ${SOFA_ROOT}/install/lib/cmake @@ -63,7 +63,7 @@ if (NOT SOFA_FIND_COMPONENTS) endif() # Compatibility layer -set(SOFA_VERSION ${SofaFramework_VERSION}) +set(SOFA_VERSION ${Sofa_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/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..5c106120 100644 --- a/src/SofaCaribou/Ode/BackwardEulerODESolver.cpp +++ b/src/SofaCaribou/Ode/BackwardEulerODESolver.cpp @@ -220,7 +220,7 @@ void BackwardEulerODESolver::propagate_solution_increment(const MechanicalParams MechanicalVOpVisitor(&mechanical_parameters, v_id, p_previous_v_id, p_a_id, h).execute(this->getContext()); // 5. Solve velocity constraints - constraint_parameters.setOrder(sofa::core::ConstraintParams::VEL); + constraint_parameters.setOrder(sofa::core::ConstraintOrder::VEL); for (auto * solver : constraint_solvers) { solver->solveConstraint(&constraint_parameters, v_id); } @@ -229,7 +229,7 @@ void BackwardEulerODESolver::propagate_solution_increment(const MechanicalParams MechanicalVOpVisitor(&mechanical_parameters, x_id, p_previous_x_id, v_id, h).execute(this->getContext()); // 7. Solve position constraints - constraint_parameters.setOrder(sofa::core::ConstraintParams::POS); + constraint_parameters.setOrder(sofa::core::ConstraintOrder::POS); for (auto * solver : constraint_solvers) { solver->solveConstraint(&constraint_parameters, x_id); } diff --git a/src/SofaCaribou/Ode/LegacyStaticODESolver.cpp b/src/SofaCaribou/Ode/LegacyStaticODESolver.cpp index dd9886ec..cd00a8c0 100644 --- a/src/SofaCaribou/Ode/LegacyStaticODESolver.cpp +++ b/src/SofaCaribou/Ode/LegacyStaticODESolver.cpp @@ -208,7 +208,7 @@ void LegacyStaticODESolver::solve(const sofa::core::ExecParams* params, double / // Solving constraints // Calls "solveConstraint" method of every ConstraintSolver objects found in the current context tree. // todo(jnbrunet): Shouldn't this be done AFTER the position propagation of the mapped nodes? - mop.solveConstraint(x, sofa::core::ConstraintParams::POS); + mop.solveConstraint(x, sofa::core::ConstraintOrder::POS); // Propagate positions to mapped mechanical objects, for example, identity mappings, barycentric mappings, ... // This will call the methods apply and applyJ on every mechanical mappings. diff --git a/src/SofaCaribou/Ode/StaticODESolver.cpp b/src/SofaCaribou/Ode/StaticODESolver.cpp index 3cbf2ee8..c6a88126 100644 --- a/src/SofaCaribou/Ode/StaticODESolver.cpp +++ b/src/SofaCaribou/Ode/StaticODESolver.cpp @@ -112,7 +112,7 @@ void StaticODESolver::propagate_solution_increment(const sofa::core::MechanicalP // 3. Calls "solveConstraint" method of every ConstraintSolver objects found in the current context tree. sofa::core::ConstraintParams constraint_parameters = mechanical_parameters; - constraint_parameters.setOrder(sofa::core::ConstraintParams::POS); + constraint_parameters.setOrder(sofa::core::ConstraintOrder::POS); using Direction = sofa::core::objectmodel::BaseContext::SearchDirection; auto constraint_solvers = this->getContext()->getObjects(Direction::Local); diff --git a/unittest/SofaCaribou/CMakeLists.txt b/unittest/SofaCaribou/CMakeLists.txt index 0ab493de..6c3fa443 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.Config 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) @@ -35,7 +35,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC SofaHelper Sofa.Component.StateCont target_link_libraries(${PROJECT_NAME} PUBLIC $<$,$,8.0>>:stdc++fs> $<$,$,9.0>>:c++fs>) -if (${SofaFramework_VERSION} VERSION_LESS "22.06.99") +if (${Sofa_VERSION} VERSION_LESS "22.06.99") target_link_libraries(${PROJECT_NAME} PUBLIC SofaSimulationGraph) else() target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Graph)