From 16ab8dfc203f6eaf069d011c70c8de240f177f4c Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Tue, 21 Nov 2023 15:24:36 +0100 Subject: [PATCH] [PL/TimeLoop] Pass information as parameters instead directly access private attributes The goal is to make the function independent from the TimeLoop class --- ProcessLib/TimeLoop.cpp | 19 +++++++++++-------- ProcessLib/TimeLoop.h | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ProcessLib/TimeLoop.cpp b/ProcessLib/TimeLoop.cpp index b6392a98274..49fd0afbc41 100644 --- a/ProcessLib/TimeLoop.cpp +++ b/ProcessLib/TimeLoop.cpp @@ -327,8 +327,14 @@ std::pair<double, bool> TimeLoop::computeTimeStepping( auto& ppd = *_per_process_data[i]; const auto& timestep_algorithm = ppd.timestep_algorithm; + auto const& conv_crit = ppd.conv_crit; + + auto const& x = *_process_solutions[i]; + auto const& x_prev = *_process_solutions_prev[i]; + const double solution_error = - computeRelativeSolutionChangeFromPreviousTimestep(t, i); + computeRelativeSolutionChangeFromPreviousTimestep( + t, timestep_algorithm.get(), conv_crit.get(), x, x_prev); ppd.timestep_current.setAccepted( ppd.nonlinear_solver_status.error_norms_met); @@ -878,18 +884,15 @@ TimeLoop::~TimeLoop() } double TimeLoop::computeRelativeSolutionChangeFromPreviousTimestep( - double const t, std::size_t process_index) const + double const t, NumLib::TimeStepAlgorithm const* timestep_algorithm, + NumLib::ConvergenceCriterion const* conv_crit, GlobalVector const& x, + GlobalVector const& x_prev) const { - auto const& ppd = *_per_process_data[process_index]; - if (!computationOfChangeNeeded(ppd.timestep_algorithm.get(), t)) + if (!computationOfChangeNeeded(timestep_algorithm, t)) { return 0.0; } - auto const& x = *_process_solutions[process_index]; - auto const& x_prev = *_process_solutions_prev[process_index]; - - auto const& conv_crit = ppd.conv_crit; const MathLib::VecNormType norm_type = (conv_crit) ? conv_crit->getVectorNormType() : MathLib::VecNormType::NORM2; diff --git a/ProcessLib/TimeLoop.h b/ProcessLib/TimeLoop.h index f07881c9dcf..336b27032d8 100644 --- a/ProcessLib/TimeLoop.h +++ b/ProcessLib/TimeLoop.h @@ -132,7 +132,9 @@ private: std::vector<std::function<double(double, double)>> generateOutputTimeStepConstraints(std::vector<double>&& fixed_times) const; double computeRelativeSolutionChangeFromPreviousTimestep( - double const t, std::size_t process_index) const; + double const t, NumLib::TimeStepAlgorithm const* timestep_algorithm, + NumLib::ConvergenceCriterion const* conv_crit, GlobalVector const& x, + GlobalVector const& x_prev) const; void preOutputInitialConditions(const double t) const; std::vector<GlobalVector*> _process_solutions; std::vector<GlobalVector*> _process_solutions_prev; -- GitLab