OGS
PhreeqcIOData/CreateKineticReactant.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <optional>
7
9#include "KineticReactant.h"
10#include "MeshLib/Mesh.h"
12
13namespace ChemistryLib
14{
15namespace PhreeqcIOData
16{
17std::vector<KineticReactant> createKineticReactants(
18 std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh& mesh)
19{
20 if (!config)
21 {
22 return {};
23 }
24
25 std::vector<KineticReactant> kinetic_reactants;
26 for (
27 auto const& reactant_config :
29 config->getConfigSubtreeList("kinetic_reactant"))
30 {
32 auto name = reactant_config.getConfigParameter<std::string>("name");
33
34 auto chemical_formula =
36 reactant_config.getConfigParameter<std::string>("chemical_formula",
37 "");
38
39 auto parameters =
41 reactant_config.getConfigParameter<std::vector<double>>(
42 "parameters", {});
43
44 bool const fix_amount =
46 reactant_config.getConfigParameter<bool>("fix_amount", false);
47
50
52 mesh, name + "_prev", MeshLib::MeshItemType::IntegrationPoint, 1);
53
54 auto volume_fraction = MeshLib::getOrCreateMeshProperty<double>(
55 mesh, "phi_" + name, MeshLib::MeshItemType::IntegrationPoint, 1);
56
57 auto volume_fraction_prev = MeshLib::getOrCreateMeshProperty<double>(
58 mesh,
59 "phi_" + name + "_prev",
61 1);
62
63 auto mesh_prop_molality = MeshLib::getOrCreateMeshProperty<double>(
64 mesh, name + "_avg", MeshLib::MeshItemType::Cell, 1);
65 assert(mesh_prop_molality->size() == mesh.getNumberOfElements());
66
67 kinetic_reactants.emplace_back(std::move(name),
68 std::move(chemical_formula),
69 molality,
70 molality_prev,
71 volume_fraction,
72 volume_fraction_prev,
73 mesh_prop_molality,
74 std::move(parameters),
75 fix_amount);
76 }
77
78 return kinetic_reactants;
79}
80} // namespace PhreeqcIOData
81} // namespace ChemistryLib
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:88
std::vector< KineticReactant > createKineticReactants(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh &mesh)
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)