OGS
CreateKineticReactant.cpp
Go to the documentation of this file.
1
12
13#include <optional>
14#include <vector>
15
16#include "BaseLib/ConfigTree.h"
17#include "KineticReactant.h"
18#include "MeshLib/Mesh.h"
20
21namespace ChemistryLib
22{
23namespace PhreeqcKernelData
24{
25std::unique_ptr<Kinetics> createKineticReactants(
26 std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh const& mesh)
27{
28 if (!config)
29 {
30 return nullptr;
31 }
32
33 std::vector<KineticReactant> kinetic_reactants;
34 for (
35 auto const& reactant_config :
37 config->getConfigSubtreeList("kinetic_reactant"))
38 {
40 auto name = reactant_config.getConfigParameter<std::string>("name");
41
42 double const initial_amount =
44 reactant_config.getConfigParameter<double>("initial_amount");
45
47 const_cast<MeshLib::Mesh&>(mesh),
48 name,
50 1);
51 std::fill(std::begin(*amount), std::end(*amount), initial_amount);
52
53 kinetic_reactants.emplace_back(std::move(name), initial_amount);
54 }
55
56 return std::make_unique<Kinetics>(kinetic_reactants);
57}
58} // namespace PhreeqcKernelData
59} // namespace ChemistryLib
Definition of the Mesh class.
std::unique_ptr< Kinetics > createKineticReactants(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)