MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
module-damper-graall.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/modules/module-damper-graall/module-damper-graall.cc,v 1.5 2017/01/12 14:50:01 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include <cmath>
35 #include <cfloat>
36 #include <fstream>
37 
38 #include "dataman.h"
39 #include "drive_.h"
40 #include "constltp.h"
41 
42 /* GRAALLDamperConstitutiveLaw - begin */
43 
44 extern "C" {
45 int __FC_DECL__(dmpfr) (doublereal* DL,
46  doublereal* DLDT,
47  doublereal* V,
48  doublereal* TBDMR,
49  doublereal* TBDMA,
50  doublereal* TBCVR,
51  doublereal* TBCVA,
52  doublereal* VETVIS,
53  integer* NPDMR,
54  integer* NPDMA,
55  integer* NPCVR,
56  integer* NPCVA,
57  integer* NPVT,
58  doublereal* FTOT,
59  doublereal* FVISDL,
60  doublereal* FELDL);
61 }
62 
64 : public ConstitutiveLaw<doublereal, doublereal> {
65 private:
66  enum {
67  RLA = 1,
68  PNTR = 2,
69  P0 = 3,
70  A0 = 4,
71  RL0 = 5,
72  PLTREX = 6,
73  TCOST = 7,
74  TLIN = 8,
75  TEMPORIF = 9,
76  VELRIF = 10,
77  CORONA = 11,
78  TRIFVUOTO = 12,
79  T = 13,
80  TRIFTEMP = 14,
81  RNURIF = 15,
82  ASTNT = 16,
83  R0 = 17,
84  TIME = 18
85  };
86 
88 
89  /*
90  RLA = 0, // lunghezza iniziale ammortizzatore
91  PNTR; // coeff. di interazione corsa
92  P0; // pressione di precarica
93  A0; // sezione gas
94  RL0; // lunghezza iniziale camera gas
95  PLTREX // esponente politropica
96  tcost;
97  tlin; // legge lineare coeff attrito con corsa
98  C temporif tempo di riferimento per profilo attrito
99  C velrif velocita' di riferimento per profilo attrito
100  C corona area corona per effetto risucchio
101  C trifvuoto tempo di riferimento per profilo attrito
102  C T temperatura olio in passaggio
103  C triftemp tempo di riferimento per effetto temperatura olio
104  C RNURIF cvis di riferimento
105  C SWITCH 0 ammortizzatore passivo, >0 modo di controllo
106  C ASTNT sezione stantuffo olio
107  C RO densita' olio
108 
109  C TIME tempo dall'inizio della compressione dell'ammortizzatore
110 
111  C TBDMR tabella sezione trafilamento ritorno NPDMR punti
112  C TBDMA tabella sezione trafilamento andata NPDMA punti
113  C TBCVR tabella coeff. efflusso ritorno NPCVR punti
114  C TBCVA tabella coeff. efflusso ritorno NPCVA punti
115  C VETVIS tabella viscosita'/temperatura NPVT punti
116  */
117 
124 
128 
129 public:
131  const doublereal& rla,
132  const char* const filename)
134  NPDMR(0), NPDMA(0), NPCVR(0), NPCVA(0), NPVT(0),
135  TBDMR(NULL), TBDMA(NULL), TBCVR(NULL), TBCVA(NULL), VETVIS(NULL),
136  dT0(0.), Time(pDC), fWorking(0)
137  {
138  char s[1024];
139 
140  /* Si assume che il drive che viene passato sia in realta'
141  * un drive di tipo Time, che verra' usato per conoscere
142  * il tempo della simulazione */
143 
144  /* apre il file di ingresso in formato graal */
145  std::ifstream in(filename);
146 
147  /* legge alcuni parametri */
148  in.getline(s, sizeof(s));
149  DEBUGLCOUT(MYDEBUG_INPUT, "Skipping ... (remark: \"" << s
150  << "\")" << std::endl);
151 
152  in >> v[P0-1];
153  in.getline(s, sizeof(s));
154  DEBUGLCOUT(MYDEBUG_INPUT, "Reading P0 (=" << v[P0-1]
155  << ", remark: \"" << s << "\")" << std::endl);
156 
157  in >> v[A0-1];
158  in.getline(s, sizeof(s));
159  DEBUGLCOUT(MYDEBUG_INPUT, "Reading A0 (=" << v[A0-1]
160  << ", remark: \"" << s << "\")" << std::endl);
161 
162  in >> v[PNTR-1];
163  in.getline(s, sizeof(s));
164  DEBUGLCOUT(MYDEBUG_INPUT, "Reading PNTR (=" << v[PNTR-1]
165  << ", remark: \"" << s << "\")" << std::endl);
166 
167  in >> v[RL0-1];
168  in.getline(s, sizeof(s));
169  DEBUGLCOUT(MYDEBUG_INPUT, "Reading RL0 (=" << v[RL0-1]
170  << ", remark: \"" << s << "\")" << std::endl);
171 
172  in >> v[PLTREX-1];
173  in.getline(s, sizeof(s));
174  DEBUGLCOUT(MYDEBUG_INPUT, "Reading PLTREX (=" << v[PLTREX-1]
175  << ", remark: \"" << s << "\")" << std::endl);
176 
177  in.getline(s, sizeof(s));
178  DEBUGLCOUT(MYDEBUG_INPUT, "Skipping ... (remark: \"" << s
179  << "\")" << std::endl);
180 
181  in >> v[ASTNT-1];
182  in.getline(s, sizeof(s));
183  DEBUGLCOUT(MYDEBUG_INPUT, "Reading ASTNT (=" << v[ASTNT-1]
184  << ", remark: \"" << s << "\")" << std::endl);
185 
186  in >> v[R0-1];
187  in.getline(s, sizeof(s));
188  DEBUGLCOUT(MYDEBUG_INPUT, "Reading R0 (=" << v[R0-1]
189  << ", remark: \"" << s << "\")" << std::endl);
190 
191  in >> v[TCOST-1];
192  in.getline(s, sizeof(s));
193  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TCOST (=" << v[TCOST-1]
194  << ", remark: \"" << s << "\")" << std::endl);
195 
196  in >> v[TLIN-1];
197  in.getline(s, sizeof(s));
198  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TLIN (=" << v[TLIN-1]
199  << ", remark: \"" << s << "\")" << std::endl);
200 
201  in >> v[TEMPORIF-1];
202  in.getline(s, sizeof(s));
203  DEBUGLCOUT(MYDEBUG_INPUT, "Reading A0 (=" << v[TEMPORIF-1]
204  << ", remark: \"" << s << "\")" << std::endl);
205 
206  in >> v[VELRIF-1];
207  in.getline(s, sizeof(s));
208  DEBUGLCOUT(MYDEBUG_INPUT, "Reading VELRIF (=" << v[VELRIF-1]
209  << ", remark: \"" << s << "\")" << std::endl);
210 
211  in >> v[CORONA-1];
212  in.getline(s, sizeof(s));
213  DEBUGLCOUT(MYDEBUG_INPUT, "Reading CORONA (=" << v[CORONA-1]
214  << ", remark: \"" << s << "\")" << std::endl);
215 
216  in >> v[TRIFVUOTO-1];
217  in.getline(s, sizeof(s));
218  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TRIFVUOTO (=" << v[TRIFVUOTO-1]
219  << ", remark: \"" << s << "\")" << std::endl);
220 
221  in >> v[RNURIF-1];
222  in.getline(s, sizeof(s));
223  DEBUGLCOUT(MYDEBUG_INPUT, "Reading RNURIF (=" << v[RNURIF-1]
224  << ", remark: \"" << s << "\")" << std::endl);
225 
226  in >> v[TRIFTEMP-1];
227  in.getline(s, sizeof(s));
228  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TRIFTEMP (=" << v[TRIFTEMP-1]
229  << ", remark: \"" << s << "\")" << std::endl);
230 
231  /* legge le tabelle */
232 
233  /* legge TBDMR */
234  in.getline(s, sizeof(s));
235  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TBDMR (remark: \"" << s
236  << "\")" << std::endl);
237 
238  in >> NPDMR;
239  in.getline(s, sizeof(s));
240  DEBUGLCOUT(MYDEBUG_INPUT, "NPDMR=" << NPDMR
241  << " (remark: \"" << s << "\")" << std::endl);
242 
243  SAFENEWARR(TBDMR, doublereal, 2*NPDMR);
244 
245  for (integer i = 0; i < NPDMR; i++) {
246  in >> TBDMR[i];
247  in >> TBDMR[NPDMR+i];
248  in.getline(s, sizeof(s));
249  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TBDMR[" << i+1
250  << "]=(" << TBDMR[i]
251  << "," << TBDMR[NPDMR+i]
252  << ") (remark: \"" << s << "\")" << std::endl);
253  }
254 
255  /* legge TBDMA */
256  in.getline(s, sizeof(s));
257  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TBDMA (remark: \"" << s
258  << "\")" << std::endl);
259 
260  in >> NPDMA;
261  in.getline(s, sizeof(s));
262  DEBUGLCOUT(MYDEBUG_INPUT, "NPDMA=" << NPDMA
263  << " (remark: \"" << s << "\")" << std::endl);
264 
265  SAFENEWARR(TBDMA, doublereal, 2*NPDMA);
266 
267  for (integer i = 0; i < NPDMA; i++) {
268  in >> TBDMA[i];
269  in >> TBDMA[NPDMA+i];
270  in.getline(s, sizeof(s));
271  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TBDMA[" << i+1
272  << "]=(" << TBDMA[i]
273  << "," << TBDMA[NPDMA+i]
274  << ") (remark: \"" << s << "\")" << std::endl);
275  }
276 
277  /* legge TBCVR */
278  in.getline(s, sizeof(s));
279  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TBCVR (remark: \"" << s
280  << "\")" << std::endl);
281 
282  in >> NPCVR;
283  in.getline(s, sizeof(s));
284  DEBUGLCOUT(MYDEBUG_INPUT, "NPCVR=" << NPCVR
285  << " (remark: \"" << s << "\")" << std::endl);
286 
287  SAFENEWARR(TBCVR, doublereal, 2*NPCVR);
288 
289  for (integer i = 0; i < NPCVR; i++) {
290  in >> TBCVR[i];
291  in >> TBCVR[NPCVR+i];
292  in.getline(s, sizeof(s));
293  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TBCVR[" << i+1
294  << "]=(" << TBCVR[i]
295  << "," << TBCVR[NPCVR+i]
296  << ") (remark: \"" << s << "\")" << std::endl);
297  }
298 
299  /* legge TBCVA */
300  in.getline(s, sizeof(s));
301  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TBCVA (remark: \"" << s
302  << "\")" << std::endl);
303 
304  in >> NPCVA;
305  in.getline(s, sizeof(s));
306  DEBUGLCOUT(MYDEBUG_INPUT, "NPCVA=" << NPCVA
307  << " (remark: \"" << s << "\")" << std::endl);
308 
309  SAFENEWARR(TBCVA, doublereal, 2*NPCVA);
310 
311  for (integer i = 0; i < NPCVA; i++) {
312  in >> TBCVA[i];
313  in >> TBCVA[NPCVA+i];
314  in.getline(s, sizeof(s));
315  DEBUGLCOUT(MYDEBUG_INPUT, "Reading TBCVA[" << i+1
316  << "]=(" << TBCVA[i]
317  << "," << TBCVA[NPCVA+i]
318  << ") (remark: \"" << s << "\")" << std::endl);
319  }
320 
321  /* legge VETVIS */
322  in.getline(s, sizeof(s));
323  DEBUGLCOUT(MYDEBUG_INPUT, "Reading VETVIS (remark: \"" << s
324  << "\")" << std::endl);
325 
326  in >> NPVT;
327  in.getline(s, sizeof(s));
328  DEBUGLCOUT(MYDEBUG_INPUT, "NPVT=" << NPVT
329  << " (remark: \"" << s << "\")" << std::endl);
330 
331  SAFENEWARR(VETVIS, doublereal, 2*NPVT);
332 
333  for (integer i = 0; i < NPVT; i++) {
334  in >> VETVIS[i];
335  in >> VETVIS[NPVT+i];
336  in.getline(s, sizeof(s));
337  DEBUGLCOUT(MYDEBUG_INPUT, "Reading VETVIS[" << i+1
338  << "]=(" << VETVIS[i]
339  << "," << VETVIS[NPVT+i]
340  << ") (remark: \"" << s << "\")" << std::endl);
341  }
342 
343  /* fine */
344  in.close();
345 
346  /* Inizializza altri dati */
347  v[RLA-1] = rla; // passato come argomento, per ora
348  v[T-1] = 273.16; // T assoluta ?!?
349  v[TIME-1] = Time.dGet();
350  };
351 
358  };
359 
362  };
363 
365  return 0;
366  };
367 
368  virtual std::ostream& Restart(std::ostream& out) const {
369  return out << "GRAALLDamperConstitutiveLaw not implemented yet!" << std::endl;
370  };
371 
372  virtual void Update(const doublereal& Eps, const doublereal& EpsPrime = 0.) {
373  Epsilon = Eps;
374  EpsilonPrime = EpsPrime;
375 
376  /* se non e' attivo, esegue un test sulla velocita' relativa;
377  * se si sta muovendo, allora setta il flag di stato su attivo,
378  * e calcola il tempo di inizio */
379  if (fWorking == 0) {
380  if (fabs(EpsPrime) < 1.e-6) {
381  F = 0.;
382  FDE = 0.;
383  FDEPrime = 0.;
384  return;
385  } else {
386  fWorking = 1;
387  dT0 = Time.dGet();
388  }
389  }
390 
391  v[TIME-1] = Time.dGet() - dT0;
392 
393  doublereal E = Epsilon*v[RLA-1];
394  doublereal EP = EpsilonPrime*v[RLA-1];
395 
396  __FC_DECL__(dmpfr) (
397  &E,
398  &EP,
399  v,
400  TBDMR,
401  TBDMA,
402  TBCVR,
403  TBCVA,
404  VETVIS,
405  &NPDMR,
406  &NPDMA,
407  &NPCVR,
408  &NPCVA,
409  &NPVT,
410  &F,
411  &FDE,
412  &FDEPrime);
413  };
414 };
415 
416 /* GRAALLDamperConstitutiveLaw - end */
417 
418 struct GRAALLDamperCLR : public ConstitutiveLawRead<doublereal, doublereal> {
420  Read(const DataManager* pDM, MBDynParser& HP, ConstLawType::Type& CLType) {
422 
424 
425  const char* filename = HP.GetFileName();
426  DEBUGCOUT("Graall damper input file: \""
427  << filename << "\"" << std::endl);
428 
429  doublereal rla = HP.GetReal();
430  DEBUGCOUT("Reference length: " << rla << std::endl);
431 
432  DriveCaller* pDC = NULL;
435  TimeDriveCaller(pDM->pGetDrvHdl()));
436 
437  typedef GRAALLDamperConstitutiveLaw L;
439  L,
440  L(pDC, rla, filename));
441 
442  return pCL;
443  };
444 };
445 
446 extern "C" int
447 module_init(const char *module_name, void *pdm, void *php)
448 {
449 #if 0
450  DataManager *pDM = (DataManager *)pdm;
451  MBDynParser *pHP = (MBDynParser *)php;
452 #endif
453 
455  = new GRAALLDamperCLR;
456  if (!SetCL1D("GRAALL" "damper", rf1D)) {
457  delete rf1D;
458 
459  silent_cerr("GRAALLDamperConstitutiveLaw: "
460  "module_init(" << module_name << ") "
461  "failed" << std::endl);
462 
463  return -1;
464  }
465 
466  return 0;
467 }
468 
long int flag
Definition: mbdyn.h:43
static char * filename
Definition: ann_sf.c:71
GRAALLDamperConstitutiveLaw(const DriveCaller *pDC, const doublereal &rla, const char *const filename)
virtual ConstitutiveLaw< doublereal, doublereal > * Read(const DataManager *pDM, MBDynParser &HP, ConstLawType::Type &CLType)
int module_init(const char *module_name, void *pdm, void *php)
This function registers our user defined element for the math parser.
virtual std::ostream & Restart(std::ostream &out) const
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
virtual const char * GetFileName(enum Delims Del=DEFAULTDELIM)
Definition: parsinc.cc:673
const DriveHandler * pGetDrvHdl(void) const
Definition: dataman.h:340
virtual void Update(const doublereal &Eps, const doublereal &EpsPrime=0.)
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
virtual ConstitutiveLaw< doublereal, doublereal > * pCopy(void) const
int __FC_DECL__() dmpfr(doublereal *DL, doublereal *DLDT, doublereal *V, doublereal *TBDMR, doublereal *TBDMA, doublereal *TBCVR, doublereal *TBCVA, doublereal *VETVIS, integer *NPDMR, integer *NPDMA, integer *NPCVR, integer *NPCVA, integer *NPVT, doublereal *FTOT, doublereal *FVISDL, doublereal *FELDL)
#define DEBUGCOUT(msg)
Definition: myassert.h:232
bool SetCL1D(const char *name, ConstitutiveLawRead< doublereal, doublereal > *rf)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
ConstLawType::Type GetConstLawType(void) const
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
static std::stack< const HighParser * > pHP
Definition: parser.cc:598
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056