15#include <dune/functions/gridfunctions/discreteglobalbasisfunction.hh>
16#include <dune/grid/io/file/vtk/subsamplingvtkwriter.hh>
18#pragma GCC diagnostic push
19#pragma GCC diagnostic ignored "-Wswitch-enum"
34 static constexpr int components = Basis::LocalView::Tree::degree() == 0 ? 1 : Basis::LocalView::Tree::degree();
48 vtkWriter_(
basis.gridView(),
Dune::refinementLevels(refinementLevels)),
60 auto setFieldInfo(std::string&& name, Dune::VTK::FieldInfo::Type type, std::size_t size,
61 Dune::VTK::Precision prec = Dune::VTK::Precision::float32) {
62 fieldInfo_ = Dune::VTK::FieldInfo(std::move(name), type, size, prec);
63 isFieldInfoSet_ =
true;
82 assert(isFieldInfoSet_ &&
"You need to call setFieldInfo first!");
85 auto disp = Dune::Functions::makeDiscreteGlobalBasisFunction<Dune::FieldVector<double, components>>(*basis_,
87 vtkWriter_.addVertexData(disp, fieldInfo_);
88 vtkWriter_.write(prefixString_ + std::to_string(step_++));
97 Dune::SubsamplingVTKWriter<typename Basis::GridView> vtkWriter_;
98 const Eigen::VectorXd* solution_;
100 Dune::VTK::FieldInfo fieldInfo_{
"Default", Dune::VTK::FieldInfo::Type::scalar, 1};
101 std::string prefixString_{};
102 bool isFieldInfoSet_{
false};
105#pragma GCC diagnostic pop
Enums for observer messages.
Implementation of the observer design pattern.
ControlMessages
Enum class defining control-routine-related messages.
Definition: observermessages.hh:17
Definition: assemblermanipulatorbuildingblocks.hh:22
Definition: utils/dirichletvalues.hh:30
def basis(gv, tree)
Definition: basis.py:10
ControlSubsamplingVertexVTKWriter class for writing VTK files with subsampling based on control messa...
Definition: controlvtkwriter.hh:32
ControlSubsamplingVertexVTKWriter(const Basis &basis, const Eigen::VectorXd &sol, int refinementLevels=0)
Constructor for ControlSubsamplingVertexVTKWriter.
Definition: controlvtkwriter.hh:46
void updateImpl(ControlMessages message) final
Implementation of the update method.
Definition: controlvtkwriter.hh:81
auto setFileNamePrefix(std::string &&name)
Set the file name prefix for VTK files.
Definition: controlvtkwriter.hh:71
auto setFieldInfo(std::string &&name, Dune::VTK::FieldInfo::Type type, std::size_t size, Dune::VTK::Precision prec=Dune::VTK::Precision::float32)
Set field information for the VTK file.
Definition: controlvtkwriter.hh:60
Generic observer interface for the Observer design pattern. See for a description of the design patt...
Definition: observer.hh:26