Class OneStepNSProblem#

Defined in Program listing for file kernel/src/simulationTools/OneStepNSProblem.hpp

class OneStepNSProblem#

Non Smooth Problem Formalization and Simulation.

This is an abstract class, that provides an interface to define a non smooth problem:

  • a formulation (ie the way the problem is written)

  • a solver (algorithm and solving formulation, that can be different from problem formulation)

  • routines to compute the problem solution.

Two types of problem formulation are available :

  • Quadratic Problem

  • Linear Problem

See derived classes (QP and LinearOSNS) for details.

For Linear problems, the following formulations exists:

The usual way to build and initialize a one-step nonsmooth problem is :

  • call constructor with the id of the required Numerics solver. (see Solver class or Numerics documentation for details on algorithm name and parameters).

  • initialize(simulation) Initialize process is usually done through model->initialize(simulation). See Examples for practical details.

Options for Numerics and the driver for solvers

When the Numerics driver is called a set of solver options (name, tolerance, max. number of iterations …) is required –> SolverOptions.

Default values are always set in solver options the OneStepNSProblem is built but if you need to set them yourself, please check Users’guide, Numerics solvers part.

Subclassed by LinearOSNS, QP

Public Functions

inline OneStepNSProblem(SP::SolverOptions options)#

constructor from a pre-defined solver options set.


options – the options set

inline virtual ~OneStepNSProblem()#


inline SP::SolverOptions numericsSolverOptions() const#

To get the SolverOptions structure.


, the numerics structure used to save solver parameters

inline unsigned int getSizeOutput() const#

returns the dimension of the nonsmooth problem

inline SP::Simulation simulation() const#

get the simulation which owns this nonsmooth problem


a pointer on Simulation

inline void setSimulationPtr(SP::Simulation newS)#

set the Simulation of the OneStepNSProblem


newS – a pointer to Simulation

inline unsigned int indexSetLevel() const#

get indexSetLevel


an unsigned int

inline void setIndexSetLevel(unsigned int newVal)#

set the value of level min


newVal – an unsigned int

inline unsigned int inputOutputLevel() const#

get the Input/Output level


an unsigned int

inline void setInputOutputLevel(unsigned int newVal)#

set the value of Input/Output level


newVal – an unsigned int

inline unsigned int maxSize() const#

get maximum value allowed for the dimension of the problem


an unsigned int

inline void setMaxSize(const unsigned int newVal)#

set the value of maxSize


newVal – an unsigned int

void setNumericsVerboseMode(bool vMode)#

Turn on/off verbose mode in numerics solver.

void setNumericsVerboseLevel(int level)#

set the verbose level in numerics solver

bool hasInteractions() const#

Check if the OSNSPb has interactions.


bool = true if the osnsp has interactions, i.e. indexSet(_indexSetLevel)->size >0

virtual void displayBlocks(SP::InteractionsGraph indexSet)#

Display the set of blocks for a given indexSet.


indexSet – the concerned index set

virtual void updateInteractionBlocks()#

compute interactionBlocks if necessary (this depends on the type of OSNS, on the indexSets …)

virtual void computeInteractionBlock(const InteractionsGraph::EDescriptor &ed) = 0#

compute extra-diagonal interactionBlock-matrix


ed – an edge descriptor

virtual void computeDiagonalInteractionBlock(const InteractionsGraph::VDescriptor &vd) = 0#

compute diagonal Interaction block


vd – a vertex descriptor

inline bool hasBeenUpdated()#

bool _hasBeenUpdated

inline void setHasBeenUpdated(bool v)#

turn activation flag


v – to set _hasBeenUpdated.

virtual void initialize(SP::Simulation sim)#

initialize the problem (topology and so on)


sim – the simulation that owns this OSNSPB

virtual bool preCompute(double time) = 0#

prepare data of the osns for solving


time – the current time


true if the computation of the OSNS has to be carry on, false otherwise

virtual int compute(double time) = 0#

To run the solver for ns problem.


time – current time


int information about the solver convergence.

virtual void postCompute() = 0#

post treatment for output of the solver

void setSolverId(int solverId)#

change the solver type and its default parameters

  • clear memory for the existing options set

  • create and initialize a new one


solverId – the new solver

SP::SimpleMatrix getOSIMatrix(OneStepIntegrator &osi, SP::DynamicalSystem ds)#

get the OSI-related matrices used to compute the current InteractionBlock (Ex: for MoreauJeanOSI, W)

  • osi – the OSI of the concerned dynamical system

  • ds – the concerned dynamical system


the required matrix