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

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

namespace Dune { namespace experimental
{
7
8
9
10
11
12
13
14
15
16
17
18
19

namespace Impl
{
  // Should be specialized for concrete structured grid
  template <class GridView, class Grid>
  struct StructuredDataCollector;
}

template <class GridView>
using StructuredDataCollector = typename Impl::StructuredDataCollector<GridView, typename GridView::Grid>::type;


/// The Interface for structured data-collectors
20
21
22
template <class GridView, class Derived>
class StructuredDataCollectorInterface
    : public DataCollectorInterface<GridView, Derived>
23
{
24
25
protected:
  using Super = DataCollectorInterface<GridView, Derived>;
26
27
28
29
  using Super::gridView_;
  using ctype = typename GridView::ctype;

public:
30
  StructuredDataCollectorInterface (GridView const& gridView)
31
    : Super(gridView)
32
    , defaultDataCollector_(gridView)
33
34
35
36
37
  {}

  /// Return number of grid vertices
  std::uint64_t numPointsImpl () const
  {
38
    return gridView_.size(GridView::dimension);
39
40
  }

41
  void updateImpl ()
42
  {
43
    defaultDataCollector_.update();
44
45
  }

46
  std::array<int, 6> const& wholeExtent () const
47
  {
48
    return this->asDerived().wholeExtentImpl();
49
50
  }

51
  FieldVector<ctype, 3> const& origin () const
52
  {
53
    return this->asDerived().originImpl();
54
55
  }

56
  FieldVector<ctype, 3> const& spacing () const
57
  {
58
59
    return this->asDerived().spacingImpl();
  }
60

61
62
63
64
65
66
67
68
69
70
  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);
71
72
73
74
75
76
  }

  /// Return the coordinates of all grid vertices in the order given by the indexSet
  template <class T>
  std::vector<T> pointsImpl () const
  {
77
    return defaultDataCollector_.template points<T>();
78
79
80
81
82
83
  }

  /// Evaluate the `fct` at the corners of the elements
  template <class T, class GlobalFunction>
  std::vector<T> pointDataImpl (GlobalFunction const& fct) const
  {
84
    return defaultDataCollector_.template pointData<T>(fct);
85
86
87
  }

private:
88
  DefaultDataCollector<GridView> defaultDataCollector_;
89
90
91
};

}} // end namespace Dune::experimental