Program listing for file kernel/src/simulationTools/Hem5OSI.hpp#
Return to documentation for this file
1#ifndef Hem5OSI_H
2#define Hem5OSI_H
3
4#include "OneStepIntegrator.hpp"
5
6#include <vector>
7
8#define HEM5_ATOL_DEFAULT 100 * MACHINE_PREC;
9#define HEM5_RTOL_DEFAULT 10 * MACHINE_PREC;
10
11class Hem5OSI_impl;
12TYPEDEF_SPTR(Hem5OSI_impl);
13
14
15class Hem5OSI : public OneStepIntegrator {
16private:
17
18 ACCEPT_SERIALIZATION(Hem5OSI);
19
20
21 std::vector<integer> _intData;
22
23 integer _idid;
24
25
26 SA::doublereal rtol;
27
28 SA::doublereal atol;
29
30 SA::doublereal rwork;
31
32 SA::integer iwork;
33
34 doublereal _timeStep;
35
36
37 SP::BlockVector _qWork;
38
39 SP::BlockVector _vWork;
40
41 SP::BlockVector _uWork;
42
43 SP::BlockVector _aWork;
44
45 SP::BlockVector _lambdaWork;
46
47 SP::BlockVector _forcesWork;
48
49 SP::SiconosVector _qtmp;
50 SP::SiconosVector _vtmp;
51 SP::SiconosVector _utmp;
52 SP::SiconosVector _atmp;
53 SP::SiconosVector _lambdatmp;
54 SP::SiconosVector _forcestmp;
55
56
57 struct _NSLEffectOnFreeOutput;
58 friend struct _NSLEffectOnFreeOutput;
59
60public:
61 SP::Hem5OSI_impl _impl;
62 friend class Hem5OSI_impl;
63
64 enum Hem5OSI_ds_workVector_id { FREE, WORK_LENGTH };
65
66 enum Hem5OSI_interaction_workVector_id { OSNSP_RHS, WORK_INTERACTION_LENGTH };
67
68 enum Hem5OSI_interaction_workBlockVector_id { xfree, BLOCK_WORK_LENGTH };
69
70
71 Hem5OSI();
72
73
74 ~Hem5OSI(){};
75
76
77 inline const std::vector<integer> intData() const { return _intData; }
78
79
80 inline integer intData(unsigned int i) const { return _intData[i]; }
81
82 inline void setIntData(unsigned int i, int newValue)
83 {
84 _intData[i] = newValue;
85 }
86
87
88 inline const SA::doublereal getRtol() const { return rtol; }
89
90
91 inline const SA::doublereal getAtol() const { return atol; }
92
93
94 inline int getMaxNstep() const { return iwork[11]; }
95
96
97 inline const SA::doublereal getRwork() const { return rwork; }
98
99
100 inline SA::integer getIwork() const { return iwork; }
101
102
103 void setTol(integer itol, SA::doublereal rtol, SA::doublereal atol);
104
105
106 void setTol(integer itol, doublereal rtol, doublereal atol);
107
108
109 void setMaxNstep(integer nstepmax);
110
111
112 void setMaxStepSize(doublereal maxstepsize);
113
114
115 void updateIntData();
116
117
118 void updateData();
119
120
121 void fillqWork(integer *sizex, doublereal *x);
122
123
124 void fillvWork(integer *sizex, doublereal *x);
125
126
127 void computeRhs(double);
128
129
130 void computeJacobianRhs(double);
131
132 unsigned int numberOfConstraints();
133
134 void f(integer *sizeOfX, doublereal *time, doublereal *x, doublereal *xdot);
135
136 void g(integer *nEq, doublereal *time, doublereal *x, integer *ng,
137 doublereal *gOut);
138
139 void jacobianfx(integer *, doublereal *, doublereal *, integer *, integer *,
140 doublereal *, integer *);
141
142
143 void initialize() override;
144
145 void initializeWorkVectorsForDS(double t, SP::DynamicalSystem ds) override;
146
147
148 void initializeWorkVectorsForInteraction(Interaction &inter,
149 InteractionProperties &interProp,
150 DynamicalSystemsGraph &DSG) override;
151
152
153 unsigned int numberOfIndexSets() const override { return 3; };
154
155
156 void integrate(double &tinit, double &tend, double &tout, int &idid) override;
157
158
159 void updateState(const unsigned int level) override;
160
161 void prepareNewtonIteration(double time) override { assert(0); };
162
163
164 void computeFreeOutput(InteractionsGraph::VDescriptor &vertex_inter,
165 OneStepNSProblem *osnsp) override;
166
167
168 SiconosVector& osnsp_rhs(InteractionsGraph::VDescriptor& vertex_inter, InteractionsGraph& indexSet) override
169 {
170 return *(*indexSet.properties(vertex_inter).workVectors)[Hem5OSI::OSNSP_RHS];
171 };
172
173
174 void display() override;
175
176 ACCEPT_STD_VISITORS();
177};
178
179#endif