MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
c81data.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void c81_data_destroy (c81_data *data)
 
c81_datac81_data_get (long int jpro)
 
int c81_data_set (long int jpro, c81_data *data)
 
int c81_data_merge (unsigned ndata, const c81_data **data, const doublereal *upper_bounds, doublereal dCsi, doublereal dcltol, c81_data *i_data)
 
int c81_data_do_stall (c81_data *data, const doublereal dcltol)
 
doublereal c81_data_get_coef (int nm, doublereal *m, int na, doublereal *a, doublereal alpha, doublereal mach)
 
int c81_data_flip (c81_data *data)
 

Function Documentation

void c81_data_destroy ( c81_data data)

Definition at line 276 of file c81data.cc.

References c81_data::ad, c81_data::al, c81_data::am, c81_data::md, c81_data::ml, c81_data::mm, c81_data::mstall, and c81_data::stall.

Referenced by main(), C81InterpolatedAeroData::~C81InterpolatedAeroData(), and MBDynParser::~MBDynParser().

277 {
278  delete[] data->ml;
279  delete[] data->al;
280 
281  delete[] data->md;
282  delete[] data->ad;
283 
284  delete[] data->mm;
285  delete[] data->am;
286 
287  delete[] data->stall;
288  delete[] data->mstall;
289 }
doublereal * mm
Definition: aerodc81.h:167
doublereal * ad
Definition: aerodc81.h:163
doublereal * mstall
Definition: aerodc81.h:158
doublereal * stall
Definition: aerodc81.h:157
doublereal * am
Definition: aerodc81.h:168
doublereal * al
Definition: aerodc81.h:149
doublereal * md
Definition: aerodc81.h:162
doublereal * ml
Definition: aerodc81.h:148
int c81_data_do_stall ( c81_data data,
const doublereal  dcltol 
)

Definition at line 1244 of file c81data.cc.

References c81_data::al, c81_data::am, do_stall(), c81_data::mstall, c81_data::NAL, c81_data::NAM, c81_data::NML, c81_data::NMM, and c81_data::stall.

Referenced by c81_data_fc511_read(), c81_data_merge(), c81_data_nrel_read(), c81_data_read(), and c81_data_read_free_format().

1245 {
1246  if (data == NULL || data->NML <= 0 || data->NMM <= 0) {
1247  return -1;
1248  }
1249 
1250  data->stall = new doublereal[3*data->NML];
1251  do_stall(data->NML, data->NAL, data->al, data->stall, dcltol);
1252 
1253  data->mstall = new doublereal[3*data->NMM];
1254  do_stall(data->NMM, data->NAM, data->am, data->mstall, dcltol);
1255 
1256  return 0;
1257 }
int NAM
Definition: aerodc81.h:166
int NMM
Definition: aerodc81.h:165
int NML
Definition: aerodc81.h:146
int NAL
Definition: aerodc81.h:147
doublereal * mstall
Definition: aerodc81.h:158
doublereal * stall
Definition: aerodc81.h:157
doublereal * am
Definition: aerodc81.h:168
doublereal * al
Definition: aerodc81.h:149
double doublereal
Definition: colamd.c:52
static int do_stall(int NM, int NA, doublereal *a, doublereal *stall, const doublereal dcltol)
Definition: c81data.cc:1170

Here is the call graph for this function:

int c81_data_flip ( c81_data data)

Definition at line 1286 of file c81data.cc.

References c81_data::ad, c81_data::al, c81_data::am, flip_one(), c81_data::NAD, c81_data::NAL, c81_data::NAM, c81_data::NMD, c81_data::NML, and c81_data::NMM.

Referenced by MBDynParser::C81Data_int(), and main().

1287 {
1288  int rc;
1289 
1290  rc = flip_one(data->NML, data->NAL, data->al, -1);
1291  if (rc) {
1292  return rc;
1293  }
1294 
1295  rc = flip_one(data->NMD, data->NAD, data->ad, 1);
1296  if (rc) {
1297  return rc;
1298  }
1299 
1300  rc = flip_one(data->NMM, data->NAM, data->am, -1);
1301  return rc;
1302 }
int NMD
Definition: aerodc81.h:160
int NAM
Definition: aerodc81.h:166
int NMM
Definition: aerodc81.h:165
int NML
Definition: aerodc81.h:146
int NAL
Definition: aerodc81.h:147
doublereal * ad
Definition: aerodc81.h:163
static int flip_one(int NM, int NA, doublereal *v, int ss)
Definition: c81data.cc:1260
doublereal * am
Definition: aerodc81.h:168
doublereal * al
Definition: aerodc81.h:149
int NAD
Definition: aerodc81.h:161

Here is the call graph for this function:

c81_data* c81_data_get ( long int  jpro)
doublereal c81_data_get_coef ( int  nm,
doublereal m,
int  na,
doublereal a,
doublereal  alpha,
doublereal  mach 
)

Definition at line 90 of file aerodc81.c.

References c, and get_coef().

Referenced by main().

91 {
92  doublereal c;
93 
94  get_coef(nm, m, na, a, alpha, mach, &c, NULL);
95 
96  return c;
97 }
static int get_coef(int nm, doublereal *m, int na, doublereal *a, doublereal alpha, doublereal mach, doublereal *c, doublereal *c0)
Definition: aerodc81.c:637
static std::stack< cleanup * > c
Definition: cleanup.cc:59
static const doublereal a
Definition: hfluid_.h:289
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

int c81_data_merge ( unsigned  ndata,
const c81_data **  data,
const doublereal upper_bounds,
doublereal  dCsi,
doublereal  dcltol,
c81_data i_data 
)

Definition at line 396 of file c81data.cc.

References c81_data::ad, c81_data::al, c81_data::am, ASSERT, c81_data_do_stall(), for(), c81_data::header, c81_data::md, c81_data::ml, c81_data::mm, c81_data::NAD, c81_data::NAL, c81_data::NAM, c81_data::NMD, c81_data::NML, and c81_data::NMM.

Referenced by C81InterpolatedAeroData::C81InterpolatedAeroData().

403 {
404  ASSERT(ndata > 0);
405  ASSERT(data != 0);
406  ASSERT(upper_bounds != 0);
407  ASSERT(dCsi >= -1.);
408  ASSERT(dCsi <= 1.);
409  ASSERT(dcltol > 0.);
410  ASSERT(i_data != 0);
411 
412  if (dCsi < upper_bounds[0]) {
413  silent_cerr("cannot find C81 data lower bound for point xi=" << dCsi << std::endl);
414  return -1;
415  }
416 
417  int to = 0;
418  for (unsigned i = 1; i < ndata; i++) {
419  if (upper_bounds[i] > dCsi) {
420  to = i;
421  break;
422  }
423  }
424  if (to == 0) {
425  silent_cerr("cannot find C81 data upper bound for point xi=" << dCsi << std::endl);
426  return -1;
427  }
428 
429  int from = to - 1;
430  if (unsigned(from) == ndata) {
431  silent_cerr("cannot find C81 data upper bound for point xi=" << dCsi << std::endl);
432  return -1;
433  }
434 
435  /* we need to interpolate between data[from]
436  * and data[to] */
437 
438  /* we only accept homogeneous data sources,
439  * i.e. same Mach and alpha patterns */
440  if (data[from]->NML != data[to]->NML) {
441  silent_cerr("number of Mach points for Cl between airfoils "
442  << from << " (" << data[from]->NML << ") and "
443  << to << " (" << data[to]->NML << ") do not match"
444  << std::endl);
445  return -1;
446  }
447 
448  if (data[from]->NAL != data[to]->NAL) {
449  silent_cerr("number of AoA points for Cl between airfoils "
450  << from << " (" << data[from]->NAL << ") and "
451  << to << " (" << data[to]->NAL << ") do not match"
452  << std::endl);
453  return -1;
454  }
455 
456  if (data[from]->NMD != data[to]->NMD) {
457  silent_cerr("number of Mach points for Cd between airfoils "
458  << from << " (" << data[from]->NMD << ") and "
459  << to << " (" << data[to]->NMD << ") do not match"
460  << std::endl);
461  return -1;
462  }
463 
464  if (data[from]->NAD != data[to]->NAD) {
465  silent_cerr("number of AoA points for Cd between airfoils "
466  << from << " (" << data[from]->NAD << ") and "
467  << to << " (" << data[to]->NAD << ") do not match"
468  << std::endl);
469  return -1;
470  }
471 
472  if (data[from]->NMM != data[to]->NMM) {
473  silent_cerr("number of Mach points for Cm between airfoils "
474  << from << " (" << data[from]->NMM << ") and "
475  << to << " (" << data[to]->NMM << ") do not match"
476  << std::endl);
477  return -1;
478  }
479 
480  if (data[from]->NAM != data[to]->NAM) {
481  silent_cerr("number of AoA points for Cm between airfoils "
482  << from << " (" << data[from]->NAM << ") and "
483  << to << " (" << data[to]->NAM << ") do not match"
484  << std::endl);
485  return -1;
486  }
487 
488  for (int i = 0; i < data[from]->NML; i++) {
489  if (data[from]->ml[i] != data[to]->ml[i]) {
490  silent_cerr("Mach point " << i << "for Cl of airfoils "
491  << from << " (" << data[from]->ml[i] << ") and "
492  << to << " (" << data[to]->ml[i] << ") differs"
493  << std::endl);
494  return -1;
495  }
496  }
497 
498  for (int i = 0; i < data[from]->NAL; i++) {
499  if (data[from]->al[i] != data[to]->al[i]) {
500  silent_cerr("AoA point " << i << "for Cl of airfoils "
501  << from << " (" << data[from]->al[i] << ") and "
502  << to << " (" << data[to]->al[i] << ") differs"
503  << std::endl);
504  return -1;
505  }
506  }
507 
508  for (int i = 0; i < data[from]->NMD; i++) {
509  if (data[from]->md[i] != data[to]->md[i]) {
510  silent_cerr("Mach point " << i << "for Cd of airfoils "
511  << from << " (" << data[from]->md[i] << ") and "
512  << to << " (" << data[to]->md[i] << ") differs"
513  << std::endl);
514  return -1;
515  }
516  }
517 
518  for (int i = 0; i < data[from]->NAD; i++) {
519  if (data[from]->ad[i] != data[to]->ad[i]) {
520  silent_cerr("AoA point " << i << "for Cd of airfoils "
521  << from << " (" << data[from]->ad[i] << ") and "
522  << to << " (" << data[to]->ad[i] << ") differs"
523  << std::endl);
524  return -1;
525  }
526  }
527 
528  for (int i = 0; i < data[from]->NMM; i++) {
529  if (data[from]->mm[i] != data[to]->mm[i]) {
530  silent_cerr("Mach point " << i << "for Cm of airfoils "
531  << from << " (" << data[from]->mm[i] << ") and "
532  << to << " (" << data[to]->mm[i] << ") differs"
533  << std::endl);
534  return -1;
535  }
536  }
537 
538  for (int i = 0; i < data[from]->NAM; i++) {
539  if (data[from]->am[i] != data[to]->am[i]) {
540  silent_cerr("AoA point " << i << "for Cm of airfoils "
541  << from << " (" << data[from]->am[i] << ") and "
542  << to << " (" << data[to]->am[i] << ") differs"
543  << std::endl);
544  return -1;
545  }
546  }
547 
548  snprintf(i_data->header, sizeof(i_data->header),
549  "interpolated (\"%s\"[%e]->\"%s\"[%e]: [%e])",
550  data[from]->header, upper_bounds[from],
551  data[to]->header, upper_bounds[to], dCsi);
552 
553  i_data->NML = data[from]->NML;
554  i_data->NAL = data[from]->NAL;
555  i_data->NMD = data[from]->NMD;
556  i_data->NAD = data[from]->NAD;
557  i_data->NMM = data[from]->NMM;
558  i_data->NAM = data[from]->NAM;
559 
560  doublereal dw = upper_bounds[to] - upper_bounds[from];
561  doublereal dw_from = (upper_bounds[to] - dCsi)/dw;
562  doublereal dw_to = (dCsi - upper_bounds[from])/dw;
563 
564  /* lift */
565  i_data->ml = new doublereal[i_data->NML];
566  for (int i = 0; i < i_data->NML; i++) {
567  i_data->ml[i] = data[from]->ml[i];
568  }
569  i_data->al = new doublereal[(i_data->NML + 1)*i_data->NAL];
570  for (int i = 0; i < i_data->NAL; i++) {
571  i_data->al[i] = data[from]->al[i];
572  }
573  for (int i = i_data->NAL; i < (i_data->NML + 1)*i_data->NAL; i++) {
574  i_data->al[i] = dw_from*data[from]->al[i] + dw_to*data[to]->al[i];
575  }
576 
577  /* drag */
578  i_data->md = new doublereal[i_data->NMD];
579  for (int i = 0; i < i_data->NMD; i++) {
580  i_data->md[i] = data[from]->md[i];
581  }
582  i_data->ad = new doublereal[(i_data->NMD + 1)*i_data->NAD];
583  for (int i = 0; i < i_data->NAD; i++) {
584  i_data->ad[i] = data[from]->ad[i];
585  }
586  for (int i = i_data->NAD; i < (i_data->NMD + 1)*i_data->NAD; i++) {
587  i_data->ad[i] = dw_from*data[from]->ad[i] + dw_to*data[to]->ad[i];
588  }
589 
590  /* moment */
591  i_data->mm = new doublereal[i_data->NMM];
592  for (int i = 0; i < i_data->NMM; i++) {
593  i_data->mm[i] = data[from]->mm[i];
594  }
595  i_data->am = new doublereal[(i_data->NMM + 1)*i_data->NAM];
596  for (int i = 0; i < i_data->NAM; i++) {
597  i_data->am[i] = data[from]->am[i];
598  }
599  for (int i = i_data->NAM; i < (i_data->NMM + 1)*i_data->NAM; i++) {
600  i_data->am[i] = dw_from*data[from]->am[i] + dw_to*data[to]->am[i];
601  }
602 
603  // FIXME: maybe this is not the best place
604  c81_data_do_stall(i_data, dcltol);
605 
606  return 0;
607 }
int NMD
Definition: aerodc81.h:160
int NAM
Definition: aerodc81.h:166
int c81_data_do_stall(c81_data *data, const doublereal dcltol)
Definition: c81data.cc:1244
int NMM
Definition: aerodc81.h:165
int NML
Definition: aerodc81.h:146
doublereal * mm
Definition: aerodc81.h:167
char header[31]
Definition: aerodc81.h:144
int NAL
Definition: aerodc81.h:147
doublereal * ad
Definition: aerodc81.h:163
#define ASSERT(expression)
Definition: colamd.c:977
for(int i=0;i< 3;++i) for(int j=0
doublereal * am
Definition: aerodc81.h:168
doublereal * al
Definition: aerodc81.h:149
double doublereal
Definition: colamd.c:52
doublereal * md
Definition: aerodc81.h:162
doublereal * ml
Definition: aerodc81.h:148
int NAD
Definition: aerodc81.h:161

Here is the call graph for this function:

int c81_data_set ( long int  jpro,
c81_data data 
)

Definition at line 1137 of file c81data.cc.

References __c81_pdata, and c81_ndata.

1138 {
1139  if (__c81_pdata == NULL || jpro >= c81_ndata) {
1140  c81_data** pp = NULL;
1141  int ndata = c81_ndata;
1142 
1143  if (jpro >= c81_ndata) {
1144  ndata = jpro+1;
1145  }
1146 
1147  pp = new c81_data*[ndata];
1148  if (__c81_pdata != NULL) {
1149  for (int i = 0; i < ndata; i++) {
1150  pp[i] = __c81_pdata[i];
1151  }
1152  delete[] __c81_pdata;
1153  }
1154  __c81_pdata = pp;
1155  c81_ndata = ndata;
1156  } else if (__c81_pdata[jpro] != NULL) {
1157  silent_cerr("profile " << jpro << "already defined" << std::endl);
1158  return -1;
1159  }
1160 
1161  __c81_pdata[jpro] = data;
1162 
1163  return 0;
1164 }
static int c81_ndata
Definition: c81data.cc:1124
static c81_data ** __c81_pdata
Definition: c81data.cc:1125