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)
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;
static std::optional< T > get(std::string const &key)
Get parameter-values from parameter-tree.
Definition: Initfile.hpp:25
constexpr bool GridFunction
GridFunction GF is a Type that has LocalFunction and provides some typedefs for Domain,...
Definition: GridFunction.hpp:72