585 std::ifstream in(fname.c_str());
588 silent_cerr(
"ReadGenericAerodynamicData: "
589 "unable to open file \"" << fname <<
"\""
599 for (c = in.get(); c ==
'%' || c ==
'#'; c = in.get()) {
601 in.getline(buf,
sizeof(buf));
606 in >> nAlpha >> nBeta;
608 in.getline(buf,
sizeof(buf));
611 silent_cerr(
"ReadGenericAerodynamicData(" << fname <<
"): "
612 "unable to read size of data matrix "
613 "from file \"" << fname <<
"\"" << std::endl);
618 silent_cerr(
"ReadGenericAerodynamicData(" << fname <<
"): "
619 "invalid number of angles of attack " << nAlpha <<
" "
620 "from file \"" << fname <<
"\"" << std::endl);
625 silent_cerr(
"ReadGenericAerodynamicData(" << fname <<
"): "
626 "invalid number of sideslip angles " << nBeta <<
" "
627 "from file \"" << fname <<
"\"" << std::endl);
632 for (c = in.get(); c ==
'%' || c ==
'#'; c = in.get()) {
634 in.getline(buf,
sizeof(buf));
639 silent_cerr(
"ReadGenericAerodynamicData(" << fname <<
"): "
640 "unable to get to data "
641 "in file \"" << fname <<
"\"" << std::endl);
649 pData->
nBeta = nBeta;
651 pData->
Alpha.resize(nAlpha);
652 pData->
Beta.resize(nBeta);
653 pData->
Data.resize(nBeta);
655 doublereal dScaleForce = dScaleLength*dScaleLength;
656 doublereal dScaleMoment = dScaleForce*dScaleLength;
658 dScaleForce, dScaleForce, dScaleForce,
659 dScaleMoment, dScaleMoment, dScaleMoment
663 for (
int iBeta = 0; iBeta < nBeta; iBeta++) {
664 pData->
Data[iBeta].resize(nAlpha);
666 for (
int iAlpha = 0; iAlpha < nAlpha; iAlpha++) {
674 if (std::abs(dErr) > std::numeric_limits<doublereal>::epsilon()) {
675 silent_cerr(
"ReadGenericAerodynamicData(" << fname <<
"): "
676 "warning, alpha[0] != -pi/2 (error=" << 100*dErr/::
dAlphaMax[bAlphaFirst] <<
"%)" << std::endl);
678 }
else if (iAlpha == nAlpha - 1) {
679 doublereal dErr = dCoef*dScaleAngle - ::dAlphaMax[bAlphaFirst];
680 if (std::abs(dErr) > std::numeric_limits<doublereal>::epsilon()) {
681 silent_cerr(
"ReadGenericAerodynamicData(" << fname <<
"): "
682 "warning, alpha[" << iAlpha <<
"] != pi/2 (error=" << 100*dErr/::
dAlphaMax[bAlphaFirst] <<
"%)" << std::endl);
686 pData->
Alpha[iAlpha] = dCoef;
688 }
else if (dCoef != pData->
Alpha[iAlpha]) {
689 silent_cerr(
"ReadGenericAerodynamicData"
690 "(" << fname <<
"): "
691 "inconsistent data, "
692 "Alpha[" << iAlpha <<
"]"
694 "for Beta[" << iBeta <<
"]"
695 "=" << pData->
Beta[iBeta] <<
" "
696 "differs from previous, "
697 << pData->
Alpha[iAlpha]
708 if (std::abs(dErr) > std::numeric_limits<doublereal>::epsilon()) {
709 silent_cerr(
"ReadGenericAerodynamicData(" << fname <<
"): "
710 "warning, beta[0] != -pi (error=" << 100*dErr/::
dBetaMax[bAlphaFirst] <<
"%)" << std::endl);
712 }
else if (iBeta == nBeta - 1) {
713 doublereal dErr = dCoef*dScaleAngle - ::dBetaMax[bAlphaFirst];
714 if (std::abs(dErr) > std::numeric_limits<doublereal>::epsilon()) {
715 silent_cerr(
"ReadGenericAerodynamicData(" << fname <<
"): "
716 "warning, beta[" << iBeta <<
"] != pi (error=" << 100*dErr/::
dBetaMax[bAlphaFirst] <<
"%)" << std::endl);
720 pData->
Beta[iBeta] = dCoef;
722 }
else if (dCoef != pData->
Beta[iBeta]) {
723 silent_cerr(
"ReadGenericAerodynamicData"
724 "(" << fname <<
"): "
725 "inconsistent data, "
726 "Beta[" << iBeta <<
"]"
728 "for Alpha[" << iAlpha <<
"]"
729 "=" << pData->
Alpha[iAlpha] <<
" "
730 "differs from previous, "
731 << pData->
Beta[iBeta]
737 for (
int iCoef = 0; iCoef < 6; iCoef++) {
740 pData->
Data[iBeta][iAlpha].dCoef[iCoef] = dCoef*dScale[iCoef];
744 if (iAlpha < nAlpha - 1 && iBeta < nBeta - 1) {
745 in.getline(buf,
sizeof(buf));
748 silent_cerr(
"ReadGenericAerodynamicData"
749 "(" << fname <<
"): "
750 "unable to read data past "
751 "iAlpha=" << iAlpha <<
", "
752 "iBeta=" << iBeta << std::endl);
761 for (
int iAlpha = 0; iAlpha < nAlpha; iAlpha++) {
762 pData->
Alpha[iAlpha] *= dScaleAngle;
768 if ( pData->
Alpha[iAlpha] <= pData->
Alpha[iAlpha - 1]) {
769 silent_cerr(
"ReadGenericAerodynamicData"
770 "(" << fname <<
"): "
771 "strict ordering violated between "
772 "Alpha #" << iAlpha - 1 <<
" and "
773 "Alpha #" << iAlpha << std::endl);
780 for (
int iBeta = 0; iBeta < nBeta; iBeta++) {
781 pData->
Beta[iBeta] *= dScaleAngle;
787 if ( pData->
Beta[iBeta] <= pData->
Beta[iBeta - 1]) {
788 silent_cerr(
"ReadGenericAerodynamicData"
789 "(" << fname <<
"): "
790 "strict ordering violated between "
791 "Beta #" << iBeta - 1 <<
" and "
792 "Beta #" << iBeta << std::endl);
static const doublereal dAlphaMax[]
#define MBDYN_EXCEPT_ARGS
std::vector< doublereal > Alpha
std::vector< std::vector< GenericAerodynamicCoef > > Data
std::vector< doublereal > Beta
static const doublereal dBetaMax[]
static std::stack< cleanup * > c
static doublereal buf[BUFSIZE]