13#include <dune/functions/gridfunctions/discreteglobalbasisfunction.hh>
14#include <dune/grid/io/file/vtk/subsamplingvtkwriter.hh>
35 static constexpr int components = Basis::LocalView::Tree::degree() == 0 ? 1 : Basis::LocalView::Tree::degree();
48 vtkWriter_(
basis.gridView(),
Dune::refinementLevels(refinementLevels)) {}
50 template <
typename BC>
65 auto setFieldInfo(std::string&& name, Dune::VTK::FieldInfo::Type type, std::size_t size,
66 Dune::VTK::Precision prec = Dune::VTK::Precision::float32) {
67 fieldInfo_ = Dune::VTK::FieldInfo(std::move(name), type, size, prec);
68 isFieldInfoSet_ =
true;
88 assert(isFieldInfoSet_ &&
"You need to call setFieldInfo first!");
91 auto disp = Dune::Functions::makeDiscreteGlobalBasisFunction<Dune::FieldVector<double, components>>(
92 basis_, state.domain.globalSolution());
93 vtkWriter_.addVertexData(disp, fieldInfo_);
94 vtkWriter_.write(prefixString_ + std::to_string(step_++));
103 Dune::SubsamplingVTKWriter<typename Basis::GridView> vtkWriter_;
105 Dune::VTK::FieldInfo fieldInfo_{
"Default", Dune::VTK::FieldInfo::Type::scalar, 1};
106 std::string prefixString_{};
107 bool isFieldInfoSet_{
false};
111template <
typename Basis>
112ControlSubsamplingVertexVTKWriter(
const Basis&,
int) -> ControlSubsamplingVertexVTKWriter<Basis>;
Implementation of the observer design pattern with broadcasters.
Enums for observer messages.
Definition: assemblermanipulatorbuildingblocks.hh:22
ControlMessages
Enum class defining control-routine-related messages.
Definition: broadcastermessages.hh:18
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:33
void update(ControlMessages message, const Concepts::ControlRoutineState auto &state)
Implementation of the update method.
Definition: controlvtkwriter.hh:87
ControlSubsamplingVertexVTKWriter & subscribeTo(BC &bc)
Definition: controlvtkwriter.hh:51
auto setFileNamePrefix(std::string &&name)
Set the file name prefix for VTK files.
Definition: controlvtkwriter.hh:76
ControlSubsamplingVertexVTKWriter(const Basis &basis, int refinementLevels=0)
Constructor for ControlSubsamplingVertexVTKWriter.
Definition: controlvtkwriter.hh:46
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:65
Implements a listener.
Definition: listener.hh:28
auto subscribe(Broadcaster &broadcaster, std::function< void(typename Broadcaster::MessageType, const typename Broadcaster::State &)> callback)
Function to subscribe to a broadcaster with a given function (either a lambda, std::function or funct...
Definition: listener.hh:41
Concept to check if a type represents a control routine state.
Definition: utils/concepts.hh:649