OGS
PhreeqcKernelData/CreateEquilibriumReactants.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#include <vector>
8
11#include "MeshLib/Mesh.h"
13
14namespace ChemistryLib
15{
16namespace PhreeqcKernelData
17{
18std::unique_ptr<EquilibriumReactants> createEquilibriumReactants(
19 std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh const& mesh)
20{
21 if (!config)
22 {
23 return nullptr;
24 }
25
26 std::vector<PhaseComponent> phase_components;
27 for (
28 auto const& phase_component_config :
30 config->getConfigSubtreeList("phase_component"))
31 {
32 auto name =
34 phase_component_config.getConfigParameter<std::string>("name");
35
36 double const initial_amount =
38 phase_component_config.getConfigParameter<double>("initial_amount");
39
40 double const saturation_index =
42 phase_component_config.getConfigParameter<double>(
43 "saturation_index");
44
46 const_cast<MeshLib::Mesh&>(mesh),
47 name,
49 1);
50 std::fill(amount->begin(), amount->end(), initial_amount);
51
52 phase_components.emplace_back(
53 std::move(name), initial_amount, saturation_index);
54 }
55
56 return std::make_unique<EquilibriumReactants>(phase_components);
57}
58} // namespace PhreeqcKernelData
59} // namespace ChemistryLib
std::unique_ptr< EquilibriumReactants > createEquilibriumReactants(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)