18#include "dune/functions/functionspacebases/powerbasis.hh"
19#include "dune/functions/functionspacebases/subspacebasis.hh"
20#include <dune/common/fvector.hh>
21#include <dune/functions/gridfunctions/discreteglobalbasisfunction.hh>
22#include <dune/grid/yaspgrid.hh>
23#include <dune/vtk/vtkwriter.hh>
24#include <dune/vtk/writers/unstructuredgridwriter.hh>
32 template <
typename Container>
33 constexpr auto sizeOfContainer = []() {
34 if constexpr (
requires { std::tuple_size<Container>::value; })
35 return std::tuple_size<Container>::value;
40 template <
class PreBasis>
41 struct ResultContainerPre
46 template <
class Basis>
47 struct ResultContainer
49 using type = ResultContainerPre<typename Basis::PreBasis>::type;
52 template <
class RB,
class PP>
53 struct ResultContainer<
Dune::Functions::SubspaceBasis<RB, PP>>
58 template <
class Basis>
59 using ResultContainer_t =
typename ResultContainer<Basis>::type;
62 template <
class IMS,
class SPB, std::
size_t size>
63 struct ResultContainerPre<
Dune::Functions::PowerPreBasis<IMS, SPB, size>>
65 using type = std::array<typename ResultContainerPre<SPB>::type, size>;
78template <
typename AS,
typename DC,
typename Base>
79requires(Concepts::FlatAssembler<AS> && Concepts::DataCollector<DC>)
87 using FEType =
typename std::remove_cvref_t<FEContainer>::value_type;
98 template <
class... Args>
99 Writer(std::shared_ptr<AS> assembler, Args... args)
100 : Base(assembler->gridView(),
std::forward<Args>(args)...),
101 assembler_(assembler) {}
110 template <
typename DC_,
class... Args>
112 Writer(std::shared_ptr<AS> assembler, DC_&& dc, Args... args)
113 : Base(
std::forward<
std::decay_t<DC_>>(dc),
std::forward<Args>(args)...),
114 assembler_(assembler) {}
123 template <
typename RF>
126 Base::addCellData(std::forward<RF>(resultFunction));
128 Base::addPointData(std::forward<RF>(resultFunction));
137 template <
template <
typename,
int,
int>
class RT>
140 auto resFunction = makeResultVtkFunction<RT>(assembler_);
141 addResultFunction(std::move(resFunction), dataTag);
150 using ResultTuple =
typename FEType::SupportedResultTypes;
152 Dune::Hybrid::forEach(ResultTuple(), [&]<
typename RT>(RT i) { addResult<RT::template Rebind>(dataTag); });
168 template <
typename Basis,
typename R>
170 using Container = Impl::ResultContainer_t<Basis>;
172 auto gridFunction = Dune::Functions::makeDiscreteGlobalBasisFunction<Container>(
basis, std::forward<R>(vals));
173 auto fieldInfo = Dune::Vtk::FieldInfo(name, Impl::sizeOfContainer<Container>);
176 Base::addCellData(std::move(gridFunction), fieldInfo);
178 Base::addPointData(std::move(gridFunction), fieldInfo);
182 std::shared_ptr<Assembler> assembler_;
198template <
int dim,
typename Coordinates>
208template <
typename GV>
214 std::conditional_t<isStructured, Dune::Vtk::YaspDataCollector<GV>, Dune::Vtk::ContinuousDataCollector<GV>>;
216 template <
typename DC = DefaultDataCollector>
217 using DefaultVTKWriter = std::conditional_t<isStructured, Dune::Vtk::RectilinearGridWriter<typename DC::GridView, DC>,
218 Dune::Vtk::UnstructuredGridWriter<typename DC::GridView, DC>>;
223template <
typename AS,
class... Args>
229template <
typename AS,
typename DC,
class... Args, Dune::Vtk::IsDataCollector<std::decay_t<DC>> =
true>
231Writer(std::shared_ptr<AS>, DC&&, Args...)
Ikarus Result Function for Stress and other finite element results.
Definition: vtkdatatag.hh:8
Writer(std::shared_ptr< AS >, Args...) -> Writer< AS, typename DefaultVTKWriterManager< typename AS::GridView >::DefaultDataCollector, typename DefaultVTKWriterManager< typename AS::GridView >::template DefaultVTKWriter<> >
DataTag
Tag enum indicating cell data or point data.
Definition: vtkdatatag.hh:13
Definition: utils/dirichletvalues.hh:30
def basis(gv, tree)
Definition: basis.py:10
Manages writing results using VTK, based on assembler and data collector.
Definition: io/vtkwriter.hh:81
void addAllResults(DataTag dataTag=DataTag::asPointData)
Adds all results for the given data tag.
Definition: io/vtkwriter.hh:149
Writer(std::shared_ptr< AS > assembler, DC_ &&dc, Args... args)
Constructor with assembler, data collector, and additional arguments.
Definition: io/vtkwriter.hh:112
typename std::remove_cvref_t< FEContainer >::value_type FEType
Definition: io/vtkwriter.hh:87
void addInterpolation(R &&vals, const Basis &basis, const std::string &name, DataTag dataTag=DataTag::asPointData)
Adds interpolation data for the given basis and container.
Definition: io/vtkwriter.hh:169
AS Assembler
Definition: io/vtkwriter.hh:83
DC DataCollector
Definition: io/vtkwriter.hh:89
Base VTKWriter
Definition: io/vtkwriter.hh:90
Writer(std::shared_ptr< AS > assembler, Args... args)
Constructor with assembler and additional arguments.
Definition: io/vtkwriter.hh:99
void addResult(DataTag dataTag=DataTag::asPointData)
Adds a result for the given data tag.
Definition: io/vtkwriter.hh:139
void addResultFunction(RF &&resultFunction, DataTag dataTag)
Adds a result function for the given data tag.
Definition: io/vtkwriter.hh:124
typename Assembler::FEContainer FEContainer
Definition: io/vtkwriter.hh:86
typename Assembler::GridView GridView
Definition: io/vtkwriter.hh:84
typename Assembler::FERequirement FERequirement
Definition: io/vtkwriter.hh:85
Meta type to check whether a grid is structured, inherits from false_type.
Definition: io/vtkwriter.hh:192
Manages the default template parameter for the Vtk::Writer
Definition: io/vtkwriter.hh:211
static constexpr bool isStructured
Definition: io/vtkwriter.hh:212
std::conditional_t< isStructured, Dune::Vtk::RectilinearGridWriter< typename DC::GridView, DC >, Dune::Vtk::UnstructuredGridWriter< typename DC::GridView, DC > > DefaultVTKWriter
Definition: io/vtkwriter.hh:218
std::conditional_t< isStructured, Dune::Vtk::YaspDataCollector< GV >, Dune::Vtk::ContinuousDataCollector< GV > > DefaultDataCollector
Definition: io/vtkwriter.hh:214
A concept to check if a template type satisfies the ResultType requirements.
Definition: concepts.hh:488
Concept representing the requirements for a FlatAssembler.A type T satisfies FlatAssembler if it prov...
Definition: concepts.hh:500
Definition: concepts.hh:572
Definition: concepts.hh:581