Skip to content

Commit

Permalink
Merge pull request #11 from sergeiNikolaev/v21.06
Browse files Browse the repository at this point in the history
UPDATE: plugin up to date with Sofa v21.06
  • Loading branch information
sergeiNikolaev authored Feb 17, 2022
2 parents e45e121 + 5cf701e commit 2d48b7a
Show file tree
Hide file tree
Showing 109 changed files with 3,654 additions and 3,166 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-18.04]
python-version: [3.7]
python-version: ['3.10']
env:
SOFA_ROOT_DIRECTORY: /opt/sofa
SOFA_BUILD_DIRECTORY: /opt/sofa/build_release
Expand All @@ -31,13 +31,13 @@ jobs:

- name: Install requirements
run: |
sudo apt install -qq libeigen3-dev libboost-all-dev libpthread-stubs0-dev libblas-dev freeglut3 freeglut3-dev libglew-dev
sudo apt install -qq libeigen3-dev libboost-all-dev libblas-dev freeglut3 freeglut3-dev libglew-dev
python3 -m pip install --upgrade pip
python3 -m pip install numpy pyyaml
- name: Build pybind11
run: |
git clone -b v2.4 --depth 1 https://github.com/pybind/pybind11.git /tmp/pybind11
git clone -b v2.8 --depth 1 https://github.com/pybind/pybind11.git /tmp/pybind11
cd /tmp/pybind11
cmake -DPYBIND11_TEST=OFF .
cmake -DPYBIND11_TEST=OFF .
Expand All @@ -50,7 +50,7 @@ jobs:
- name: Build SOFA
run: |
git clone --branch v20.12 https://github.com/sofa-framework/sofa.git $SOFA_ROOT_DIRECTORY
git clone --branch v21.06 https://github.com/sofa-framework/sofa.git $SOFA_ROOT_DIRECTORY
mkdir $SOFA_BUILD_DIRECTORY
cd $SOFA_BUILD_DIRECTORY
cmake -DSOFAGUI_QGLVIEWER=OFF -DSOFAGUI_QT=OFF -DSOFAGUI_QTVIEWER=OFF ..
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Build python3 plugin
run: |
git clone --branch v20.12 https://github.com/sofa-framework/SofaPython3.git $SOFA_PYTHON3_DIRECTORY
git clone --branch v21.06 https://github.com/sofa-framework/SofaPython3.git $SOFA_PYTHON3_DIRECTORY
mkdir $SOFA_PYTHON3_BUILD_DIRECTORY
cd $SOFA_PYTHON3_BUILD_DIRECTORY
cmake -DCMAKE_PREFIX_PATH=$SOFA_BUILD_DIRECTORY/install ..
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ find_package(Eigen3 3.3 REQUIRED NO_MODULE)


include_directories(${EIGEN3_INCLUDE_DIR})
set(LINKER_DEPENDENCIES SofaCore SofaBase SofaGeneralAnimationLoop SofaGeneralEngine SofaImplicitOdeSolver SofaGeneralLinearSolver SofaGeneralRigid SofaBoundaryCondition SofaBaseTopology SofaExporter SofaUserInteraction SofaConstraint SofaSimpleFem SofaGeneralTopology SofaTopologyMapping SofaUserInteraction SofaConstraint SofaGeneralLoader SofaMiscEngine SofaMiscFem SofaMiscForceField SofaMiscMapping SofaMiscSolver SofaMiscTopology SofaGuiCommon blas pthread Eigen3::Eigen)
set(LINKER_DEPENDENCIES SofaCore SofaBase SofaGeneralAnimationLoop SofaGeneralEngine SofaImplicitOdeSolver SofaGeneralLinearSolver SofaGeneralRigid SofaBoundaryCondition SofaBaseTopology SofaExporter SofaUserInteraction SofaConstraint SofaSimpleFem SofaGeneralTopology SofaTopologyMapping SofaUserInteraction SofaConstraint SofaGeneralLoader SofaMiscEngine SofaMiscFem SofaMiscForceField SofaMiscMapping SofaMiscSolver SofaMiscTopology SofaGuiCommon blas Eigen3::Eigen)
set(COMPILATION_FLAGS "-DSOFA_BUILD_OPTIMUS -Wno-unused-local-typedef -Wno-deprecated")

set(STOCHASTIC_FILTERING "1" CACHE BOOL "Set to activate the compilation of the filtering module" FORCE)
Expand Down Expand Up @@ -168,7 +168,7 @@ add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${README_FILE
if(SofaPardisoSolver_FOUND)
set(LINKER_DEPENDENCIES ${LINKER_DEPENDENCIES} SofaPardisoSolver)
else()
message("SofaPardisoSolver not found, some scenes may not work")
message("SofaPardisoSolver not found, PardisoSolver component will not work")
endif()

target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
Expand Down
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In order to obtain the plugin, it is necessary to perform git clone of the plugi
Requirements
------------

Except for SOFA, the plugin dependencies are BLAS, Eigen, pthread. It is highly recommended to use Pardiso solver with Optimus, as other solvers in SOFA are less reliable and might impact the estimation.
Except for SOFA, the plugin dependencies are Eigen and BLAS. It is highly recommended to use Pardiso solver with Optimus, as other solvers in SOFA are less reliable and might impact the estimation.


In-tree build
Expand Down
1 change: 1 addition & 0 deletions benchmarks/assimBC_synthBrick/assimBC_synthBrick_GenObs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='Deformable', pluginName='SofaDeformable')
rootNode.addObject('RequiredPlugin', name='MeshCollision', pluginName='SofaMeshCollision')
rootNode.addObject('RequiredPlugin', name='Loader', pluginName='SofaLoader')
rootNode.addObject('RequiredPlugin', name='Exporter', pluginName='SofaExporter')
rootNode.addObject('RequiredPlugin', name='Visual', pluginName='SofaOpenglVisual')
# rootNode.addObject('RequiredPlugin', name='Python3', pluginName='SofaPython3')
rootNode.addObject('RequiredPlugin', name='Optimus', pluginName='Optimus')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='GeneralImplicitOdeSolver', pluginName='SofaGeneralImplicitOdeSolver')
rootNode.addObject('RequiredPlugin', name='SparseSolver', pluginName='SofaSparseSolver')
rootNode.addObject('RequiredPlugin', name='BoundaryCondition', pluginName='SofaBoundaryCondition')
rootNode.addObject('RequiredPlugin', name='Loader', pluginName='SofaLoader')
rootNode.addObject('RequiredPlugin', name='DataLoader', pluginName='SofaLoader')
rootNode.addObject('RequiredPlugin', name='MiscForceField', pluginName='SofaMiscForceField')
rootNode.addObject('RequiredPlugin', name='Rigid', pluginName='SofaRigid')
rootNode.addObject('RequiredPlugin', name='SimpleFem', pluginName='SofaSimpleFem')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@


def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='SofaGeneralEngine')
rootNode.addObject('RequiredPlugin', name='GeneralEngine', pluginName='SofaGeneralEngine')
rootNode.addObject('RequiredPlugin', name='Engine', pluginName='SofaEngine')
rootNode.addObject('RequiredPlugin', name='BoundaryCondition', pluginName='SofaBoundaryCondition')
rootNode.addObject('RequiredPlugin', name='ImplicitOdeSolver', pluginName='SofaImplicitOdeSolver')
rootNode.addObject('RequiredPlugin', name='SparseSolver', pluginName='SofaSparseSolver')
rootNode.addObject('RequiredPlugin', name='MiscForceField', pluginName='SofaMiscForceField')
rootNode.addObject('RequiredPlugin', name='SimpleFem', pluginName='SofaSimpleFem')
rootNode.addObject('RequiredPlugin', name='Deformable', pluginName='SofaDeformable')
rootNode.addObject('RequiredPlugin', name='Loader', pluginName='SofaLoader')
rootNode.addObject('RequiredPlugin', name='Visual', pluginName='SofaOpenglVisual')
rootNode.addObject('RequiredPlugin', name='Optimus', pluginName='Optimus')
# rootNode.addObject('RequiredPlugin', name='Python3', pluginName='SofaPython3')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@


def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='SofaGeneralEngine')
rootNode.addObject('RequiredPlugin', name='GeneralEngine', pluginName='SofaGeneralEngine')
rootNode.addObject('RequiredPlugin', name='Engine', pluginName='SofaEngine')
rootNode.addObject('RequiredPlugin', name='BoundaryCondition', pluginName='SofaBoundaryCondition')
rootNode.addObject('RequiredPlugin', name='ImplicitOdeSolver', pluginName='SofaImplicitOdeSolver')
rootNode.addObject('RequiredPlugin', name='SparseSolver', pluginName='SofaSparseSolver')
rootNode.addObject('RequiredPlugin', name='MiscForceField', pluginName='SofaMiscForceField')
rootNode.addObject('RequiredPlugin', name='SimpleFem', pluginName='SofaSimpleFem')
rootNode.addObject('RequiredPlugin', name='Deformable', pluginName='SofaDeformable')
rootNode.addObject('RequiredPlugin', name='Loader', pluginName='SofaLoader')
rootNode.addObject('RequiredPlugin', name='Optimus', pluginName='Optimus')
# rootNode.addObject('RequiredPlugin', name='Python3', pluginName='SofaPython3')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='BoundaryCondition', pluginName='SofaBoundaryCondition')
rootNode.addObject('RequiredPlugin', name='SLoader', pluginName='SofaLoader')
rootNode.addObject('RequiredPlugin', name='SimpleFem', pluginName='SofaSimpleFem')
rootNode.addObject('RequiredPlugin', name='Exporter', pluginName='SofaExporter')
rootNode.addObject('RequiredPlugin', name='GraphComponent', pluginName='SofaGraphComponent')
# rootNode.addObject('RequiredPlugin', name='Python3', pluginName='SofaPython3')
rootNode.addObject('RequiredPlugin', name='Optimus', pluginName='Optimus')
Expand Down
47 changes: 0 additions & 47 deletions benchmarks/crontask/plugin_list.conf.default

This file was deleted.

12 changes: 4 additions & 8 deletions benchmarks/crontask/runOptimusTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ SOFA_PYTHON3_BUILD_DIRECTORY=$SOFA_PYTHON3_DIRECTORY/build_release
### export pardiso license
export PARDISO_LIC_PATH=$HOME_DIRECTORY/External_libraries/Pardiso
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME_DIRECTORY/External_libraries/Pardiso
export PYTHONPATH=$SOFA_PYTHON3_BUILD_DIRECTORY/lib/site-packages
export SOFA_ROOT=$BUILD_DIRECTORY/install
export PYTHONPATH=$SOFA_PYTHON3_BUILD_DIRECTORY/lib/python3/site-packages
export SOFA_PLUGIN_PATH=$OPTIMUS_BUILD_DIRECTORY


Expand Down Expand Up @@ -66,15 +67,10 @@ fi
echo "Recompile sofa sources"
cd $BUILD_DIRECTORY
/usr/bin/make clean
/usr/local/bin/cmake -DSOFA_BUILD_TESTS=ON -DSOFAGUI_BUILD_TESTS=ON -DSOFA_EXTERNAL_DIRECTORIES=/home/sergei/Optimus_test/sofaconfig/sergei .. 2>&1 >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
/usr/local/bin/cmake .. 2>&1 >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
/usr/bin/make -B -j 8 2>&1 >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
/usr/bin/make install 2>&1 >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt

### remove SofaPython plugin with python2 from the plugins default list (use local version of list)
cp $OPTIMUS_DIRECTORY/benchmarks/crontask/plugin_list.conf.default $BUILD_DIRECTORY/lib/plugin_list.conf.default
cp $OPTIMUS_DIRECTORY/benchmarks/crontask/plugin_list.conf.default $BUILD_DIRECTORY/install/lib/plugin_list.conf.default


echo "Recompile python3 plugin"
if ! [ -d "$SOFA_PYTHON3_BUILD_DIRECTORY" ]; then
mkdir $SOFA_PYTHON3_BUILD_DIRECTORY
Expand Down Expand Up @@ -106,7 +102,7 @@ do
cd $FOLDER
if [ -f $FOLDER/verify.sh ]; then
echo "Perform test: $FOLDER"
$FOLDER/verify.sh $BUILD_DIRECTORY/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
$FOLDER/verify.sh $BUILD_DIRECTORY/install/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
fi
done
echo "All tests have been executed"
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/crontask/runOptimusTests_without_compiling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ SOFA_PYTHON3_BUILD_DIRECTORY=$SOFA_PYTHON3_DIRECTORY/build_release
### export pardiso license
export PARDISO_LIC_PATH=$HOME_DIRECTORY/External_libraries/Pardiso
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME_DIRECTORY/External_libraries/Pardiso
export PYTHONPATH=$SOFA_PYTHON3_BUILD_DIRECTORY/lib/site-packages
export SOFA_ROOT=$BUILD_DIRECTORY/install
export PYTHONPATH=$SOFA_PYTHON3_BUILD_DIRECTORY/lib/python3/site-packages
export SOFA_PLUGIN_PATH=$OPTIMUS_BUILD_DIRECTORY


Expand All @@ -35,7 +36,7 @@ do
cd $FOLDER
if [ -f $FOLDER/verify.sh ]; then
echo "Perform test: $FOLDER"
$FOLDER/verify.sh $BUILD_DIRECTORY/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
$FOLDER/verify.sh $BUILD_DIRECTORY/install/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
fi
done
echo "All tests have been executed"
Expand Down
4 changes: 2 additions & 2 deletions src/genericComponents/AddNoiseEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
//#include <sofa/helper/accessor.h>



namespace sofa
{

Expand All @@ -36,8 +37,6 @@ namespace component
namespace engine
{

using namespace defaulttype;



SOFA_DECL_CLASS(AddNoiseEngine)
Expand All @@ -50,6 +49,7 @@ int AddNoiseEngineClass = core::RegisterObject("AddNoiseEngine")
template class AddNoiseEngine<defaulttype::Vec3Types>;



} // namespace engine

} // namespace component
Expand Down
8 changes: 4 additions & 4 deletions src/genericComponents/AddNoiseEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
#include <sofa/simulation/AnimateEndEvent.h>
#include <sofa/simulation/AnimateBeginEvent.h>

#include <sofa/defaulttype/Mat.h>
#include <sofa/defaulttype/Vec.h>
#include <sofa/type/Mat.h>
#include <sofa/type/Vec.h>

#include <sofa/core/topology/Topology.h>
#include <sofa/helper/AdvancedTimer.h>
#include <sofa/helper/gl/template.h>
#include <sofa/gl/template.h>

#include <random>
#include <chrono>
Expand Down Expand Up @@ -64,7 +64,7 @@ class AddNoiseEngine : public sofa::core::DataEngine
typedef typename DataTypes::Coord Coord;
typedef typename DataTypes::Deriv Deriv;
typedef typename DataTypes::Real Real;
typedef typename sofa::defaulttype::Vec3d Vector3;
typedef typename sofa::type::Vec3d Vector3;
typedef sofa::core::topology::Topology::Edge Edge;

AddNoiseEngine();
Expand Down
6 changes: 4 additions & 2 deletions src/genericComponents/CorrectionForceField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
******************************************************************************/

#include "genericComponents/CorrectionForceField.inl"
#include <sofa/core/visual/DrawTool.h>
#include <sofa/helper/visual/DrawTool.h>
#include <sofa/core/ObjectFactory.h>



namespace sofa
{

Expand All @@ -36,13 +38,13 @@ namespace forcefield

SOFA_DECL_CLASS(CorrectionForceField)


int CorrectionForceFieldClass = core::RegisterObject("Simple elastic springs applied to given degrees of freedom between their current and rest shape position")
.add< CorrectionForceField<defaulttype::Rigid3Types> >()
.add< CorrectionForceField<defaulttype::Vec3Types> >()
;



} // namespace forcefield

} // namespace component
Expand Down
30 changes: 14 additions & 16 deletions src/genericComponents/CorrectionForceField.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,27 @@ class CorrectionForceField : public core::behavior::ForceField<DataTypes>
typedef typename DataTypes::CPos CPos;
typedef typename DataTypes::Deriv Deriv;
typedef typename DataTypes::Real Real;
typedef helper::vector< unsigned int > VecIndex;
typedef helper::vector< Real > VecReal;
typedef type::vector< unsigned int > VecIndex;
typedef type::vector< Real > VecReal;
typedef sofa::component::topology::PointSubsetData< VecIndex > SetIndex;

typedef core::objectmodel::Data<VecCoord> DataVecCoord;
typedef core::objectmodel::Data<VecDeriv> DataVecDeriv;


Data< Deriv > d_force;
SetIndex d_indices;
Data< VecDeriv > d_forces;
Data<helper::vector<double>> d_Optimforces;
Data<double> d_delta;
Data<double> d_paramF;
SetIndex d_indices;
Data< VecDeriv > d_forces;
Data< type::vector<double> > d_Optimforces;
Data< double > d_delta;
Data< double > d_paramF;

type::vector<bool> m_active;


protected:
CorrectionForceField();

protected:
CorrectionForceField();
public:
/// BaseObject initialization method.
void bwdInit() override;
Expand All @@ -101,15 +104,10 @@ class CorrectionForceField : public core::behavior::ForceField<DataTypes>
return 0.0;
}


virtual void draw(const core::visual::VisualParams* /* vparams */) override;
void plusF();
void minusF();
void plusF();
void minusF();
void handleEvent(sofa::core::objectmodel::Event *event) override;

helper::vector<bool> m_active;


};


Expand Down
Loading

0 comments on commit 2d48b7a

Please sign in to comment.