47class VtkVectorFunction :
public Dune::VTKFunction<GridView>
49 enum { dim = GridView::dimension };
50 using ctype =
typename GridView::ctype;
51 using Element =
typename GridView::template Codim<0>::Entity;
53 using VectorBuffer = BaseOutputWriter::VectorBuffer;
56 VtkVectorFunction(std::string_view name,
57 const GridView& gridView,
59 const VectorBuffer& buf,
66 { assert(
int(buf_.size()) ==
int(mapper_.size())); }
68 std::string name()
const override
71 int ncomps()
const override
72 {
return static_cast<int>(buf_[0].size()); }
74 double evaluate(
int mycomp,
76 const Dune::FieldVector<ctype, dim>& xi)
const override
81 idx =
static_cast<unsigned>(mapper_.index(e));
83 else if (codim_ == dim) {
88 Dune::GeometryType gt = e.type();
89 int n =
static_cast<int>(e.subEntities(dim));
90 for (
int i = 0; i < n; ++i) {
91 Dune::FieldVector<ctype, dim> local =
92 Dune::ReferenceElements<ctype, dim>::general(gt).position(i, dim);
95 if (local.infinity_norm() < min) {
96 min = local.infinity_norm();
102 idx =
static_cast<unsigned>(mapper_.subIndex(e, imin, codim_));
105 throw std::logic_error(
"Only element and vertex based vector fields are "
106 "supported so far.");
109 return static_cast<double>(
static_cast<float>(buf_[idx][
static_cast<unsigned>(mycomp)]));
113 const std::string name_;
114 const GridView gridView_;
115 const Mapper& mapper_;
116 const VectorBuffer& buf_;
117 const unsigned codim_;