From e1cce486501d9acf859573a857b0fd75c85418ce Mon Sep 17 00:00:00 2001 From: renchao_lu <renchao.lu@gmail.com> Date: Thu, 4 Jun 2020 11:14:50 +0200 Subject: [PATCH] [CL] Use GlobalVector as data container. --- ChemistryLib/PhreeqcIOData/AqueousSolution.h | 20 +++++++++++++++---- .../PhreeqcIOData/CreateSolutionComponent.cpp | 4 ++-- .../PhreeqcIOData/CreateSolutionComponent.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ChemistryLib/PhreeqcIOData/AqueousSolution.h b/ChemistryLib/PhreeqcIOData/AqueousSolution.h index 715a58a3d62..43532f62d19 100644 --- a/ChemistryLib/PhreeqcIOData/AqueousSolution.h +++ b/ChemistryLib/PhreeqcIOData/AqueousSolution.h @@ -11,9 +11,12 @@ #pragma once #include <iosfwd> +#include <memory> #include <string> #include <vector> +#include "MathLib/LinAlg/GlobalMatrixVectorTypes.h" +#include "MathLib/LinAlg/MatrixVectorTraits.h" #include "Output.h" namespace ChemistryLib @@ -24,10 +27,16 @@ namespace PhreeqcIOData { struct Component { - explicit Component(std::string name_) : name(std::move(name_)) {} + explicit Component(std::string name_, + std::size_t const num_chemical_systems_) + : name(std::move(name_)), + amount(MathLib::MatrixVectorTraits<GlobalVector>::newInstance( + num_chemical_systems_)) + { + } std::string const name; - double amount = std::numeric_limits<double>::quiet_NaN(); + std::unique_ptr<GlobalVector> amount; static const ItemType item_type = ItemType::Component; }; @@ -37,9 +46,12 @@ struct AqueousSolution double pressure_, double pe_, std::vector<Component>&& components_, - ChargeBalance charge_balance_) + ChargeBalance charge_balance_, + std::size_t const num_chemical_systems_) : temperature(temperature_), pressure(pressure_), + pH(MathLib::MatrixVectorTraits<GlobalVector>::newInstance( + num_chemical_systems_)), pe(pe_), components(std::move(components_)), charge_balance(charge_balance_) @@ -51,8 +63,8 @@ struct AqueousSolution double temperature; double pressure; - double pH = std::numeric_limits<double>::quiet_NaN(); double pe; + std::unique_ptr<GlobalVector> pH; std::vector<Component> components; ChargeBalance const charge_balance; }; diff --git a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp index 44c0fce8422..3d9d25577b4 100644 --- a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp +++ b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.cpp @@ -17,7 +17,7 @@ namespace ChemistryLib namespace PhreeqcIOData { std::vector<Component> createSolutionComponents( - BaseLib::ConfigTree const& config) + BaseLib::ConfigTree const& config, std::size_t const num_chemical_systems) { std::vector<Component> components; //! \ogs_file_param{prj__chemical_system__solution__components} @@ -27,7 +27,7 @@ std::vector<Component> createSolutionComponents( //! \ogs_file_param{prj__chemical_system__solution__components__component} comp_config.getConfigParameterList<std::string>("component")) { - components.emplace_back(component_name); + components.emplace_back(component_name, num_chemical_systems); } return components; diff --git a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.h b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.h index 417450e9dac..d745e90979c 100644 --- a/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.h +++ b/ChemistryLib/PhreeqcIOData/CreateSolutionComponent.h @@ -24,6 +24,6 @@ namespace PhreeqcIOData struct Component; std::vector<Component> createSolutionComponents( - BaseLib::ConfigTree const& config); + BaseLib::ConfigTree const& config, std::size_t const num_chemical_systems); } // namespace PhreeqcIOData } // namespace ChemistryLib -- GitLab