Skip to content

Commit

Permalink
Merge pull request #1 from jnbrunet/master_alban
Browse files Browse the repository at this point in the history
Minor adjustments to linear solver bindings
  • Loading branch information
AlbanOdot authored Oct 13, 2021
2 parents f1111e4 + 2b00ae6 commit d9a7a6b
Show file tree
Hide file tree
Showing 29 changed files with 212 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
- 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/MacOS/*zip*/MacOS.zip"
curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=master,CI_SCOPE=standard/lastSuccessfulBuild/artifact/MacOS/*zip*/MacOS.zip"
else
curl --output sofa.zip -L "https://github.com/sofa-framework/sofa/releases/download/$SOFA_VERSION/SOFA_"$SOFA_VERSION"_MacOS.zip"
fi
Expand Down
43 changes: 35 additions & 8 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,28 @@ jobs:
build:
name: Building with ${{ matrix.sofa_version }}
runs-on: ubuntu-20.04
container: jnbrunet/caribou-ubuntu-1804-builder:latest
container: ${{ matrix.CONTAINER }}
strategy:
fail-fast: false
matrix:
sofa_version: [ v20.06.01, v20.12.03, v21.06.00, master ]
include:
- sofa_version: master
CONTAINER: jnbrunet/caribou-ubuntu-2004-builder:latest
PYTHON_VERSION: 3.8
- sofa_version: v21.06.00
CONTAINER: jnbrunet/caribou-ubuntu-1804-builder:latest
PYTHON_VERSION: 3.7
- sofa_version: v20.12.03
CONTAINER: jnbrunet/caribou-ubuntu-1804-builder:latest
PYTHON_VERSION: 3.7
- sofa_version: v20.06.01
CONTAINER: jnbrunet/caribou-ubuntu-1804-builder:latest
PYTHON_VERSION: 3.7
env:
SOFA_VERSION: ${{ matrix.sofa_version }}
SOFA_ROOT: /opt/sofa
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}

steps:
- uses: actions/checkout@v2
Expand All @@ -35,7 +49,7 @@ jobs:
- 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"
curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=master,CI_SCOPE=standard/lastSuccessfulBuild/artifact/Linux/*zip*/Linux.zip"
unzip sofa.zip -d temp
mv temp/Linux/`ls temp/Linux` sofa.zip
rm -rf temp
Expand Down Expand Up @@ -75,19 +89,21 @@ jobs:
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 6
CCACHE_MAXSIZE: "500M"
PYTHONEXE: ${{ format('/usr/bin/python{0}', matrix.PYTHON_VERSION) }}
run:
export CCACHE_BASEDIR=$GITHUB_WORKSPACE &&
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache &&
ccache -z &&
cmake
-DPYTHON_EXECUTABLE=/usr/bin/python3.7
-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
.
&& make && make install
&& cmake --build . && cmake --install .
&& tar czvf SofaCaribou.tar.gz SofaCaribou
&& echo ${CCACHE_BASEDIR}
&& ccache -s
Expand All @@ -107,16 +123,25 @@ jobs:
fail-fast: false
matrix:
sofa_version: [ v20.06.01, v20.12.03, v21.06.00, master ]
include:
- sofa_version: master
PYTHON_VERSION: 3.8
- sofa_version: v21.06.00
PYTHON_VERSION: 3.7
- sofa_version: v20.12.03
PYTHON_VERSION: 3.7
- sofa_version: v20.06.01
PYTHON_VERSION: 3.7
env:
SOFA_VERSION: ${{ matrix.sofa_version }}
SOFA_ROOT: /opt/sofa
CARIBOU_ROOT: /opt/sofa/plugins/SofaCaribou

steps:
- name: Set up Python 3.7
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: ${{ matrix.PYTHON_VERSION }}

- name: Install dependencies
run: |
Expand All @@ -128,7 +153,7 @@ jobs:
- name: Install SOFA
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"
curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=master,CI_SCOPE=standard/lastSuccessfulBuild/artifact/Linux/*zip*/Linux.zip"
unzip sofa.zip -d temp
mv temp/Linux/`ls temp/Linux` sofa.zip
rm -rf temp
Expand Down Expand Up @@ -193,10 +218,12 @@ jobs:
python3 $CARIBOU_ROOT/bin/pytest/SofaCaribou_Forcefield_HyperelasticForcefield.py
deploy:
name: Deploy ${{ matrix.sofa_version }}
needs: [test]
runs-on: ubuntu-20.04
if: github.event_name == 'schedule'
strategy:
matrix:
sofa_version: [ v20.06.01, v20.12.03, v21.06.00, master ]
Expand Down Expand Up @@ -261,4 +288,4 @@ jobs:
mv $ARTIFACT_TARGET/SofaCaribou.tar.gz $ARTIFACT_TARGET.tar.gz
rm -rf $ARTIFACT_TARGET
rm -f $ARTIFACT_LATEST
ln -s $ARTIFACT_TARGET.tar.gz $ARTIFACT_LATEST
ln -s $ARTIFACT_TARGET.tar.gz $ARTIFACT_LATEST
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,34 @@ class HyperelasticForcefieldRecomputeF : public ::SofaCaribou::forcefield::Carib

// Public methods

CARIBOU_API

HyperelasticForcefieldRecomputeF();

CARIBOU_API

void init() override;

CARIBOU_API

void addForce(const sofa::core::MechanicalParams* mparams, sofa::core::MultiVecDerivId fId ) override;

CARIBOU_API

void addForce(
const sofa::core::MechanicalParams* mparams,
sofa::core::objectmodel::Data<VecDeriv>& d_f,
const sofa::core::objectmodel::Data<VecCoord>& d_x,
const sofa::core::objectmodel::Data<VecDeriv>& d_v) override;

CARIBOU_API

void addDForce(
const sofa::core::MechanicalParams* /*mparams*/,
sofa::core::objectmodel::Data<VecDeriv>& /*d_df*/,
const sofa::core::objectmodel::Data<VecDeriv>& /*d_dx*/) override;

CARIBOU_API

SReal getPotentialEnergy(
const sofa::core::MechanicalParams* /* mparams */,
const sofa::core::objectmodel::Data<VecCoord>& /* d_x */) const override;

CARIBOU_API

void addKToMatrix(sofa::defaulttype::BaseMatrix * /*matrix*/, SReal /*kFact*/, unsigned int & /*offset*/) override;

/** Get the set of Gauss integration nodes of an element */
Expand Down Expand Up @@ -148,11 +148,11 @@ class HyperelasticForcefieldRecomputeF : public ::SofaCaribou::forcefield::Carib
}

/** Get the eigen values of the tangent stiffness matrix */
CARIBOU_API

auto eigenvalues() -> const Vector<Eigen::Dynamic> &;

/** Get the condition number of the tangent stiffness matrix */
CARIBOU_API

auto cond() -> Real;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,34 @@ class HyperelasticForcefieldStoreF : public ::SofaCaribou::forcefield::CaribouFo

// Public methods

CARIBOU_API

HyperelasticForcefieldStoreF();

CARIBOU_API

void init() override;

CARIBOU_API

void addForce(const sofa::core::MechanicalParams* mparams, sofa::core::MultiVecDerivId fId ) override;

CARIBOU_API

void addForce(
const sofa::core::MechanicalParams* mparams,
sofa::core::objectmodel::Data<VecDeriv>& d_f,
const sofa::core::objectmodel::Data<VecCoord>& d_x,
const sofa::core::objectmodel::Data<VecDeriv>& d_v) override;

CARIBOU_API

void addDForce(
const sofa::core::MechanicalParams* /*mparams*/,
sofa::core::objectmodel::Data<VecDeriv>& /*d_df*/,
const sofa::core::objectmodel::Data<VecDeriv>& /*d_dx*/) override;

CARIBOU_API

SReal getPotentialEnergy(
const sofa::core::MechanicalParams* /* mparams */,
const sofa::core::objectmodel::Data<VecCoord>& /* d_x */) const override;

CARIBOU_API

void addKToMatrix(sofa::defaulttype::BaseMatrix * /*matrix*/, SReal /*kFact*/, unsigned int & /*offset*/) override;

/** Get the set of Gauss integration nodes of an element */
Expand Down Expand Up @@ -149,11 +149,11 @@ class HyperelasticForcefieldStoreF : public ::SofaCaribou::forcefield::CaribouFo
}

/** Get the eigen values of the tangent stiffness matrix */
CARIBOU_API

auto eigenvalues() -> const Vector<Eigen::Dynamic> &;

/** Get the condition number of the tangent stiffness matrix */
CARIBOU_API

auto cond() -> Real;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,34 @@ class HyperelasticForcefieldStoreFAndS : public ::SofaCaribou::forcefield::Carib

// Public methods

CARIBOU_API

HyperelasticForcefieldStoreFAndS();

CARIBOU_API

void init() override;

CARIBOU_API

void addForce(const sofa::core::MechanicalParams* mparams, sofa::core::MultiVecDerivId fId ) override;

CARIBOU_API

void addForce(
const sofa::core::MechanicalParams* mparams,
sofa::core::objectmodel::Data<VecDeriv>& d_f,
const sofa::core::objectmodel::Data<VecCoord>& d_x,
const sofa::core::objectmodel::Data<VecDeriv>& d_v) override;

CARIBOU_API

void addDForce(
const sofa::core::MechanicalParams* /*mparams*/,
sofa::core::objectmodel::Data<VecDeriv>& /*d_df*/,
const sofa::core::objectmodel::Data<VecDeriv>& /*d_dx*/) override;

CARIBOU_API

SReal getPotentialEnergy(
const sofa::core::MechanicalParams* /* mparams */,
const sofa::core::objectmodel::Data<VecCoord>& /* d_x */) const override;

CARIBOU_API

void addKToMatrix(sofa::defaulttype::BaseMatrix * /*matrix*/, SReal /*kFact*/, unsigned int & /*offset*/) override;

/** Get the set of Gauss integration nodes of an element */
Expand Down Expand Up @@ -152,11 +152,11 @@ class HyperelasticForcefieldStoreFAndS : public ::SofaCaribou::forcefield::Carib
}

/** Get the eigen values of the tangent stiffness matrix */
CARIBOU_API

auto eigenvalues() -> const Vector<Eigen::Dynamic> &;

/** Get the condition number of the tangent stiffness matrix */
CARIBOU_API

auto cond() -> Real;

/**
Expand Down
12 changes: 6 additions & 6 deletions Benchmark/SofaCaribou/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#include <SofaCaribou/config.h>

extern "C" {
CARIBOU_API void initExternalModule();
CARIBOU_API const char* getModuleName();
CARIBOU_API const char* getModuleVersion();
CARIBOU_API const char* getModuleLicense();
CARIBOU_API const char* getModuleDescription();
CARIBOU_API const char* getModuleComponentList();
void initExternalModule();
const char* getModuleName();
const char* getModuleVersion();
const char* getModuleLicense();
const char* getModuleDescription();
const char* getModuleComponentList();
}

void initExternalModule()
Expand Down
4 changes: 4 additions & 0 deletions src/SofaCaribou/Algebra/BaseVectorOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

DISABLE_ALL_WARNINGS_BEGIN
#include <sofa/version.h>
#if (defined(SOFA_VERSION) && SOFA_VERSION < 211299)
#include <sofa/defaulttype/BaseVector.h>
#else
#include <sofa/linearalgebra/BaseVector.h>
#endif // #if (defined(SOFA_VERSION) && SOFA_VERSION < 211299)
#include <SofaBaseLinearSolver/FullVector.h>
DISABLE_ALL_WARNINGS_END

Expand Down
14 changes: 13 additions & 1 deletion src/SofaCaribou/Algebra/BaseVectorOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@
// Various utilities to perform numerical operations on SOFA's BaseVector.
// These utilities are responsible to automatically find the type of vector
// and perform the optimal operations on them.
DISABLE_ALL_WARNINGS_BEGIN
#include <sofa/version.h> // for SOFA_VERSION
DISABLE_ALL_WARNINGS_END

#if (defined(SOFA_VERSION) && SOFA_VERSION < 211299)
namespace sofa::defaulttype {
class BaseVector;
class BaseVector;
}
#else
namespace sofa::linearalgebra {
class BaseVector;
}
namespace sofa::defaulttype {
using BaseVector = sofa::linearalgebra::BaseVector;
}
#endif // (defined(SOFA_VERSION) && SOFA_VERSION < 211299)

namespace SofaCaribou::Algebra {

Expand Down
5 changes: 4 additions & 1 deletion src/SofaCaribou/Forcefield/TractionForcefield.inl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ DISABLE_ALL_WARNINGS_BEGIN
#include <sofa/core/visual/VisualParams.h>
#include <sofa/simulation/AnimateBeginEvent.h>
#include <sofa/helper/AdvancedTimer.h>
#if (defined(SOFA_VERSION) && SOFA_VERSION >= 210600)
#include <sofa/helper/ScopedAdvancedTimer.h>
#endif
DISABLE_ALL_WARNINGS_END

#if (defined(SOFA_VERSION) && SOFA_VERSION <= 201299)
Expand Down Expand Up @@ -275,4 +278,4 @@ TractionForcefield<Element>::get_gauss_nodes(const size_t & /*element_id*/, cons
return gauss_nodes;
}

} // namespace SofaCaribou::forcefield
} // namespace SofaCaribou::forcefield
3 changes: 3 additions & 0 deletions src/SofaCaribou/Mass/CaribouMass.inl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

DISABLE_ALL_WARNINGS_BEGIN
#include <sofa/helper/AdvancedTimer.h>
#if (defined(SOFA_VERSION) && SOFA_VERSION >= 210600)
#include <sofa/helper/ScopedAdvancedTimer.h>
#endif
#include <sofa/core/MechanicalParams.h>
#include <sofa/core/behavior/Mass.inl>
DISABLE_ALL_WARNINGS_END
Expand Down
3 changes: 3 additions & 0 deletions src/SofaCaribou/Ode/NewtonRaphsonSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
DISABLE_ALL_WARNINGS_BEGIN
#include <sofa/version.h>
#include <sofa/helper/AdvancedTimer.h>
#if (defined(SOFA_VERSION) && SOFA_VERSION >= 210600)
#include <sofa/helper/ScopedAdvancedTimer.h>
#endif
#include <sofa/simulation/MechanicalOperations.h>
#include <sofa/simulation/Node.h>
#include <sofa/simulation/VectorOperations.h>
Expand Down
Loading

0 comments on commit d9a7a6b

Please sign in to comment.