Program listing for file kernel/src/simulationTools/EventDriven.hpp#
Return to documentation for this file
1#ifndef EventDriven_H
2#define EventDriven_H
3
4#include "SiconosFwd.hpp"
5#include "Simulation.hpp"
6
7
8class EventDriven : public Simulation {
9private:
10
11 ACCEPT_SERIALIZATION(EventDriven);
12
13
14 int _istate;
15
16 void initializeOneStepNSProblem() override;
17
18
19 void initOSIs();
20
21
22 void initOSIRhs();
23
24protected:
25
26 static double _TOL_ED;
27
28
29 bool _isNewtonConverge;
30
31
32 unsigned int _newtonMaxIteration;
33
34
35 unsigned int _newtonNbIterations;
36
37
38 double _newtonResiduDSMax;
39
40
41 double _newtonResiduYMax;
42
43
44 double _newtonTolerance;
45
46
47 unsigned int _localizeEventMaxIter;
48
49
50 unsigned int _numberOfOneStepNSproblems;
51
52
53 SP::InteractionsGraph _indexSet0;
54
55
56 SP::DynamicalSystemsGraph _DSG0;
57
58public:
59
60 EventDriven(SP::NonSmoothDynamicalSystem nsds, SP::TimeDiscretisation td);
61
62
63 EventDriven(SP::NonSmoothDynamicalSystem nsds, SP::TimeDiscretisation td,
64 int nb);
65
66
67 EventDriven() : _isNewtonConverge(false){};
68
69
70 ~EventDriven() noexcept = default;
71
72
73 void initialize() override;
74
75
76 void firstInitialize() override;
77
78
79
80
81 inline void setIstate(int newValue) { _istate = newValue; }
82
83 inline double istate() { return _istate; }
84
85
86 inline void setToleranceED(double var) { _TOL_ED = var; }
87
88 inline double toleranceED() { return _TOL_ED; }
89
90
91 bool isNewtonConverge() { return _isNewtonConverge; };
92
93
94 unsigned int getNewtonNbIterations() { return _newtonNbIterations; }
95
96
97 void setNewtonMaxIteration(unsigned int maxStep)
98 {
99 _newtonMaxIteration = maxStep;
100 };
101
102
103 void setLocalizeEventsMaxIteration(unsigned int maxIter)
104 {
105 _localizeEventMaxIter = maxIter;
106 }
107
108
109 double newtonMaxIteration() { return _newtonMaxIteration; };
110
111
112 unsigned int LocalizeEventsMaxIteration() { return _localizeEventMaxIter; }
113
114
115 double newtonResiduDSMax() { return _newtonResiduDSMax; };
116
117
118 double newtonResiduYMax() { return _newtonResiduYMax; };
119
120
121 void setNewtonTolerance(double tol) { _newtonTolerance = tol; };
122
123
124 double newtonTolerance() { return _newtonTolerance; };
125
126
127 void insertIntegrator(SP::OneStepIntegrator) override;
128
129
130
131 void updateIndexSet(unsigned int i) override;
132
133
134 void updateIndexSetsWithDoubleCondition();
135
136
137 void computef(OneStepIntegrator &osi, integer *sizeOfX, doublereal *time,
138 doublereal *x, doublereal *xdot);
139
140
141 void computeJacobianfx(OneStepIntegrator &osi, integer *sizeOfX,
142 doublereal *time, doublereal *x, doublereal *jacob);
143
144
145 virtual unsigned int computeSizeOfg();
146
147
148 virtual void computeg(SP::OneStepIntegrator osi, integer *sizeX,
149 doublereal *time, doublereal *x, integer *sizeG,
150 doublereal *g);
151
152
153 void updateImpactState();
154
155
156 void updateSmoothState();
157
158
159 void updateInput(unsigned int level) override {}
160
161
162 void updateState(unsigned int level) override;
163
164
165 void updateOutput(unsigned int level) override;
166
167
168 void advanceToEvent() override;
169
170
171
172
173 double computeResiduConstraints();
174
175
176 void prepareNewtonIteration();
177
178
179 bool newtonCheckConvergence(double);
180
181
182 void predictionNewtonIteration();
183
184
185 void correctionNewtonIteration();
186
187
188 void newtonSolve(double criterion, unsigned int maxStep);
189
190
191 double detectEvents(bool updateIstate = true);
192
193
194 void LocalizeFirstEvent();
195
196 ACCEPT_STD_VISITORS();
197};
198#endif