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

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

  1#ifndef _OSNSMULTIPLEIMPACT_
  2#define _OSNSMULTIPLEIMPACT_
  3
  4#include "LinearOSNS.hpp"
  5#include "SiconosConst.hpp"
  6
  7#include <string>
  8
  9#define DEFAULT__tolImpact MACHINE_PREC
 10#define DEFAULT_TOL_VEL MACHINE_PREC
 11#define DEFAULT_TOL_ENER MACHINE_PREC
 12
 13
 14class MultipleImpact : public LinearOSNS {
 15private:
 16
 17  ACCEPT_SERIALIZATION(MultipleImpact);
 18
 19
 20  double _impulseVariable = 0.;
 21
 22  double _timeVariable = 0.;
 23
 24  unsigned int _nContact = 0;
 25
 26  unsigned int _nStepMax = 100000;
 27
 28  double _tolImpact = DEFAULT__tolImpact;
 29
 30  std::string _typeCompLaw = "BiStiffness";
 31
 32
 33
 34
 35
 36  SP::SiconosVector _velocityContact;
 37
 38
 39  SP::SiconosVector _oldVelocityContact;
 40
 41  SP::SiconosVector _energyContact;
 42
 43  SP::SiconosVector _WorkcContact;
 44
 45  SP::SiconosVector _distributionVector;
 46
 47  SP::IndexInt _stateContact;
 48
 49  SP::SiconosVector _Kcontact;
 50
 51  SP::SiconosVector _restitutionContact;
 52
 53  SP::SiconosVector _elasticyCoefficientcontact;
 54
 55  SP::SiconosVector _deltaImpulseContact;
 56
 57  SP::SiconosVector _tolImpulseContact;
 58
 59  SP::SiconosVector _impulseContactUpdate;
 60
 61  SP::SiconosVector _forceContact;
 62
 63  unsigned int _primaryContactId = 0;
 64
 65  bool _isPrimaryContactEnergy = false;
 66
 67  double _relativeVelocityPrimaryContact = 0.;
 68
 69  double _energyPrimaryContact = 0.;
 70
 71  double _deltaP = 0.;
 72
 73  std::string _namefile = "DataMultipleImpact.dat";
 74
 75  bool _saveData = false;
 76
 77  unsigned int _nStepSave =
 78      100;
 79
 80  SP::SiconosMatrix _DataMatrix;
 81
 82  unsigned int _sizeDataSave = 1000;
 83
 84  bool _IsImpactEnd = true;
 85
 86  double _Tol_Vel = DEFAULT_TOL_VEL;
 87
 88  double _Tol_Ener = DEFAULT_TOL_ENER;
 89
 90
 91  double _ZeroVel_EndIm = DEFAULT_TOL_VEL;
 92
 93
 94  double _ZeroEner_EndIm = DEFAULT_TOL_ENER;
 95
 96  unsigned int _stepMinSave = 1, _stepMaxSave = _nStepMax;
 97
 98public:
 99
100  MultipleImpact() : LinearOSNS(){};
101
102
103  MultipleImpact(std::string type, double step = 1.0e-5);
104
105
106  ~MultipleImpact(){};
107
108
109  inline std::string get_typeCompLaw() const { return _typeCompLaw; };
110
111
112  void set_typeCompLaw(std::string newTypeLaw);
113
114
115  void setTolImpact(double newTolZero);
116
117
118  inline double getTolImpact() { return _tolImpact; };
119
120
121  void SetSaveData(bool var);
122
123
124  void SetNameOutput(std::string file_name);
125
126
127  inline double GetStepSize() { return _deltaP; };
128
129
130  inline double DurationImpact() { return _timeVariable; };
131
132
133  void SetNstepSave(unsigned int var);
134
135
136  void SetNstepMax(unsigned int var);
137
138
139  void SetSizeDataSave(unsigned int var);
140
141
142  void SetTolVel(double var);
143
144
145  void SetTolEner(double var);
146
147
148  void SetZeroVelEndImp(double var);
149
150
151  void SetZeroEnerEndImp(double var);
152
153
154  void SetStepMinMaxSave(unsigned int min, unsigned int max);
155
156
157  bool isZero(double var);
158
159
160  bool isVelNegative(double var);
161
162
163  bool isEnerZero(double var);
164
165
166  void SelectPrimaContact();
167
168
169  void Compute_distributionVector();
170
171
172  void ComputeImpulseContact();
173
174
175  void Compute_velocityContact();
176
177
178  void Compute_energyContact();
179
180
181  void UpdateDuringImpact();
182
183
184  void ComputeImpact();
185
186
187  void PostComputeImpact();
188
189
190  bool IsMulImpactTerminate();
191
192
193  void AllocateMemory();
194
195
196  void BuildParaContact();
197
198
199  void InitializeInput();
200
201
202  void Check_stateContact();
203
204
205  void PreComputeImpact();
206
207
208  void PrimConVelocity();
209
210
211  void PrimConEnergy();
212
213
214  bool IsEnermaxZero();
215
216
217  bool IsVcminNegative();
218
219
220  int compute(double time) override;
221
222
223  void initialize(SP::Simulation sim) override;
224
225  bool checkCompatibleNSLaw(NonSmoothLaw &nslaw) override;
226
227  void display() const override;
228
229
230
231  void WriteVectorIntoMatrix(const SiconosVector &v, const unsigned int row,
232                             const unsigned int col);
233
234
235  void SaveDataOneStep(unsigned int i);
236
237
238  unsigned int EstimateNdataCols();
239
240  ACCEPT_STD_VISITORS();
241};
242
243#endif