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

[CL] Output equilibrium reactants on the element level.

parent 8ff48187
No related branches found
No related tags found
No related merge requests found
...@@ -373,6 +373,14 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io) ...@@ -373,6 +373,14 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io)
auto const& surface = phreeqc_io._surface; auto const& surface = phreeqc_io._surface;
int const num_skipped_lines = surface.empty() ? 1 : 2; int const num_skipped_lines = surface.empty() ? 1 : 2;
auto& equilibrium_reactants =
phreeqc_io._chemical_system->equilibrium_reactants;
for (auto& equilibrium_reactant : equilibrium_reactants)
{
std::fill(equilibrium_reactant.amount_avg->begin(),
equilibrium_reactant.amount_avg->end(), 0.);
}
auto& kinetic_reactants = phreeqc_io._chemical_system->kinetic_reactants; auto& kinetic_reactants = phreeqc_io._chemical_system->kinetic_reactants;
for (auto& kinetic_reactant : kinetic_reactants) for (auto& kinetic_reactant : kinetic_reactants)
{ {
...@@ -449,8 +457,6 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io) ...@@ -449,8 +457,6 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io)
auto& aqueous_solution = auto& aqueous_solution =
phreeqc_io._chemical_system->aqueous_solution; phreeqc_io._chemical_system->aqueous_solution;
auto& components = aqueous_solution->components; auto& components = aqueous_solution->components;
auto& equilibrium_reactants =
phreeqc_io._chemical_system->equilibrium_reactants;
auto& user_punch = phreeqc_io._user_punch; auto& user_punch = phreeqc_io._user_punch;
for (int item_id = 0; for (int item_id = 0;
item_id < static_cast<int>(accepted_items.size()); item_id < static_cast<int>(accepted_items.size());
...@@ -502,6 +508,8 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io) ...@@ -502,6 +508,8 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io)
item_name + "'."); item_name + "'.");
(*equilibrium_reactant.amount)[chemical_system_id] = (*equilibrium_reactant.amount)[chemical_system_id] =
accepted_items[item_id]; accepted_items[item_id];
(*equilibrium_reactant.amount_avg)[mesh_item_id] +=
accepted_items[item_id];
break; break;
} }
case ItemType::KineticReactant: case ItemType::KineticReactant:
...@@ -537,6 +545,12 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io) ...@@ -537,6 +545,12 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io)
} }
} }
for (auto& equilibrium_reactant : equilibrium_reactants)
{
(*equilibrium_reactant.amount_avg)[mesh_item_id] /=
num_local_chemical_system;
}
for (auto& kinetic_reactant : kinetic_reactants) for (auto& kinetic_reactant : kinetic_reactants)
{ {
(*kinetic_reactant.amount_avg)[mesh_item_id] /= (*kinetic_reactant.amount_avg)[mesh_item_id] /=
......
...@@ -50,8 +50,15 @@ std::vector<EquilibriumReactant> createEquilibriumReactants( ...@@ -50,8 +50,15 @@ std::vector<EquilibriumReactant> createEquilibriumReactants(
auto amount = MeshLib::getOrCreateMeshProperty<double>( auto amount = MeshLib::getOrCreateMeshProperty<double>(
mesh, name, MeshLib::MeshItemType::IntegrationPoint, 1); mesh, name, MeshLib::MeshItemType::IntegrationPoint, 1);
equilibrium_reactants.emplace_back( auto mesh_prop_amount = MeshLib::getOrCreateMeshProperty<double>(
std::move(name), amount, initial_amount, saturation_index); mesh, name + "_avg", MeshLib::MeshItemType::Cell, 1);
mesh_prop_amount->resize(mesh.getNumberOfElements());
equilibrium_reactants.emplace_back(std::move(name),
amount,
mesh_prop_amount,
initial_amount,
saturation_index);
} }
return equilibrium_reactants; return equilibrium_reactants;
......
...@@ -30,10 +30,12 @@ struct EquilibriumReactant ...@@ -30,10 +30,12 @@ struct EquilibriumReactant
{ {
EquilibriumReactant(std::string name_, EquilibriumReactant(std::string name_,
MeshLib::PropertyVector<double>* amount_, MeshLib::PropertyVector<double>* amount_,
MeshLib::PropertyVector<double>* amount_avg_,
double const initial_amount_, double const initial_amount_,
double saturation_index_) double saturation_index_)
: name(std::move(name_)), : name(std::move(name_)),
amount(amount_), amount(amount_),
amount_avg(amount_avg_),
initial_amount(initial_amount_), initial_amount(initial_amount_),
saturation_index(saturation_index_) saturation_index(saturation_index_)
{ {
...@@ -43,6 +45,7 @@ struct EquilibriumReactant ...@@ -43,6 +45,7 @@ struct EquilibriumReactant
std::string const name; std::string const name;
MeshLib::PropertyVector<double>* amount; MeshLib::PropertyVector<double>* amount;
MeshLib::PropertyVector<double>* amount_avg;
double const initial_amount; double const initial_amount;
double const saturation_index; double const saturation_index;
static const ItemType item_type = ItemType::EquilibriumReactant; static const ItemType item_type = ItemType::EquilibriumReactant;
......
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