OGS
CreateReactionRate.cpp
Go to the documentation of this file.
1
11#include <optional>
12
13#include "BaseLib/ConfigTree.h"
16
17namespace ChemistryLib
18{
19template <typename ReactionRate>
20std::vector<ReactionRate> createReactionRates(
21 std::optional<BaseLib::ConfigTree> const& config)
22{
23 if (!config)
24 {
25 return {};
26 }
27
28 std::vector<ReactionRate> reaction_rates;
29 for (auto const& rate_config :
31 config->getConfigSubtreeList("rate"))
32 {
33 auto kinetic_reactant =
35 rate_config.getConfigParameter<std::string>("kinetic_reactant");
36
37 auto const expression_config =
39 rate_config.getConfigSubtree("expression");
40 auto const& statements =
42 expression_config.getConfigParameterList<std::string>("statement");
43
44 std::vector<std::string> expression_statements;
45 expression_statements.reserve(statements.size());
46 std::copy(begin(statements),
47 end(statements),
48 back_inserter(expression_statements));
49
50 reaction_rates.emplace_back(std::move(kinetic_reactant),
51 std::move(expression_statements));
52 }
53
54 return reaction_rates;
55}
56
57template std::vector<PhreeqcIOData::ReactionRate>
59 std::optional<BaseLib::ConfigTree> const& config);
60
61template std::vector<PhreeqcKernelData::ReactionRate>
63 std::optional<BaseLib::ConfigTree> const& config);
64} // namespace ChemistryLib
template std::vector< PhreeqcKernelData::ReactionRate > createReactionRates< PhreeqcKernelData::ReactionRate >(std::optional< BaseLib::ConfigTree > const &config)
std::vector< ReactionRate > createReactionRates(std::optional< BaseLib::ConfigTree > const &config)
template std::vector< PhreeqcIOData::ReactionRate > createReactionRates< PhreeqcIOData::ReactionRate >(std::optional< BaseLib::ConfigTree > const &config)