# Class LinearOSNS¶

class LinearOSNS : public OneStepNSProblem

Base (abstract) class for linear non-smooth problems.

Base class for linear non-smooth problems, usually in the form:

$$w = q + M z$$

where

• $$w \in R^{n}$$ and $$z \in R^{n}$$ are the unknowns,

• $$M \in R^{n \times n }$$ and $$q \in R^{n}$$

examples: LCP, FrictionContact

Public Functions

LinearOSNS(SP::SolverOptions options)

constructor from a pre-defined solver options set.

Parameters

virtual ~LinearOSNS()

destructor

virtual int compute(double time) = 0

Compute the unknown z and w and update the Interaction (y and lambda )

Return

Parameters
• time: the current time

virtual void computeDiagonalInteractionBlock(const InteractionsGraph::VDescriptor &vd)

compute diagonal Interaction block

Parameters
• vd: a vertex descriptor

virtual void computeInteractionBlock(const InteractionsGraph::EDescriptor &ed)

compute extra-diagonal interactionBlock-matrix

Parameters
• ed: an edge descriptor

virtual void computeq(double time)

compute vector q

Parameters
• time: the current time

virtual void computeqBlock(InteractionsGraph::VDescriptor &vertex, unsigned int pos)

To compute a part of the “q” vector of the OSNS.

Parameters
• vertexvertex: (interaction) which corresponds to the considered block

• pos: the position of the first element of yOut to be set

virtual void display() const

print the data to the screen

int getMStorageType() const

get the type of storage used for M

Return

int (0: dense, 1:sparse)

const SiconosVector getQ() const

get the value of q, the constant vector in the LinearOSNS

Return

const SiconosVector getW() const

copy of the current value of vector w

Return

const SiconosVector getz() const

copy of the current value of vector z

Return

virtual void initialize(SP::Simulation sim)

To initialize the LinearOSNS problem(computes topology …)

Parameters
• sim: the simulation owning this OSNSPB

virtual void initOSNSMatrix()

initialize the _M matrix

void initVectorsMemory()

Memory allocation or resizing for z,w,q.

SP::OSNSMatrix M() const

Return

pointer on a OSNSMatrix

virtual void postCompute()

update interactions variables (y and lambda) according to current problem found solutions.

virtual bool preCompute(double time)

build problem coefficients (if required)

Return

true if succeeded

Parameters
• time: the current time

SP::SiconosVector q() const

get q, the the constant vector in the LinearOSNS

Return

pointer on a SiconosVector

void setKeepLambdaAndYState(bool val)

choose initialisation behavior for w and z.

Parameters
• val: true: init w and z with previous values of y and lambda saved in interactions, false: init to 0.

void setMPtr(SP::OSNSMatrix newM)

set M to pointer newPtr

Parameters
• newM: the new M matrix

void setMStorageType(int i)

set which type of storage will be used for M

Warning

this function does not allocate any memory for M, it just sets an indicator for future use

Parameters
• i: (0:dense, 1:sparse)

void setQPtr(SP::SiconosVector newQ)

set q to pointer newPtr

Parameters
• newQ: the new q vector

void setWPtr(SP::SiconosVector newPtr)

Parameters
• newPtr: the new SP::SiconosVector

void setzPtr(SP::SiconosVector newPtr)

Parameters
• newPtr: the new SP::SiconosVector

SP::SiconosVector w() const

SP::SiconosVector z() const