Skip to content

Commit

Permalink
Add read_reaction_set_data API
Browse files Browse the repository at this point in the history
This one takes a pointer to a ParserBase object and then does
the read. Slight refactoring of existing function to reuse existing
capability. Really, this should just all be in the ParserBase
and XMLParser classes, but until we address libantioch#260, we're stuck
with this simple change/(gross) API extension.
  • Loading branch information
pbauman committed Jul 10, 2018
1 parent fdedca7 commit 626d4ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/parsing/include/antioch/read_reaction_set_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
namespace Antioch
{

template <typename NumericType>
class ParserBase;

template <typename NumericType>
class ASCIIParser;

Expand Down Expand Up @@ -128,6 +131,12 @@ namespace Antioch
ReactionSet<NumericType>& reaction_set,
ParsingType type = ASCII );

template<typename NumericType>
void read_reaction_set_data(const std::string &filename,
const bool verbose,
ReactionSet<NumericType>& reaction_set,
ParserBase<NumericType> * parser );

template <typename NumericType>
void verify_unit_of_parameter(Units<NumericType> & default_unit, const std::string & provided_unit,
const std::vector<std::string> & accepted_unit,
Expand Down
20 changes: 15 additions & 5 deletions src/parsing/src/read_reaction_set_data.C
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,21 @@ namespace Antioch
antioch_parsing_error("unknown type");
}

read_reaction_set_data(filename,verbose,reaction_set,parser);

if(parser)
delete parser;
}

template<typename NumericType>
void read_reaction_set_data( const std::string& filename,
const bool verbose,
ReactionSet<NumericType>& reaction_set,
ParserBase<NumericType> * parser )
{
//error or no reaction data
if(!parser->initialize())return;
if(!parser->initialize())
return;

const ChemicalMixture<NumericType>& chem_mixture = reaction_set.chemical_mixture();
unsigned int n_species = chem_mixture.n_species();
Expand Down Expand Up @@ -414,7 +427,7 @@ namespace Antioch
my_rxn->type() == ReactionType::TROE_FALLOFF_THREE_BODY)
)
{

std::cerr << "In reaction " << parser->reaction_id() << "\n"
<< "An equation of the form \"A * exp(-Ea/(R*T))\" is an Arrhenius equation,\n"
<< "and most certainly not a Kooij one\n"
Expand Down Expand Up @@ -743,9 +756,6 @@ namespace Antioch

if(verbose) std::cout << "\n\n";
}

if(parser)
delete parser;
}

// Instantiate
Expand Down

0 comments on commit 626d4ce

Please sign in to comment.