Skip to content
Snippets Groups Projects
Commit e1cce486 authored by renchao.lu's avatar renchao.lu
Browse files

[CL] Use GlobalVector as data container.

parent f89fc01b
No related branches found
No related tags found
No related merge requests found
......@@ -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;
};
......
......@@ -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;
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment