gridfamily.hh 6.09 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/localgeometrywrapper.hh>
20
#include <dune/curvedsurfacegrid/gridfunctions/gridfunction.hh>
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
21

22
23
24
25
#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
26
27
28
29
namespace Dune
{

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

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

48
      using Range = typename Functions::SignatureTraits<GF>::Range;
49
50
51
52
53
      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
54
55
56
    // GridFamily
    // ----------

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

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

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

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

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

76
77
78
79
        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
80

Praetorius, Simon's avatar
Praetorius, Simon committed
81
82
83
84
        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
85

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

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

94
          using LocalTransformation = std::conditional_t<(codim == 0),
95
96
            DefaultLocalGeometry<ctype, dimension, dimension>,
            CGeo::LocalGeometryWrapper<LocalGeometry>>;
97

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

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

Praetorius, Simon's avatar
Praetorius, Simon committed
106
107
108
          // 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
109

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

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

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

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

Praetorius, Simon's avatar
Praetorius, Simon committed
128
129
130
        // 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
131

Praetorius, Simon's avatar
Praetorius, Simon committed
132
133
134
        // 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
135

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

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

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

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