File kernel/src/modelingTools/Interaction.hpp#
Go to the source code of this file
Interaction class and related typedef.
-
class Interaction : public std::enable_shared_from_this<Interaction>
- #include <Interaction.hpp>
Description of a non-smooth interaction.
The object Interaction is used to defined a “link” between one or two DynamicalSystem, like unilateral constraints and some nonsmooth law (e.g. complementarity).
It holds two vectors of “local” variables, \( y \) and \( \lambda \) and their derivatives, which are related to the state variables and the inputs of the DynamicalSystem (x,R) through constraints defined in a Relation and completed with a NonSmoothLaw involving those variables.
Remarks:
one and only one Relation (access: relation()) per Interaction
one and only one NonSmoothLaw (access: nonSmoothLaw()) per Interaction
dimension() is the size of the interaction and so the size of vectors y, lambda and their derivatives.
output: y(i), to get derivative i of y
input: lambda(i), to get derivative i of lambda
DSlink graph property management
-
void __initDataFirstOrder(VectorOfBlockVectors &DSlink, DynamicalSystem &ds1, DynamicalSystem &ds2)#
update DSlink property content with dynamical systems members, FirstOrder relations case.
- Parameters:
DSlink – the container of the link to DynamicalSystem attributes
ds1 – first ds linked to this Interaction
ds2 – second ds linked to this Interaction. ds1 == ds2 is allowed.
-
void __initDSDataFirstOrder(DynamicalSystem &ds, VectorOfBlockVectors &DSlink)#
Initialize the link with the DynamicalSystem, FirstOrderDS variant.
- Parameters:
ds – a DynamicalSystem concerned by this Interaction
DSlink – the container of the link to DynamicalSystem attributes
-
void __initDataLagrangian(VectorOfBlockVectors &DSlink, DynamicalSystem &ds1, DynamicalSystem &ds2)#
update DSlink property content with dynamical systems members, Lagrangian relations case.
- Parameters:
DSlink – the container of the link to DynamicalSystem attributes
ds1 – first ds linked to this Interaction
ds2 – second ds linked to this Interaction. ds1 == ds2 is allowed.
-
void __initDSDataLagrangian(DynamicalSystem &ds, VectorOfBlockVectors &DSlink)#
Initialize the link with the DynamicalSystem, LagrangianDS variant.
- Parameters:
ds – a DynamicalSystem concerned by this Interaction
DSlink – the container of the link to DynamicalSystem attributes
-
void __initDataNewtonEuler(VectorOfBlockVectors &DSlink, DynamicalSystem &ds1, DynamicalSystem &ds2)#
update DSlink property content with dynamical systems members, NewtonEuler relations case.
- Parameters:
DSlink – the container of the link to DynamicalSystem attributes
ds1 – first ds linked to this Interaction
ds2 – second ds linked to this Interaction. ds1 == ds2 is allowed.
-
void __initDSDataNewtonEuler(DynamicalSystem &ds, VectorOfBlockVectors &DSlink)#
Initialize the link with the DynamicalSystem, NewtonEulerDS variant.
- Parameters:
ds – a DynamicalSystem concerned by this Interaction
DSlink – the container of the link to DynamicalSystem attributes
Public Functions
-
Interaction(SP::NonSmoothLaw NSL, SP::Relation rel)
Interaction constructor.
- Parameters:
NSL – pointer object describing the nonsmooth law; the interaction size if infered from the size of this law.
rel – a pointer object describing the functions used to compute the constraints
-
inline ~Interaction()
destructor
-
void reset()
Update interactions attributes.
Must be called when levels have been modified.
-
void initializeLinkToDsVariables(DynamicalSystem &ds1, DynamicalSystem &ds2)
set the links to the DynamicalSystem(s) and allocate the required workspaces
- Parameters:
interProp – the InteractionProperties of this Interaction
ds1 – first ds linked to this Interaction (i.e IG->vertex.source)
workV1 – work vectors of ds1
ds2 – second ds linked to this Interaction (i.e IG->vertex.target) ds1 == ds2 is allowed.
workV2 – work vectors of ds2 set the links between the interaction and the DynamicalSystem(s) members.
ds1 – first ds linked to this Interaction (i.e IG->vertex.source)
ds2 – second ds linked to this Interaction (i.e IG->vertex.target) ds1 == ds2 is allowed
-
void resetAllLambda()
set all lambda to zero
-
void resetLambda(unsigned int level)
set lambda to zero for a given level
- Parameters:
level –
-
void initializeMemory(unsigned int steps)
build memories vectors for y and \( \lambda \)
- Parameters:
computeResiduY – true if interaction should compute extra residu value
steps – number of required memories (depends on the OSI)
-
inline size_t number() const
- Returns:
the id of the interaction
-
inline void setLowerLevelForOutput(const unsigned int newVal)
Set the lower level for output y.
- Parameters:
newVal – : an unsigned int
-
inline void setUpperLevelForOutput(const unsigned int newVal)
Set the upper level for output y.
- Parameters:
newVal – : an unsigned int
-
inline unsigned int lowerLevelForOutput()
Get the lower level for output y.
- Returns:
an unsigned int.
-
inline unsigned int upperLevelForOutput()
Get the upper level for output y.
- Returns:
an unsigned int.
-
inline void setLowerLevelForInput(const unsigned int newVal)
Set the lower level for input Lambda.
- Parameters:
newVal – : an unsigned int
-
inline void setUpperLevelForInput(const unsigned int newVal)
Set the upper level for input Lambda.
- Parameters:
newVal – : an unsigned int.
-
inline unsigned int lowerLevelForInput()
Get the lower level for input Lambda.
- Returns:
an unsigned int.
-
inline unsigned int upperLevelForInput()
Get the upper level for input Lambda.
- Returns:
an unsigned int.
-
inline unsigned int dimension() const
returns dimension (i.e.
nslaw size == y and lambda size)
-
inline unsigned int getSizeOfDS() const
- Returns:
the sum of DS sizes, for DS involved in interaction
-
inline void setHas2Bodies(bool val)
Set the number of dynamical systems concerned by this interaction.
Warning FP: this function is supposed to be called only during topology->link(inter, ds1, ds2) call.
- Parameters:
val – : true if two ds, else false
-
inline bool has2Bodies() const
Check the number of dynamical systems concerned by this interaction.
- Returns:
bool : true if two ds, else false
-
inline const SiconosVector getCopyOfy(const unsigned int i) const
Get y[i], derivative number i of output.
- Parameters:
i – : the derivative number
- Returns:
-
inline const VectorOfVectors y() const
get vector of output derivatives
- Returns:
a VectorOfVectors
-
inline SP::SiconosVector y(const unsigned int i) const
get y[i], derivative number i of output
- Parameters:
i – derivative number i of output
- Returns:
pointer on a SiconosVector
-
void setY(const VectorOfVectors &v)
set the output vector y to newVector with copy of the y[i] (ie memory allocation)
- Parameters:
v – VectorOfVectors
-
void setYPtr(const VectorOfVectors &v)
set the output vector y to newVector with direct pointer equality for the y[i]
- Parameters:
v – VectorOfVectors
-
void setY(const unsigned int i, const SiconosVector &v)
set y[i] to newValue
- Parameters:
i – derivative number i of output
v – a SiconosVector and an unsigned int
-
void setYPtr(const unsigned int i, SP::SiconosVector v)
set y[i] to pointer newPtr
- Parameters:
i – derivative number i of output
v – a SP::SiconosVector and an unsigned int
-
inline SiconosMemory &yMemory(unsigned int level)
get all the values of the output y stored in memory
- Parameters:
level –
- Returns:
a memory
-
inline const SiconosVector &y_k(const unsigned int i) const
get the last value of the output y stored in memory
- Parameters:
level –
- Returns:
a SiconosVector reference
-
inline const VectorOfVectors getLambda() const
get vector of input derivatives
- Returns:
a VectorOfVectors
-
inline const SiconosVector getLambda(const unsigned int i) const
get _lambda[i], derivative number i of input
- Parameters:
i – derivative number i of output
- Returns:
-
inline SP::SiconosVector lambda(const unsigned int i) const
get _lambda[i], derivative number i of input
- Parameters:
i – derivative number i of output
- Returns:
pointer on a SiconosVector
-
inline SiconosMemory &lambdaMemory(unsigned int level)
get all the values of the multiplier lambda stored in memory
- Parameters:
level –
- Returns:
a memory
-
inline const SiconosVector &lambda_k(const unsigned int i) const
get the last value of the multiplier lambda stored in memory
- Parameters:
level –
- Returns:
a SiconosVector reference
-
void setLambda(const VectorOfVectors &v)
set the input vector _lambda to newVector
- Parameters:
v – VectorOfVectors
-
void setLambdaPtr(const VectorOfVectors &v)
set vector _lambda to newVector with direct pointer equality for the _lambda[i]
- Parameters:
v – VectorOfVectors
-
void setLambda(const unsigned int i, const SiconosVector &newValue)
set _lambda[i] to newValue
- Parameters:
i – derivative number i of output
newValue – a SiconosVector
-
void setLambdaPtr(const unsigned int i, SP::SiconosVector newPtr)
set _lambda[i] to pointer newPtr
- Parameters:
i – derivative number i of output
newPtr – a SP::SiconosVector
-
inline SP::Relation relation() const
get the Relation of this Interaction
- Returns:
a pointer on this Relation
-
inline SP::NonSmoothLaw nonSmoothLaw() const
get the NonSmoothLaw of this Interaction
- Returns:
a pointer on this NonSmoothLaw
-
inline VectorOfBlockVectors &linkToDSVariables()#
-
inline VectorOfVectors &relationVectors()#
-
inline VectorOfSMatrices &relationMatrices()#
-
inline void setDSSizes(unsigned int s1)
set interaction ‘ds-dimension’, i.e.
sum of all sizes of the dynamical systems linked by the current interaction. This must be done by topology during call to link(inter, ds, …).
- Parameters:
s1 – int sum of ds sizes
-
void swapInMemory()
Must be call to fill the memory.
(after convergence of the Newton iterations)
-
void display(bool brief = true) const
print the data to the screen
-
void computeOutput(double time, unsigned int derivativeNumber = 0)
Computes output y, depends on the relation type.
- Parameters:
time – current time
derivativeNumber – number of the derivative to compute, optional, default = 0
-
void computeInput(double time, unsigned int level = 0)
Compute input r of all Dynamical Systems involved in the present Interaction.
- Parameters:
time – current time
level – order of _lambda used to compute input.
-
SP::SiconosMatrix getLeftInteractionBlock() const
gets the matrix used in interactionBlock computation, (left * W * right), depends on the relation type (ex, LinearTIR, left = C, right = B).
- Returns:
InteractionBlock a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
-
SP::SiconosMatrix getLeftInteractionBlockForDS(unsigned int pos, unsigned int size, unsigned int sizeDS) const
gets the matrix used in interactionBlock computation
(left * W * right), depends on the relation type (ex, LinearTIR, left = C, right = B). We get only the part corresponding to one ds.
- Parameters:
pos – int, relative position of the beginning of the required block in relation matrix.
size – int, size(0) of the block
sizeDS – int, size(1) of the block
- Returns:
InteractionBlock a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
-
void getLeftInteractionBlockForDSProjectOnConstraints(unsigned int pos, SP::SiconosMatrix InteractionBlock) const
gets the matrix used in interactionBlock computation.
Used only for the formulation projecting on the constraints. We get only the part corresponding to ds.
- Parameters:
pos – int, relative position of the beginning of the required block in relation matrix.
InteractionBlock – a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
-
SP::SiconosMatrix getRightInteractionBlockForDS(unsigned int pos, unsigned int sizeDS, unsigned size) const
gets the matrix used in interactionBlock computation
(left * W * rigth), depends on the relation type (ex, LinearTIR, left = C, right = B). We get only the part corresponding to ds.
- Parameters:
pos – int, relative position of the beginning of the required block in relation matrix.
sizeDS – int, size(0) of the block
size – int, size(1) of the block
- Returns:
InteractionBlock a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
-
void getExtraInteractionBlock(SP::SiconosMatrix InteractionBlock) const
gets extra interactionBlock corresponding to the present Interaction
- Parameters:
InteractionBlock – [inout] SP::SiconosMatrix
Public Static Functions
-
static inline size_t resetCount(size_t new_count = 0)
reset the global Interaction counter (for ids)
- Returns:
the previous value of count
Protected Functions
-
inline Interaction()#
Private Functions
-
ACCEPT_SERIALIZATION(Interaction)#
-
Interaction(const Interaction &inter) = delete#
-
Interaction &operator=(const Interaction&) = delete#
Private Members
-
size_t _number#
Interaction id.
-
unsigned int _lowerLevelForOutput = 0#
Minimum required ‘level’ for output y y will be initialized from y[_lowerLevelForOutput] to y[_upperLevelForOutput].
-
unsigned int _upperLevelForOutput = 0#
Maximum required ‘level’ for output y y will be initialized from y[_lowerLevelForOutput] to y[_upperLevelForOutput].
-
unsigned int _lowerLevelForInput = 0#
Minimum required ‘level’ for input lambda lambda will be initialized from lambda[_lowerLevelForIntput] to lambda[_upperLevelForInput].
-
unsigned int _upperLevelForInput = 0#
Maximum required ‘level’ for input lambda lambda will be initialized from lambda[_lowerLevelForIntput] to lambda[_upperLevelForInput].
-
unsigned int _interactionSize = 0#
size of the interaction, ie size of y[i] and _lambda[i]
-
unsigned int _sizeOfDS = 0#
sum of all DS sizes, for DS involved in the interaction
-
bool _has2Bodies = false#
Bool to check the number of DS concerned by this interaction (1 or 2 indeed) True if 2 DS.
Note FP : usefull in NewtonEuler jacobians computation.
-
VectorOfVectors _y#
relation between constrained variables and states variables vector of output derivatives y[0] is y, y[1] is yDot and so on
-
VectorOfMemories _yMemory#
memory of previous coordinates of the system
-
VectorOfVectors _lambda#
result of the computeInput function
-
VectorOfMemories _lambdaMemory#
memory of previous coordinates of the system
-
VectorOfBlockVectors _linkToDSVariables#
pointer links to DS variables needed for computation, mostly used in Relations (computeOutput and computeInput) and OneStepIntegrator classes.
-
VectorOfSMatrices _relationMatrices#
-
VectorOfVectors _relationVectors#
Private Static Attributes
-
static size_t __count#
Friends
- friend struct Interaction::_setLevels