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

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

  1#ifndef D1MINUSLINEAR_H
  2#define D1MINUSLINEAR_H
  3
  4#ifdef DEBUG_D1MINUSLINEAR
  5
  6#endif
  7
  8#include "OneStepIntegrator.hpp"
  9#include "SimpleMatrix.hpp"
 10
 11
 12
 13const double DEFAULT_TOL_D1MINUS = 1e-8;
 14
 15class D1MinusLinearOSI : public OneStepIntegrator {
 16public:
 17protected:
 18
 19  struct _NSLEffectOnFreeOutput : public SiconosVisitor {
 20
 21    using SiconosVisitor::visit;
 22
 23    OneStepNSProblem *_osnsp;
 24    SP::Interaction _inter;
 25    InteractionProperties &_interProp;
 26    _NSLEffectOnFreeOutput(OneStepNSProblem *p, SP::Interaction inter,
 27                           InteractionProperties &interProp)
 28        : _osnsp(p), _inter(inter), _interProp(interProp){};
 29
 30    void visit(const NewtonImpactNSL &nslaw);
 31    void visit(const EqualityConditionNSL &nslaw) { ; }
 32  };
 33
 34
 35  bool _isThereImpactInTheTimeStep;
 36  unsigned int _typeOfD1MinusLinearOSI;
 37
 38public:
 39
 40  enum ListOfTypeOfD1MinusLinearOSI {
 41    halfexplicit_acceleration_level,
 42    halfexplicit_acceleration_level_full,
 43    explicit_velocity_level,
 44    halfexplicit_velocity_level,
 45    numberOfTypeOfD1MinusLinearOSI
 46  };
 47
 48  enum D1MinusLinearOSI_ds_workVector_id {
 49    RESIDU_FREE,
 50    FREE,
 51    FREE_TDG,
 52    WORK_LENGTH
 53  };
 54
 55  enum D1MinusLinearOSI_interaction_workVector_id {
 56    OSNSP_RHS,
 57    WORK_INTERACTION_LENGTH
 58  };
 59
 60  enum D1MinusLinearOSI_workBlockVector_id { xfree, BLOCK_WORK_LENGTH };
 61
 62
 63  D1MinusLinearOSI();
 64
 65
 66  D1MinusLinearOSI(unsigned int type);
 67
 68
 69  virtual ~D1MinusLinearOSI(){};
 70
 71
 72  void setTypeOfD1MinusLinearOSI(unsigned int type);
 73
 74
 75  unsigned int typeOfD1MinusLinearOSI() { return _typeOfD1MinusLinearOSI; };
 76
 77
 78  unsigned int numberOfIndexSets() const override;
 79
 80
 81  void initialize_nonsmooth_problems() override;
 82
 83
 84  void initializeWorkVectorsForDS(double t, SP::DynamicalSystem ds) override;
 85
 86
 87  void initializeWorkVectorsForInteraction(Interaction &inter,
 88                                           InteractionProperties &interProp,
 89                                           DynamicalSystemsGraph &DSG) override;
 90
 91
 92  double computeResidu() override;
 93
 94
 95  virtual double computeResiduHalfExplicitAccelerationLevel();
 96
 97
 98  virtual double computeResiduHalfExplicitAccelerationLevelFull();
 99
100
101  virtual double computeResiduHalfExplicitVelocityLevel();
102
103
104  void computeFreeState() override;
105
106
107  void computeFreeOutput(InteractionsGraph::VDescriptor &vertex_inter,
108                         OneStepNSProblem *osnsp) override;
109
110
111  SiconosVector& osnsp_rhs(InteractionsGraph::VDescriptor& vertex_inter, InteractionsGraph& indexSet) override
112  {
113    return *(*indexSet.properties(vertex_inter).workVectors)[D1MinusLinearOSI::OSNSP_RHS];
114  };
115
116
117  virtual void computeFreeOutputHalfExplicitAccelerationLevel(
118      InteractionsGraph::VDescriptor &vertex_inter, OneStepNSProblem *osnsp);
119
120
121  virtual void computeFreeOutputHalfExplicitVelocityLevel(
122      InteractionsGraph::VDescriptor &vertex_inter, OneStepNSProblem *osnsp);
123
124
125  void integrate(double &ti, double &tf, double &t, int &flag) override
126  {
127    THROW_EXCEPTION("D1MinusLinearOSI::integrate - not implemented!");
128  }
129
130
131  void updateState(const unsigned int level) override;
132
133
134  bool addInteractionInIndexSet(SP::Interaction inter, unsigned int i) override;
135
136
137  bool removeInteractionFromIndexSet(SP::Interaction inter,
138                                     unsigned int i) override;
139
140
141  virtual bool
142  addInteractionInIndexSetHalfExplicitAccelerationLevel(SP::Interaction inter,
143                                                        unsigned int i);
144
145
146  virtual bool removeInteractionFromIndexSetHalfExplicitAccelerationLevel(
147      SP::Interaction inter, unsigned int i);
148
149
150  virtual bool
151  addInteractionInIndexSetHalfExplicitVelocityLevel(SP::Interaction inter,
152                                                    unsigned int i);
153
154
155  virtual bool
156  removeInteractionFromIndexSetHalfExplicitVelocityLevel(SP::Interaction inter,
157                                                         unsigned int i);
158
159
160  void display() override
161  {
162    THROW_EXCEPTION("D1MinusLinearOSI::display - not implemented!");
163  }
164
165
166  void prepareNewtonIteration(double time) override
167  {
168    THROW_EXCEPTION(
169        "D1MinusLinearOSI::prepareNewtonIteration - not implemented!");
170  }
171
172  ACCEPT_STD_VISITORS();
173};
174
175#endif