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
-
inline EventDriven()
defaut constructor (needed for serialization)
-
~EventDriven() noexcept = default
destructor
-
virtual void initialize() override
Overload Simulation::initialize.
-
virtual void firstInitialize() override
First (and unique) run of initialization step.
-
inline void setIstate(int newValue)
Set value to _istate.
- Parameters:
newValue –
-
inline double istate()
Get value of _istate.
- Returns:
_istate a double
-
inline void setToleranceED(double var)
Set value to _TOL_ED.
- Parameters:
var – the new tolerance
-
inline double toleranceED()
Get value of _epsilon.
- Returns:
double
-
inline bool isNewtonConverge()
To know if Newton Iteratio is convergent.
- Returns:
_isNewtonConverge
-
inline unsigned int getNewtonNbIterations()
To known the number of steps performed by the Newton algorithm.
- Returns:
_newtonNbIterations
-
inline void setNewtonMaxIteration(unsigned int maxStep)
Set value to the maximum number of iterations.
- Parameters:
maxStep – maximum number of step
-
inline void setLocalizeEventsMaxIteration(unsigned int maxIter)
To set maximum number of iterations to localize events.
- Parameters:
maxIter – maximum number of iterations
-
inline double newtonMaxIteration()
get the maximum number of Newton iteration
- Returns:
unsigned int
-
inline unsigned int LocalizeEventsMaxIteration()
get the maximum number of iterations to localize events
- Returns:
unsigned int: maximum number of iterations
-
inline double newtonResiduDSMax()
accessor to _newtonResiduDSMax
- Returns:
double _newtonResiduDSMax
-
inline double newtonResiduYMax()
accessor to _newtonResiduYMax
- Returns:
double _newtonResiduYMax
-
inline void setNewtonTolerance(double tol)
set the Default Newton tolerance
- Parameters:
tol – new tolerance
-
inline double newtonTolerance()
get the Newton tolerance
- Returns:
tolerance
-
virtual void insertIntegrator(SP::OneStepIntegrator) override
Redefine method insertIntegrator of the class Simulation.
-
virtual void updateIndexSet(unsigned int i) override
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 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
-
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
-
virtual unsigned int computeSizeOfg()
compute the size of constraint function g(x,t,…) for osi
- Returns:
unsigned int
-
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 updateImpactState()
update input for impact case (ie compute p[1])
-
void updateSmoothState()
update state for smooth dynamic case (i.e.
compute p[2] and update acceleration)
-
inline virtual void updateInput(unsigned int level) override
update input
- Parameters:
level – of lambda used to compute input
-
virtual void updateState(unsigned int level) override
update state.
- Parameters:
level – of lambda used to compute input
-
virtual void updateOutput(unsigned int level) override
update output and indexSets.
- Parameters:
level – of lambda used to compute input
-
virtual void advanceToEvent() override
run simulation from one Event to the next, according to events manager settings.
-
double computeResiduConstraints()
Methods for NewMarkAlphaOSI scheme.
compute maximum residu over all gap functions of Index2 contacts
- Returns:
double: maximum residu for all gap functions
-
void prepareNewtonIteration()
prepare for Newton iterations for all OSIs
- Returns:
maximum residu over all DSs
-
bool newtonCheckConvergence(double)
Check convergence of Newton iteration.
- Returns:
bool: true if convergent, false otherwise
-
void predictionNewtonIteration()
Predict the state of all Dynamical Systems before Newton iterations.
-
void correctionNewtonIteration()
Correct the state of all Dynamical Systems during Newton iterations.
-
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 detectEvents(bool updateIstate = true)
Detect whether or not events occur during each integration step.
- Parameters:
updateIstate – true if we need to update the flag _istate, false otherwise
- Returns:
double, maximum of absolute values of constraint fonctions over all activated ot deactivated contacts
-
void LocalizeFirstEvent()
Localize time of the first event.
-
ACCEPT_STD_VISITORS()#
Protected Attributes
-
bool _isNewtonConverge#
boolean variable to known whether Newton iterations converges or not
-
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 _localizeEventMaxIter#
Maximum number of iterations to localize events.
-
unsigned int _numberOfOneStepNSproblems#
number of OneStepNSProblems considered in the simulation
Protected Static Attributes
-
static double _TOL_ED#
an epsilon to define the contraint g for Interaction in IndexSet[1]
Private Functions
-
ACCEPT_SERIALIZATION(EventDriven)#
-
virtual void initializeOneStepNSProblem() override#
initialisation for OneStepNSProblem.
-
void initOSIs()#
Initialize OneStepIntergrators.
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
-
EventDriven(SP::NonSmoothDynamicalSystem nsds, SP::TimeDiscretisation td)