Class Interaction#

Defined in Program listing for file kernel/src/modelingTools/Interaction.hpp

class Interaction : public std::enable_shared_from_this<Interaction>#

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:

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:

BlockVector

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:

SiconosVector

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