Skip to content
Snippets Groups Projects
Commit f6a32cda authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Dmitri Naumov
Browse files

[PL] Changed lambda to separate method

parent 4037b590
No related branches found
No related tags found
No related merge requests found
...@@ -284,40 +284,13 @@ std::pair<double, bool> TimeLoop::computeTimeStepping( ...@@ -284,40 +284,13 @@ std::pair<double, bool> TimeLoop::computeTimeStepping(
[](auto const& ppd) -> bool [](auto const& ppd) -> bool
{ return ppd->timestep_current.timeStepNumber() == 0; }); { return ppd->timestep_current.timeStepNumber() == 0; });
auto computeSolutionError = [this, t](auto const i) -> double
{
auto const& ppd = *_per_process_data[i];
const auto& timestep_algorithm = ppd.timestep_algorithm;
if (!timestep_algorithm->isSolutionErrorComputationNeeded())
{
return 0.0;
}
if (t == timestep_algorithm->begin())
{
// Always accepts the zeroth step
return 0.0;
}
auto const& x = *_process_solutions[i];
auto const& x_prev = *_process_solutions_prev[i];
auto const& conv_crit = ppd.conv_crit;
const MathLib::VecNormType norm_type =
(conv_crit) ? conv_crit->getVectorNormType()
: MathLib::VecNormType::NORM2;
const double solution_error =
NumLib::computeRelativeChangeFromPreviousTimestep(x, x_prev,
norm_type);
return solution_error;
};
for (std::size_t i = 0; i < _per_process_data.size(); i++) for (std::size_t i = 0; i < _per_process_data.size(); i++)
{ {
auto& ppd = *_per_process_data[i]; auto& ppd = *_per_process_data[i];
const auto& timestep_algorithm = ppd.timestep_algorithm; const auto& timestep_algorithm = ppd.timestep_algorithm;
const double solution_error = computeSolutionError(i); const double solution_error =
computeRelativeSolutionChangeFromPreviousTimestep(t, i);
ppd.timestep_current.setAccepted( ppd.timestep_current.setAccepted(
ppd.nonlinear_solver_status.error_norms_met); ppd.nonlinear_solver_status.error_norms_met);
...@@ -903,4 +876,31 @@ TimeLoop::~TimeLoop() ...@@ -903,4 +876,31 @@ TimeLoop::~TimeLoop()
} }
} }
double TimeLoop::computeRelativeSolutionChangeFromPreviousTimestep(
double const t, std::size_t process_index) const
{
auto const& ppd = *_per_process_data[process_index];
const auto& timestep_algorithm = ppd.timestep_algorithm;
if (!timestep_algorithm->isSolutionErrorComputationNeeded())
{
return 0.0;
}
if (t == timestep_algorithm->begin())
{
// Always accepts the zeroth step
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;
const double solution_error =
NumLib::computeRelativeChangeFromPreviousTimestep(x, x_prev, norm_type);
return solution_error;
};
} // namespace ProcessLib } // namespace ProcessLib
...@@ -131,6 +131,8 @@ private: ...@@ -131,6 +131,8 @@ private:
private: private:
std::vector<std::function<double(double, double)>> std::vector<std::function<double(double, double)>>
generateOutputTimeStepConstraints(std::vector<double>&& fixed_times) const; generateOutputTimeStepConstraints(std::vector<double>&& fixed_times) const;
double computeRelativeSolutionChangeFromPreviousTimestep(
double const t, std::size_t process_index) const;
std::vector<GlobalVector*> _process_solutions; std::vector<GlobalVector*> _process_solutions;
std::vector<GlobalVector*> _process_solutions_prev; std::vector<GlobalVector*> _process_solutions_prev;
std::vector<Output> _outputs; std::vector<Output> _outputs;
......
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