command line option logic done
This commit is contained in:
parent
4ebde595d0
commit
521c1b1f69
1 changed files with 34 additions and 7 deletions
41
ct2foam.C
41
ct2foam.C
|
|
@ -59,32 +59,59 @@ int main(int argc, char *argv[])
|
|||
|
||||
cxxopts::Options options("ct2foam", "Utility Converts Cantera formatted data in OpenFOAM format");
|
||||
|
||||
std::string scti;
|
||||
std::string sgas("");
|
||||
std::string sthermo;
|
||||
std::string srxn;
|
||||
|
||||
std::ofstream fthermo;
|
||||
std::ofstream frxn;
|
||||
|
||||
|
||||
options.add_options()
|
||||
("cti", "Input CTI File name", cxxopts::value<std::string>())
|
||||
("reaction", "Output OpenFOAM Reaction File name", cxxopts::value<std::string>())
|
||||
("thermo", "Output OpenFOAM Thermo File name", cxxopts::value<std::string>())
|
||||
("name", "Name of ideal gas mix in CTI file", cxxopts::value(sgas))
|
||||
("h,help", "print help message")
|
||||
;
|
||||
|
||||
options.add_options("internal")
|
||||
("cti", "Input CTI File name", cxxopts::value(scti))
|
||||
("reaction", "Output OpenFOAM Reaction File name", cxxopts::value(srxn)->default_value("reactions"))
|
||||
("thermo", "Output OpenFOAM Thermo File name", cxxopts::value(sthermo)->default_value("thermos"))
|
||||
("rest", "Input CTI File name", cxxopts::value<std::vector<std::string>>())
|
||||
;
|
||||
|
||||
options.parse_positional({"cti", "reaction", "thermo", "rest"});
|
||||
|
||||
options.positional_help("CTI [REACTION [THERMO]]");
|
||||
|
||||
cxxopts::ParseResult result = options.parse(argc, argv);
|
||||
|
||||
if (result["help"].as<bool>())
|
||||
if (result.count("help"))
|
||||
{
|
||||
std::cout << options.help();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::ofstream fthermo(result["thermo"].as<std::string>());
|
||||
if (!result["cti"].count())
|
||||
{
|
||||
std::cerr << "CTI file name must be provided" << std::endl << std::endl;
|
||||
|
||||
std::ofstream frxn(result["reaction"].as<std::string>());
|
||||
std::cout << options.help();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Cantera::IdealGasMix gas_ ("gri30.cti", "gri30_mix");
|
||||
Cantera::IdealGasMix gas_(scti, sgas);
|
||||
Cantera::Transport *tr_ = Cantera::newTransportMgr("Mix", &gas_);
|
||||
int nCanteraSp_ = gas_.nSpecies();
|
||||
|
||||
fthermo.open(sthermo);
|
||||
|
||||
frxn.open(srxn);
|
||||
|
||||
// these constants define the location of coefficient "a6" in the
|
||||
// cofficient array c. The c array contains Tmid in the first
|
||||
// location, followed by the 7 low-temperature coefficients, then
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue