File kernel/src/simulationTools/EventDriven.hpp

Go to the source code of this file

Event Driven Simulation.

class EventDriven : public Simulation
#include <EventDriven.hpp>

Simulation based on event driven method, ie events detection (see theoretical manual for more details).

WARNING: at the time only written for Lagrangian systems !!!

Public Functions

EventDriven(SP::NonSmoothDynamicalSystem nsds, SP::TimeDiscretisation td)

defaut constructor

Parameters
  • nsds: current nonsmooth dynamical system
  • td: time discretisation

EventDriven(SP::NonSmoothDynamicalSystem nsds, SP::TimeDiscretisation td, int nb)

constructor with data

Parameters
  • nsds: current nonsmooth dynamical system
  • td: time discretisation
  • nb: number of NSProblem

EventDriven()

defaut constructor (needed for serialization)

~EventDriven()

destructor

ACCEPT_STD_VISITORS()
void advanceToEvent()

Initialize EventDriven.

run simulation from one Event to the next, according to events manager settings.

void computef(OneStepIntegrator &osi, integer *sizeOfX, doublereal *time, doublereal *x, doublereal *xdot)

compute right-hand side of xdot = f(x,t), for the integrator osi.

Parameters
  • osi: the integrator (Lsodar)
  • sizeOfX: size of vector x
  • time: current time given by the integrator
  • x: state vector
  • xdot: derivative of x

virtual void computeg(SP::OneStepIntegrator osi, integer *sizeX, doublereal *time, doublereal *x, integer *sizeG, doublereal *g)

compute constraint function g(x,t,…) for osi.

Parameters
  • osi: pointer to OneStepIntegrator.
  • sizeX: integer*, size of vector x
  • time: doublereal*, time
  • x: doublereal*, x:array of double
  • sizeG: integer*, size of vector g (ie number of constraints)
  • g: doublereal*, g (in-out parameter)

void computeJacobianfx(OneStepIntegrator &osi, integer *sizeOfX, doublereal *time, doublereal *x, doublereal *jacob)

compute jacobian of the right-hand side

Parameters
  • osi: the integrator (Lsodar)
  • sizeOfX: size of vector x
  • time: current time given by the integrator
  • x: state vector
  • jacob: jacobian of f according to x

double computeResiduConstraints()

visitors hook

Methods for NewMarkAlphaOSI scheme compute maximum residu over all gap functions of Index2 contacts

Return
double: maximum residu for all gap functions

virtual unsigned int computeSizeOfg()

compute the size of constraint function g(x,t,…) for osi

Return
unsigned int

void correctionNewtonIteration()

Correct the state of all Dynamical Systems during Newton iterations.

double detectEvents(bool updateIstate = true)

Detect whether or not events occur during each integration step.

Return
double, maximum of absolute values of constraint fonctions over all activated ot deactivated contacts
Parameters
  • updateIstate: true if we need to update the flag _istate, false otherwise

unsigned int getNewtonNbIterations()

To known the number of steps performed by the Newton algorithm.

Return
_newtonNbIterations

void initialize()

Overload Simulation::initialize.

void insertIntegrator(SP::OneStepIntegrator)

Redefine method insertIntegrator of the class Simulation.

bool isNewtonConverge()

To know if Newton Iteratio is convergent.

Return
_isNewtonConverge

double istate()

Get value of _istate.

Return
_istate a double

unsigned int LocalizeEventsMaxIteration()

get the maximum number of iterations to localize events

Return
unsigned int: maximum number of iterations

void LocalizeFirstEvent()

Localize time of the first event.

bool newtonCheckConvergence(double)

Check convergence of Newton iteration.

Return
bool: true if convergent, false otherwise

double newtonMaxIteration()

get the maximum number of Newton iteration

Return
unsigned int

double newtonResiduDSMax()

accessor to _newtonResiduDSMax

Return
double _newtonResiduDSMax

double newtonResiduYMax()

accessor to _newtonResiduYMax

Return
double _newtonResiduYMax

void newtonSolve(double criterion, unsigned int maxStep)

Newton iteration to get the state of all Dynamical Systems at the end of step.

Parameters
  • criterion: tolerance to check convergence
  • maxStep: maximum number of steps

double newtonTolerance()

get the Newton tolerance

Return
tolerance

void predictionNewtonIteration()

Predict the state of all Dynamical Systems before Newton iterations.

void prepareNewtonIteration()

prepare for Newton iterations for all OSIs

Return
maximum residu over all DSs

void setIstate(int newValue)

Set value to _istate.

Parameters
  • newValue:

void setLocalizeEventsMaxIteration(unsigned int maxIter)

To set maximum number of iterations to localize events.

Parameters
  • maxIter: maximum number of iterations

void setNewtonMaxIteration(unsigned int maxStep)

Set value to the maximum number of iterations.

Parameters
  • maxStep: maximum number of step

void setNewtonTolerance(double tol)

set the Default Newton tolerance

Parameters
  • tol: new tolerance

void setToleranceED(double var)

Set value to _TOL_ED.

Parameters
  • var: the new tolerance

double toleranceED()

Get value of _epsilon.

Return
double

void updateImpactState()

update input for impact case (ie compute p[1])

void updateIndexSet(unsigned int i)

update indexSets[i] of the topology, using current y and lambda values of Interactions.

Parameters
  • i: the number of the set to be updated

void updateIndexSetsWithDoubleCondition()

update indexSets[1] and [2] (using current y and lambda values of Interactions) with conditions on y[2] AND lambda[2].

void updateInput(unsigned int level)

update input

Parameters
  • level: of lambda used to compute input

void updateOutput(unsigned int level)

update output and indexSets.

Parameters
  • level: of lambda used to compute input

void updateSmoothState()

update state for smooth dynamic case (i.e.

compute p[2] and update acceleration)

void updateState(unsigned int level)

update state.

Parameters
  • level: of lambda used to compute input

Protected Attributes

SP::DynamicalSystemsGraph _DSG0

store the graph of DynamicalSystems for performance reason (Lsodar)

SP::InteractionsGraph _indexSet0

store the indexSet0 for performance reason (Lsodar)

bool _isNewtonConverge

boolean variable to known whether Newton iterations converges or not

unsigned int _localizeEventMaxIter

Maximum number of iterations to localize events.

unsigned int _newtonMaxIteration

Default maximum number of Newton iteration.

unsigned int _newtonNbIterations

Number of steps performed is the Newton Loop.

double _newtonResiduDSMax

Maximum Residual for the Dynamical system.

double _newtonResiduYMax

Maximum Residual for the output of the relation.

double _newtonTolerance

Tolerance to check Newton iteration convergence.

unsigned int _numberOfOneStepNSproblems

number of OneStepNSProblems considered in the simulation

Protected Static Attributes

double _TOL_ED

an epsilon to define the contraint g for Interaction in IndexSet[1]

Private Functions

ACCEPT_SERIALIZATION(EventDriven)

serialization hooks

void initOSIRhs()

Initialize the Rhs of the OSI.

void initOSIs()

Initialize OneStepIntergrators.

void initOSNS()

initialisation for OneStepNSProblem.

Private Members

int _istate

flag used in DLSODAR - As input: 1 if first call, else 2 As output: 2 if no root found, else 3