Program listing for file kernel/src/modelingTools/NonSmoothDynamicalSystem.hpp#
Return to documentation for this file
1#ifndef NSDS_H
2#define NSDS_H
3
4#include "SiconosPointers.hpp"
5#include "Topology.hpp"
6#include "DynamicalSystem.hpp"
7
8
9class NonSmoothDynamicalSystem
10{
11public:
12 typedef enum
13 {
14 addDynamicalSystem, rmDynamicalSystem, addInteraction, rmInteraction, clearTopology
15 } ChangeType;
16
17 class Change
18 {
19 private:
20 ACCEPT_SERIALIZATION(NonSmoothDynamicalSystem::Change);
21 Change() = default;
22 public:
23 ChangeType typeOfChange;
24 SP::DynamicalSystem ds;
25 SP::Interaction i;
26
27 Change(ChangeType t, SP::DynamicalSystem dsnew ):typeOfChange(t),ds(dsnew){};
28 Change(ChangeType t, SP::Interaction inew):typeOfChange(t),i(inew){};
29 Change(ChangeType t):typeOfChange(t){};
30 void display() const;
31 };
32
33 typedef std::list<Change> ChangeLog;
34 class ChangeLogIter
35 {
36 ACCEPT_SERIALIZATION(NonSmoothDynamicalSystem::Change);
37 public:
38 ChangeLogIter(){};
39 ChangeLogIter(const ChangeLog& log,
40 const ChangeLog::const_iterator& i)
41 : _log(&log), it(i) {};
42 const ChangeLog *_log;
43 ChangeLog::const_iterator it;
44 };
45
46private:
47
48 ACCEPT_SERIALIZATION(NonSmoothDynamicalSystem);
49
50
51 double _t0 = 0.;
52
53
54 double _t = _t0;
55
56
57 double _T = 0.;
58
59
60 std::string _title = "none",
61 _author = "none",
62 _description = "none",
63 _date="unknown";
64
65
66 bool _BVP = false;
67
68
69 std::list<Change> _changeLog;
70
71
72 SP::Topology _topology;
73
74
75 bool _mIsLinear = true;
76
77
78 NonSmoothDynamicalSystem(const NonSmoothDynamicalSystem& nsds) = delete;
79
80
81 OneStepNSProblem& operator=(const OneStepNSProblem& osnsp) = delete;
82
83
84protected:
85 NonSmoothDynamicalSystem(){};
86
87public:
88
89
90 NonSmoothDynamicalSystem(double t0, double T);
91
92
93 ~NonSmoothDynamicalSystem();
94
95
96
97 inline double currentTime() const
98 {
99 return _t;
100 }
101
102
103 inline void setCurrentTime(double newValue)
104 {
105 _t = newValue;
106 }
107
108
109 inline double t0() const
110 {
111 return _t0;
112 }
113
114
115 inline void sett0(double newT0)
116 {
117 _t0 = newT0;
118 };
119
120
121 inline double finalT() const
122 {
123 return _T;
124 }
125
126
127 void setT(double newValue)
128 {
129 _T = newValue;
130 };
131
132
133 inline const std::string title() const
134 {
135 return _title;
136 }
137
138
139 inline void setTitle(const std::string & s)
140 {
141 _title = s;
142 }
143
144
145 inline const std::string author() const
146 {
147 return _author;
148 }
149
150
151 inline void setAuthor(const std::string & s)
152 {
153 _author = s;
154 }
155
156
157 inline const std::string description() const
158 {
159 return _description;
160 }
161
162
163 inline void setDescription(const std::string & s)
164 {
165 _description = s;
166 }
167
168
169 inline const std::string date() const
170 {
171 return _date;
172 }
173
174
175 inline void setDate(const std::string & s)
176 {
177 _date = s;
178 }
179
180
181 inline bool isBVP() const
182 {
183 return _BVP;
184 }
185
186
187 inline bool isIVP() const
188 {
189 return !_BVP;
190 }
191
192
193 inline void setBVP(const bool& newBvp)
194 {
195 _BVP = newBvp;
196 }
197
198
199
200 inline const ChangeLog& changeLog()
201 {
202 return _changeLog;
203 };
204
205
206 inline ChangeLogIter changeLogPosition()
207 {
208 ChangeLogIter it(_changeLog, _changeLog.end());
209
210 --it.it;
211 return it;
212 };
213
214
215 inline ChangeLogIter changeLogBegin()
216 {
217 ChangeLogIter it(_changeLog, _changeLog.begin());
218 return it;
219 };
220
221
222 void clearChangeLogTo(const ChangeLogIter& it);
223
224
225
226
227
228 inline size_t getNumberOfDS() const
229 {
230 return _topology->dSG(0)->size();
231 }
232
233
234 inline const SP::DynamicalSystemsGraph dynamicalSystems() const
235 {
236 return _topology->dSG(0);
237 }
238
239
240 std::vector<SP::DynamicalSystem> dynamicalSystemsVector() const;
241
242
243
244 void insertDynamicalSystem(SP::DynamicalSystem ds);
245
246
247 inline SP::DynamicalSystem dynamicalSystem(unsigned int nb) const
248 {
249 return _topology->getDynamicalSystem(nb);
250 }
251 inline void displayDynamicalSystems() const
252 {
253 _topology->displayDynamicalSystems();
254 }
255
256
257 void removeDynamicalSystem(SP::DynamicalSystem ds);
258
259
260
261
262 inline size_t getNumberOfInteractions() const
263 {
264 return _topology->indexSet0()->size();
265 };
266
267
268 inline const SP::InteractionsGraph interactions() const
269 {
270 return _topology->indexSet0();
271 };
272
273
274
275 void removeInteraction(SP::Interaction inter);
276
277
278 inline SP::Interaction interaction(unsigned int nb) const
279 {
280 return _topology->getInteraction(nb);
281 }
282
283
284 inline SP::Interaction interaction(std::string name) const
285 {
286 return _topology->getInteraction(name);
287 }
288
289
290 std::vector<SP::Interaction> InteractionsVector() const;
291
292
293 void link(SP::Interaction inter, SP::DynamicalSystem ds1, SP::DynamicalSystem ds2 = SP::DynamicalSystem());
294
295
296 inline void setName(SP::DynamicalSystem ds, const std::string& name)
297 {
298 _topology->setName(ds, name);
299 };
300
301
302 std::string name(SP::DynamicalSystem ds)
303 {
304 return _topology->name(ds);
305 }
306
307
308 inline void setName(SP::Interaction interaction, const std::string& name)
309 {
310 _topology->setName(interaction, name);
311 };
312
313
314 std::string name(SP::Interaction inter)
315 {
316 return _topology->name(inter);
317 }
318
319
320 void setControlProperty(SP::Interaction inter, const bool isControlInteraction)
321 {
322 _topology->setControlProperty(inter, isControlInteraction);
323 }
324
325
326
327 inline SP::Topology topology() const
328 {
329 return _topology;
330 }
331
332
333 void display() const;
334
335
336 inline bool isLinear() const
337 {
338 return _mIsLinear;
339 };
340
341 void clear();
342
343
344 void setSymmetric(bool val);
345
346
347 void resetNonSmoothPart(unsigned int level);
348
349
350 void swapInMemory();
351
352
353 void pushInteractionsInMemory();
354
355
356 void updateDSPlugins(double time);
357
358
359 void updateInput(double time, unsigned int level);
360
361
362 void updateOutput(double time, unsigned int level = 0);
363
364
365 void updateOutput(double time, unsigned int level_min, unsigned int level_max);
366
367
368 void computeInteractionJacobians(double time);
369
370
371 void computeInteractionJacobians(double time, InteractionsGraph& indexSet);
372
373
374 void visitDynamicalSystems(SP::SiconosVisitor visitor);
375};
376
377
378#endif