OGS
CreateKineticReactant.cpp
Go to the documentation of this file.
1
12
13#include <optional>
14
15#include "BaseLib/ConfigTree.h"
16#include "KineticReactant.h"
17#include "MeshLib/Mesh.h"
19
20namespace ChemistryLib
21{
22namespace PhreeqcIOData
23{
24std::vector<KineticReactant> createKineticReactants(
25 std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh& mesh)
26{
27 if (!config)
28 {
29 return {};
30 }
31
32 std::vector<KineticReactant> kinetic_reactants;
33 for (
34 auto const& reactant_config :
36 config->getConfigSubtreeList("kinetic_reactant"))
37 {
39 auto name = reactant_config.getConfigParameter<std::string>("name");
40
41 auto chemical_formula =
43 reactant_config.getConfigParameter<std::string>("chemical_formula",
44 "");
45
46 auto parameters =
48 reactant_config.getConfigParameter<std::vector<double>>(
49 "parameters", {});
50
51 bool const fix_amount =
53 reactant_config.getConfigParameter<bool>("fix_amount", false);
54
55 auto molality = MeshLib::getOrCreateMeshProperty<double>(
57
58 auto molality_prev = MeshLib::getOrCreateMeshProperty<double>(
59 mesh, name + "_prev", MeshLib::MeshItemType::IntegrationPoint, 1);
60
61 auto volume_fraction = MeshLib::getOrCreateMeshProperty<double>(
62 mesh, "phi_" + name, MeshLib::MeshItemType::IntegrationPoint, 1);
63
64 auto volume_fraction_prev = MeshLib::getOrCreateMeshProperty<double>(
65 mesh,
66 "phi_" + name + "_prev",
68 1);
69
70 auto mesh_prop_molality = MeshLib::getOrCreateMeshProperty<double>(
71 mesh, name + "_avg", MeshLib::MeshItemType::Cell, 1);
72 mesh_prop_molality->resize(mesh.getNumberOfElements());
73
74 kinetic_reactants.emplace_back(std::move(name),
75 std::move(chemical_formula),
76 molality,
77 molality_prev,
78 volume_fraction,
79 volume_fraction_prev,
80 mesh_prop_molality,
81 std::move(parameters),
82 fix_amount);
83 }
84
85 return kinetic_reactants;
86}
87} // namespace PhreeqcIOData
88} // namespace ChemistryLib
Definition of the Mesh class.
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
std::vector< KineticReactant > createKineticReactants(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh &mesh)