27 #ifndef VTK_VECTOR_FUNCTION_HH
28 #define VTK_VECTOR_FUNCTION_HH
32 #include <dune/grid/io/file/vtk/function.hh>
33 #include <dune/istl/bvector.hh>
34 #include <dune/common/fvector.hh>
35 #include <dune/common/version.hh>
37 #include <opm/common/Exceptions.hpp>
38 #include <opm/common/ErrorMacros.hpp>
50 template <
class Gr
idView,
class Mapper>
53 enum { dim = GridView::dimension };
54 typedef typename GridView::ctype ctype;
55 typedef typename GridView::template Codim<0>::Entity Element;
57 typedef BaseOutputWriter::VectorBuffer VectorBuffer;
61 const GridView& gridView,
63 const VectorBuffer& buf,
70 { assert(
int(buf_.size()) == mapper_.size()); }
72 virtual std::string name()
const
75 virtual int ncomps()
const
76 {
return static_cast<int>(buf_[0].size()); }
78 virtual double evaluate(
int mycomp,
80 const Dune::FieldVector<ctype, dim>& xi)
const
85 idx =
static_cast<unsigned>(mapper_.index(e));
87 else if (codim_ == dim) {
92 Dune::GeometryType gt = e.type();
93 int n =
static_cast<int>(e.subEntities(dim));
94 for (
int i = 0; i < n; ++i) {
95 Dune::FieldVector<ctype, dim> local =
96 Dune::ReferenceElements<ctype, dim>::general(gt).position(i, dim);
99 if (local.infinity_norm() < min) {
100 min = local.infinity_norm();
106 idx =
static_cast<unsigned>(mapper_.subIndex(e, imin, codim_));
109 OPM_THROW(std::logic_error,
"Only element and vertex based vector "
110 " fields are supported so far.");
112 return static_cast<double>(
static_cast<float>(buf_[idx][
static_cast<unsigned>(mycomp)]));
116 const std::string name_;
117 const GridView gridView_;
118 const Mapper& mapper_;
119 const VectorBuffer& buf_;
Provides a vector-valued function using Dune::FieldVectors as elements.
Definition: vtkvectorfunction.hh:51
The base class for all output writers.