structureddatacollector.hh 1.81 KB
Newer Older
1
2
#pragma once

3
#include <dune/vtk/datacollectors/continuousdatacollector.hh>
4
5
6

namespace Dune { namespace experimental
{
7
8
9
template <class GridView, class Derived>
class StructuredDataCollectorInterface
    : public DataCollectorInterface<GridView, Derived>
10
{
11
12
protected:
  using Super = DataCollectorInterface<GridView, Derived>;
13
14
15
16
  using Super::gridView_;
  using ctype = typename GridView::ctype;

public:
17
  StructuredDataCollectorInterface (GridView const& gridView)
18
    : Super(gridView)
19
    , defaultDataCollector_(gridView)
20
21
22
23
24
  {}

  /// Return number of grid vertices
  std::uint64_t numPointsImpl () const
  {
25
    return gridView_.size(GridView::dimension);
26
27
  }

28
  void updateImpl ()
29
  {
30
    defaultDataCollector_.update();
31
32
  }

33
  std::array<int, 6> const& wholeExtent () const
34
  {
35
    return this->asDerived().wholeExtentImpl();
36
37
  }

38
  FieldVector<ctype, 3> const& origin () const
39
  {
40
    return this->asDerived().originImpl();
41
42
  }

43
  FieldVector<ctype, 3> const& spacing () const
44
  {
45
46
    return this->asDerived().spacingImpl();
  }
47

48
49
50
51
52
53
54
55
56
57
  template <class Writer>
  void writeLocalPiece (Writer const& writer) const
  {
    this->asDerived().writeLocalPieceImpl(writer);
  }

  template <class Writer>
  void writePieces (Writer const& writer) const
  {
    this->asDerived().writePiecesImpl(writer);
58
59
60
61
62
63
  }

  /// Return the coordinates of all grid vertices in the order given by the indexSet
  template <class T>
  std::vector<T> pointsImpl () const
  {
64
    return defaultDataCollector_.template points<T>();
65
66
67
68
69
70
  }

  /// Evaluate the `fct` at the corners of the elements
  template <class T, class GlobalFunction>
  std::vector<T> pointDataImpl (GlobalFunction const& fct) const
  {
71
    return defaultDataCollector_.template pointData<T>(fct);
72
73
74
  }

private:
75
  DefaultDataCollector<GridView> defaultDataCollector_;
76
77
78
};

}} // end namespace Dune::experimental