Skip to content

Commit

Permalink
Compatibility with SOFA 23.12
Browse files Browse the repository at this point in the history
  • Loading branch information
jnbrunet committed May 31, 2024
1 parent 2aa665c commit a90fe64
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
6 changes: 3 additions & 3 deletions cmake/FindSOFA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions src/SofaCaribou/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/SofaCaribou/Ode/BackwardEulerODESolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SofaCaribou/Ode/LegacyStaticODESolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/SofaCaribou/Ode/StaticODESolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sofa::core::behavior::ConstraintSolver>(Direction::Local);
Expand Down
4 changes: 2 additions & 2 deletions unittest/SofaCaribou/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -35,7 +35,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC SofaHelper Sofa.Component.StateCont
target_link_libraries(${PROJECT_NAME} PUBLIC
$<$<AND:$<PLATFORM_ID:Linux>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,8.0>>:stdc++fs>
$<$<AND:$<PLATFORM_ID:Darwin>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,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)
Expand Down

0 comments on commit a90fe64

Please sign in to comment.