Commit ce4823ba authored by Lukas Riedel's avatar Lukas Riedel

Let RichardsSimulation hold grid view directly

Grid view does not require memory management
parent ecf38fea
......@@ -11,20 +11,19 @@ RichardsSimulation<Traits>::RichardsSimulation (
):
helper(_helper),
inifile(_inifile),
verbose(inifile.get<int>("output.verbose")),
output_type(_inifile.get<bool>("output.asciiVtk") ?
Dune::VTK::OutputType::ascii : Dune::VTK::OutputType::base64),
grid(_grid_mapper->get_grid()),
gv(grid->leafGridView()),
mbe_slop(estimate_mbe_entries<typename MBE::size_type>(
Traits::dim,Traits::GridGeometryType)),
mbe_tlop(1),
verbose(inifile.get<int>("output.verbose")),
output_type(_inifile.get<bool>("output.asciiVtk") ? Dune::VTK::OutputType::ascii : Dune::VTK::OutputType::base64)
mbe_tlop(1)
{
Dune::Timer timer;
// create the grid
grid = _grid_mapper->get_grid();
gv = std::make_shared<GV>(grid->leafGridView());
// --- Grid Function Space ---
gfs = std::make_unique<GFS>(GFSHelper::create(*gv));
gfs = std::make_unique<GFS>(GFSHelper::create(gv));
gfs->name("matric_head");
cc = std::make_unique<CC>();
Dune::PDELab::constraints(*gfs,*cc,false);
......@@ -36,7 +35,7 @@ RichardsSimulation<Traits>::RichardsSimulation (
// --- Operator Helper Classes ---
fboundary = std::make_unique<FlowBoundary>(inifile);
fsource = std::make_unique<FlowSource>(inifile);
finitial = std::make_unique<FlowInitial>(inifile, *gv);
finitial = std::make_unique<FlowInitial>(inifile, gv);
// --- Local Operators ---
#ifdef EXPERIMENTAL_DG_FEATURES
......@@ -47,13 +46,13 @@ RichardsSimulation<Traits>::RichardsSimulation (
const auto upwinding = std::get<OP::RichardsDGUpwinding::Type>(settings);
const auto weights = std::get<OP::RichardsDGWeights::Type>(settings);
slop = std::make_unique<SLOP>(inifile, *fparam, *gv, *fboundary, *fsource,
slop = std::make_unique<SLOP>(inifile, *fparam, gv, *fboundary, *fsource,
method, upwinding, weights);
#else
slop = std::make_unique<SLOP>(inifile, *fparam, *gv, *fboundary, *fsource);
slop = std::make_unique<SLOP>(inifile, *fparam, gv, *fboundary, *fsource);
#endif // EXPERIMENTAL_DG_FEATURES
tlop = std::make_unique<TLOP>(inifile, *fparam, *gv);
tlop = std::make_unique<TLOP>(inifile, *fparam, gv);
controller = std::make_unique<CalculationController>(inifile,*fboundary,helper);
// --- Solution Vectors and Initial Condition ---
......@@ -70,7 +69,7 @@ RichardsSimulation<Traits>::RichardsSimulation (
_inifile.get<int>("output.subsamplingLevel", 0);
const auto subsamling_intervals = Dune::refinementLevels(subsamling_lvl);
auto subsamling_vtk =
std::make_shared<Dune::SubsamplingVTKWriter<GV>>(*gv,
std::make_shared<Dune::SubsamplingVTKWriter<GV>>(gv,
subsamling_intervals);
vtkwriter = std::make_unique<Writer>(subsamling_vtk,
......@@ -99,7 +98,7 @@ void RichardsSimulation<Traits>::operator_setup()
igo = std::make_unique<IGO>(*go0,*go1);
// --- Solvers ---
lsgfs = std::make_unique<LSGFS>(LSGFSHelper::create(*gv));
lsgfs = std::make_unique<LSGFS>(LSGFSHelper::create(gv));
lscc = std::make_unique<LSCC>();
ls = std::make_unique<LS>(*igo,*cc,*lsgfs,*lscc,1000,0,true,true);
......@@ -129,7 +128,7 @@ void RichardsSimulation<Traits>::operator_setup()
auto DOFnumber = gfs->globalSize();
if(verbose>1)
std::cout << " Process " << helper.rank() << ": number of DOF: " << DOFnumber << std::endl;
DOFnumber = gv->comm().sum(DOFnumber);
DOFnumber = gv.comm().sum(DOFnumber);
if (helper.rank()==0)
std::cout << " Total number of DOF: " << DOFnumber << std::endl;
}
......@@ -187,7 +186,7 @@ void RichardsSimulation<Traits>::step()
template<typename Traits>
void RichardsSimulation<Traits>::mark_grid()
{
adaptivity->mark_grid(*grid, *gv, *gfs, *fparam,
adaptivity->mark_grid(*grid, gv, *gfs, *fparam,
*fboundary, time_before+dt_before, *u);
}
......@@ -211,9 +210,9 @@ void RichardsSimulation<Traits>::update_adapters () const
{
udgf = std::make_shared<GFMatricHead>(gfs, u);
fluxdgf = std::make_shared<GFWaterFlux>(gfs, u, fparam);
condgf = std::make_shared<GFConductivity>(*gv, fparam);
waterdgf = std::make_shared<GFWaterContent>(udgf, *gv, fparam);
satdgf = std::make_shared<GFSaturation>(udgf, *gv, fparam);
condgf = std::make_shared<GFConductivity>(gv, fparam);
waterdgf = std::make_shared<GFWaterContent>(udgf, gv, fparam);
satdgf = std::make_shared<GFSaturation>(udgf, gv, fparam);
}
template<typename Traits>
......
......@@ -231,9 +231,12 @@ protected:
Dune::MPIHelper& helper;
Dune::ParameterTree& inifile;
const int verbose;
const Dune::VTK::OutputType output_type;
std::shared_ptr<GFS> gfs;
std::shared_ptr<Grid> grid;
std::shared_ptr<GV> gv;
GV gv;
std::unique_ptr<CC> cc;
std::unique_ptr<LSGFS> lsgfs;
......@@ -269,9 +272,6 @@ protected:
std::unique_ptr<Writer> vtkwriter;
std::unique_ptr<AdaptivityHandler> adaptivity;
const int verbose;
const Dune::VTK::OutputType output_type;
RF time_before;
RF dt_before;
public:
......
......@@ -236,7 +236,7 @@ public:
using FluxGO = ERRGO<FluxLOP>;
// create GFS and operators
auto errgfs = ERRGFSHelper::create(*this->gv);
auto errgfs = ERRGFSHelper::create(this->gv);
FluxLOP fluxlop(*this->fparam, *this->fboundary);
fluxlop.setTime(time);
MBE mbe(0);
......@@ -257,7 +257,7 @@ public:
using WCGO = ERRGO<WCLOP>;
// create GFS and operators
auto errgfs = ERRGFSHelper::create(*this->gv);
auto errgfs = ERRGFSHelper::create(this->gv);
WCLOP wclop(*this->fparam);
MBE mbe(0);
WCGO wcgo(*this->gfs, errgfs, wclop, mbe);
......
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