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

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

  1#ifndef LsodarOSI_H
  2#define LsodarOSI_H
  3
  4#include "OneStepIntegrator.hpp"
  5
  6#include <vector>
  7
  8#define ATOL_DEFAULT 100 * MACHINE_PREC;
  9#define RTOL_DEFAULT 10 * MACHINE_PREC;
 10
 11
 12class LsodarOSI : public OneStepIntegrator {
 13private:
 14  ACCEPT_SERIALIZATION(LsodarOSI);
 15
 16
 17  std::vector<integer> _intData;
 18
 19  unsigned int _sizeTol;
 20
 21
 22  unsigned int _itol;
 23
 24
 25  SA::doublereal rtol;
 26
 27  SA::doublereal atol;
 28
 29  SA::doublereal rwork;
 30
 31  SA::integer iwork;
 32
 33  SA::integer jroot;
 34
 35  SP::BlockVector _xWork;
 36
 37  SP::SiconosVector _xtmp;
 38
 39  struct _NSLEffectOnFreeOutput;
 40  friend struct _NSLEffectOnFreeOutput;
 41
 42public:
 43  enum LsodarOSI_ds_workVector_id { FREE, WORK_LENGTH };
 44
 45  enum LsodarOSI_interaction_workVector_id { OSNSP_RHS, WORK_INTERACTION_LENGTH };
 46
 47  enum LsodarOSI_interaction_workBlockVector_id { xfree, BLOCK_WORK_LENGTH };
 48
 49
 50  static int count_NST;
 51
 52  static int count_NFE;
 53
 54
 55  LsodarOSI();
 56
 57
 58  ~LsodarOSI(){};
 59
 60
 61  inline const std::vector<integer> intData() const { return _intData; }
 62
 63
 64  inline integer intData(unsigned int i) const { return _intData[i]; }
 65
 66
 67  inline void setIntData(unsigned int i, int newValue) { _intData[i] = newValue; }
 68
 69
 70  inline const SA::doublereal getRtol() const { return rtol; }
 71
 72
 73  inline const SA::doublereal getAtol() const { return atol; }
 74
 75
 76  inline int getMaxNstep() const { return iwork[5]; }
 77
 78
 79  inline const SA::doublereal getRwork() const { return rwork; }
 80
 81
 82  inline SA::integer getIwork() const { return iwork; }
 83
 84
 85  inline SA::integer getJroot() const { return jroot; }
 86
 87
 88  inline void setJT(integer newJT) { _intData[8] = newJT; };
 89
 90
 91  void setTol(integer newItol, SA::doublereal newRtol, SA::doublereal newAtol);
 92
 93
 94  void setTol(integer newItol, doublereal newRtol, doublereal newAtol);
 95
 96
 97  void setMaxNstep(integer maxNumberSteps);
 98
 99
100  void setMinMaxStepSizes(doublereal minStep, doublereal maxStep);
101
102
103  void setMaxOrder(integer maxorderNonStiff, integer maxorderStiff);
104
105
106  void updateData();
107
108
109  void fillXWork(integer *size, doublereal *array);
110
111
112  void computeRhs(double t);
113
114
115  void computeJacobianRhs(double t, DynamicalSystemsGraph &DSG0);
116
117  void f(integer *sizeOfX, doublereal *time, doublereal *x, doublereal *xdot);
118
119  void g(integer *nEq, doublereal *time, doublereal *x, integer *ng, doublereal *gOut);
120
121  void jacobianfx(integer *, doublereal *, doublereal *, integer *, integer *, doublereal *,
122                  integer *);
123
124
125  void initialize() override;
126
127
128  void initializeWorkVectorsForDS(double t, SP::DynamicalSystem ds) override;
129
130
131  void initializeWorkVectorsForInteraction(Interaction &inter,
132                                           InteractionProperties &interProp,
133                                           DynamicalSystemsGraph &DSG) override;
134
135
136  unsigned int numberOfIndexSets() const override { return 3; };
137
138
139  void integrate(double &tinit, double &tend, double &tout, int &ioparam) override;
140
141
142  void updateState(const unsigned int level) override;
143
144  void prepareNewtonIteration(double time) override { assert(0); };
145
146
147  void computeFreeOutput(InteractionsGraph::VDescriptor &vertex_descr,
148                         OneStepNSProblem *osnsp) override;
149
150
151  SiconosVector& osnsp_rhs(InteractionsGraph::VDescriptor& vertex_inter, InteractionsGraph& indexSet) override
152  {
153    return *(*indexSet.properties(vertex_inter).workVectors)[LsodarOSI::OSNSP_RHS];
154  };
155
156
157  void display() override;
158
159
160  static int count_rhs_call() { return count_NFE; }
161
162
163  static int count_steps() { return count_NST; }
164
165  ACCEPT_STD_VISITORS();
166};
167
168#endif