Program listing for file kernel/src/simulationTools/EulerMoreauOSI.hpp

Program listing for file kernel/src/simulationTools/EulerMoreauOSI.hpp#

  1#ifndef EulerMoreauOSI_H
  2#define EulerMoreauOSI_H
  3
  4#include "OneStepIntegrator.hpp"
  5
  6
  7
  8class EulerMoreauOSI : public OneStepIntegrator {
  9protected:
 10  ACCEPT_SERIALIZATION(EulerMoreauOSI);
 11
 12
 13  double _theta;
 14
 15
 16  double _gamma;
 17
 18
 19  bool _useGamma;
 20
 21
 22  bool _useGammaForRelation;
 23
 24
 25  struct _NSLEffectOnFreeOutput;
 26
 27  friend struct _NSLEffectOnFreeOutput;
 28
 29
 30  EulerMoreauOSI(){};
 31
 32public:
 33  enum EulerMoreauOSI_ds_workVector_id {
 34    RESIDU,
 35    RESIDU_FREE,
 36    FREE,
 37    X_PARTIAL_NS_FOR_RELATION,
 38    DELTA_X_FOR_RELATION,
 39    LOCAL_BUFFER,
 40    WORK_LENGTH
 41  };
 42
 43  enum EulerMoreauOSI_interaction_workVector_id {
 44    OSNSP_RHS,
 45    VEC_X,
 46    H_ALPHA,
 47    VEC_RESIDU_Y,
 48    VEC_RESIDU_R,
 49    YOLD,
 50    LAMBDAOLD,
 51    WORK_INTERACTION_LENGTH
 52  };
 53
 54  enum EulerMoreauOSI_interaction_workBlockVector_id {
 55    XFREE,
 56    X_PARTIAL_NS,
 57    DELTA_X,
 58    G_ALPHA,
 59    BLOCK_WORK_LENGTH
 60  };
 61
 62  enum EulerMoreauOSI_interaction_workMat_id {
 63    MAT_KHAT,
 64    MAT_KTILDE,
 65    MAT_WORK_LENGTH
 66  };
 67
 68
 69  EulerMoreauOSI(double theta);
 70
 71
 72  EulerMoreauOSI(double theta, double gamma);
 73
 74
 75  virtual ~EulerMoreauOSI(){};
 76
 77
 78
 79
 80  const SimpleMatrix getW(SP::DynamicalSystem ds = SP::DynamicalSystem());
 81
 82
 83  SP::SimpleMatrix W(SP::DynamicalSystem ds);
 84
 85
 86
 87
 88  const SimpleMatrix
 89  getWBoundaryConditions(SP::DynamicalSystem ds = SP::DynamicalSystem());
 90
 91
 92  SP::SiconosMatrix WBoundaryConditions(SP::DynamicalSystem ds);
 93
 94
 95
 96
 97  inline double theta() { return _theta; };
 98
 99
100  inline void setTheta(double newTheta) { _theta = newTheta; };
101
102
103
104
105  inline double gamma() { return _gamma; };
106
107
108  inline void setGamma(double newGamma)
109  {
110    _gamma = newGamma;
111    _useGamma = true;
112  };
113
114
115
116
117  inline bool useGamma() { return _useGamma; };
118
119
120  inline void setUseGamma(bool b) { _useGamma = b; };
121
122
123  inline bool useGammaForRelation() { return _useGammaForRelation; };
124
125
126  inline void setUseGammaForRelation(bool newUseGammaForRelation)
127  {
128    _useGammaForRelation = newUseGammaForRelation;
129    if (_useGammaForRelation)
130      _useGamma = false;
131  };
132
133
134
135
136
137
138
139  void initializeWorkVectorsForDS(double t, SP::DynamicalSystem ds) override;
140
141
142  void initializeWorkVectorsForInteraction(Interaction &inter,
143                                           InteractionProperties &interProp,
144                                           DynamicalSystemsGraph &DSG) override;
145
146
147  unsigned int numberOfIndexSets() const override { return 1; } ;
148
149
150  void initializeIterationMatrixW(double time, SP::DynamicalSystem ds);
151
152
153  void computeW(double time, DynamicalSystem &ds,
154                DynamicalSystemsGraph::VDescriptor &dsv, SiconosMatrix &W);
155
156  void computeKhat(Interaction &inter, SiconosMatrix &m,
157                   VectorOfSMatrices &workM, double h) const;
158
159
160  void computeWBoundaryConditions(SP::DynamicalSystem ds);
161
162
163  void initializeIterationMatrixWBoundaryConditions(SP::DynamicalSystem ds);
164
165
166  double computeResidu() override;
167
168
169  void computeFreeState() override;
170
171
172  void updateOutput(double time) override;
173
174
175  void updateInput(double time) override;
176
177
178  void updateOutput(double time, unsigned int level) override;
179
180
181  void updateInput(double time, unsigned int level) override;
182
183  double computeResiduOutput(double time,
184                             SP::InteractionsGraph indexSet) override;
185
186  double computeResiduInput(double time,
187                            SP::InteractionsGraph indexSet) override;
188
189
190  void computeFreeOutput(InteractionsGraph::VDescriptor &vertex_inter,
191                         OneStepNSProblem *osnsp) override;
192
193
194
195  SiconosVector& osnsp_rhs(InteractionsGraph::VDescriptor& vertex_inter,   InteractionsGraph& indexSet) override
196  {
197    return *(*indexSet.properties(vertex_inter).workVectors)[EulerMoreauOSI::OSNSP_RHS];
198  };
199
200
201  void prepareNewtonIteration(double time) override;
202
203
204  void integrate(double &tinit, double &tend, double &tout,
205                 int &useless) override;
206
207
208  void updateState(const unsigned int level) override;
209
210
211  void display() override;
212
213  ACCEPT_STD_VISITORS();
214};
215
216#endif