diff --git a/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp index ac9be9045e42071c1070a325fc6f8d23d23b830e..54d312c284a24807e4b983079f7efe3aaf3f0ff6 100644 --- a/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp +++ b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp @@ -7,13 +7,18 @@ * */ +#include <boost/optional/optional.hpp> + #include "BaseLib/ConfigTree.h" +#include "CreateKineticReactant.h" #include "KineticReactant.h" +#include "MeshLib/Mesh.h" namespace ChemistryLib { std::vector<KineticReactant> createKineticReactants( - boost::optional<BaseLib::ConfigTree> const& config) + boost::optional<BaseLib::ConfigTree> const& config, + MeshLib::Mesh const& mesh) { if (!config) { @@ -43,9 +48,16 @@ std::vector<KineticReactant> createKineticReactants( reactant_config.getConfigParameter<std::vector<double>>( "parameters", {}); + auto amount = MeshLib::getOrCreateMeshProperty<double>( + const_cast<MeshLib::Mesh&>(mesh), + name, + MeshLib::MeshItemType::Node, + 1); + std::fill(std::begin(*amount), std::end(*amount), initial_amount); + kinetic_reactants.emplace_back(std::move(name), std::move(chemical_formula), - initial_amount, + amount, std::move(parameters)); } diff --git a/ChemistryLib/PhreeqcIOData/CreateKineticReactant.h b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.h index 8aaa80ac9e7fadfd46046126d15d3c36eb4ab666..65811f4b5b6b6613378e3876eda5eb4b8cfab38a 100644 --- a/ChemistryLib/PhreeqcIOData/CreateKineticReactant.h +++ b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.h @@ -9,7 +9,7 @@ #pragma once -#include <boost/optional/optional.hpp> +#include <boost/optional/optional_fwd.hpp> #include <vector> namespace BaseLib @@ -17,6 +17,11 @@ namespace BaseLib class ConfigTree; } +namespace MeshLib +{ +class Mesh; +} + namespace ChemistryLib { struct KineticReactant; @@ -25,5 +30,6 @@ struct KineticReactant; namespace ChemistryLib { std::vector<KineticReactant> createKineticReactants( - boost::optional<BaseLib::ConfigTree> const& config); + boost::optional<BaseLib::ConfigTree> const& config, + MeshLib::Mesh const& mesh); } // namespace ChemistryLib diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.h b/ChemistryLib/PhreeqcIOData/KineticReactant.h index ed8a983c5569220d11cc2ac02971e04257974019..557582e1d36856d381b1d21b09c2149de3adcc3f 100644 --- a/ChemistryLib/PhreeqcIOData/KineticReactant.h +++ b/ChemistryLib/PhreeqcIOData/KineticReactant.h @@ -15,6 +15,7 @@ #include <vector> #include "ChemistryLib/Output.h" +#include "MeshLib/PropertyVector.h" namespace ChemistryLib { @@ -22,7 +23,7 @@ struct KineticReactant { KineticReactant(std::string&& name_, std::string&& chemical_formula_, - double amount_, + MeshLib::PropertyVector<double>* amount_, std::vector<double>&& parameters_) : name(std::move(name_)), chemical_formula(std::move(chemical_formula_)), @@ -36,7 +37,7 @@ struct KineticReactant std::string const name; std::string const chemical_formula; - double amount; + MeshLib::PropertyVector<double>* amount; std::vector<double> const parameters; static const ItemType item_type = ItemType::KineticReactant; };