https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
ReactionNetworkUtils::Reaction Struct Reference

#include <ReactionNetworkUtils.h>

Public Member Functions

std::vector< VariableName > getSpecies () const
 Get all species involved in the reaction.
 
std::vector< VariableName > getUniqueSpecies () const
 Get all unique species involved in the reaction Note: a species will only appear once even if both a reactant and a product.
 
std::vector< Real > getStoichiometricCoefficients () const
 Get the stoeichiometric coefficients for each species in the reaction The sign used matches the sign in the reaction equation.
 
std::map< VariableName, Real > getUniqueStoichiometricCoefficients () const
 Get the stoeichiometric coefficients for each unique species in the reaction Note: if a species is both a reactant and a product, the coefficient will be the difference between its product and reactor coefficients Note: this means all coefficients for reactants that are not products are negative, unlike in getStoichiometricCoefficients()
 
std::vector< VariableName > getReactantSpecies () const
 Get all reactant species involved in the reaction (on LHS)
 
std::vector< VariableName > getUniqueReactantSpecies () const
 Get all unique reactant species involved in the reaction (on LHS)
 
std::vector< std::string > getProductSpecies () const
 Get all product species involved in the reaction (on RHS)
 
std::vector< std::string > getUniqueProductSpecies () const
 Get all unique product species involved in the reaction (on RHS)
 
template<typename T >
bool hasMetaData (const std::string &key) const
 Whether the reaction has the metadata with the given type.
 
bool hasMetaData (const std::string &key) const
 Whether the reaction has the metadata.
 
const std::string & getMetaData (const std::string &key) const
 Get the metadata from the reaction.
 
template<>
bool hasMetaData (const std::string &key) const
 

Public Attributes

TermList reactants
 
TermList products
 
Metadata metadata
 

Detailed Description

Definition at line 44 of file ReactionNetworkUtils.h.

Member Function Documentation

◆ getMetaData()

const std::string & ReactionNetworkUtils::Reaction::getMetaData ( const std::string &  key) const

Get the metadata from the reaction.

Definition at line 327 of file ReactionNetworkUtils.C.

328{
329 // Get a better error
330 if (hasMetaData(key))
331 return libmesh_map_find(metadata, key);
332 else
333 mooseError("MetaData item '" + key + "' was not found in reaction:\n" +
334 Moose::stringify(*this));
335}
void mooseError(Args &&... args)
std::string stringify(const T &t)
bool hasMetaData(const std::string &key) const
Whether the reaction has the metadata with the given type.

◆ getProductSpecies()

std::vector< std::string > ReactionNetworkUtils::Reaction::getProductSpecies ( ) const

Get all product species involved in the reaction (on RHS)

Definition at line 283 of file ReactionNetworkUtils.C.

284{
285 std::vector<std::string> species;
286 for (const auto & term : products)
287 species.push_back(term.species + term.state.value_or("") + term.charge.value_or(""));
288 return species;
289}

◆ getReactantSpecies()

std::vector< VariableName > ReactionNetworkUtils::Reaction::getReactantSpecies ( ) const

Get all reactant species involved in the reaction (on LHS)

Definition at line 260 of file ReactionNetworkUtils.C.

261{
262 std::vector<VariableName> species;
263 for (const auto & term : reactants)
264 species.push_back(term.species + term.state.value_or("") + term.charge.value_or(""));
265 return species;
266}

◆ getSpecies()

std::vector< VariableName > ReactionNetworkUtils::Reaction::getSpecies ( ) const

Get all species involved in the reaction.

Definition at line 201 of file ReactionNetworkUtils.C.

202{
203 std::vector<VariableName> species;
204 for (const auto & term : reactants)
205 species.push_back(term.species + term.state.value_or("") + term.charge.value_or(""));
206 for (const auto & term : products)
207 species.push_back(term.species + term.state.value_or("") + term.charge.value_or(""));
208 return species;
209}

◆ getStoichiometricCoefficients()

std::vector< Real > ReactionNetworkUtils::Reaction::getStoichiometricCoefficients ( ) const

Get the stoeichiometric coefficients for each species in the reaction The sign used matches the sign in the reaction equation.

Definition at line 232 of file ReactionNetworkUtils.C.

233{
234 std::vector<Real> coeffs;
235 for (const auto & term : reactants)
236 coeffs.push_back(term.coefficient);
237 for (const auto & term : products)
238 coeffs.push_back(term.coefficient);
239 return coeffs;
240}

◆ getUniqueProductSpecies()

std::vector< std::string > ReactionNetworkUtils::Reaction::getUniqueProductSpecies ( ) const

Get all unique product species involved in the reaction (on RHS)

Definition at line 292 of file ReactionNetworkUtils.C.

293{
294 std::vector<std::string> species;
295 std::set<Term> terms_gathered;
296 for (const auto & term : products)
297 if (terms_gathered.find(term) == terms_gathered.end())
298 {
299 species.push_back(term.species + term.state.value_or("") + term.charge.value_or(""));
300 terms_gathered.insert(term);
301 }
302 return species;
303}
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
if(subdm)

◆ getUniqueReactantSpecies()

std::vector< VariableName > ReactionNetworkUtils::Reaction::getUniqueReactantSpecies ( ) const

Get all unique reactant species involved in the reaction (on LHS)

Definition at line 269 of file ReactionNetworkUtils.C.

270{
271 std::vector<VariableName> species;
272 std::set<Term> terms_gathered;
273 for (const auto & term : reactants)
274 if (terms_gathered.find(term) == terms_gathered.end())
275 {
276 species.push_back(term.species + term.state.value_or("") + term.charge.value_or(""));
277 terms_gathered.insert(term);
278 }
279 return species;
280}

◆ getUniqueSpecies()

std::vector< VariableName > ReactionNetworkUtils::Reaction::getUniqueSpecies ( ) const

Get all unique species involved in the reaction Note: a species will only appear once even if both a reactant and a product.

Definition at line 212 of file ReactionNetworkUtils.C.

213{
214 std::vector<VariableName> species;
215 std::set<Term> terms_gathered;
216 for (const auto & term : reactants)
217 if (terms_gathered.find(term) == terms_gathered.end())
218 {
219 species.push_back(term.species + term.state.value_or("") + term.charge.value_or(""));
220 terms_gathered.insert(term);
221 }
222 for (const auto & term : products)
223 if (terms_gathered.find(term) == terms_gathered.end())
224 {
225 species.push_back(term.species + term.state.value_or("") + term.charge.value_or(""));
226 terms_gathered.insert(term);
227 }
228 return species;
229}

◆ getUniqueStoichiometricCoefficients()

std::map< VariableName, Real > ReactionNetworkUtils::Reaction::getUniqueStoichiometricCoefficients ( ) const

Get the stoeichiometric coefficients for each unique species in the reaction Note: if a species is both a reactant and a product, the coefficient will be the difference between its product and reactor coefficients Note: this means all coefficients for reactants that are not products are negative, unlike in getStoichiometricCoefficients()

Definition at line 243 of file ReactionNetworkUtils.C.

244{
245 std::map<VariableName, Real> terms_gathered;
246 for (const auto & term : reactants)
247 {
248 const auto term_str = term.species + term.state.value_or("") + term.charge.value_or("");
249 terms_gathered[term_str] -= term.coefficient;
250 }
251 for (const auto & term : products)
252 {
253 const auto term_str = term.species + term.state.value_or("") + term.charge.value_or("");
254 terms_gathered[term_str] += term.coefficient;
255 }
256 return terms_gathered;
257}

◆ hasMetaData() [1/3]

template<typename T >
bool ReactionNetworkUtils::Reaction::hasMetaData ( const std::string &  key) const

Whether the reaction has the metadata with the given type.

Definition at line 314 of file ReactionNetworkUtils.C.

315{
316 mooseError("Has metadata not implemented for type " + MooseUtils::prettyCppType<T>());
317 return false;
318}

Referenced by getMetaData().

◆ hasMetaData() [2/3]

bool ReactionNetworkUtils::Reaction::hasMetaData ( const std::string &  key) const

Whether the reaction has the metadata.

Definition at line 321 of file ReactionNetworkUtils.C.

322{
323 return metadata.count(key);
324}

◆ hasMetaData() [3/3]

template<>
bool ReactionNetworkUtils::Reaction::hasMetaData ( const std::string &  key) const

Definition at line 306 of file ReactionNetworkUtils.C.

308{
309 return metadata.count(key) && MooseUtils::isFloat(libmesh_map_find(metadata, key));
310}

Member Data Documentation

◆ metadata

Metadata ReactionNetworkUtils::Reaction::metadata

◆ products

TermList ReactionNetworkUtils::Reaction::products

◆ reactants

TermList ReactionNetworkUtils::Reaction::reactants

The documentation for this struct was generated from the following files: