8#include <dune/vtk/pvdwriter.hh>
9#include <dune/vtk/vtkwriter.hh>
11#include <amdis/Initfile.hpp>
12#include <amdis/common/Filesystem.hpp>
13#include <amdis/io/FileWriterBase.hpp>
22 template <
class GV,
class GF>
24 :
public FileWriterBase
27 using Writer = Dune::Vtk::VtkWriter<GridView>;
28 using SeqWriter = Dune::Vtk::PvdWriter<Writer>;
33 DuneVtkWriter(std::string
const& name, GridView
const& gridView, GridFunction
const& gridFunction)
34 : FileWriterBase(name)
35 , gridFunction_(gridFunction)
38 Parameters::get(name +
"->animation", animation_);
39 Parameters::get(name +
"->mode", m);
40 Parameters::get(name +
"->precision", p);
42 Dune::Vtk::FormatTypes mode =
43 m == 0 ? Dune::Vtk::FormatTypes::ASCII :
44 m == 1 ? Dune::Vtk::FormatTypes::BINARY :
45 Dune::Vtk::FormatTypes::COMPRESSED;
47 Dune::Vtk::DataTypes precision =
48 p == 0 ? Dune::Vtk::DataTypes::FLOAT32 :
49 Dune::Vtk::DataTypes::FLOAT64;
52 vtkSeqWriter_ = std::make_shared<SeqWriter>(gridView, mode, precision);
53 vtkSeqWriter_->addPointData(gridFunction_, this->name());
55 vtkWriter_ = std::make_shared<Writer>(gridView, mode, precision);
56 vtkWriter_->addPointData(gridFunction_, this->name());
61 void write(AdaptInfo& adaptInfo,
bool force)
override
63 std::string data_dir = this->dir() +
"/_piecefiles";
64 filesystem::create_directories(data_dir);
66 std::string filename = filesystem::path({this->dir(), this->filename() +
".vtk"}).
string();
67 if (this->doWrite(adaptInfo) || force) {
69 vtkSeqWriter_->writeTimestep(adaptInfo.time(), filename, data_dir,
true);
71 vtkWriter_->write(filename, data_dir);
78 std::shared_ptr<Writer> vtkWriter_;
79 std::shared_ptr<SeqWriter> vtkSeqWriter_;
82 bool animation_ =
false;
constexpr bool GridFunction
GridFunction GF is a Type that has LocalFunction, provides some typedefs for Domain,...
Definition GridFunction.hpp:89