MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
hfluid.cc File Reference
#include "mbconfig.h"
#include <cfloat>
#include <limits>
#include "dataman.h"
#include "hfluid.h"
#include "hfluid_.h"
Include dependency graph for hfluid.cc:

Go to the source code of this file.

Functions

HydraulicFluidReadHydraulicFluid (MBDynParser &HP, unsigned int uLabel)
 

Function Documentation

HydraulicFluid* ReadHydraulicFluid ( MBDynParser HP,
unsigned int  uLabel 
)

Definition at line 85 of file hfluid.cc.

References IncludeParser::GetLineData(), HighParser::GetReal(), HighParser::IsKeyWord(), LASTKEYWORD, MBDYN_EXCEPT_ARGS, SAFENEWWITHCONSTRUCTOR, and HighParser::UNKNOWN.

Referenced by MBDynParser::GetHydraulicFluid(), and MBDynParser::HydraulicFluid_int().

86 {
87  /* tipi di fluidi */
88  const char* sKeyWords[] = {
89  "uncompressible", /* deprecated (typo) */
90  "incompressible",
91  "linear" "compressible",
92  "linear" "thermal" "compressible",
93  "super",
94  "exponential",
95 
96  NULL
97  };
98 
99  enum KeyWords {
100  UNKNOWN = -1,
101 
102  UNCOMPRESSIBLE = 0, /* deprecated (typo) */
103  INCOMPRESSIBLE,
104  LINEARCOMPRESSIBLE,
105  LINEARTHERMALCOMPRESSIBLE,
106  SUPER,
107  EXPONENTIAL,
108 
110  };
111 
112  /* tabella delle parole chiave */
113  KeyTable K(HP, sKeyWords);
114 
115  /* lettura del tipo di drive */
116  KeyWords CurrKeyWord = KeyWords(HP.IsKeyWord());
117  if (CurrKeyWord == UNKNOWN) {
118  CurrKeyWord = INCOMPRESSIBLE;
119  }
120 
121  HydraulicFluid* pHF = 0;
122 
123  switch (CurrKeyWord) {
124  case UNCOMPRESSIBLE: /* deprecated (typo) */
125  case INCOMPRESSIBLE: {
126  doublereal dDensity(0.);
127  if (HP.IsKeyWord("density")) {
128  dDensity = HP.GetReal();
129  }
130 
131  if (dDensity < std::numeric_limits<doublereal>::epsilon()) {
132  silent_cerr("line " << HP.GetLineData()
133  << ": illegal density " << dDensity
134  << " for hydraulic fluid " << uLabel << std::endl);
136  }
137 
138  doublereal dViscosity(0.);
139  if (HP.IsKeyWord("viscosity")) {
140  dViscosity = HP.GetReal();
141  }
142 
143  if (dViscosity < std::numeric_limits<doublereal>::epsilon()) {
144  silent_cerr("line " << HP.GetLineData()
145  << ": illegal viscosity " << dViscosity
146  << std::endl);
148  }
149 
150  doublereal dPres0(-1.);
151  if (HP.IsKeyWord("pressure")) {
152  dPres0 = HP.GetReal();
153  if (dPres0 < 0.) {
154  silent_cerr("line " << HP.GetLineData()
155  << ": illegal reference pressure " << dPres0
156  << " for hydraulic fluid " << uLabel << std::endl);
157  }
158  }
159 
160  doublereal dTemp0(-1.);
161  if (HP.IsKeyWord("temperature")) {
162  dTemp0 = HP.GetReal();
163  if (dTemp0 < 0.) {
164  silent_cerr("line " << HP.GetLineData()
165  << ": illegal reference temperature " << dTemp0
166  << " for hydraulic fluid " << uLabel << std::endl);
167  }
168  }
169 
173  dDensity,
174  dViscosity,
175  dPres0,
176  dTemp0));
177  } break;
178 
179  case LINEARCOMPRESSIBLE:
180  case SUPER:
181  case EXPONENTIAL: {
182  doublereal dDensity(0.);
183  doublereal dBeta(0.);
184  doublereal dPres0(0.);
185  if (HP.IsKeyWord("density")) {
186  dDensity = HP.GetReal();
187 
188  if (HP.IsKeyWord("sound" "celerity")) {
189  doublereal sound = HP.GetReal();
190  if (sound < std::numeric_limits<doublereal>::epsilon()) {
191  silent_cerr("line " << HP.GetLineData()
192  << ": illegal sound celerity " << sound
193  << std::endl);
195  }
196 
197  dBeta = sound*sound*dDensity;
198  } else {
199  dBeta = HP.GetReal();
200  if (std::abs(dBeta) < std::numeric_limits<doublereal>::epsilon()) {
201  silent_cerr("line " << HP.GetLineData()
202  << ": illegal bulk modulus " << dBeta
203  << std::endl);
205  }
206  }
207 
208  if (dDensity < std::numeric_limits<doublereal>::epsilon()) {
209  silent_cerr("line " << HP.GetLineData()
210  << ": illegal density " << dDensity
211  << " for hydraulic fluid " << uLabel << std::endl);
212  }
213 
214  dPres0 = HP.GetReal();
215  if (dPres0 < 0.) {
216  silent_cerr("line " << HP.GetLineData()
217  << ": illegal reference pressure " << dPres0
218  << " for hydraulic fluid " << uLabel << std::endl);
219  }
220  }
221 
222  doublereal dViscosity(0.);
223  if (HP.IsKeyWord("viscosity")) {
224  dViscosity = HP.GetReal();
225  }
226 
227  if (dViscosity < std::numeric_limits<doublereal>::epsilon()) {
228  silent_cerr("line " << HP.GetLineData()
229  << ": illegal viscosity " << dViscosity
230  << std::endl);
232  }
233 
234  doublereal dTemp0(-1.);
235  if (HP.IsKeyWord("temperature")) {
236  dTemp0 = HP.GetReal();
237  if (dTemp0 < 0.) {
238  silent_cerr("line " << HP.GetLineData()
239  << ": illegal reference temperature " << dTemp0
240  << " for hydraulic fluid " << uLabel << std::endl);
241  }
242  }
243 
244  switch (CurrKeyWord) {
245  default:
247 
248  case LINEARCOMPRESSIBLE:
252  dDensity,
253  dBeta,
254  dPres0,
255  dViscosity,
256  dTemp0));
257  break;
258 
259  case SUPER:
262  SuperHydraulicFluid(uLabel,
263  dDensity,
264  dBeta,
265  dPres0,
266  dViscosity,
267  dTemp0));
268  break;
269 
270  case EXPONENTIAL:
271  doublereal dPsat = HP.GetReal();
272 
275  ExpHydraulicFluid(uLabel,
276  dDensity,
277  dBeta,
278  dPres0,
279  dPsat,
280  dViscosity,
281  dTemp0));
282  break;
283  }
284 
285  } break;
286 
287  case LINEARTHERMALCOMPRESSIBLE: {
288  doublereal dDensity(0.);
289  doublereal dBeta(0.);
290  doublereal dPres0(0.);
291  doublereal dAlpha(0.);
292  doublereal dTemp0(0.);
293  if (HP.IsKeyWord("density")) {
294  dDensity = HP.GetReal();
295 
296  if (HP.IsKeyWord("sound" "celerity")) {
297  doublereal sound = HP.GetReal();
298  if (sound < std::numeric_limits<doublereal>::epsilon()) {
299  silent_cerr("line " << HP.GetLineData()
300  << ": illegal sound celerity " << sound
301  << " for hydraulic fluid " << uLabel << std::endl);
303  }
304 
305  dBeta = sound*sound*dDensity;
306 
307  } else {
308  dBeta = HP.GetReal();
309  if (std::abs(dBeta) < std::numeric_limits<doublereal>::epsilon()) {
310  silent_cerr("line " << HP.GetLineData()
311  << ": illegal bulk modulus " << dBeta
312  << " for hydraulic fluid " << uLabel << std::endl);
314  }
315  }
316 
317  if (dDensity < std::numeric_limits<doublereal>::epsilon()) {
318  silent_cerr("line " << HP.GetLineData()
319  << ": illegal density " << dDensity
320  << " for hydraulic fluid " << uLabel << std::endl);
321  }
322 
323  dPres0 = HP.GetReal();
324  if (dPres0 < 0.) {
325  silent_cerr("line " << HP.GetLineData()
326  << ": illegal reference pressure " << dPres0
327  << " for hydraulic fluid " << uLabel << std::endl);
328  }
329 
330  dAlpha = HP.GetReal();
331 
332  dTemp0 = HP.GetReal();
333  if (dTemp0 < 0.) {
334  silent_cerr("line " << HP.GetLineData()
335  << ": illegal reference temperature " << dTemp0
336  << " for hydraulic fluid " << uLabel << std::endl);
337  }
338  }
339 
340  doublereal dViscosity(0.);
341  if (HP.IsKeyWord("viscosity")) {
342  dViscosity = HP.GetReal();
343  }
344 
345  if (dViscosity < std::numeric_limits<doublereal>::epsilon()) {
346  silent_cerr("line " << HP.GetLineData()
347  << ": illegal viscosity " << dViscosity
348  << std::endl);
350  }
351 
355  dDensity,
356  dBeta,
357  dPres0,
358  dAlpha,
359  dTemp0,
360  dViscosity));
361  } break;
362 
363  default:
364  silent_cerr("line " << HP.GetLineData()
365  << ": unknown hydraulic fluid type" << std::endl);
367  }
368 
369  return pHF;
370 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
KeyWords
Definition: dataman4.cc:94
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function: