From 2dc7449b627ceff2dccd67ba48435fbfb58bbd62 Mon Sep 17 00:00:00 2001 From: renchao_lu <renchao.lu@gmail.com> Date: Wed, 17 Jun 2020 17:30:11 +0200 Subject: [PATCH] [CL] Get int_pt_process_solutions from chemical solver interface. --- ChemistryLib/ChemicalSolverInterface.h | 2 ++ ChemistryLib/PhreeqcIO.cpp | 17 +++++++++++++++-- ChemistryLib/PhreeqcIO.h | 2 ++ ChemistryLib/PhreeqcKernel.h | 5 +++++ ProcessLib/TimeLoop.cpp | 11 +++-------- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChemistryLib/ChemicalSolverInterface.h b/ChemistryLib/ChemicalSolverInterface.h index 729ff2b1500..e821496003a 100644 --- a/ChemistryLib/ChemicalSolverInterface.h +++ b/ChemistryLib/ChemicalSolverInterface.h @@ -25,6 +25,8 @@ public: virtual void doWaterChemistryCalculation( std::vector<GlobalVector*>& process_solutions, double const dt) = 0; + virtual std::vector<GlobalVector*> getIntPtProcessSolutions() const = 0; + virtual std::vector<std::string> const getComponentList() const { return {}; diff --git a/ChemistryLib/PhreeqcIO.cpp b/ChemistryLib/PhreeqcIO.cpp index fdda6e0de58..b9f08563af3 100644 --- a/ChemistryLib/PhreeqcIO.cpp +++ b/ChemistryLib/PhreeqcIO.cpp @@ -124,9 +124,22 @@ void PhreeqcIO::executeInitialCalculation( execute(); readOutputsFromFile(); +} - setAqueousSolutionsOrUpdateProcessSolutions( - process_solutions, Status::UpdatingProcessSolutions); +std::vector<GlobalVector*> PhreeqcIO::getIntPtProcessSolutions() const +{ + auto const& aqueous_solution = _chemical_system->aqueous_solution; + std::vector<GlobalVector*> int_pt_process_solutions; + int_pt_process_solutions.reserve(aqueous_solution->components.size() + 1); + + std::transform(aqueous_solution->components.begin(), + aqueous_solution->components.end(), + std::back_inserter(int_pt_process_solutions), + [](auto const& c) { return c.amount.get(); }); + + int_pt_process_solutions.push_back(aqueous_solution->pH.get()); + + return int_pt_process_solutions; } void PhreeqcIO::doWaterChemistryCalculation( diff --git a/ChemistryLib/PhreeqcIO.h b/ChemistryLib/PhreeqcIO.h index e2625497a85..38a1bfa79e8 100644 --- a/ChemistryLib/PhreeqcIO.h +++ b/ChemistryLib/PhreeqcIO.h @@ -63,6 +63,8 @@ public: void readOutputsFromFile(); + std::vector<GlobalVector*> getIntPtProcessSolutions() const override; + friend std::ostream& operator<<(std::ostream& os, PhreeqcIO const& phreeqc_io); diff --git a/ChemistryLib/PhreeqcKernel.h b/ChemistryLib/PhreeqcKernel.h index 85004f3c32d..565725cd9fc 100644 --- a/ChemistryLib/PhreeqcKernel.h +++ b/ChemistryLib/PhreeqcKernel.h @@ -53,6 +53,11 @@ public: void execute(std::vector<GlobalVector*>& process_solutions); + std::vector<GlobalVector*> getIntPtProcessSolutions() const override + { + return {}; + } + void updateNodalProcessSolutions( std::vector<GlobalVector*> const& process_solutions, std::size_t const node_id); diff --git a/ProcessLib/TimeLoop.cpp b/ProcessLib/TimeLoop.cpp index af09a73f344..41abad0cdfe 100644 --- a/ProcessLib/TimeLoop.cpp +++ b/ProcessLib/TimeLoop.cpp @@ -455,11 +455,8 @@ void TimeLoop::initialize() time_phreeqc.start(); auto& pcs = _per_process_data[0]->process; - auto const interpolated_process_solutions = - pcs.interpolateNodalValuesToIntegrationPoints(_process_solutions); - _chemical_solver_interface->executeInitialCalculation( - interpolated_process_solutions); + pcs.interpolateNodalValuesToIntegrationPoints(_process_solutions)); INFO("[time] Phreeqc took {:g} s.", time_phreeqc.elapsed()); } @@ -823,11 +820,9 @@ TimeLoop::solveCoupledEquationSystemsByStaggeredScheme( time_phreeqc.start(); auto& pcs = _per_process_data[0]->process; - auto const interpolated_process_solutions = - pcs.interpolateNodalValuesToIntegrationPoints(_process_solutions); - _chemical_solver_interface->doWaterChemistryCalculation( - interpolated_process_solutions, dt); + pcs.interpolateNodalValuesToIntegrationPoints(_process_solutions), + dt); INFO("[time] Phreeqc took {:g} s.", time_phreeqc.elapsed()); } -- GitLab