4#ifndef DUNE_GRID_IO_FILE_VTK_SKELETONFUNCTION_HH
5#define DUNE_GRID_IO_FILE_VTK_SKELETONFUNCTION_HH
13#include <dune/grid/io/file/vtk/functionwriter.hh>
14#include <dune/grid/io/file/vtk/pvtuwriter.hh>
15#include <dune/grid/io/file/vtk/vtuwriter.hh>
34 template<
typename GV,
typename RF>
35 struct SkeletonFunctionTraits {
37 typedef typename GV::Intersection Cell;
39 typedef typename GV::ctype DomainField;
40 static const unsigned dimDomain = GV::dimension-1;
41 typedef FieldVector<DomainField, dimDomain> Domain;
43 typedef RF RangeField;
44 typedef std::vector<RangeField> Range;
48 template <
typename GV,
typename RF>
51 typedef SkeletonFunctionTraits<GV, RF> Traits;
65 typename Traits::Range& result)
const;
78 template<
typename Func>
82 typedef typename Func::Traits::RangeField RF;
84 std::shared_ptr<const Func> func;
87 std::shared_ptr<DataArrayWriter<RF> > arraywriter;
91 const std::string&
name,
unsigned dimR_)
92 : func(func_), name_(
name), dimR(dimR_)
96 const std::string&
name)
97 : func(func_), name_(
name), dimR(func->dimRange())
101 virtual std::string
name()
const {
return name_; }
104 virtual unsigned ncomps()
const {
return dimR; }
115 return !arraywriter->writeIsNoop();
119 virtual void write(
const typename Func::Traits::Cell& cell,
120 const typename Func::Traits::Domain& xl) {
121 typename Func::Traits::Range result;
122 func->evaluate(cell, xl, result);
123 for(
unsigned d = 0; d < result.size() && d < dimR; ++d)
124 arraywriter->write(result[d]);
125 for(
unsigned d = result.size(); d < dimR; ++d)
126 arraywriter->write(0);
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Base class for function writers.
Definition: functionwriter.hh:32
Dump a .vtu/.vtp files contents to a stream.
Definition: pvtuwriter.hh:60
void addArray(const std::string &name, unsigned ncomps)
Add an array to the output file.
Definition: pvtuwriter.hh:205
A prototype for VTKFunctions on the skeleton.
Definition: skeletonfunction.hh:49
unsigned dimRange() const
get dimension of the Range
void evaluate(const typename Traits::Cell &c, const typename Traits::Domain &xl, typename Traits::Range &result) const
evaluate at local point xl in Cell c, store in result
function writer for skeleton functions
Definition: skeletonfunction.hh:81
virtual std::string name() const
return name
Definition: skeletonfunction.hh:101
virtual void addArray(PVTUWriter &writer)
add this field to the given parallel writer
Definition: skeletonfunction.hh:107
virtual void write(const typename Func::Traits::Cell &cell, const typename Func::Traits::Domain &xl)
write at the given position
Definition: skeletonfunction.hh:119
virtual bool beginWrite(VTUWriter &writer, std::size_t nitems)
start writing with the given writer
Definition: skeletonfunction.hh:112
virtual void endWrite()
signal end of writing
Definition: skeletonfunction.hh:130
virtual unsigned ncomps() const
return number of components of the vector
Definition: skeletonfunction.hh:104
Dump a .vtu/.vtp files contents to a stream.
Definition: vtuwriter.hh:96
DataArrayWriter< T > * makeArrayWriter(const std::string &name, unsigned ncomps, unsigned nitems)
acquire a DataArrayWriter
Definition: vtuwriter.hh:379
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:10