Commit eef17e9b authored by Lukas Riedel's avatar Lukas Riedel 🎧
Browse files

write() function takes time as parameter. Base class needs to know the Traits

parent 7886996d
......@@ -23,24 +23,29 @@ public:
using SatDGF = Dune::Dorie::SaturationAdapter<Traits,Parameters,UDGF>;
};
/// Dummy Output Writer class. Does nothing.
template<typename Traits>
class OutputWriterBase
{
private:
using RF = typename Traits::RF;
public:
OutputWriterBase () = default;
virtual ~OutputWriterBase () = default;
/// Do nothing
virtual void write_vtk_output () {};
virtual void write_vtk_output (const RF time) {};
};
template<typename Traits>
class OutputWriter : public OutputWriterBase
class OutputWriter : public OutputWriterBase<Traits>
{
private:
using SimTraits = Dune::Dorie::SimulationTraits<Traits>;
using OutputTraits = Dune::Dorie::OutputTraits<Traits,SimTraits>;
using Grid = typename Traits::Grid;
using RF = typename Traits::RF;
using GV = typename Traits::GV;
using GFS = typename SimTraits::GFS::Type;
......@@ -67,7 +72,7 @@ public:
/// Set up the VTK output writer. Create adapters and stack them to the sequence writer
OutputWriter (Dune::ParameterTree& _inifile, GV& gv, GFS& gfs, Param& param, U& unew)
: OutputWriterBase(),
: OutputWriterBase<Traits>(),
vtkwriter(gv,
_inifile.get<std::string>("output.fileName"),
_inifile.get<std::string>("output.outputPath"),
......@@ -94,24 +99,26 @@ public:
}
/// Write the VTK files for the current solution unew
/** \throw Dune::IOError Cannot write output
/** \param time Current simulation time, will be saved into output
* \throw Dune::IOError Cannot write output
* (VTKWriter has bad exception handling)
*/
/*
void write_vtk_output ()
void write_vtk_output (const RF time) override
{
try{
vtkwriter.write(this->controller->getTime(),output_type);
vtkwriter.write(time,output_type);
}
catch(...){
DUNE_THROW(Dune::IOError,"Cannot write VTK output!");
}
}
*/
};
/// Factory class for creating an OutputWriter based on Traits
/** \tparam Traits Dune::Dorie::BaseTraits defining the Simulation
* The constexpr boolean enable_adaptivity in Dune::Dorie::BaseTraits will
* define which create() function is enabled at compile time.
*/
template<typename Traits>
struct OutputWriterFactory
......@@ -124,16 +131,16 @@ public:
/// Create a dummy OutputWriter
template<bool active = Traits::enable_adaptivity>
static std::unique_ptr<OutputWriterBase> create (Dune::ParameterTree& inifile, typename Traits::GV& gv, typename SimTraits::GFS::Type& gfs, typename SimTraits::Parameters& param, typename SimTraits::U& unew, typename std::enable_if_t<!active,int> = 0)
static std::unique_ptr<OutputWriterBase<Traits>> create (Dune::ParameterTree& inifile, typename Traits::GV& gv, typename SimTraits::GFS::Type& gfs, typename SimTraits::Parameters& param, typename SimTraits::U& unew, typename std::enable_if_t<!active,int> = 0)
{
return std::make_unique<OutputWriterBase>();
return std::make_unique<OutputWriterBase<Traits>>();
}
/// Create a true OutputWriter
template<bool active = Traits::enable_adaptivity>
static std::unique_ptr<OutputWriterBase> create (Dune::ParameterTree& inifile, typename Traits::GV& gv, typename SimTraits::GFS::Type& gfs, typename SimTraits::Parameters& param, typename SimTraits::U& unew, typename std::enable_if_t<active,int> = 0)
static std::unique_ptr<OutputWriterBase<Traits>> create (Dune::ParameterTree& inifile, typename Traits::GV& gv, typename SimTraits::GFS::Type& gfs, typename SimTraits::Parameters& param, typename SimTraits::U& unew, typename std::enable_if_t<active,int> = 0)
{
std::unique_ptr<OutputWriterBase> p;
std::unique_ptr<OutputWriterBase<Traits>> p;
p = std::make_unique<OutputWriter<Traits>>(inifile,gv,gfs,param,unew);
return 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