gridfamily.hh 6.02 KB
Newer Older
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
1
2
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
Praetorius, Simon's avatar
Praetorius, Simon committed
3
4
#ifndef DUNE_CURVED_SURFACE_GRID_GRIDFAMILY_HH
#define DUNE_CURVED_SURFACE_GRID_GRIDFAMILY_HH
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
5

6
7
#include <type_traits>

Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
8
9
10
11
#include <dune/grid/common/grid.hh>
#include <dune/curvedsurfacegrid/capabilities.hh>
#include <dune/curvedsurfacegrid/entity.hh>
#include <dune/curvedsurfacegrid/entityseed.hh>
12
#include <dune/curvedsurfacegrid/geometry.hh>
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
13
14
15
16
17
18
#include <dune/curvedsurfacegrid/gridview.hh>
#include <dune/curvedsurfacegrid/intersection.hh>
#include <dune/curvedsurfacegrid/intersectioniterator.hh>
#include <dune/curvedsurfacegrid/iterator.hh>
#include <dune/curvedsurfacegrid/idset.hh>
#include <dune/curvedsurfacegrid/indexsets.hh>
19
#include <dune/curvedsurfacegrid/gridfunctions/gridfunction.hh>
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
20

21
22
23
24
#include <dune/functions/common/functionconcepts.hh>
#include <dune/functions/common/signature.hh>
#include <dune/functions/gridfunctions/localderivativetraits.hh>

Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
25
26
27
28
namespace Dune
{

  /** \brief namespace containing the implementations of CurvedSurfaceGrid
Praetorius, Simon's avatar
Praetorius, Simon committed
29
   *  \ingroup CurvedGeo
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
30
   */
Praetorius, Simon's avatar
Praetorius, Simon committed
31
  namespace CGeo
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
32
  {
33
34
35
    template< class GF >
    struct DimRange
    {
36
      using SigTraits = Functions::SignatureTraits<GF>;
37
38
39
40
41
42
43
      using Range = typename SigTraits::RawRange;
      static const int value = Range::size();
    };

    template< class GF, class LF >
    struct DifferentiableLocalFunction
    {
44
      using EntitySet = typename GF::EntitySet;
45
46
      using LocalContext = typename EntitySet::Element;

47
      using Range = typename Functions::SignatureTraits<GF>::Range;
48
49
50
51
52
      using LocalSignature = Range(typename EntitySet::LocalCoordinate);

      static const bool value = Functions::Concept::isDifferentiableLocalFunction<LF,LocalSignature,LocalContext,Functions::LocalDerivativeTraits<EntitySet>::template Traits>();
    };

Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
53
54
55
    // GridFamily
    // ----------

56
    template< class GF, int order >
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
57
58
59
60
    struct GridFamily
    {
      struct Traits
      {
61
        using Grid = CurvedSurfaceGrid<GF,order>;
62
        using HostGrid = GridOf_t<GF>;
63
64

        using GridFunction = GF;
65
        using LocalFunction = std::decay_t<decltype(localFunction(std::declval<GF const&>()))>;
66
67

        static const bool differentiableLocalFunction = DifferentiableLocalFunction<GF, LocalFunction>::value;
68
        static_assert((differentiableLocalFunction || order>0), "Either provide a differentiable GridFunction or set ORDER > 0");
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
69

Praetorius, Simon's avatar
Praetorius, Simon committed
70
        using ctype = typename HostGrid::ctype;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
71

72
        static const int dimension = HostGrid::dimension;
73
        static const int dimensionworld = DimRange<GridFunction>::value;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
74

75
76
77
78
        using LeafIntersection
          = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, typename HostGrid::LeafIntersection>>;
        using LevelIntersection
          = Dune::Intersection<const Grid, CGeo::Intersection<const Grid, typename HostGrid::LevelIntersection>>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
79

Praetorius, Simon's avatar
Praetorius, Simon committed
80
81
82
83
        using LeafIntersectionIterator
          = Dune::IntersectionIterator<const Grid, CGeo::IntersectionIterator<const Grid, typename HostGrid::LeafIntersectionIterator>, CGeo::Intersection<const Grid, typename HostGrid::LeafIntersection> >;
        using LevelIntersectionIterator
          = Dune::IntersectionIterator<const Grid, CGeo::IntersectionIterator<const Grid, typename HostGrid::LevelIntersectionIterator >, CGeo::Intersection<const Grid, typename HostGrid::LevelIntersection> >;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
84

85
86
        using HierarchicIterator
          = Dune::EntityIterator<0, const Grid, CGeo::HierarchicIterator<const Grid>>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
87
88
89
90

        template< int codim >
        struct Codim
        {
91
92
          using LocalGeometry = typename HostGrid::template Codim<codim>::LocalGeometry;

93
94
95
96
          using LocalTransformation = std::conditional_t<(codim == 0),
            CGeo::Impl::DefaultLocalGeometry,
            CGeo::Impl::LocalGeometryInterface<LocalGeometry>>;

Praetorius, Simon's avatar
Praetorius, Simon committed
97
          template < int mydim, int cdim, class GridImpl >
98
99
          using GeometryImplTemplate
            = CGeo::Geometry<ctype, mydim, cdim, LocalFunction, LocalTransformation, order>;
100

Praetorius, Simon's avatar
Praetorius, Simon committed
101
102
          // geometry types
          using GeometryImpl = GeometryImplTemplate<dimension-codim, dimensionworld, const Grid>;
103
          using Geometry = Dune::Geometry<dimension-codim, dimensionworld, const Grid, GeometryImplTemplate>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
104

Praetorius, Simon's avatar
Praetorius, Simon committed
105
106
107
          // entity types
          using EntityImpl = CGeo::Entity<codim, dimension, const Grid>;
          using Entity = Dune::Entity<codim, dimension, const Grid, CGeo::Entity>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
108

Praetorius, Simon's avatar
Praetorius, Simon committed
109
          using EntitySeed = Dune::EntitySeed<const Grid, CGeo::EntitySeed<codim, const Grid> >;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
110
111
112
113

          template< PartitionIteratorType pitype >
          struct Partition
          {
114
115
            using LeafIteratorImp
              = CGeo::Iterator<typename HostGrid::LeafGridView, codim, pitype, const Grid>;
Praetorius, Simon's avatar
Praetorius, Simon committed
116
            using LeafIterator = Dune::EntityIterator<codim, const Grid, LeafIteratorImp>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
117

118
119
            using LevelIteratorImp
              = CGeo::Iterator<typename HostGrid::LevelGridView, codim, pitype, const Grid>;
Praetorius, Simon's avatar
Praetorius, Simon committed
120
            using LevelIterator = Dune::EntityIterator<codim, const Grid, LevelIteratorImp>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
121
122
          };

Praetorius, Simon's avatar
Praetorius, Simon committed
123
124
          using LeafIterator = typename Partition< All_Partition >::LeafIterator;
          using LevelIterator = typename Partition< All_Partition >::LevelIterator;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
125
126
        };

Praetorius, Simon's avatar
Praetorius, Simon committed
127
128
129
        // index-sets
        using LeafIndexSet = CGeo::IndexSet<const Grid, typename HostGrid::Traits::LeafIndexSet>;
        using LevelIndexSet = CGeo::IndexSet<const Grid, typename HostGrid::Traits::LevelIndexSet>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
130

Praetorius, Simon's avatar
Praetorius, Simon committed
131
132
133
        // id-sets
        using GlobalIdSet = CGeo::IdSet<const Grid, typename HostGrid::Traits::GlobalIdSet>;
        using LocalIdSet = CGeo::IdSet<const Grid, typename HostGrid::Traits::LocalIdSet>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
134

Praetorius, Simon's avatar
Praetorius, Simon committed
135
        using CollectiveCommunication = typename HostGrid::Traits::CollectiveCommunication;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
136

Praetorius, Simon's avatar
Praetorius, Simon committed
137
        // grid views
138
        using LeafGridView
139
          = Dune::GridView<CGeo::GridViewTraits<typename HostGrid::LeafGridView, GF, order>>;
140
        using LevelGridView
141
          = Dune::GridView<CGeo::GridViewTraits<typename HostGrid::LevelGridView, GF, order>>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
142
143
144
      };
    };

Praetorius, Simon's avatar
Praetorius, Simon committed
145
  } // namespace CGeo
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
146
147
} // namespace Dune

Praetorius, Simon's avatar
Praetorius, Simon committed
148
#endif // DUNE_CURVED_SURFACE_GRID_GRIDFAMILY_HH