From 13525889be34f5a19cef1455c83e4a44c2ff7033 Mon Sep 17 00:00:00 2001 From: Yeongdo Park Date: Wed, 14 Nov 2018 21:35:57 -0500 Subject: [PATCH] throw error for non NASA 7-coefficient thermo data in cti file --- ct2foam.C | 34 ++++++++++++++++++---------------- ofFormats.h | 10 ++++++---- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/ct2foam.C b/ct2foam.C index dd69775..3a65588 100644 --- a/ct2foam.C +++ b/ct2foam.C @@ -33,6 +33,7 @@ Description #include #include +#include #include @@ -266,7 +267,14 @@ int main(int argc, char *argv[]) doublereal minTemp, maxTemp, refPressure; // get the NASA coefficients in array c - gas_.speciesThermo().reportParams(n, type, c, minTemp, maxTemp, refPressure); + switch(gas_.speciesThermo().reportType(n)) + { + case NASA2: + gas_.speciesThermo().reportParams(n, type, c, minTemp, maxTemp, refPressure); + break; + default: + throw std::domain_error(gas_.speciesName(n) + " has a non-NASA2-type thermodynamics interpolator"); + } fthermo<<( fmt::format( @@ -328,13 +336,11 @@ int main(int argc, char *argv[]) { case Cantera::ELEMENTARY_RXN: - frxn<<( fmt::format( rxnTypeFormat, irn + rate + rxn)); - - frxn<<( fmt::format( rxnEqnFormat, ofReactionString(r) ) ); - frxn<<( fmt::format( - arrheniusFormat, + rxnTypeFormat + rxnEqnFormat + arrheniusFormat, + irn + rate + rxn, + ofReactionString(r), std::dynamic_pointer_cast(r)->rate.preExponentialFactor(), std::dynamic_pointer_cast(r)->rate.temperatureExponent(), std::dynamic_pointer_cast(r)->rate.activationEnergy_R() @@ -346,13 +352,11 @@ int main(int argc, char *argv[]) rate = "thirdBody" + rate; - frxn<<( fmt::format( rxnTypeFormat, irn + rate + rxn)); - - frxn<<( fmt::format( rxnEqnFormat, ofReactionString(r) ) ); - frxn<<( fmt::format( - arrheniusFormat, + rxnTypeFormat + rxnEqnFormat + arrheniusFormat, + irn + rate + rxn, + ofReactionString(r), std::dynamic_pointer_cast(r)->rate.preExponentialFactor(), std::dynamic_pointer_cast(r)->rate.temperatureExponent(), std::dynamic_pointer_cast(r)->rate.activationEnergy_R() @@ -403,13 +407,11 @@ int main(int argc, char *argv[]) break; } - frxn<<( fmt::format( rxnTypeFormat, irn + rate + rxn)); - - frxn<<( fmt::format( rxnEqnFormat, ofReactionString(r) ) ); - frxn<<( fmt::format( - falloffFormat, + rxnTypeFormat + rxnEqnFormat + falloffFormat, + irn + rate + rxn, + ofReactionString(r), std::dynamic_pointer_cast(r)->low_rate.preExponentialFactor(), std::dynamic_pointer_cast(r)->low_rate.temperatureExponent(), std::dynamic_pointer_cast(r)->low_rate.activationEnergy_R(), diff --git a/ofFormats.h b/ofFormats.h index fbff9a6..dfcad6e 100644 --- a/ofFormats.h +++ b/ofFormats.h @@ -28,6 +28,12 @@ std::string thermoFormat = std::string() + "}}\n" ; +std::string rxnTypeFormat = +" type {};\n"; + +std::string rxnEqnFormat = +" reaction \"{}\";\n"; + std::string arrheniusFormat = std::string() + " A {};\n" + " beta {};\n" + @@ -80,8 +86,4 @@ std::string sriFormat = std::string() + ; -std::string rxnTypeFormat = " type {};\n"; - -std::string rxnEqnFormat = " reaction \"{}\";\n"; - #endif