Skip to content

Commit

Permalink
Merge pull request #478 from SofaDefrost/deprecate_elacticitytest_cre…
Browse files Browse the repository at this point in the history
…ateSunPlanetSystem

fix VariationalSymplecticImplicitSolverNonLinearForceDynamic_test
  • Loading branch information
Hugo authored Oct 18, 2017
2 parents 9863916 + 0e105d7 commit a759d27
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 81 deletions.
63 changes: 49 additions & 14 deletions applications/plugins/SofaTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,67 @@ project(SofaTest)

set(SOFATEST_VERSION 0.1)

################################ COMPONENTS HERE ARE THE NG-SET ####################################

set(HEADER_FILES
BroadPhase_test.h
DataEngine_test.h
Elasticity_test.h
Elasticity_test.inl
ForceField_test.h
InitPlugin_test.h
Mapping_test.h
MultiMapping_test.h
Multi2Mapping_test.h
PrimitiveCreation.h
Sofa_test.h
TestMessageHandler.h
#LogMessage.h
)

set(SOURCE_FILES
Elasticity_test.cpp
InitPlugin_test.cpp
PrimitiveCreation.cpp
TestMessageHandler.cpp
Sofa_test.cpp
)

set(PYTHON_FILES "")


############################## COMPONENTS HERE ARE THE LIGHT-SET ###################################
if(SOFA_BUILD_COMPONENTSET_LIGHT)
list(APPEND HEADER_FILES

)
list(APPEND SOURCE_FILES

)
endif()

############################## COMPONENTS HERE ARE THE STANDARD-SET ################################
if(SOFA_BUILD_COMPONENTSET_STANDARD)
list(APPEND HEADER_FILES
BroadPhase_test.h
DataEngine_test.h
Elasticity_test.h
Elasticity_test.inl
ForceField_test.h
Mapping_test.h
MultiMapping_test.h
Multi2Mapping_test.h
PrimitiveCreation.h
TestMessageHandler.h
#LogMessage.h
)
list(APPEND SOURCE_FILES
Elasticity_test.cpp
PrimitiveCreation.cpp
TestMessageHandler.cpp
)
endif()

############################### COMPONENTS HERE ARE DEPRECATED ####################################
if(SOFA_BUILD_COMPONENTSET_FULL)
list(APPEND HEADER_FILES
Elasticity_test_deprecated.h
Elasticity_test_deprecated.inl
)
list(APPEND SOURCE_FILES
Elasticity_test_deprecated.cpp
)

endif()



find_package(SofaFramework REQUIRED)
find_package(SofaMisc REQUIRED)
find_package(SceneCreator REQUIRED)
Expand Down
11 changes: 0 additions & 11 deletions applications/plugins/SofaTest/Elasticity_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@ simulation::Node::SPtr createMassSpringSystem(
VecCoord xMass,
VecDeriv vMass);

/// Create sun-planet system
simulation::Node::SPtr createSunPlanetSystem(
simulation::Node::SPtr root,
double mSun,
double mPlanet,
double g,
Coord xSun,
Deriv vSun,
Coord xPlanet,
Deriv vPlanet);

};


Expand Down
52 changes: 0 additions & 52 deletions applications/plugins/SofaTest/Elasticity_test.inl
Original file line number Diff line number Diff line change
Expand Up @@ -449,58 +449,6 @@ return root;

}

template<class DataTypes>
simulation::Node::SPtr Elasticity_test<DataTypes>::createSunPlanetSystem(
simulation::Node::SPtr root,
double mSun,
double mPlanet,
double g,
Coord xSun,
Deriv vSun,
Coord xPlanet,
Deriv vPlanet)
{

// Mechanical object with 2 dofs: first sun, second planet
MechanicalObject3::SPtr sunPlanet_dof = modeling::addNew<MechanicalObject3>(root,"sunPlanet_MO");

// Set position and velocity
sunPlanet_dof->resize(2);
// Position
MechanicalObject3::VecCoord positions(2);
positions[0] = xSun;
positions[1]= xPlanet;
MechanicalObject3::WriteVecCoord xdof = sunPlanet_dof->writePositions();
copyToData( xdof, positions );
// Velocity
MechanicalObject3::VecDeriv velocities(2);
velocities[0] = vSun;
velocities[1]= vPlanet;
MechanicalObject3::WriteVecDeriv vdof = sunPlanet_dof->writeVelocities();
copyToData( vdof, velocities );

// Fix sun
FixedConstraint3::SPtr fixed = modeling::addNew<FixedConstraint3>(root,"FixedSun");
fixed->addConstraint(0);

// Uniform Mass
UniformMass3::SPtr massPtr = modeling::addNew<UniformMass3>(root,"mass");
massPtr->d_totalMass.setValue(mPlanet + mSun);

// Lennard Jones Force Field
//TODO: Find another FF to add in this test. If Sympletic solver are not deprecated. Erik STC #4
//typename component::forcefield::LennardJonesForceField<DataTypes>::SPtr ff =
// modeling::addNew<typename component::forcefield::LennardJonesForceField<DataTypes> >(root);
//// Set froce field parameters
//ff->setAlpha(1);
//ff->setBeta(-1);
//ff->setAInit(mPlanet*mSun*g);

return root;

}


}// sofa

#endif
Expand Down
12 changes: 12 additions & 0 deletions applications/plugins/SofaTest/Elasticity_test_deprecated.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "Elasticity_test_deprecated.inl"
namespace sofa {

using namespace sofa::defaulttype;

#ifdef SOFA_WITH_DOUBLE
template struct SOFA_TestPlugin_API Elasticity_test_deprecated<sofa::defaulttype::Vec3dTypes>;
#endif
#ifdef SOFA_WITH_FLOAT
template struct SOFA_TestPlugin_API Elasticity_test_deprecated<sofa::defaulttype::Vec3fTypes>;
#endif
}
55 changes: 55 additions & 0 deletions applications/plugins/SofaTest/Elasticity_test_deprecated.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture, development version *
* (c) 2006-2017 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation; either version 2 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef SOFA_Elasticity_test_deprecated_H
#define SOFA_Elasticity_test_deprecated_H


#include "Elasticity_test.h"

namespace sofa {

template< class DataTypes>
struct SOFA_TestPlugin_API Elasticity_test_deprecated: public Elasticity_test<DataTypes>
{
typedef component::container::MechanicalObject<DataTypes> DOFs;
typedef typename DOFs::Coord Coord;
typedef typename DOFs::Deriv Deriv;

/// Create sun-planet system
simulation::Node::SPtr createSunPlanetSystem(
simulation::Node::SPtr root,
double mSun,
double mPlanet,
double g,
Coord xSun,
Deriv vSun,
Coord xPlanet,
Deriv vPlanet);

};




} // namespace sofa

#endif
120 changes: 120 additions & 0 deletions applications/plugins/SofaTest/Elasticity_test_deprecated.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture, development version *
* (c) 2006-2017 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation; either version 2 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef SOFA_Elasticity_test_deprecated_INL
#define SOFA_Elasticity_test_deprecated_INL

#include "Elasticity_test_deprecated.h"

// Solvers
#include <SofaImplicitOdeSolver/EulerImplicitSolver.h>
#include <SofaImplicitOdeSolver/StaticSolver.h>
#include <SofaBaseLinearSolver/CGLinearSolver.h>

// Box roi
#include <SofaGeneralEngine/PairBoxRoi.h>
#include <SofaEngine/BoxROI.h>
#include <SofaGeneralEngine/GenerateCylinder.h>

// Constraint
#include <SofaBoundaryCondition/ProjectToLineConstraint.h>
#include <SofaBoundaryCondition/FixedConstraint.h>
#include <SofaBoundaryCondition/AffineMovementConstraint.h>
#include <SofaBoundaryCondition/FixedPlaneConstraint.h>

// ForceField
#include <SofaBoundaryCondition/TrianglePressureForceField.h>
#include <SofaMiscForceField/LennardJonesForceField.h>

#include <SofaBaseMechanics/MechanicalObject.h>
#include <SofaBaseMechanics/UniformMass.h>
#include <SofaBaseTopology/RegularGridTopology.h>
#include <SofaBaseTopology/TetrahedronSetGeometryAlgorithms.h>
#include <SofaBaseVisual/VisualStyle.h>
#include <SofaGeneralDeformable/RegularGridSpringForceField.h>
#include <SofaDeformable/StiffSpringForceField.h>
#include <SofaMiscForceField/MeshMatrixMass.h>
#include <SofaMiscMapping/SubsetMultiMapping.h>
#include <SofaRigid/RigidMapping.h>

namespace sofa
{

typedef component::container::MechanicalObject<defaulttype::Vec3Types> MechanicalObject3;
typedef component::projectiveconstraintset::FixedConstraint<defaulttype::Vec3Types> FixedConstraint3;
typedef component::mass::UniformMass<defaulttype::Vec3Types, SReal> UniformMass3;

template<class DataTypes>
simulation::Node::SPtr Elasticity_test_deprecated<DataTypes>::createSunPlanetSystem(
simulation::Node::SPtr root,
double mSun,
double mPlanet,
double g,
Coord xSun,
Deriv vSun,
Coord xPlanet,
Deriv vPlanet)
{

// Mechanical object with 2 dofs: first sun, second planet
MechanicalObject3::SPtr sunPlanet_dof = modeling::addNew<MechanicalObject3>(root,"sunPlanet_MO");

// Set position and velocity
sunPlanet_dof->resize(2);
// Position
MechanicalObject3::VecCoord positions(2);
positions[0] = xSun;
positions[1]= xPlanet;
MechanicalObject3::WriteVecCoord xdof = sunPlanet_dof->writePositions();
copyToData( xdof, positions );
// Velocity
MechanicalObject3::VecDeriv velocities(2);
velocities[0] = vSun;
velocities[1]= vPlanet;
MechanicalObject3::WriteVecDeriv vdof = sunPlanet_dof->writeVelocities();
copyToData( vdof, velocities );

// Fix sun
FixedConstraint3::SPtr fixed = modeling::addNew<FixedConstraint3>(root,"FixedSun");
fixed->addConstraint(0);

// Uniform Mass
UniformMass3::SPtr massPtr = modeling::addNew<UniformMass3>(root,"mass");
massPtr->d_totalMass.setValue(mPlanet + mSun);

// Lennard Jones Force Field
//TODO: Find another FF to add in this test. If Sympletic solver are not deprecated. Erik STC #4
typename component::forcefield::LennardJonesForceField<DataTypes>::SPtr ff =
modeling::addNew<typename component::forcefield::LennardJonesForceField<DataTypes> >(root);
// Set froce field parameters
ff->setAlpha(1);
ff->setBeta(-1);
ff->setAInit(mPlanet*mSun*g);

return root;

}


}// sofa

#endif

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ project(SofaGeneralImplicitOdeSolver_test)

message(STATUS "SofaGeneralImplicitOdeSolver_test:")
################################ COMPONENTS HERE ARE THE NG-SET ####################################
set(SOURCE_FILES
VariationalSymplecticImplicitSolverNonLinearForceDynamic_test.cpp)
set(SOURCE_FILES ""
)

############################## COMPONENTS HERE ARE THE LIGHT-SET ###################################
if(SOFA_BUILD_COMPONENTSET_LIGHT)
Expand All @@ -30,6 +30,9 @@ endif()

############################### COMPONENTS HERE ARE DEPRECATED ####################################
if(SOFA_BUILD_COMPONENTSET_FULL)
list(APPEND SOURCE_FILES
VariationalSymplecticImplicitSolverNonLinearForceDynamic_test.cpp
)

endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <SofaTest/Elasticity_test.h>
#include <SofaTest/Elasticity_test_deprecated.h>
#include <SceneCreator/SceneCreator.h>

#include <sofa/core/ExecParams.h>
Expand Down Expand Up @@ -67,7 +67,7 @@ Check if Hamiltonian energy is constant during simulation: variational solver is
*/

template <typename _DataTypes>
struct VariationalSymplecticImplicitSolverNonLinearForceDynamic_test : public Elasticity_test<_DataTypes>
struct VariationalSymplecticImplicitSolverNonLinearForceDynamic_test : public Elasticity_test_deprecated<_DataTypes>
{
typedef _DataTypes DataTypes;
typedef typename DataTypes::Coord Coord;
Expand Down

0 comments on commit a759d27

Please sign in to comment.