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"
30 template <
typename Basis>
32 static constexpr int components = Basis::LocalView::Tree::degree() == 0 ? 1 : Basis::LocalView::Tree::degree();
45 : basis{&p_basis}, vtkWriter(p_basis.gridView(),
Dune::refinementLevels(refinementLevels)), solution{&sol} {}
56 auto setFieldInfo(std::string&& name, Dune::VTK::FieldInfo::Type type, std::size_t size,
57 Dune::VTK::Precision prec = Dune::VTK::Precision::float32) {
58 fieldInfo = Dune::VTK::FieldInfo(std::move(name), type, size, prec);
59 isFieldInfoSet =
true;
78 assert(isFieldInfoSet &&
"You need to call setFieldInfo first!");
81 auto disp = Dune::Functions::makeDiscreteGlobalBasisFunction<Dune::FieldVector<double, components>>(
83 vtkWriter.addVertexData(disp, fieldInfo);
84 vtkWriter.write(prefixString + std::to_string(step++));
93 Dune::SubsamplingVTKWriter<typename Basis::GridView> vtkWriter;
94 Eigen::VectorXd
const* solution;
96 Dune::VTK::FieldInfo fieldInfo{
"Default", Dune::VTK::FieldInfo::Type::scalar, 1};
97 std::string prefixString{};
98 bool isFieldInfoSet{
false};
101#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:16
Definition: simpleassemblers.hh:21
Definition: resultevaluators.hh:17
Wrapper class for a hierarchical basis constructed from a pre-basis.
Definition: utils/basis.hh:29
ControlSubsamplingVertexVTKWriter class for writing VTK files with subsampling based on control messa...
Definition: controlvtkwriter.hh:31
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:56
void updateImpl(ControlMessages message) final
Implementation of the update method.
Definition: controlvtkwriter.hh:77
auto setFileNamePrefix(std::string &&p_name)
Set the file name prefix for VTK files.
Definition: controlvtkwriter.hh:67
ControlSubsamplingVertexVTKWriter(const Basis &p_basis, const Eigen::VectorXd &sol, int refinementLevels=0)
Constructor for ControlSubsamplingVertexVTKWriter.
Definition: controlvtkwriter.hh:44
Generic observer interface for the Observer design pattern. See for a description of the design patt...
Definition: observer.hh:25