37 #include "ac/getopt.h"
50 "usage: c81test [<options>] <file>\n"
53 "\t-a <alpha>\t" "dump coefficients for angle of attack <alpha>\n"
54 "\t-c\t\t" "interpret <file> as traditional c81 format (default)\n"
55 "\t-C <coef>\t" "only dump coefficient <coef> (must be cl, cd or cm)\n"
56 "\t-d {<dump>|-}\t" "dump contents (to optional file <dump>, if given)\n"
57 "\t-f\t\t" "interpret <file> as free format\n"
58 "\t-F\t\t" "\"flip\" coefficients\n"
59 "\t-m <mach>\t" "dump coefficients for Mach number <mach>\n"
60 "\t-n\t\t" "interpret <file> as NREL format\n"
61 "\t-o\t\t" "interpret <file> as fc511 format\n"
62 "\t-t <tolerance>\t" "use <tolerance> to determine end of linearity\n"
72 main(
int argc,
char *argv[])
75 char *dump_fname = NULL;
84 GOT_ALPHAMACH = (GOT_ALPHA|GOT_MACH)
86 unsigned got = GOT_NONE;
91 int opt =
getopt(argc, argv,
"a:cC:d:fFm:not:");
108 if (strcasecmp(
optarg,
"cl") == 0) {
111 }
else if (strcasecmp(
optarg,
"cd") == 0) {
114 }
else if (strcasecmp(
optarg,
"cm") == 0) {
118 std::cerr <<
"unknown coefficient "
119 "\"" <<
optarg <<
"\"" << std::endl;
167 if (dump_fname || dump) {
169 std::cerr <<
"\"dump\" incompatible "
170 "with alpha/mach selection"
182 std::cerr <<
"need to select a coefficient "
183 "when alpha and mach "
184 "are not selected altogether"
196 std::ifstream in(argv[0]);
198 std::cerr <<
"unable to open file '" << argv[0] <<
"'"
237 std::cerr <<
"unable to read c81 data from file "
238 "\"" << argv[0] <<
"\"" << std::endl;
247 std::ofstream out(dump_fname);
259 if ((got & GOT_ALPHAMACH) == GOT_ALPHAMACH) {
263 data->
NAL, data->
al, alpha, mach)
269 data->
NAD, data->
ad, alpha, mach)
275 data->
NAM, data->
am, alpha, mach)
281 <<
"alpha: " << alpha << std::endl
282 <<
"mach: " << mach << std::endl
284 data->
NAL, data->
al, alpha, mach)
287 data->
NAD, data->
ad, alpha, mach)
290 data->
NAM, data->
am, alpha, mach)
295 }
else if (got & GOT_ALPHAMACH) {
297 double *m = 0, *
a = 0;
327 switch (got & GOT_ALPHAMACH) {
329 for (
int i = 0; i < NM; i++) {
339 for (
int i = 0; i < NA; i++) {
351 std::cerr <<
"don't know what to do..." << std::endl;
void c81_data_destroy(c81_data *data)
int c81_data_write_free_format(std::ostream &out, c81_data *data)
int c81_data_flip(c81_data *data)
int c81_data_read_free_format(std::istream &in, c81_data *data, const doublereal dcltol)
int c81_data_read(std::istream &in, c81_data *data, const doublereal dcltol, int *ff)
static void usage(int rc)
doublereal c81_data_get_coef(int nm, doublereal *m, int na, doublereal *a, doublereal alpha, doublereal mach)
int main(int argc, char *argv[])
int c81_data_fc511_read(std::istream &in, c81_data *data, const doublereal dcltol)
int getopt(int argc, char *const argv[], const char *opts)
int c81_data_nrel_read(std::istream &in, c81_data *data, const doublereal dcltol)
static const doublereal a