MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
mbpar.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/mbpar.h,v 1.51 2017/01/12 14:46:09 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 /* Parser per l'ingresso dati - parte generale */
33 
34 /* Si compone di tre diverse strutture di scansione,
35  * piu' le strutture di memorizzazione di stringhe e variabili.
36  *
37  * La prima struttura e' data dal LowParser, che riconosce gli elementi
38  * della sintassi. E' data da:
39  * <statement_list>::=
40  * <statement> ; <statement_list>
41  * epsilon
42  * <statement>::=
43  * <description>
44  * <description> : <arg_list>
45  * <arg_list>::=
46  * <arg>
47  * <arg> , <arg_list>
48  * <arg>::=
49  * <word>
50  * <number>
51  * ecc. ecc.
52  *
53  * La seconda struttura e' data dall'HighParser, che riconosce la sintassi
54  * vera e propria. In alternativa al LowParser, qualora sia atteso un valore
55  * numerico esprimibile mediante un'espressione regolare
56  * (espressione matematica), e' possibile invocare la terza struttura,
57  * il MathParser. Questo analizza espressioni anche complesse e multiple,
58  * se correttamente racchiuse tra parentesi.
59  *
60  * L'HighParser deve necessariamente riconoscere una parola chiave nel campo
61  * <description>, mentre puo' trovare parole qualsiasi nel campo <arg>
62  * qualora sia attesa una stringa.
63  *
64  * Le parole chiave vengono fornite all'HighParser attraverso la KeyTable,
65  * ovvero una lista di parole impaccate (senza spazi). L'uso consigliato e':
66  *
67  * const char sKeyWords[] = { "keyword0",
68  * "keyword1",
69  * "...",
70  * "keywordN"};
71  *
72  * enum KeyWords { KEYWORD0 = 0,
73  * KEYWORD1,
74  * ...,
75  * KEYWORDN,
76  * LASTKEYWORD};
77  *
78  * KeyTable K((int)LASTKEYWORD, sKeyWords);
79  *
80  * Il MathParser usa una tabella di simboli, ovvero nomi (dotati di tipo)
81  * a cui e' associato un valore. La tabella e' esterna e quindi puo' essere
82  * conservata ed utilizzata in seguito conservando in memoria i nomi
83  * definiti in precedenza.
84  *
85  * A questo punto si puo' generare la tabella dei simboli:
86  *
87  * int iSymbolTableInitialSize = 10;
88  * Table T(iSymbolTableInitialSize);
89  *
90  * Quindi si crea il MathParser:
91  *
92  * MathParser Math(T);
93  *
94  * Infine si genera l'HighParser:
95  *
96  * HighParser HP(Math, K, StreamIn);
97  *
98  * dove StreamIn e' l'istream da cui avviene la lettura.
99  */
100 
101 
102 #ifndef MBPAR_H
103 #define MBPAR_H
104 
105 #include <stack>
106 
107 #include "parsinc.h"
108 
109 /* Per reference frame */
110 #include "reffrm.h"
111 /* Riferimento assoluto */
112 extern const ReferenceFrame AbsRefFrame;
113 
114 /* Per nodi idraulici */
115 #include "hfluid.h"
116 
117 /* Aerodynamic data */
118 #include "aerodata.h"
119 
120 #include "constltp.h"
121 #include "ScalarFunctions.h"
122 
123 /* Deals with license and disclaimer output */
124 extern void mbdyn_license(void);
125 extern void mbdyn_warranty(void);
126 
127 /* MBDynParser - begin */
128 
129 class MBDynParser : public IncludeParser {
130 public:
131  class ErrGeneric : public MBDynErrBase {
132  public:
134  };
136  public:
138  };
140  public:
142  };
143 
144 public:
145  enum Frame {
147 
152 
156 
158  };
159 
160  /* Struttura e dati per la linked list di reference frames */
161 public:
162  typedef std::map<unsigned, const ReferenceFrame *> RFType;
163  const RFType& GetReferenceFrameContainer(void) const;
164 
165 protected:
167 
169 
170  bool Reference_int(void);
171 friend struct RefFrameDR;
172 
173  /* Struttura e dati per la linked list di hydraulic fluids */
174 public:
175  typedef std::map<unsigned, const HydraulicFluid *> HFType;
176  const HFType& GetHydraulicFluidContainer(void) const;
177 
178 protected:
180 
181  bool HydraulicFluid_int(void);
182 friend struct HFluidDR;
183 
184  /* Struttura e dati per la linked list di c81 data */
185 public:
186  typedef std::map<unsigned, C81Data *> ADType;
187  const ADType& GetC81DataContainer(void) const;
188 
189 protected:
191 
192  bool C81Data_int(void);
193 friend struct C81DataDR;
194 
195  typedef std::map<unsigned, const ConstitutiveLaw1D *> CL1DType;
196  typedef std::map<unsigned, const ConstitutiveLaw3D *> CL3DType;
197  typedef std::map<unsigned, const ConstitutiveLaw6D *> CL6DType;
201 
202  bool ConstitutiveLaw_int(void);
203 friend struct ConstLawDR;
204 
205  /* Drives */
206 public:
207  typedef std::map<unsigned, const DriveCaller *> DCType;
208  const DCType& GetDriveCallerContainer(void) const;
209 
210 protected:
212 
213  bool DriveCaller_int(void);
214 friend struct DriveCallerDR;
215 
216 public:
217  /* Template drives */
218  typedef std::map<unsigned, const TplDriveCaller<doublereal> *> DC1DType;
219  typedef std::map<unsigned, const TplDriveCaller<Vec3> *> DC3DType;
220  typedef std::map<unsigned, const TplDriveCaller<Vec6> *> DC6DType;
221  typedef std::map<unsigned, const TplDriveCaller<Mat3x3> *> DC3x3DType;
222  typedef std::map<unsigned, const TplDriveCaller<Mat6x6> *> DC6x6DType;
223 
224  const DC1DType& GetDriveCaller1DContainer(void) const;
225  const DC3DType& GetDriveCaller3DContainer(void) const;
226  const DC6DType& GetDriveCaller6DContainer(void) const;
227  const DC3x3DType& GetDriveCaller3x3DContainer(void) const;
228  const DC6x6DType& GetDriveCaller6x6DContainer(void) const;
229 
230 protected:
236 
237  bool TplDriveCaller_int(void);
238 friend struct TplDriveCallerDR;
239 
240  /* Scalar functions */
241  typedef std::map<std::string, const BasicScalarFunction *> SFType;
243 
244  bool ScalarFunction_int(void);
245 friend struct SFuncDR;
246 
247  /* Dynamic modules */
249  bool ModuleLoad_int(void);
250 friend struct ModuleLoadDR;
251 
253 
254 public:
255  class Manip {
256  public:
257  Manip(void) {};
258  virtual ~Manip(void) {};
259  };
260 
261 private:
262  std::stack<const Manip *> manip;
263 
264 public:
265  void PopManip(void);
266  void PushManip(const Manip *);
267  const Manip *GetManip(void) const;
268  bool bEmptyManip(void) const;
269 
270 public:
271  template <class T>
272  class TplManip : public Manip {
273  public:
274  virtual ~TplManip(void);
275  virtual T Get(const T& t) const = 0;
276  };
277 
278 private:
279  /* not allowed */
280  MBDynParser(const MBDynParser&);
281 
282 public:
283  MBDynParser(MathParser& MP, InputStream& streamIn,
284  const char *initial_file);
285  ~MBDynParser(void);
286 
287  void SetDataManager(DataManager *pdm);
288  DataManager *GetDataManager(void) const;
289 
290  // Vec*, Mat*x* moved here from parser.h
291  /* vettore Vec3 */
292  virtual Vec3 GetVec3(void);
293  /* vettore Vec3 */
294  virtual Vec3 GetVec3(const Vec3& vDef);
295  /* matrice R mediante i due vettori */
296  virtual Mat3x3 GetMatR2vec(void);
297  /* matrice 3x3 simmetrica */
298  virtual Mat3x3 GetMat3x3Sym(void);
299  /* matrice 3x3 arbitraria */
300  virtual Mat3x3 GetMat3x3(void);
301  virtual Mat3x3 GetMat3x3(const Mat3x3& mDef);
302 
303  virtual Vec6 GetVec6(void);
304  virtual Vec6 GetVec6(const Vec6& vDef);
305  virtual Mat6x6 GetMat6x6(void);
306  virtual Mat6x6 GetMat6x6(const Mat6x6& mDef);
307 
308 public:
309  virtual void GetMat6xN(Mat3xN& m1, Mat3xN& m2, integer iNumCols);
310 
311  /*
312  * Lettura di posizioni, vettori e matrici di rotazione
313  * relative ed assolute rispetto ad un riferimento
314  */
315  Vec3 GetPosRel(const ReferenceFrame& rf);
316  Vec3 GetPosRel(const ReferenceFrame& rf, const ReferenceFrame& other_rf, const Vec3& other_X);
317  Vec3 GetPosAbs(const ReferenceFrame& rf);
318  Vec3 GetVelRel(const ReferenceFrame& rf, const Vec3& x);
319  Vec3 GetVelAbs(const ReferenceFrame& rf, const Vec3& x);
320  Vec3 GetOmeRel(const ReferenceFrame& rf);
321  Vec3 GetOmeAbs(const ReferenceFrame& rf);
322  Vec3 GetVecRel(const ReferenceFrame& rf);
323  Vec3 GetVecAbs(const ReferenceFrame& rf);
324  Vec3 GetUnitVecRel(const ReferenceFrame& rf);
325  Vec3 GetUnitVecAbs(const ReferenceFrame& rf);
326  Mat3x3 GetMatRel(const ReferenceFrame& rf);
327  Mat3x3 GetMatAbs(const ReferenceFrame& rf);
328  Mat3x3 GetRotRel(const ReferenceFrame& rf);
329  Mat3x3 GetRotRel(const ReferenceFrame& rf, const ReferenceFrame& other_rf, const Mat3x3& other_R);
330  Mat3x3 GetRotAbs(const ReferenceFrame& rf);
331 
333  VM_NONE = 0,
334 
340 
343 
344  VM_MOD_REL = 0x1000U,
345  VM_MOD_OTHER = 0x2000U,
346 
352 
355 
357  };
358 
359  template <class T>
360  class RefTplManip : public TplManip<T> {
361  protected:
365 
366  public:
368  virtual ~RefTplManip(void);
369  };
370 
371  class RefVec3Manip : public RefTplManip<Vec3> {
372  public:
374  virtual ~RefVec3Manip(void);
375  virtual Vec3 Get(const Vec3& v) const;
376  };
377 
378  class VecRelManip : public RefVec3Manip {
379  public:
381  virtual ~VecRelManip(void);
382  };
383 
384  class VecAbsManip : public RefVec3Manip {
385  public:
387  virtual ~VecAbsManip(void);
388  };
389 
390  virtual doublereal Get(const doublereal& d);
391  virtual Vec3 Get(const Vec3& v);
392  virtual Mat3x3 Get(const Mat3x3& m);
393  virtual Vec6 Get(const Vec6& v);
394  virtual Mat6x6 Get(const Mat6x6& m);
395 
396  void OutputFrames(std::ostream& out) const;
397 
399 
400  const c81_data* GetC81Data(unsigned profile) const;
401 
405  const DriveCaller* GetDrive(unsigned uLabel) const;
406 
407  DriveCaller* GetDriveCaller(bool bDeferred = false);
408  template <class T> const TplDriveCaller<T> *GetTplDrive(unsigned uLabel) const;
409  template <class T> TplDriveCaller<T> *GetTplDriveCaller(void);
410 
412  const BasicScalarFunction* GetScalarFunction(const std::string &s);
413  bool SetScalarFunction(const std::string &s, const BasicScalarFunction *sf);
414 };
415 
416 /*
417  * Le funzioni:
418  * ExpectDescription()
419  * ExpectArg()
420  * informano il parser di cio' che e' atteso; di default il costruttore
421  * setta ExpectDescription().
422  *
423  * Le funzioni:
424  * GetDescription()
425  * IsKeyWord()
426  * GetWord()
427  * restituiscono un intero che corrisponde alla posizione occupata nella
428  * KeyTable dalle parole corrispondenti, oppure -1 se la parola non e'
429  * trovata. Si noti che IsKeyWord(), in caso di esito negativo, ripristina
430  * l'istream. Tutte preparano poi il parser per la lettura successiva.
431  *
432  * La funzione
433  * IsKeyWord(const char*)
434  * restituisce 0 se non trova la parola e ripristina l'istream, altrimenti
435  * restituisce 1 e prepara il parser alla lettura successiva.
436  *
437  * Le funzioni
438  * GetInt(),
439  * GetReal(),
440  * GetString(),
441  * GetStringWithDelims(enum Delims)
442  * GetFileName(enum Delims)
443  * restituiscono i valori attesi e preparano il parser alla lettura successiva.
444  */
445 
446 /* MBDynParser - end */
447 
448 #endif /* MBPAR_H */
449 
virtual ~RefTplManip(void)
Definition: mbpar.cc:2848
RFType RF
Definition: mbpar.h:166
void PushManip(const Manip *)
Definition: mbpar.cc:2191
virtual Mat6x6 GetMat6x6(void)
Definition: mbpar.cc:2547
Mat3x3 GetRotRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1795
bool bEmptyManip(void) const
Definition: mbpar.cc:2207
bool C81Data_int(void)
Definition: mbpar.cc:495
DC6DType DC6D
Definition: mbpar.h:233
CL1DType CL1D
Definition: mbpar.h:198
TplDriveCaller< T > * GetTplDriveCaller(void)
Definition: mbpar.cc:2112
const DC6x6DType & GetDriveCaller6x6DContainer(void) const
Definition: mbpar.cc:884
const TplDriveCaller< T > * GetTplDrive(unsigned uLabel) const
Definition: mbpar.cc:2064
const BasicScalarFunction * GetScalarFunction(void)
Definition: mbpar.cc:2158
ErrGeneric(MBDYN_EXCEPT_ARGS_DECL)
Definition: mbpar.h:133
std::map< unsigned, const TplDriveCaller< Vec3 > * > DC3DType
Definition: mbpar.h:219
Definition: matvec3.h:98
const DCType & GetDriveCallerContainer(void) const
Definition: mbpar.cc:854
Mat3x3 GetRotAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1857
bool ConstitutiveLaw_int(void)
Definition: mbpar.cc:695
#define MBDYN_EXCEPT_ARGS_PASSTHRU
Definition: except.h:55
const DriveCaller * GetDrive(unsigned uLabel) const
Definition: mbpar.cc:2022
void mbdyn_license(void)
Definition: legalese.cc:37
virtual void GetMat6xN(Mat3xN &m1, Mat3xN &m2, integer iNumCols)
Definition: mbpar.cc:2743
std::map< unsigned, const ConstitutiveLaw1D * > CL1DType
Definition: mbpar.h:195
ADType AD
Definition: mbpar.h:190
const Manip * GetManip(void) const
Definition: mbpar.cc:2197
Vec3 GetVelAbs(const ReferenceFrame &rf, const Vec3 &x)
Definition: mbpar.cc:1482
virtual Vec6 GetVec6(void)
Definition: mbpar.cc:2510
#define MBDYN_EXCEPT_ARGS_DECL
Definition: except.h:43
virtual ~RefVec3Manip(void)
Definition: mbpar.cc:2862
bool DriveCaller_int(void)
Definition: mbpar.cc:890
bool TplDriveCaller_int(void)
Definition: mbpar.cc:950
bool Reference_int(void)
Definition: mbpar.cc:327
std::map< unsigned, const TplDriveCaller< Mat3x3 > * > DC3x3DType
Definition: mbpar.h:221
bool ModuleLoad_int(void)
Definition: mbpar.cc:1190
DCType DC
Definition: mbpar.h:211
MBDynParser(const MBDynParser &)
virtual ~VecRelManip(void)
Definition: mbpar.cc:3031
Vec3 GetOmeRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1518
bool SetScalarFunction(const std::string &s, const BasicScalarFunction *sf)
Definition: mbpar.cc:2179
std::stack< const Manip * > manip
Definition: mbpar.h:262
const c81_data * GetC81Data(unsigned profile) const
Definition: mbpar.cc:1921
ErrReferenceAlreadyDefined(MBDYN_EXCEPT_ARGS_DECL)
Definition: mbpar.h:137
std::map< unsigned, const ConstitutiveLaw6D * > CL6DType
Definition: mbpar.h:197
Definition: matvec6.h:37
std::map< unsigned, const DriveCaller * > DCType
Definition: mbpar.h:207
Vec3 GetVelRel(const ReferenceFrame &rf, const Vec3 &x)
Definition: mbpar.cc:1441
Vec3 GetPosRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1331
DataManager * pDM
Definition: mbpar.h:252
const DC3DType & GetDriveCaller3DContainer(void) const
Definition: mbpar.cc:866
bool HydraulicFluid_int(void)
Definition: mbpar.cc:448
std::map< unsigned, const TplDriveCaller< doublereal > * > DC1DType
Definition: mbpar.h:218
DC3x3DType DC3x3D
Definition: mbpar.h:234
Frame GetRef(ReferenceFrame &rf)
Definition: mbpar.cc:1279
const ReferenceFrame AbsRefFrame
const ReferenceFrame & rf
Definition: mbpar.h:363
VecAbsManip(MBDynParser &HP, const ReferenceFrame &rf)
Definition: mbpar.cc:3036
virtual Mat3x3 GetMatR2vec(void)
Definition: mbpar.cc:2255
Vec3 GetOmeAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1551
std::map< unsigned, C81Data * > ADType
Definition: mbpar.h:186
Mat3x3 GetMatRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1737
SFType SF
Definition: mbpar.h:242
virtual Mat3x3 GetMat3x3(void)
Definition: mbpar.cc:2438
const DC3x3DType & GetDriveCaller3x3DContainer(void) const
Definition: mbpar.cc:878
RefVec3Manip(MBDynParser &HP, const ReferenceFrame &rf, VecMatOpType type)
Definition: mbpar.cc:2853
virtual ~Manip(void)
Definition: mbpar.h:258
Vec3 GetPosAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1401
bool ScalarFunction_int(void)
Definition: mbpar.cc:1169
const HFType & GetHydraulicFluidContainer(void) const
Definition: mbpar.cc:843
Mat3x3 GetMatAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1766
DC6x6DType DC6x6D
Definition: mbpar.h:235
DataManager * GetDataManager(void) const
Definition: mbpar.cc:314
const RFType & GetReferenceFrameContainer(void) const
Definition: mbpar.cc:837
std::map< unsigned, const TplDriveCaller< Vec6 > * > DC6DType
Definition: mbpar.h:220
std::map< unsigned, const ReferenceFrame * > RFType
Definition: mbpar.h:162
ConstitutiveLaw6D * GetConstLaw6D(ConstLawType::Type &clt)
Definition: mbpar.cc:1995
std::map< unsigned, const ConstitutiveLaw3D * > CL3DType
Definition: mbpar.h:196
virtual ~VecAbsManip(void)
Definition: mbpar.cc:3044
Vec3 GetUnitVecAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1716
DC1DType DC1D
Definition: mbpar.h:231
VecMatOpType type
Definition: mbpar.h:364
CL6DType CL6D
Definition: mbpar.h:200
Vec3 GetVecRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1584
Vec3 GetVecAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1641
std::map< unsigned, const HydraulicFluid * > HFType
Definition: mbpar.h:175
virtual Vec3 Get(const Vec3 &v) const
Definition: mbpar.cc:2974
void PopManip(void)
Definition: mbpar.cc:2185
MBDynParser & HP
Definition: mbpar.h:362
const ADType & GetC81DataContainer(void) const
Definition: mbpar.cc:848
virtual Mat3x3 GetMat3x3Sym(void)
Definition: mbpar.cc:2402
virtual T Get(const T &t) const =0
ErrReferenceUndefined(MBDYN_EXCEPT_ARGS_DECL)
Definition: mbpar.h:141
std::map< unsigned, const TplDriveCaller< Mat6x6 > * > DC6x6DType
Definition: mbpar.h:222
~MBDynParser(void)
Definition: mbpar.cc:232
void SetDataManager(DataManager *pdm)
Definition: mbpar.cc:296
HydraulicFluid * GetHydraulicFluid(void)
Definition: mbpar.cc:1893
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
void mbdyn_warranty(void)
Definition: legalese.cc:44
CL3DType CL3D
Definition: mbpar.h:199
virtual ~TplManip(void)
Definition: mbpar.cc:2830
Vec3 GetUnitVecRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1695
HFType HF
Definition: mbpar.h:179
const DC6DType & GetDriveCaller6DContainer(void) const
Definition: mbpar.cc:872
DC3DType DC3D
Definition: mbpar.h:232
virtual doublereal Get(const doublereal &d)
Definition: mbpar.cc:2213
double doublereal
Definition: colamd.c:52
ConstitutiveLaw3D * GetConstLaw3D(ConstLawType::Type &clt)
Definition: mbpar.cc:1968
long int integer
Definition: colamd.c:51
bool moduleInitialized
Definition: mbpar.h:248
RefTplManip(MBDynParser &HP, const ReferenceFrame &rf, VecMatOpType type)
Definition: mbpar.cc:2836
ConstitutiveLaw1D * GetConstLaw1D(ConstLawType::Type &clt)
Definition: mbpar.cc:1941
virtual Vec3 GetVec3(void)
Definition: mbpar.cc:2220
void OutputFrames(std::ostream &out) const
Definition: mbpar.cc:1323
VecMatOpType
Definition: mbpar.h:332
VecRelManip(MBDynParser &HP, const ReferenceFrame &rf)
Definition: mbpar.cc:3023
std::map< std::string, const BasicScalarFunction * > SFType
Definition: mbpar.h:241
const DC1DType & GetDriveCaller1DContainer(void) const
Definition: mbpar.cc:860