Skip to content
Snippets Groups Projects
Commit b9417536 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[PL] TimeLoop: Remove generic setEquationSystem.

This is preparation for the PETSc nonlinear solver.
There we need different (from Picard) behaviour in
the Newton tag case.
parent 580454c4
No related branches found
No related tags found
No related merge requests found
...@@ -21,30 +21,8 @@ ...@@ -21,30 +21,8 @@
#include "CoupledSolutionsForStaggeredScheme.h" #include "CoupledSolutionsForStaggeredScheme.h"
#include "ProcessData.h" #include "ProcessData.h"
namespace namespace
{ {
//! Sets the EquationSystem for the given nonlinear solver,
//! which is Picard or Newton depending on the NLTag.
template <NumLib::NonlinearSolverTag NLTag>
void setEquationSystem(NumLib::NonlinearSolverBase& nonlinear_solver,
NumLib::EquationSystem& eq_sys,
NumLib::ConvergenceCriterion& conv_crit)
{
using Solver = NumLib::NonlinearSolver<NLTag>;
using EqSys = NumLib::NonlinearSystem<NLTag>;
assert(dynamic_cast<Solver*>(&nonlinear_solver) != nullptr);
assert(dynamic_cast<EqSys*>(&eq_sys) != nullptr);
auto& nl_solver_ = static_cast<Solver&>(nonlinear_solver);
auto& eq_sys_ = static_cast<EqSys&>(eq_sys);
nl_solver_.setEquationSystem(eq_sys_, conv_crit);
}
//! Sets the EquationSystem for the given nonlinear solver,
//! transparently both for Picard and Newton solvers.
void setEquationSystem(NumLib::NonlinearSolverBase& nonlinear_solver, void setEquationSystem(NumLib::NonlinearSolverBase& nonlinear_solver,
NumLib::EquationSystem& eq_sys, NumLib::EquationSystem& eq_sys,
NumLib::ConvergenceCriterion& conv_crit, NumLib::ConvergenceCriterion& conv_crit,
...@@ -54,11 +32,42 @@ void setEquationSystem(NumLib::NonlinearSolverBase& nonlinear_solver, ...@@ -54,11 +32,42 @@ void setEquationSystem(NumLib::NonlinearSolverBase& nonlinear_solver,
switch (nl_tag) switch (nl_tag)
{ {
case Tag::Picard: case Tag::Picard:
setEquationSystem<Tag::Picard>(nonlinear_solver, eq_sys, conv_crit); {
using EqSys = NumLib::NonlinearSystem<Tag::Picard>;
auto& eq_sys_ = static_cast<EqSys&>(eq_sys);
if (auto* nl_solver =
dynamic_cast<NumLib::NonlinearSolver<Tag::Picard>*>(
&nonlinear_solver);
nl_solver != nullptr)
{
nl_solver->setEquationSystem(eq_sys_, conv_crit);
}
else
{
OGS_FATAL(
"Could not cast nonlinear solver to Picard type solver.");
}
break; break;
}
case Tag::Newton: case Tag::Newton:
setEquationSystem<Tag::Newton>(nonlinear_solver, eq_sys, conv_crit); {
using EqSys = NumLib::NonlinearSystem<Tag::Newton>;
auto& eq_sys_ = static_cast<EqSys&>(eq_sys);
if (auto* nl_solver =
dynamic_cast<NumLib::NonlinearSolver<Tag::Newton>*>(
&nonlinear_solver);
nl_solver != nullptr)
{
nl_solver->setEquationSystem(eq_sys_, conv_crit);
}
else
{
OGS_FATAL(
"Could not cast nonlinear solver to Newton type solver.");
}
break; break;
}
} }
} }
......
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