Commit e13e90d8 authored by Lukas Riedel's avatar Lukas Riedel

switching between parallel (ovlp) and sequential linear solver in runtime

parent 926d1779
......@@ -63,25 +63,44 @@ void Simulation<Traits>::operator_setup ()
go1 = std::make_unique<GO1>(*gfs,*cc,*gfs,*cc,*tlop,mbe_tlop);
igo = std::make_unique<IGO>(*go0,*go1);
// --- Solvers ---
lsgfs = std::make_unique<LSGFS>(LSGFSHelper::create(gv));
lscc = std::make_unique<LSCC>();
//Dune::PDELab::constraints(*lsgfs,*lscc,false);
//ls = std::make_unique<LS>(*gfs);
ls = std::make_unique<LS>(*igo,*cc,*lsgfs,*lscc);
//ls = std::make_unique<LS>(5000,0);
pdesolver = std::make_unique<PDESOLVER>(*igo,*ls);
pdesolver->setParameters(inifile.sub("NewtonParameters"));
pdesolver->setVerbosityLevel(verbose);
// --- Time Step Operators ---
Dune::PDELab::OneStepMethodResult osm_result;
if(osm){
osm_result = osm->result(); // cache old result
// build parallel solvers
if (helper.size() > 1) {
// --- Solvers ---
lsgfs = std::make_unique<LSGFS>(LSGFSHelper::create(gv));
lscc = std::make_unique<LSCC>();
ls_par = std::make_unique<LSPar>(*igo,*cc,*lsgfs,*lscc);
pdesolver_par = std::make_unique<PDESOLVERPar>(*igo,*ls_par);
pdesolver_par->setParameters(inifile.sub("NewtonParameters"));
pdesolver_par->setVerbosityLevel(verbose);
// --- Time Step Operators ---
Dune::PDELab::OneStepMethodResult osm_result;
if(osm_par){
osm_result = osm_par->result(); // cache old result
}
osm_par = std::make_unique<OSMPar>(alex2,*igo,*pdesolver_par);
osm_par->setResult(osm_result);
osm_par->setVerbosityLevel(verbose+1);
}
// build sequential solvers
else {
ls_seq = std::make_unique<LSSeq>(5000,0);
pdesolver_seq = std::make_unique<PDESOLVERSeq>(*igo,*ls_seq);
pdesolver_seq->setParameters(inifile.sub("NewtonParameters"));
pdesolver_seq->setVerbosityLevel(verbose);
// --- Time Step Operators ---
Dune::PDELab::OneStepMethodResult osm_result;
if(osm_seq){
osm_result = osm_seq->result(); // cache old result
}
osm_seq = std::make_unique<OSMSeq>(alex2,*igo,*pdesolver_seq);
osm_seq->setResult(osm_result);
osm_seq->setVerbosityLevel(verbose+1);
}
osm = std::make_unique<OSM>(alex2,*igo,*pdesolver);
osm->setResult(osm_result);
osm->setVerbosityLevel(verbose+1);
gfs->update();
......@@ -107,11 +126,20 @@ bool Simulation<Traits>::compute_time_step ()
{
const RF t = controller->getTime();
const RF dt = controller->getDT();
pdesolver->setMaxIterations(controller->getIterations());
bool exception = false;
try
{
osm->apply(t,dt,*uold,*unew);
// solve in parallel
if (helper.size() > 1) {
pdesolver_par->setMaxIterations(controller->getIterations());
osm_par->apply(t,dt,*uold,*unew);
}
// solve sequentially
else {
pdesolver_seq->setMaxIterations(controller->getIterations());
osm_seq->apply(t,dt,*uold,*unew);
}
*uold = *unew;
}
catch (Dune::PDELab::NewtonError &e){
......
......@@ -64,16 +64,18 @@ protected:
using IGO = Dune::PDELab::OneStepGridOperator<GO0,GO1>;
/// Solution vector type
using U = typename IGO::Traits::Domain;
/// Linear solver type
using LS = Dune::PDELab::ISTLBackend_OVLP_AMG_4_DG<IGO,CC,LSGFS,LSCC,
/// Linear solver types
using LSSeq = Dune::PDELab::ISTLBackend_SEQ_SuperLU;
using LSPar = Dune::PDELab::ISTLBackend_OVLP_AMG_4_DG<IGO,CC,LSGFS,LSCC,
Dune::PDELab::CG2DGProlongation,Dune::SeqSSOR,Dune::BiCGSTABSolver>;
//using LS = Dune::PDELab::ISTLBackend_BCGS_AMG_SSOR<IGO>;
/// Non-linear solver type
using PDESOLVER = Dune::PDELab::Newton<IGO,LS,U>;
/// Non-linear solver types
using PDESOLVERSeq = Dune::PDELab::Newton<IGO,LSSeq,U>;
using PDESOLVERPar = Dune::PDELab::Newton<IGO,LSPar,U>;
/// Time stepping scheme
using TimeStepScheme = Dune::PDELab::Alexander2Parameter<RF>;
/// Method computing the time step
using OSM = Dune::PDELab::OneStepMethod<RF,IGO,PDESOLVER,U,U>;
/// Methods computing the time step
using OSMSeq = Dune::PDELab::OneStepMethod<RF,IGO,PDESOLVERSeq,U,U>;
using OSMPar = Dune::PDELab::OneStepMethod<RF,IGO,PDESOLVERPar,U,U>;
// -- Utility Class Definitions -- //
/// VTK Output writer base class
......@@ -109,9 +111,12 @@ protected:
std::unique_ptr<GO0> go0;
std::unique_ptr<GO1> go1;
std::unique_ptr<IGO> igo;
std::unique_ptr<LS> ls;
std::unique_ptr<PDESOLVER> pdesolver;
std::unique_ptr<OSM> osm;
std::unique_ptr<LSSeq> ls_seq;
std::unique_ptr<LSPar> ls_par;
std::unique_ptr<PDESOLVERSeq> pdesolver_seq;
std::unique_ptr<PDESOLVERPar> pdesolver_par;
std::unique_ptr<OSMSeq> osm_seq;
std::unique_ptr<OSMPar> osm_par;
TimeStepScheme alex2;
std::unique_ptr<U> uold;
......
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