File kernel/src/simulationTools/OneStepIntegrator.hpp

Contents

File kernel/src/simulationTools/OneStepIntegrator.hpp#

Go to the source code of this file

Base class (i.e. common interface) for dynamical system integration over a time step.

class OneStepIntegrator : public std::enable_shared_from_this<OneStepIntegrator>
#include <OneStepIntegrator.hpp>

Generic class to manage DynamicalSystem(s) time-integration.

This is a virtual class, interface for some specific integrators.

At the time, available integrators are:

Subclassed by D1MinusLinearOSI, EulerMoreauOSI, Hem5OSI, LsodarOSI, MoreauJeanBilbaoOSI, MoreauJeanOSI, NewMarkAlphaOSI, SchatzmanPaoliOSI, ZeroOrderHoldOSI

Public Functions

inline virtual ~OneStepIntegrator()

destructor

inline OSI::TYPES getType() const
Returns:

the id of the integrator (see list in OSI::TYPES enum)

inline SP::DynamicalSystemsGraph dynamicalSystemsGraph() const

get the graph of dynamical systems associated with the Integrator warning: returns the whole ds graph, not only ds integrated by the present osi.

Returns:

a SP::DynamicalSystemsGraph

inline void setDynamicalSystemsGraph(SP::DynamicalSystemsGraph dsg)

set the graph of dynamical systems associated with the Integrator

inline unsigned int getSizeMem() const

get number of internal memory vectors needed in dynamical systems integrated with this osi.

Returns:

an unsigned int

inline SP::Simulation simulation() const

get the Simulation that owns the OneStepIntegrator (pointer link)

Returns:

a pointer to Simulation

inline void setSimulationPtr(SP::Simulation newS)

set the Simulation of the OneStepIntegrator

Parameters:

newS – a pointer to Simulation

inline virtual unsigned int levelMinForOutput()

minimal level required for output var used with this integration scheme.

var[level] is the derivative of order ‘level’ of var.

inline virtual unsigned int levelMaxForOutput()

maximal level required for output var used with this integration scheme.

var[level] is the derivative of order ‘level’ of var.

inline virtual unsigned int levelMinForInput()

minimal level required for input var used with this integration scheme.

var[level] is the derivative of order ‘level’ of var.

inline virtual unsigned int levelMaxForInput()

maximal level required for input var used with this integration scheme.

var[level] is the derivative of order ‘level’ of var.

virtual unsigned int numberOfIndexSets() const = 0

get the number of index sets required for the simulation

Returns:

unsigned int

inline bool isInitialized()#
inline void setIsInitialized(bool value)#
inline bool explicitJacobiansOfRelation()#
inline void setExplicitJacobiansOfRelation(bool newval)#
virtual void initialize()

initialise the integrator

inline virtual void initialize_nonsmooth_problems()

Initialization process of the nonsmooth problems linked to this OSI.

virtual void initializeWorkVectorsForDS(double t, SP::DynamicalSystem ds) = 0

initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi

Parameters:
  • t – time of initialization

  • ds – the dynamical system

virtual void initializeWorkVectorsForInteraction(Interaction &inter, InteractionProperties &interProp, DynamicalSystemsGraph &DSG) = 0

initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi

Parameters:
  • inter – the interaction

  • interProp – the properties on the graph

  • DSG – the dynamical systems graph

void UpdateAndSwapAllOutput(double time)

compute interaction output (y) for all levels and swaps in memory

Parameters:
  • time – value for output computation

  • interaction_properties – properties of the interaction, in the Interaction Graph I0

void UpdateAndSwapAllOutput(Interaction &inter, double time)

compute interaction output (y) for all levels and swaps in memory

Parameters:
  • inter – the interaction to update

  • time – value for output computation

  • interaction_properties – properties of the interaction, in the Interaction Graph I0

inline virtual void computeInitialNewtonState()

compute the initial state (for dynamical system variables) of the Newton loop.

inline virtual double computeResidu()

return the maximum of all norms for the discretized residus of DS

Returns:

a double

inline virtual void computeFreeState()

integrates the Dynamical System linked to this integrator, without taking constraints into account.

inline virtual void computeFreeOutput(InteractionsGraph::VDescriptor &vertex_inter, OneStepNSProblem *osnsp)

integrates the Interaction linked to this integrator, without taking non-smooth effects into account

Parameters:
  • vertex_inter – of the interaction graph

  • osnsp – pointer to OneStepNSProblem

virtual double computeResiduOutput(double time, SP::InteractionsGraph indexSet)

compute the residu of the output of the relation (y) This computation depends on the type of OSI

Parameters:
  • time – time of computation

  • indexSet – the index set of the interaction that are concerned

virtual double computeResiduInput(double time, SP::InteractionsGraph indexSet)

compute the residu of the input of the relation (R or p) This computation depends on the type of OSI

Parameters:
  • time – time of computation

  • indexSet – the index set of the interaction that are concerned

virtual void integrate(double &tinit, double &tend, double &tout, int &idid) = 0

integrate the system, between tinit and tend, with possible stop at tout

Parameters:
  • tinit – start time

  • tend – expected end time

  • tout – real end time

  • idid – extra flag, meaningful only for OSI used in EventDriven schemes

void resetAllNonSmoothParts()

set to zero all the r vectors of the DynamicalSystems integrated by this OSI

void resetNonSmoothPart(unsigned int level)

set to zero all the r vectors of the DynamicalSystems of the present OSI for a given level

Parameters:

level

virtual void updateState(const unsigned int level) = 0

update the state of the DynamicalSystem attached to this Integrator

Parameters:

level – level of interest for the dynamics level is set to 0 by default since in all time-stepping schemes we update all the state whatever the value of level

inline void updateState()

update the state of the DynamicalSystem attached to this Integrator level is set to 0 by default since in all time-stepping schemes we update all the state whatever the value of level

virtual void updateOutput(double time)

update the output of the Interaction attached to this Integrator

virtual void updateInput(double time)

update the input of the Interaction attached to this Integrator

virtual void updateOutput(double time, unsigned int level)

update the output of the Interaction attached to this Integrator

Parameters:
  • time – current time

  • level – level of interest for the dynamics

virtual void updateInput(double time, unsigned int level)

update the input of the Interaction attached to this Integrator

Warning

VA: 27/10/2022 Whatever the level, the updateInput method loops over indexSet0 This is sometimes necessary for some OSI but for some others it may burden the computational time for nothing. For instance, in standard MoreauJEANOSI, p[1] is only defined on indexSet1. we should go towards virtual void updateInput(double time, unsigned int pLevel, unsigned int indexSetLevel );

Parameters:
  • time – current time

  • level – level of interest for the dynamics

virtual void prepareNewtonIteration(double time) = 0#
virtual void display() = 0

print the data to the screen

inline virtual bool addInteractionInIndexSet(SP::Interaction inter, unsigned int i)

Apply the rule to one Interaction to known if is it should be included in the IndexSet of level i.

Parameters:
  • inter

  • i

Returns:

bool

inline virtual bool removeInteractionFromIndexSet(SP::Interaction inter, unsigned int i)

Apply the rule to one Interaction to know if is it should be removed from the IndexSet of level i.

Parameters:
  • inter

  • i

Returns:

bool

inline SP::ExtraAdditionalTerms extraAdditionalTerms()

get the ExtraAdditionalTerms.

Returns:

the ExtraAdditionalTerms

inline void setExtraAdditionalTerms(SP::ExtraAdditionalTerms eat)

set the ExtraAdditionalTerms to add smooth terms for the integration process.

Useful when a control loop is added to a DynamicalSystem.

Parameters:

eat – the ExtraAdditionalTerms to use

inline bool checkOSI(DynamicalSystemsGraph::VIterator dsi)

True if the dynamical system (a vertex in the ds graph) is integrated by this osi.

Parameters:

dsi – the iterator on the node of the graph corresponding to the dynamical system of interest.

inline bool checkOSI(DynamicalSystemsGraph::VDescriptor dsgv)

True if the dynamical system (a vertex in the ds graph) is integrated by this osi.

Parameters:

dsgv – the descriptor of the node in the graph corresponding to the dynamical system of interest.

inline bool checkInteractionOSI(InteractionsGraph &indexSet0, InteractionsGraph::VIterator ui)

True if the dynamical system (a vertex in the ds graph) is integrated by this osi.

Parameters:

dsi – the iterator on the node of the graph corresponding to the dynamical system of interest.

virtual SiconosVector &osnsp_rhs(InteractionsGraph::VDescriptor &vertex_inter, InteractionsGraph &indexSet) = 0#
VIRTUAL_ACCEPT_VISITORS(OneStepIntegrator)#

Protected Functions

ACCEPT_SERIALIZATION(OneStepIntegrator)#
inline OneStepIntegrator(const OSI::TYPES &type)#

basic constructor with OSI Id

Parameters:

type – integrator type/name

void _check_and_update_interaction_levels(Interaction &inter)#

Compare interaction and current OSI levels for input and output.

Reset interaction if they are not compliant.

Parameters:

inter – a reference to an Interaction

SP::VectorOfVectors _initializeDSWorkVectors(SP::DynamicalSystem ds)#

initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi &#8212; common code.

Parameters:

ds – the dynamical system

inline OneStepIntegrator()#

default constructor

Protected Attributes

OSI::TYPES _integratorType#

type/name of the Integrator

SP::DynamicalSystemsGraph _dynamicalSystemsGraph#

a graph of dynamical systems to integrate For the moment, we point to the graph of dynamical systems in the topology.

We use the properties “osi” to check if the dynamical system is integrated by this osi. It has to be improved by using a subgraph to avoid the use of checkOSI

unsigned int _sizeMem#

size of the memory for the integrator

unsigned int _steps#

steps of the integrator

unsigned int _levelMinForOutput#

_levelMinForOutput is the minimum level for the output needed by the OneStepIntegrator

unsigned int _levelMaxForOutput#

_levelMaxForOutput is the maximum level for the output needed by the OneStepIntegrator

unsigned int _levelMinForInput#

_levelMinForInput is the minimum level for the input needed by the OneStepIntegrator

unsigned int _levelMaxForInput#

_levelMaxForInput is the maximum level for the input needed by the OneStepIntegrator

bool _isInitialized#
bool _explicitJacobiansOfRelation#

boolean variable to force an explicit evaluation of the Jacobians mapping of relations only at the beginning of the time&#8212;step and not in the Newton iteration

SP::Simulation _simulation#

A link to the simulation that owns this OSI.

SP::ExtraAdditionalTerms _extraAdditionalTerms#

struct to add terms in the integration.

Useful for Control

Private Functions

OneStepIntegrator(const OneStepIntegrator&)#

copy constructor, private, no copy nor pass-by value allowed

OneStepIntegrator &operator=(const OneStepIntegrator &OSI)#

assignment (private => forbidden)

Parameters:

OSI

Returns:

OneStepIntegrator&