OGS
CreateEquilibriumReactants.cpp
Go to the documentation of this file.
1
12
13#include <optional>
14#include <vector>
15
16#include "BaseLib/ConfigTree.h"
18#include "MeshLib/Mesh.h"
20
21namespace ChemistryLib
22{
23namespace PhreeqcKernelData
24{
25std::unique_ptr<EquilibriumReactants> createEquilibriumReactants(
26 std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh const& mesh)
27{
28 if (!config)
29 {
30 return nullptr;
31 }
32
33 std::vector<PhaseComponent> phase_components;
34 for (
35 auto const& phase_component_config :
37 config->getConfigSubtreeList("phase_component"))
38 {
39 auto name =
41 phase_component_config.getConfigParameter<std::string>("name");
42
43 double const initial_amount =
45 phase_component_config.getConfigParameter<double>("initial_amount");
46
47 double const saturation_index =
49 phase_component_config.getConfigParameter<double>(
50 "saturation_index");
51
52 auto amount = MeshLib::getOrCreateMeshProperty<double>(
53 const_cast<MeshLib::Mesh&>(mesh),
54 name,
56 1);
57 std::fill(amount->begin(), amount->end(), initial_amount);
58
59 phase_components.emplace_back(
60 std::move(name), initial_amount, saturation_index);
61 }
62
63 return std::make_unique<EquilibriumReactants>(phase_components);
64}
65} // namespace PhreeqcKernelData
66} // namespace ChemistryLib
Definition of the Mesh class.
std::unique_ptr< EquilibriumReactants > createEquilibriumReactants(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)