File kernel/src/modelingTools/Interaction.hpp

Go to the source code of this file

Interaction class and related typedef.

class Interaction : public std11::enable_shared_from_this<Interaction>
#include <Interaction.hpp>

Non-smooth interaction involving 1 or 2 Dynamical Systems.

An interaction represents the “link” between a set of Dynamical Systems. The state variables and inputs of the DynamicalSystem (x,R) are related to the interaction variables (y,lambda) thanks to the interaction with the help of the relation The interaction completed by a non-smooth law that describes the type of law between y and lambda.

Thus, the interaction main members are:

  • relation: a pointer to a Relation object that determines the type of relation and so the way it is computed. Warning: there is only one Relation object (ie only one type of relation for an interaction) but there can be several “relations”, in the sense of constraints equations between (y,lambda) and (x,r).

  • nslaw: the nonsmooth law

  • the local variable y (its size is interactionSize). STL vectors are used and y[i] usually represents the i-eme derivative of variable y.

  • the local variable lambda (its size is interactionSize). STL vectors are used and lambda[i] represents various level of multiplier involved in the nonsmooth law with y[i]

    y (resp, lambda) is a container of SiconosVector.

DSlink graph property management

set the links to the DynamicalSystem(s) and allocate the required workspaces

Parameters

void __initDataFirstOrder(VectorOfBlockVectors &DSlink, DynamicalSystem &ds1, DynamicalSystem &ds2)

update DSlink property content with dynamical systems members, FirstOrder relations case.

Parameters

void __initDSDataFirstOrder(DynamicalSystem &ds, VectorOfBlockVectors &DSlink)

Initialize the link with the DynamicalSystem, FirstOrderDS variant.

Parameters

void __initDataLagrangian(VectorOfBlockVectors &DSlink, DynamicalSystem &ds1, DynamicalSystem &ds2)

update DSlink property content with dynamical systems members, Lagrangian relations case.

Parameters

void __initDSDataLagrangian(DynamicalSystem &ds, VectorOfBlockVectors &DSlink)

Initialize the link with the DynamicalSystem, LagrangianDS variant.

Parameters

void __initDataNewtonEuler(VectorOfBlockVectors &DSlink, DynamicalSystem &ds1, DynamicalSystem &ds2)

update DSlink property content with dynamical systems members, NewtonEuler relations case.

Parameters

void __initDSDataNewtonEuler(DynamicalSystem &ds, VectorOfBlockVectors &DSlink)

Initialize the link with the DynamicalSystem, NewtonEulerDS variant.

Parameters

void initializeLinkToDsVariables(DynamicalSystem &ds1, DynamicalSystem &ds2)

set the links between the interaction and the DynamicalSystem(s) members.

Parameters
  • 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.

Public Functions

Interaction(SP::NonSmoothLaw NSL, SP::Relation rel)

constructor with NonSmoothLaw and Relation (i.e.

inter size == nslaw size)

Parameters

~Interaction()

destructor

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.

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.

unsigned int dimension() const

returns dimension (i.e.

nslaw size == y and lambda size)

void display(bool brief = true) const

print the data to the screen

const SiconosVector getCopyOfy(const unsigned int i) const

Get y[i], derivative number i of output.

Return
BlockVector
Parameters
  • i: : the derivative number.

const SiconosVector getCopyOfyOld(const unsigned int i) const

get y[i], derivative number i of output

Return
BlockVector
Parameters
  • i: derivative number i of output

void getExtraInteractionBlock(SP::SiconosMatrix InteractionBlock) const

gets extra interactionBlock corresponding to the present Interaction (see the top of this files for extra interactionBlock meaning)

Parameters
  • InteractionBlock: SP::SiconosMatrix

const VectorOfVectors getLambda() const

get vector of input derivatives

Return
a VectorOfVectors

const SiconosVector getLambda(const unsigned int i) const

get _lambda[i], derivative number i of input

Return
SiconosVector
Parameters
  • i: derivative number i of output

const VectorOfVectors getLambdaOld() const

get vector of input derivatives

Return
a VectorOfVectors

const SiconosVector getLambdaOld(const unsigned int i) const

get _lambdaOld[i], derivative number i of input

Return
SiconosVector
Parameters
  • i: derivative number i of output

void getLeftInteractionBlockForDS(unsigned int pos, SP::SiconosMatrix InteractionBlock) 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.
  • 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

void getRightInteractionBlockForDS(unsigned int pos, SP::SiconosMatrix InteractionBlock) 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.
  • InteractionBlock: a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix

unsigned int getSizeOfDS() const

Get the sum of DS sizes, for DS involved in interaction.

Return
an unsigned int

const VectorOfVectors getYOld() const

get vector of output derivatives

Return
a VectorOfVectors

const SiconosVector getYOld(const unsigned int i) const

get yOld[i], derivative number i of output

Return
BlockVector
Parameters
  • i: derivative number i of output

bool has2Bodies() const

Check the number of dynamical systems concerned by this interaction.

Return
bool : true if two ds, else false

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)

SP::SiconosVector lambda(const unsigned int i) const

get _lambda[i], derivative number i of input

Return
pointer on a SiconosVector
Parameters
  • i: derivative number i of output

SiconosMemory &lambdaMemory(unsigned int level)

get all the values of the multiplier lambda stored in memory

Return
a memory
Parameters
  • level:

SP::SiconosVector lambdaOld(const unsigned int i) const

get _lambdaOld[i], derivative number i of input

Return
pointer on a SiconosVector
Parameters
  • i: derivative number i of output

VectorOfBlockVectors &linkToDSVariables()
unsigned int lowerLevelForInput()

Get the lower level for input Lambda.

Return
an unsigned int.

unsigned int lowerLevelForOutput()

Get the lower level for output y.

Return
an unsigned int.

SP::NonSmoothLaw nonSmoothLaw() const

get the NonSmoothLaw of this Interaction

Return
a pointer on this NonSmoothLaw

int number() const

get the value of number

Return
the value of number

SP::Relation relation() const

get the Relation of this Interaction

Return
a pointer on this Relation

VectorOfSMatrices &relationMatrices()
VectorOfVectors &relationVectors()
void reset()

Update interactions attributes.

Must be called when levels have been modified.

void resetAllLambda()

set all lambda to zero

void resetLambda(unsigned int level)

set lambda to zero for a given level

Parameters
  • level:

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 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

void setLambda(const VectorOfVectors &v)

set the input vector _lambda to newVector

Parameters
  • v: VectorOfVectors

void setLambda(const unsigned int i, const SiconosVector &newValue)

set _lambda[i] to newValue

Parameters

void setLambdaOld(const VectorOfVectors &v)

set the input vector _lambdaOld to newVector

Parameters
  • v: VectorOfVectors

void setLambdaOld(const unsigned int i, const SiconosVector &v)

set _lambdaOld[i] to newValue

Parameters

void setLambdaOldPtr(const VectorOfVectors &v)

set vector _lambdaOld to newVector with direct pointer equality for the _lambdaOld

Parameters
  • v: VectorOfVectors

void setLambdaOldPtr(const unsigned int i, SP::SiconosVector newPtr)

set _lambdaOld[i] to pointer newPtr

Parameters
  • i: derivative number i of output
  • newPtr: a SP::SiconosVector

void setLambdaPtr(const VectorOfVectors &v)

set vector _lambda to newVector with direct pointer equality for the _lambda[i]

Parameters
  • v: VectorOfVectors

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

void setLowerLevelForInput(const unsigned int newVal)

Set the lower level for input Lambda.

Parameters
  • newVal: : an unsigned int

void setLowerLevelForOutput(const unsigned int newVal)

Set the lower level for output y.

Parameters
  • newVal: : an unsigned int

void setUpperLevelForInput(const unsigned int newVal)

Set the upper level for input Lambda.

Parameters
  • newVal: : an unsigned int.

void setUpperLevelForOutput(const unsigned int newVal)

Set the upper level for output y.

Parameters
  • newVal: : an unsigned int

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 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 setYOld(const VectorOfVectors &v)

set the output vector yOld to newVector

Parameters
  • v: VectorOfVectors

void setYOld(const unsigned int i, const SiconosVector &v)

set yOld[i] to newValue

Parameters
  • i: derivative number i of output
  • v: a SiconosVector and an unsigned int

void setYOldPtr(const VectorOfVectors &v)

set vector yOld to newVector with direct pointer equality for the yOld[i]

Parameters
  • v: VectorOfVectors

void setYOldPtr(const unsigned int i, SP::SiconosVector v)

set yOld[i] to pointer newPtr

Parameters
  • i: derivative number i of output
  • v: a SP::SiconosVector and an unsigned int

void setYPtr(const VectorOfVectors &v)

set the output vector y to newVector with direct pointer equality for the y[i]

Parameters
  • v: VectorOfVectors

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

void swapInMemory()

Must be call to fill _y_k.

(after convergence of the Newton iterations)

void swapInOldVariables()

put values of y into yOld, the same for _lambda

unsigned int upperLevelForInput()

Get the upper level for input Lambda.

Return
an unsigned int.

unsigned int upperLevelForOutput()

Get the upper level for output y.

Return
an unsigned int.

const VectorOfVectors y() const

get vector of output derivatives

Return
a VectorOfVectors

SP::SiconosVector y(const unsigned int i) const

get y[i], derivative number i of output

Return
pointer on a SiconosVector
Parameters
  • i: derivative number i of output

SP::SiconosVector y_k(const unsigned int i) const
SiconosMemory &yMemory(unsigned int level)

get all the values of the state vector y stored in memory

Return
a memory
Parameters
  • level:

SP::SiconosVector yOld(const unsigned int i) const

get yOld[i], derivative number i of output

Return
pointer on a SiconosVector
Parameters
  • i: derivative number i of output

Public Static Functions

static int resetCount(int new_count = 0)

reset the global Interaction counter (for ids)

Return
the previous value of count

Protected Functions

Interaction()

Default constructor.

Private Functions

Interaction(const Interaction &inter)

copy constructor => private, no copy nor pass-by-value.

Parameters
  • inter: to copy

void __init()

Initialisation common to all constructors.

ACCEPT_SERIALIZATION(Interaction)

Private Members

bool _has2Bodies

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.

unsigned int _interactionSize

size of the interaction, ie size of y[i] and _lambda[i]

VectorOfVectors _lambda

result of the computeInput function

VectorOfMemories _lambdaMemory

memory of previous coordinates of the system

VectorOfVectors _lambdaOld

previous step values for _lambda

Warning
: VA 24/05/2013 this has to be put into the workspace vector or we have to use the _yMemory storage

VectorOfBlockVectors _linkToDSVariables

pointer links to DS variables needed for computation, mostly used in Relations (computeOutput and computeInput) and OneStepIntegrator classes.

unsigned int _lowerLevelForInput

Minimum required ‘level’ for input lambda lambda will be initialized from lambda[_lowerLevelForIntput] to lambda[_upperLevelForInput].

unsigned int _lowerLevelForOutput

Minimum required ‘level’ for output y y will be initialized from y[_lowerLevelForOutput] to y[_upperLevelForOutput].

SP::NonSmoothLaw _nslaw

the Non-smooth Law of the interaction

unsigned int _number

Interaction id.

SP::Relation _relation

the type of Relation of the interaction

VectorOfSMatrices _relationMatrices
VectorOfVectors _relationVectors
unsigned int _sizeOfDS

sum of all DS sizes, for DS involved in the interaction

unsigned int _upperLevelForInput

Maximum required ‘level’ for input lambda lambda will be initialized from lambda[_lowerLevelForIntput] to lambda[_upperLevelForInput].

unsigned int _upperLevelForOutput

Maximum required ‘level’ for output y y will be initialized from y[_lowerLevelForOutput] to y[_upperLevelForOutput].

VectorOfVectors _y

relation between constrained variables and states variables vector of output derivatives y[0] is y, y[1] is yDot and so on

VectorOfVectors _y_k

value of the previous time-step

VectorOfMemories _yMemory

memory of previous coordinates of the system

VectorOfVectors _yOld

previous value of Newton iteration for y

Warning
: VA 24/05/2013 this has to be put into the workspace vector or we have to use the _yMemory storage

Private Static Attributes

unsigned int __count

internal counter used to set interaction number

Friends

friend Interaction::_setLevels