SOFA API  ca665544
Open source framework for multi-physics simuation
sofa::MultiMapping_test< _MultiMapping > Struct Template Reference

#include <MultiMappingTestCreation.h>

Base class for the MultiMapping tests, directly adapted from Mapping_test. More...

Inheritance diagram for sofa::MultiMapping_test< _MultiMapping >:

Detailed Description

template<class _MultiMapping>
struct sofa::MultiMapping_test< _MultiMapping >

Base class for the MultiMapping tests, directly adapted from Mapping_test.

See also
Mapping_test
Author
François Faure
Date
2014

Public Attributes

core::MultiMapping< In, Out > * mapping
 the mapping to be tested More...
 
type::vector< typename InDOFs::SPtrinDofs
 mapping input More...
 
OutDOFs::SPtr outDofs
 mapping output More...
 
simulation::Node::SPtr root
 Root of the scene graph, created by the constructor an re-used in the tests. More...
 
simulation::Node::SPtr child
 Child node, created by setupScene. More...
 
type::vector< simulation::Node::SPtrparents
 Parent nodes, created by setupScene. More...
 
simulation::Simulationsimulation
 created by the constructor an re-used in the tests More...
 
std::pair< Real, RealdeltaRange
 The minimum and maximum magnitudes of the change of each scalar value of the small displacement is deltaRange * numeric_limits<Real>::epsilon. This epsilon is 1.19209e-07 for float and 2.22045e-16 for double. More...
 
Real errorMax
 The test is successful if the (infinite norm of the) difference is less than maxError * numeric_limits<Real>::epsilon. More...
 
- Public Attributes inherited from sofa::testing::BaseTest
sofa::testing::MessageAsTestFailure m_fatal
 
sofa::testing::MessageAsTestFailure m_error
 

Public Member Functions

 MultiMapping_test ()
 
void setupScene (int numParents)
 
OutDeriv difference (const OutCoord &c1, const OutCoord &c2)
 
bool runTest (const type::vector< InVecCoord > &parentCoords, const OutVecCoord &expectedChildCoords)
 
 ~MultiMapping_test () override
 
- Public Member Functions inherited from sofa::testing::BaseSimulationTest
 BaseSimulationTest ()
 
bool importPlugin (const std::string &name)
 
- Public Member Functions inherited from sofa::testing::BaseTest
 BaseTest ()
 Initialize Sofa and the random number generator. More...
 
 ~BaseTest () override
 
virtual void onSetUp ()
 
virtual void onTearDown ()
 
- Public Member Functions inherited from sofa::testing::NumericTest< _MultiMapping::In::Real >
 NumericTest ()
 
Real vectorMaxDiff (const Container1 &c1, const Container2 &c2)
 Return the maximum difference between two containers. Issues a failure if sizes are different. More...
 
Real vectorMaxAbs (const Container &c)
 Return the maximum absolute value of a container. More...
 

Additional Inherited Members

- Static Public Attributes inherited from sofa::testing::BaseTest
static int seed = (unsigned int)time(nullptr)
 Seed value. More...
 
- Static Public Member Functions inherited from sofa::testing::NumericTest< _MultiMapping::In::Real >
static Real matrixMaxDiff (const Matrix1 &m1, const Matrix2 &m2)
 return the maximum difference between corresponding entries, or the infinity if the matrices have different sizes More...
 
static Real matrixMaxDiff (const sofa::type::Mat< M, N, Real > &m1, const Matrix2 &m2)
 Return the maximum difference between corresponding entries, or the infinity if the matrices have different sizes. More...
 
static Real epsilon ()
 the smallest real number More...
 
static Real infinity ()
 Infinity. More...
 
static bool isSmall (Real r, Real ratio=1.)
 true if the magnitude of r is less than ratio*epsilon More...
 
static Real vectorMaxDiff (const sofa::type::Vec< N, Real > &m1, const Vector2 &m2)
 return the maximum difference between corresponding entries, or the infinity if the vectors have different sizes More...
 
static Real vectorMaxDiff (const sofa::type::Vec< N, Real > &m1, const sofa::type::Vec< N, Real > &m2)
 return the maximum difference between corresponding entries More...
 
- Static Protected Member Functions inherited from sofa::testing::NumericTest< _MultiMapping::In::Real >
static float norm (float a)
 
static double norm (double a)
 
static Real norm (T a)
 

Attribute details

◆ child

template<class _MultiMapping >
simulation::Node::SPtr sofa::MultiMapping_test< _MultiMapping >::child

Child node, created by setupScene.

◆ deltaRange

template<class _MultiMapping >
std::pair<Real,Real> sofa::MultiMapping_test< _MultiMapping >::deltaRange

The minimum and maximum magnitudes of the change of each scalar value of the small displacement is deltaRange * numeric_limits<Real>::epsilon. This epsilon is 1.19209e-07 for float and 2.22045e-16 for double.

◆ errorMax

template<class _MultiMapping >
Real sofa::MultiMapping_test< _MultiMapping >::errorMax

The test is successful if the (infinite norm of the) difference is less than maxError * numeric_limits<Real>::epsilon.

◆ inDofs

template<class _MultiMapping >
type::vector<typename InDOFs::SPtr> sofa::MultiMapping_test< _MultiMapping >::inDofs

mapping input

◆ mapping

template<class _MultiMapping >
core::MultiMapping<In,Out>* sofa::MultiMapping_test< _MultiMapping >::mapping

the mapping to be tested

◆ outDofs

template<class _MultiMapping >
OutDOFs::SPtr sofa::MultiMapping_test< _MultiMapping >::outDofs

mapping output

◆ parents

template<class _MultiMapping >
type::vector<simulation::Node::SPtr> sofa::MultiMapping_test< _MultiMapping >::parents

Parent nodes, created by setupScene.

◆ root

template<class _MultiMapping >
simulation::Node::SPtr sofa::MultiMapping_test< _MultiMapping >::root

Root of the scene graph, created by the constructor an re-used in the tests.

◆ simulation

template<class _MultiMapping >
simulation::Simulation* sofa::MultiMapping_test< _MultiMapping >::simulation

created by the constructor an re-used in the tests

Constructor details

◆ MultiMapping_test()

template<class _MultiMapping >
sofa::MultiMapping_test< _MultiMapping >::MultiMapping_test ( )
inline

◆ ~MultiMapping_test()

template<class _MultiMapping >
sofa::MultiMapping_test< _MultiMapping >::~MultiMapping_test ( )
inlineoverride

Function details

◆ difference()

template<class _MultiMapping >
OutDeriv sofa::MultiMapping_test< _MultiMapping >::difference ( const OutCoord c1,
const OutCoord c2 
)
inline

Returns OutCoord subtraction a-b (should return a OutDeriv, but???)

◆ runTest()

template<class _MultiMapping >
bool sofa::MultiMapping_test< _MultiMapping >::runTest ( const type::vector< InVecCoord > &  parentCoords,
const OutVecCoord expectedChildCoords 
)
inline

Test the mapping using the given values and small changes. Return true in case of success, if all errors are below maxError*epsilon. The parent position is applied, the resulting child position is compared with the expected one. Additionally, the Jacobian-related methods are tested using finite differences.

The parent coordinates are transferred in the parent states, then the scene is initialized, then various mapping functions are applied. The parent states are resized based on the size of the parentCoords vectors. The child state is not resized. Its should be already sized, or its size set automatically during initialization.

Parameters
parentCoordsParent positions (one InVecCoord per parent)
expectedChildCoordsexpected position of the child corresponding to the parent positions

◆ setupScene()

template<class _MultiMapping >
void sofa::MultiMapping_test< _MultiMapping >::setupScene ( int  numParents)
inline

Create scene with given number of parent states. Currently, only one child state is handled. All the parents are set as child of the root node, while the child is in a child node.