Commit ed1c784f authored by Santiago Ospina's avatar Santiago Ospina

run loop as in master and deleted the dorie discrete grid function

parent 5fddf899
......@@ -61,10 +61,10 @@ RichardsSimulation<Traits>::RichardsSimulation (Dune::MPIHelper& _helper, std::s
{
const int subsamling_lvl = _inifile.get<int>("output.subsamplingLevel", 0);
const auto subsamling_intervals = Dune::refinementLevels(subsamling_lvl);
auto sub_vtk = std::make_shared<Dune::SubsamplingVTKWriter<GV>>(gv,
auto subsamling_vtk = std::make_shared<Dune::SubsamplingVTKWriter<GV>>(gv,
subsamling_intervals);
vtkwriter = std::make_unique<Writer>(sub_vtk,
vtkwriter = std::make_unique<Writer>(subsamling_vtk,
inifile.get<std::string>("output.fileName"),
inifile.get<std::string>("output.outputPath"),
"./");
......@@ -163,26 +163,21 @@ bool RichardsSimulation<Traits>::compute_time_step ()
template<typename Traits>
void RichardsSimulation<Traits>::run ()
{
if constexpr (Traits::write_output)
write_data(controller->getTime());
{
write_data(controller->getTime());
while(controller->doStep()) {
const auto previous_time = controller->getTime();
const RF dt = controller->getDT();
if(!compute_time_step()) {
const auto time = controller->getTime();
const auto dt = controller->getDT();
if(!compute_time_step()){
continue;
}
const auto next_time = controller->getTime();
if constexpr (Traits::write_output)
write_data(next_time);
write_data(controller->getTime());
if(controller->doStep()
&& adaptivity->adapt_grid(*grid, gv, *gfs, *param, *fboundary, previous_time, *u))
&& adaptivity->adapt_grid(*grid, gv, *gfs, *param, *fboundary,
time+dt, // need "old" boundary condition
*u))
{
operator_setup(); // reset operators if grid changes
}
......@@ -202,27 +197,30 @@ void RichardsSimulation<Traits>::update_adapters ()
template<typename Traits>
void RichardsSimulation<Traits>::write_data (RF time)
{
update_adapters();
if (inifile.get<bool>("output.vertexData")) {
vtkwriter->addVertexData(udgf,"head");
vtkwriter->addVertexData(fluxdgf,"flux");
vtkwriter->addVertexData(condgf,"K_0");
vtkwriter->addVertexData(waterdgf,"theta_w");
vtkwriter->addVertexData(satdgf,"Theta");
} else {
vtkwriter->addCellData(udgf,"head");
vtkwriter->addCellData(fluxdgf,"flux");
vtkwriter->addCellData(condgf,"K_0");
vtkwriter->addCellData(waterdgf,"theta_w");
vtkwriter->addCellData(satdgf,"Theta");
}
try{
vtkwriter->write(time,output_type);
}
catch(...){
DUNE_THROW(Dune::IOError,"Cannot write VTK output!");
if constexpr (Traits::write_output)
{
update_adapters();
if (inifile.get<bool>("output.vertexData")) {
vtkwriter->addVertexData(udgf,"head");
vtkwriter->addVertexData(fluxdgf,"flux");
vtkwriter->addVertexData(condgf,"K_0");
vtkwriter->addVertexData(waterdgf,"theta_w");
vtkwriter->addVertexData(satdgf,"Theta");
} else {
vtkwriter->addCellData(udgf,"head");
vtkwriter->addCellData(fluxdgf,"flux");
vtkwriter->addCellData(condgf,"K_0");
vtkwriter->addCellData(waterdgf,"theta_w");
vtkwriter->addCellData(satdgf,"Theta");
}
try{
vtkwriter->write(time,output_type);
}
catch(...){
DUNE_THROW(Dune::IOError,"Cannot write VTK output!");
}
vtkwriter->clear();
}
vtkwriter->clear();
}
} // namespace Dorie
......
......@@ -28,7 +28,6 @@
#include "../solver/adapters/saturation.hh"
#include "../solver/adapters/water_flux.hh"
#include "../solver/adapters/conductivity.hh"
#include "../solver/adapters/discrete_grid_function.hh"
namespace Dune{
......@@ -113,7 +112,7 @@ struct RichardsSimulationTraits : public BaseTraits
// -- Grid Functions of state valriables -- //
/// Matric head
using GFMatricHead = Dune::Dorie::DiscreteGridFunction<GFS,U>;
using GFMatricHead = Dune::PDELab::DiscreteGridFunction<GFS,U>;
/// Water Flux
using GFWaterFlux = Dune::Dorie::WaterFluxAdapter<GFS,U,Parameters>;
/// Conductivity
......
#ifndef DUNE_DORIE_DISCRETE_GRID_FUNCTION_ADAPTER_HH
#define DUNE_DORIE_DISCRETE_GRID_FUNCTION_ADAPTER_HH
#include <vector>
#include <memory>
#include <dune/pdelab/common/function.hh>
#include <dune/pdelab/gridfunctionspace/localfunctionspace.hh>
#include <dune/pdelab/gridfunctionspace/lfsindexcache.hh>
namespace Dune{
namespace Dorie{
/*---------------------------------------------------------------------*//**
* @brief Convert a grid function space and a coefficient vector into a
* grid function
*
* @tparam GFS GridFunctionSpace type
* @tparam X CoefficientVector type
*/
template<typename GFS, typename X>
class DiscreteGridFunction : public Dune::PDELab::DiscreteGridFunction<GFS,X>
{
using Base = Dune::PDELab::DiscreteGridFunction<GFS,X>;
public:
struct Traits : public Base::Traits
{
using GridFunctionSpace = GFS;
using CoefficientVector = X;
};
/*-------------------------------------------------------------------*//**
* @brief Construct a DiscreteGridFunction
*
* @param gfs shared pointer to the GridFunctionsSpace
* @param x shared pointer to the coefficients vector
*/
DiscreteGridFunction(std::shared_ptr<GFS> gfs, std::shared_ptr<X> x)
: Base(gfs,x)
, pgfs(gfs)
, px(x)
{}
std::shared_ptr<GFS> gridFunctionSpace()
{
return pgfs;
}
std::shared_ptr<const GFS> gridFunctionSpace() const
{
return pgfs;
}
std::shared_ptr<X> coefficientVector()
{
return px;
}
std::shared_ptr<const X> coefficientVector() const
{
return px;
}
private:
std::shared_ptr<GFS> pgfs;
std::shared_ptr<X> px;
};
}
}
#endif
\ No newline at end of file
#ifndef DUNE_DORIE_RICHARDS_WATER_FLUX_ADAPTER_HH
#define DUNE_DORIE_RICHARDS_WATER_FLUX_ADAPTER_HH
#include "discrete_grid_function.hh"
#include "discrete_grid_function_gradient.hh"
namespace Dune{
......@@ -22,7 +21,7 @@ namespace Dune{
WaterFluxAdapter<GFS,X,P>
>
{
using DiscreteGridFunction = Dune::Dorie::DiscreteGridFunction<GFS,X>;
using DiscreteGridFunction = Dune::PDELab::DiscreteGridFunction<GFS,X>;
using DiscreteGridFunctionGradient = Dune::Dorie::DiscreteGridFunctionGradient<GFS,X>;
using Parameters = P;
......
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