Commit fde55173 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'feature/instationary-assembler-constructor' into 'master'

Feature/instationary assembler constructor

Closes #748

See merge request !1694
parents 78b57faf 457b825e
......@@ -89,6 +89,22 @@ public:
static_assert(isImplicit, "Explicit assembler for stationary problem doesn't make sense!");
}
/*!
* \brief The constructor for instationary problems
* \note this constructor is deprecated (use the one receiving the previous solution instead)
*/
[[deprecated("Please use constructor taking the previous solution instead. Will be removed after release 3.2!")]]
FVAssembler(std::shared_ptr<const Problem> problem,
std::shared_ptr<const FVGridGeometry> fvGridGeometry,
std::shared_ptr<GridVariables> gridVariables,
std::shared_ptr<const TimeLoop> timeLoop)
: problem_(problem)
, fvGridGeometry_(fvGridGeometry)
, gridVariables_(gridVariables)
, timeLoop_(timeLoop)
, isStationaryProblem_(!timeLoop)
{}
/*!
* \brief The constructor for instationary problems
* \note the grid variables might be temporarily changed during assembly (if caching is enabled)
......@@ -97,11 +113,13 @@ public:
FVAssembler(std::shared_ptr<const Problem> problem,
std::shared_ptr<const FVGridGeometry> fvGridGeometry,
std::shared_ptr<GridVariables> gridVariables,
std::shared_ptr<const TimeLoop> timeLoop)
std::shared_ptr<const TimeLoop> timeLoop,
const SolutionVector& prevSol)
: problem_(problem)
, fvGridGeometry_(fvGridGeometry)
, gridVariables_(gridVariables)
, timeLoop_(timeLoop)
, prevSol_(&prevSol)
, isStationaryProblem_(!timeLoop)
{}
......
......@@ -61,6 +61,7 @@ class StaggeredFVAssembler: public MultiDomainFVAssembler<StaggeredMultiDomainTr
diffMethod>;
using Problem = GetPropType<TypeTag, Properties::Problem>;
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
using TimeLoop = TimeLoopBase<GetPropType<TypeTag, Properties::Scalar>>;
public:
......@@ -82,6 +83,7 @@ public:
}
//! The constructor for instationary problems
[[deprecated("Please use the constructor additionally taking the previous solution. Will be removed after 3.2 release!")]]
StaggeredFVAssembler(std::shared_ptr<const Problem> problem,
std::shared_ptr<const FVGridGeometry> fvGridGeometry,
std::shared_ptr<GridVariables> gridVariables,
......@@ -96,6 +98,23 @@ public:
this->couplingManager_->setSubProblems(std::make_tuple(problem, problem));
}
//! The constructor for instationary problems
StaggeredFVAssembler(std::shared_ptr<const Problem> problem,
std::shared_ptr<const FVGridGeometry> fvGridGeometry,
std::shared_ptr<GridVariables> gridVariables,
std::shared_ptr<const TimeLoop> timeLoop,
const SolutionVector& prevSol)
: ParentType(std::make_tuple(problem, problem),
std::make_tuple(fvGridGeometry->cellCenterFVGridGeometryPtr(), fvGridGeometry->faceFVGridGeometryPtr()),
std::make_tuple(gridVariables->cellCenterGridVariablesPtr(), gridVariables->faceGridVariablesPtr()),
std::make_shared<CouplingManager>(),
timeLoop,
prevSol)
{
static_assert(isImplicit, "Explicit assembler for stationary problem doesn't make sense!");
this->couplingManager_->setSubProblems(std::make_tuple(problem, problem));
}
auto& gridVariables()
{ return ParentType::gridVariables(Dune::index_constant<0>()); }
......
......@@ -152,6 +152,26 @@ public:
std::cout << "Instantiated assembler for a stationary problem." << std::endl;
}
/*!
* \brief The constructor for instationary problems
* \note this constructor is deprecated (use the one receiving the previous solution instead)
*/
[[deprecated("Please use constructor taking the previous solution instead. Will be removed after release 3.2!")]]
MultiDomainFVAssembler(ProblemTuple&& problem,
FVGridGeometryTuple&& fvGridGeometry,
GridVariablesTuple&& gridVariables,
std::shared_ptr<CouplingManager> couplingManager,
std::shared_ptr<const TimeLoop> timeLoop)
: couplingManager_(couplingManager)
, problemTuple_(problem)
, fvGridGeometryTuple_(fvGridGeometry)
, gridVariablesTuple_(gridVariables)
, timeLoop_(timeLoop)
, isStationaryProblem_(false)
{
std::cout << "Instantiated assembler for an instationary problem." << std::endl;
}
/*!
* \brief The constructor for instationary problems
* \note the grid variables might be temporarily changed during assembly (if caching is enabled)
......@@ -161,12 +181,14 @@ public:
FVGridGeometryTuple&& fvGridGeometry,
GridVariablesTuple&& gridVariables,
std::shared_ptr<CouplingManager> couplingManager,
std::shared_ptr<const TimeLoop> timeLoop)
std::shared_ptr<const TimeLoop> timeLoop,
const SolutionVector& prevSol)
: couplingManager_(couplingManager)
, problemTuple_(problem)
, fvGridGeometryTuple_(fvGridGeometry)
, gridVariablesTuple_(gridVariables)
, timeLoop_(timeLoop)
, prevSol_(&prevSol)
, isStationaryProblem_(false)
{
std::cout << "Instantiated assembler for an instationary problem." << std::endl;
......
......@@ -178,7 +178,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -192,9 +192,6 @@ int main(int argc, char** argv) try
const bool printL2Error = getParam<bool>("Problem.PrintL2Error");
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -119,7 +119,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -170,9 +170,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -114,7 +114,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -127,9 +127,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -248,7 +248,8 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = isStationary ? std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables) : std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = isStationary ? std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables)
: std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -287,9 +288,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -116,7 +116,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -129,9 +129,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -115,7 +115,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -128,9 +128,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -114,7 +114,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -130,9 +130,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -141,7 +141,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -154,9 +154,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -138,7 +138,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::UMFPackBackend;
......@@ -151,9 +151,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
......
......@@ -120,7 +120,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::AMGBackend<TypeTag>;
......@@ -136,8 +136,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
nonLinearSolver.solve(x,*timeLoop);
// update the analytical solution
......
......@@ -118,7 +118,7 @@ int main(int argc, char** argv) try
// the assembler with time loop for instationary problem
using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop);
auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop, xOld);
// the linear solver
using LinearSolver = Dumux::AMGBackend<TypeTag>;
......@@ -134,8 +134,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(xOld);
nonLinearSolver.solve(x,*timeLoop);
// update the analytical solution
......
......@@ -256,7 +256,7 @@ int main(int argc, char** argv) try
auto assembler = std::make_shared<Assembler>(std::make_tuple(problem0, problem1),
std::make_tuple(fvGridGeometry0, fvGridGeometry1),
std::make_tuple(gridVariables0, gridVariables1),
couplingManager, timeLoop);
couplingManager, timeLoop, oldSol);
// the linear solver
using LinearSolver = ILU0BiCGSTABBackend;
......@@ -270,9 +270,6 @@ int main(int argc, char** argv) try
timeLoop->start();
while (!timeLoop->finished())
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(oldSol);
// solve the non-linear system with time step control
nonLinearSolver.solve(sol, *timeLoop);
......
......@@ -241,7 +241,7 @@ int main(int argc, char** argv) try
auto assembler = std::make_shared<Assembler>(std::make_tuple(problem0, problem1),
std::make_tuple(fvGridGeometry0, fvGridGeometry1),
std::make_tuple(gridVariables0, gridVariables1),
couplingManager, timeLoop);
couplingManager, timeLoop, oldSol);
// the linear solver
using LinearSolver = ILU0BiCGSTABBackend;
......@@ -255,9 +255,6 @@ int main(int argc, char** argv) try
timeLoop->start();
while (!timeLoop->finished())
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(oldSol);
// solve the non-linear system with time step control
nonLinearSolver.solve(sol, *timeLoop);
......
......@@ -206,7 +206,8 @@ int main(int argc, char** argv) try
stokesGridVariables->faceGridVariablesPtr(),
darcyGridVariables),
couplingManager,
timeLoop);
timeLoop,
solOld);
// the linear solver
using LinearSolver = UMFPackBackend;
......@@ -221,10 +222,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(solOld);
if(timeLoop->time() > injectionBegin - eps && timeLoop->time() < injectionEnd + eps)
stokesProblem->setInjectionState(true);
else
......
......@@ -193,7 +193,8 @@ int main(int argc, char** argv) try
stokesGridVariables->faceGridVariablesPtr(),
darcyGridVariables),
couplingManager,
timeLoop);
timeLoop,
solOld);
// the linear solver
using LinearSolver = UMFPackBackend;
......@@ -206,9 +207,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(solOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(sol, *timeLoop);
......
......@@ -193,7 +193,8 @@ int main(int argc, char** argv) try
stokesGridVariables->faceGridVariablesPtr(),
darcyGridVariables),
couplingManager,
timeLoop);
timeLoop,
solOld);
FluxOverSurface<StokesGridVariables,
decltype(stokesSol),
......@@ -229,9 +230,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(solOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(sol, *timeLoop);
......
......@@ -193,7 +193,8 @@ int main(int argc, char** argv) try
stokesGridVariables->faceGridVariablesPtr(),
darcyGridVariables),
couplingManager,
timeLoop);
timeLoop,
solOld);
// the linear solver
using LinearSolver = UMFPackBackend;
......@@ -206,9 +207,6 @@ int main(int argc, char** argv) try
// time loop
timeLoop->start(); do
{
// set previous solution for storage evaluations
assembler->setPreviousSolution(solOld);
// solve the non-linear system with time step control
nonLinearSolver.solve(sol, *timeLoop);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment