diff --git a/ChemistryLib/CreatePhreeqcIO.cpp b/ChemistryLib/CreatePhreeqcIO.cpp index 0307b4516e1a06205fc10cbdf67d640f563e3961..261d52e147070ebeae54f545291d698022e308fa 100644 --- a/ChemistryLib/CreatePhreeqcIO.cpp +++ b/ChemistryLib/CreatePhreeqcIO.cpp @@ -17,6 +17,7 @@ #include "PhreeqcIOData/AqueousSolution.h" #include "PhreeqcIOData/CreateAqueousSolution.h" #include "PhreeqcIOData/CreateEquilibriumPhase.h" +#include "PhreeqcIOData/CreateKineticReactant.h" #include "PhreeqcIOData/EquilibriumPhase.h" #include "PhreeqcIOData/KineticReactant.h" #include "PhreeqcIOData/ReactionRate.h" diff --git a/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2a95c1f2a8e09ed913071bdd2ff594e99025b8b7 --- /dev/null +++ b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.cpp @@ -0,0 +1,47 @@ +/** + * \copyright + * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include "BaseLib/ConfigTree.h" +#include "KineticReactant.h" + +namespace ChemistryLib +{ +std::vector<KineticReactant> createKineticReactants( + boost::optional<BaseLib::ConfigTree> const& config) +{ + if (!config) + { + return {}; + } + + std::vector<KineticReactant> kinetic_reactants; + for ( + auto const& reactant_config : + //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant} + config->getConfigSubtreeList("kinetic_reactant")) + { + //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__name} + auto name = reactant_config.getConfigParameter<std::string>("name"); + + double const initial_amount = + //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__initial_amount} + reactant_config.getConfigParameter<double>("initial_amount"); + + auto parameters = + //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__parameters} + reactant_config.getConfigParameterOptional<std::vector<double>>( + "parameters"); + + kinetic_reactants.emplace_back( + std::move(name), initial_amount, std::move(parameters)); + } + + return kinetic_reactants; +} +} // namespace ChemistryLib diff --git a/ChemistryLib/PhreeqcIOData/CreateKineticReactant.h b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.h new file mode 100644 index 0000000000000000000000000000000000000000..8aaa80ac9e7fadfd46046126d15d3c36eb4ab666 --- /dev/null +++ b/ChemistryLib/PhreeqcIOData/CreateKineticReactant.h @@ -0,0 +1,29 @@ +/** + * \copyright + * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#pragma once + +#include <boost/optional/optional.hpp> +#include <vector> + +namespace BaseLib +{ +class ConfigTree; +} + +namespace ChemistryLib +{ +struct KineticReactant; +} + +namespace ChemistryLib +{ +std::vector<KineticReactant> createKineticReactants( + boost::optional<BaseLib::ConfigTree> const& config); +} // namespace ChemistryLib diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp index e4e39a22a9e32a2fa516a6e1aec873124a72d317..7d014bb98cdc99bd921eecd7ec16bf680d0c0c7c 100644 --- a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp +++ b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp @@ -10,43 +10,9 @@ #include <fstream> #include "KineticReactant.h" -#include "BaseLib/ConfigTreeUtil.h" namespace ChemistryLib { -std::vector<KineticReactant> createKineticReactants( - boost::optional<BaseLib::ConfigTree> const& config) -{ - if (!config) - { - return {}; - } - - std::vector<KineticReactant> kinetic_reactants; - for ( - auto const& reactant_config : - //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant} - config->getConfigSubtreeList("kinetic_reactant")) - { - //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__name} - auto name = reactant_config.getConfigParameter<std::string>("name"); - - double const initial_amount = - //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__initial_amount} - reactant_config.getConfigParameter<double>("initial_amount"); - - auto parameters = - //! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__parameters} - reactant_config.getConfigParameterOptional<std::vector<double>>( - "parameters"); - - kinetic_reactants.emplace_back( - std::move(name), initial_amount, std::move(parameters)); - } - - return kinetic_reactants; -} - std::ofstream& operator<<(std::ofstream& out, std::vector<KineticReactant> const& kinetic_reactants) { diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.h b/ChemistryLib/PhreeqcIOData/KineticReactant.h index f0bbbb3988c345f0cf655d0a5684431a65ffbbc9..0c51aa50a50bde5634c06ec1f5b943177976f3c9 100644 --- a/ChemistryLib/PhreeqcIOData/KineticReactant.h +++ b/ChemistryLib/PhreeqcIOData/KineticReactant.h @@ -14,11 +14,6 @@ #include <string> #include <vector> -namespace BaseLib -{ -class ConfigTree; -} - namespace ChemistryLib { struct KineticReactant @@ -42,7 +37,4 @@ struct KineticReactant double amount; std::vector<double> const parameters; }; - -std::vector<KineticReactant> createKineticReactants( - boost::optional<BaseLib::ConfigTree> const& config); } // namespace ChemistryLib