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

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#ifndef _OSNSMULTIPLEIMPACT_
#define _OSNSMULTIPLEIMPACT_

#include "LinearOSNS.hpp"
#include "SiconosConst.hpp"
#include <string>

#define DEFAULT__tolImpact MACHINE_PREC
#define DEFAULT_TOL_VEL MACHINE_PREC
#define DEFAULT_TOL_ENER MACHINE_PREC


class MultipleImpact : public LinearOSNS
{
private:

  ACCEPT_SERIALIZATION(MultipleImpact);


  double _impulseVariable = 0.;

  double _timeVariable = 0.;

  unsigned int _nContact = 0;

  unsigned int _nStepMax = 100000;

  double _tolImpact = DEFAULT__tolImpact;

  std::string _typeCompLaw = "BiStiffness";





  SP::SiconosVector _velocityContact;

  SP::SiconosVector _oldVelocityContact;

  SP::SiconosVector _energyContact;

  SP::SiconosVector _WorkcContact;

  SP::SiconosVector _distributionVector;

  SP::IndexInt _stateContact;

  SP::SiconosVector  _Kcontact;

  SP::SiconosVector _restitutionContact;

  SP::SiconosVector _elasticyCoefficientcontact;

  SP::SiconosVector _deltaImpulseContact;

  SP::SiconosVector _tolImpulseContact;

  SP::SiconosVector _impulseContactUpdate;

  SP::SiconosVector _forceContact;

  unsigned int _primaryContactId = 0;

  bool _isPrimaryContactEnergy = false;

  double _relativeVelocityPrimaryContact = 0.;

  double _energyPrimaryContact = 0.;

  double _deltaP = 0.;

  std::string  _namefile = "DataMultipleImpact.dat";

  bool _saveData = false;

  unsigned int _nStepSave = 100;

  SP::SiconosMatrix _DataMatrix;

  unsigned int _sizeDataSave = 1000;

  bool _IsImpactEnd = true;

  double _Tol_Vel = DEFAULT_TOL_VEL;

  double _Tol_Ener = DEFAULT_TOL_ENER;

  double _ZeroVel_EndIm = DEFAULT_TOL_VEL;;

  double _ZeroEner_EndIm = DEFAULT_TOL_ENER;;

  unsigned int _stepMinSave = 1, _stepMaxSave = _nStepMax;
public:


  MultipleImpact():LinearOSNS(){};


  MultipleImpact(std::string type, double step = 1.0e-5);


  ~MultipleImpact(){};


  inline std::string get_typeCompLaw() const
  {
    return _typeCompLaw;
  };


  void set_typeCompLaw(std::string newTypeLaw);


  void setTolImpact(double newTolZero);


  inline double getTolImpact()
  {
    return _tolImpact;
  };


  void SetSaveData(bool var);


  void SetNameOutput(std::string file_name);


  inline double GetStepSize()
  {
    return _deltaP;
  };


  inline double DurationImpact()
  {
    return _timeVariable;
  };


  void SetNstepSave(unsigned int var);


  void SetNstepMax(unsigned int var);


  void SetSizeDataSave(unsigned int var);


  void SetTolVel(double var);


  void SetTolEner(double var);


  void SetZeroVelEndImp(double var);


  void SetZeroEnerEndImp(double var);


  void SetStepMinMaxSave(unsigned int min,  unsigned int max);


  bool isZero(double var);


  bool isVelNegative(double var);


  bool isEnerZero(double var);


  void SelectPrimaContact();


  void Compute_distributionVector();


  void ComputeImpulseContact();


  void Compute_velocityContact();


  void Compute_energyContact();


  void UpdateDuringImpact();


  void ComputeImpact();


  void PostComputeImpact();


  bool IsMulImpactTerminate();


  void AllocateMemory();


  void BuildParaContact();


  void InitializeInput();


  void Check_stateContact();


  void PreComputeImpact();


  void PrimConVelocity();


  void PrimConEnergy();


  bool IsEnermaxZero();


  bool IsVcminNegative();


  int compute(double time);


  void initialize(SP::Simulation sim);


  bool checkCompatibleNSLaw(NonSmoothLaw& nslaw);

  void display() const;



  void WriteVectorIntoMatrix(const SiconosVector& v, const unsigned int row, const unsigned int col);


  void SaveDataOneStep(unsigned int i);


  unsigned int EstimateNdataCols();

  ACCEPT_STD_VISITORS();
};

#endif