Skip to content

Commit

Permalink
[wip] Windows workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jnbrunet committed May 5, 2022
1 parent 6957494 commit c1eaeb7
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 7 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,62 @@ jobs:
with:
name: caribou_win64_${{ matrix.sofa_version }}
path: ${{github.workspace}}/sofa/plugins/SofaCaribou

test:
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
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
rm -rm temp
fi
# CARIBOU
- name: Download caribou
uses: actions/download-artifact@v2
with:
name: caribou_${{ matrix.sofa_version }}
path: ${{ format('{0}/sofa/plugins/SofaCaribou', github.workspace) }}

- name: Caribou.unittests.Geometry
if: ${{ always() }}
shell: bash
run: |
export PATH="$SOFA_ROOT/bin:$PATH"
$CARIBOU_ROOT/bin/Caribou.unittests.Geometry
15 changes: 11 additions & 4 deletions src/SofaCaribou/Algebra/EigenMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@

DISABLE_ALL_WARNINGS_BEGIN
#include <sofa/version.h>
#if (defined(SOFA_VERSION) && SOFA_VERSION < 211200)
#include <sofa/defaulttype/BaseMatrix.h>
namespace sofa::linearalgebra {
using BaseMatrix = sofa::defaulttype::BaseMatrix;
}
#else
#include <sofa/linearalgebra/BaseMatrix.h>
#endif
DISABLE_ALL_WARNINGS_END

#if (defined(SOFA_VERSION) && SOFA_VERSION < 201200)
Expand Down Expand Up @@ -68,7 +75,7 @@ namespace SofaCaribou::Algebra {
* \endcode
*/
template <typename Derived, typename Enable = void>
class EigenMatrix : public sofa::defaulttype::BaseMatrix
class EigenMatrix : public sofa::linearalgebra::BaseMatrix
{
static_assert(
std::is_base_of_v<Eigen::EigenBase<std::decay_t<Derived> >, std::decay_t<Derived> >,
Expand All @@ -77,7 +84,7 @@ class EigenMatrix : public sofa::defaulttype::BaseMatrix

public:
using EigenType = std::remove_cv_t<std::remove_reference_t<Derived>>;
using Base = sofa::defaulttype::BaseMatrix;
using Base = sofa::linearalgebra::BaseMatrix;
using Index = Base::Index;
using Real = SReal;
using Scalar = typename EigenType::Scalar;
Expand Down Expand Up @@ -168,12 +175,12 @@ class EigenMatrix : public sofa::defaulttype::BaseMatrix
/// SparseMatrix specialization ///
///////////////////////////////////
template <typename Derived>
class EigenMatrix<Derived, CLASS_REQUIRES(std::is_base_of_v<Eigen::SparseMatrixBase<std::decay_t<Derived>>, std::decay_t<Derived>>)> : public sofa::defaulttype::BaseMatrix
class EigenMatrix<Derived, CLASS_REQUIRES(std::is_base_of_v<Eigen::SparseMatrixBase<std::decay_t<Derived>>, std::decay_t<Derived>>)> : public sofa::linearalgebra::BaseMatrix
{

public:
using EigenType = std::remove_cv_t<std::remove_reference_t<Derived>>;
using Base = sofa::defaulttype::BaseMatrix;
using Base = sofa::linearalgebra::BaseMatrix;
using Index = Base::Index;
using Real = SReal;
using Scalar = typename EigenType::Scalar;
Expand Down
13 changes: 11 additions & 2 deletions src/SofaCaribou/Algebra/EigenVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
#include <Caribou/traits.h>

DISABLE_ALL_WARNINGS_BEGIN
#if (defined(SOFA_VERSION) && SOFA_VERSION < 211200)
#include <sofa/defaulttype/BaseMatrix.h>
#include <sofa/defaulttype/BaseVector.h>
namespace sofa::linearalgebra {
using BaseVector = sofa::defaulttype::BaseVector;
using BaseMatrix = sofa::defaulttype::BaseMatrix;
}
#else
#include <sofa/linearalgebra/BaseMatrix.h>
#include <sofa/linearalgebra/BaseVector.h>
#endif
DISABLE_ALL_WARNINGS_END

#include <Eigen/Dense>
Expand All @@ -23,7 +32,7 @@ namespace SofaCaribou::Algebra {
* @tparam Enable
*/
template <typename Derived, typename Enable = void>
class EigenVector : public sofa::defaulttype::BaseVector
class EigenVector : public sofa::linearalgebra::BaseVector
{
static_assert(
std::is_base_of_v<Eigen::EigenBase<std::decay_t<Derived> >, std::decay_t<Derived> >,
Expand All @@ -38,7 +47,7 @@ class EigenVector : public sofa::defaulttype::BaseVector

public:
using EigenType = std::remove_cv_t<std::remove_reference_t<Derived>>;
using Base = sofa::defaulttype::BaseVector;
using Base = sofa::linearalgebra::BaseVector;
using Index = Base::Index;
using Real = typename EigenType::Scalar;

Expand Down
2 changes: 1 addition & 1 deletion unittest/SofaCaribou/Mass/test_cariboumass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,5 @@ TEST(CaribouMass, LinearHexahedron) {
sofa_mass->addMToMatrix(&mechanical_parameters, &accessor);
SofaM.compress();

EXPECT_DOUBLE_EQ(M.sum(), SofaM.matrix().sum());
EXPECT_NEAR(M.sum(), SofaM.matrix().sum(), 1e-5);
}

0 comments on commit c1eaeb7

Please sign in to comment.