OGS
CreateEquilibriumReactants.cpp
Go to the documentation of this file.
1
12
13#include <optional>
14
15#include "BaseLib/ConfigTree.h"
16#include "EquilibriumReactant.h"
17#include "MeshLib/Mesh.h"
19
20namespace ChemistryLib
21{
22namespace PhreeqcIOData
23{
24std::vector<EquilibriumReactant> createEquilibriumReactants(
25 std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh& mesh)
26{
27 if (!config)
28 {
29 return {};
30 }
31
32 std::vector<EquilibriumReactant> equilibrium_reactants;
33 for (
34 auto const& equilibrium_reactant_config :
36 config->getConfigSubtreeList("phase_component"))
37 {
38 auto name =
40 equilibrium_reactant_config.getConfigParameter<std::string>("name");
41
42 double const saturation_index =
44 equilibrium_reactant_config.getConfigParameter<double>(
45 "saturation_index");
46
47 auto reaction_irreversibility =
49 equilibrium_reactant_config.getConfigParameter<std::string>(
50 "reaction_irreversibility", "");
51
52 if (!reaction_irreversibility.empty() &&
53 (reaction_irreversibility != "dissolve_only" &&
54 reaction_irreversibility != "precipitate_only"))
55 {
57 "{:s}: reaction direction only allows `dissolve_only` or "
58 "`precipitate_only`",
59 name);
60 }
61
62 auto molality = MeshLib::getOrCreateMeshProperty<double>(
64
65 auto molality_prev = MeshLib::getOrCreateMeshProperty<double>(
66 mesh, name + "_prev", MeshLib::MeshItemType::IntegrationPoint, 1);
67
68 auto volume_fraction = MeshLib::getOrCreateMeshProperty<double>(
69 mesh, "phi_" + name, MeshLib::MeshItemType::IntegrationPoint, 1);
70
71 auto volume_fraction_prev = MeshLib::getOrCreateMeshProperty<double>(
72 mesh,
73 "phi_" + name + "_prev",
75 1);
76
77 auto mesh_prop_molality = MeshLib::getOrCreateMeshProperty<double>(
78 mesh, name + "_avg", MeshLib::MeshItemType::Cell, 1);
79 mesh_prop_molality->resize(mesh.getNumberOfElements());
80
81 equilibrium_reactants.emplace_back(std::move(name),
82 molality,
83 molality_prev,
84 volume_fraction,
85 volume_fraction_prev,
86 mesh_prop_molality,
87 saturation_index,
88 std::move(reaction_irreversibility));
89 }
90
91 return equilibrium_reactants;
92}
93} // namespace PhreeqcIOData
94} // namespace ChemistryLib
#define OGS_FATAL(...)
Definition Error.h:26
Definition of the Mesh class.
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
std::vector< EquilibriumReactant > createEquilibriumReactants(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh &mesh)