1 #ifndef DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_SPACE_HH
2 #define DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_SPACE_HH
3 
4 #include <utility>
5 
6 #include <dune/geometry/type.hh>
7 
8 #include <dune/grid/common/gridenums.hh>
9 
10 #include <dune/fem/common/hybrid.hh>
11 #include <dune/fem/gridpart/common/capabilities.hh>
12 #include <dune/fem/space/common/capabilities.hh>
13 #include <dune/fem/space/common/commoperations.hh>
14 #include <dune/fem/space/common/defaultcommhandler.hh>
15 #include <dune/fem/space/common/functionspace.hh>
16 #include <dune/fem/space/shapefunctionset/orthonormal.hh>
17 #include <dune/fem/space/shapefunctionset/selectcaching.hh>
18 
19 #include "basisfunctionsets.hh"
20 #include "declaration.hh"
21 #include "generic.hh"
22 #include "localinterpolation.hh"
23 #include "interpolation.hh"
24 #include "shapefunctionsets.hh"
25 
26 namespace Dune
27 {
28 
29   namespace Fem
30   {
31 
32     // DiscontinuousGalerkinSpaceTraits
33     // --------------------------------
34 
35     template< class FunctionSpace, class GridPart, int polOrder, class Storage >
36     struct DiscontinuousGalerkinSpaceTraits
37     {
38       typedef DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > DiscreteFunctionSpaceType;
39 
40       typedef GridPart GridPartType;
41       typedef GridFunctionSpace< GridPartType, FunctionSpace > FunctionSpaceType;
42 
43       static const int codimension = 0;
44 
45       typedef Dune::Fem::FunctionSpace<
46           typename FunctionSpace::DomainFieldType, typename FunctionSpace::RangeFieldType,
47            GridPartType::dimension, 1
48         > ScalarShapeFunctionSpaceType;
49 
50       struct ScalarShapeFunctionSet
51         : public Dune::Fem::OrthonormalShapeFunctionSet< ScalarShapeFunctionSpaceType >
52       {
53         typedef Dune::Fem::OrthonormalShapeFunctionSet< ScalarShapeFunctionSpaceType >   BaseType;
54 
55         static constexpr int numberShapeFunctions =
56               OrthonormalShapeFunctions< ScalarShapeFunctionSpaceType::dimDomain >::size(polOrder);
57       public:
ScalarShapeFunctionSetDune::Fem::DiscontinuousGalerkinSpaceTraits::ScalarShapeFunctionSet58         explicit ScalarShapeFunctionSet ( Dune::GeometryType type )
59           : BaseType( type, polOrder )
60         {
61           assert( size() == BaseType::size() );
62         }
63 
64         // overload size method because it's a static value
sizeDune::Fem::DiscontinuousGalerkinSpaceTraits::ScalarShapeFunctionSet65         static constexpr unsigned int size() { return numberShapeFunctions; }
66       };
67 
68 
69 
70       typedef SelectCachingShapeFunctionSets< GridPartType, ScalarShapeFunctionSet, Storage > ScalarShapeFunctionSetsType;
71       typedef VectorialShapeFunctionSets< ScalarShapeFunctionSetsType, typename FunctionSpaceType::RangeType > ShapeFunctionSetsType;
72 
73       typedef DefaultBasisFunctionSets< GridPartType, ShapeFunctionSetsType > BasisFunctionSetsType;
74       typedef typename BasisFunctionSetsType::BasisFunctionSetType BasisFunctionSetType;
75 
76       typedef CodimensionMapper< GridPartType, codimension > BlockMapperType;
77 
78       typedef Hybrid::IndexRange< int, FunctionSpaceType::dimRange * ScalarShapeFunctionSet::numberShapeFunctions > LocalBlockIndices;
79 
80       template <class DiscreteFunction, class Operation = DFCommunicationOperation::Copy >
81       struct CommDataHandle
82       {
83         typedef Operation OperationType;
84         typedef DefaultCommunicationHandler< DiscreteFunction, Operation > Type;
85       };
86     };
87 
88 
89 
90     // DiscontinuousGalerkinSpace
91     // --------------------------
92 
93     template< class FunctionSpace, class GridPart, int polOrder, class Storage = CachingStorage >
94     class DiscontinuousGalerkinSpace
95     : public GenericDiscontinuousGalerkinSpace< DiscontinuousGalerkinSpaceTraits< FunctionSpace, GridPart, polOrder, Storage > >
96     {
97       typedef GenericDiscontinuousGalerkinSpace< DiscontinuousGalerkinSpaceTraits< FunctionSpace, GridPart, polOrder, Storage > > BaseType;
98       typedef DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > ThisType;
99 
100     public:
101       using BaseType::basisFunctionSet;
102 
103       static const int polynomialOrder = polOrder;
104 
105       typedef typename BaseType::GridPartType GridPartType;
106       typedef typename BaseType::EntityType EntityType;
107 
108       typedef typename BaseType::BasisFunctionSetsType BasisFunctionSetsType;
109       typedef typename BaseType::BasisFunctionSetType BasisFunctionSetType;
110 
111       typedef DiscontinuousGalerkinLocalInterpolation< ThisType > InterpolationType;
112       typedef InterpolationType  InterpolationImplType;
113 
114 
DiscontinuousGalerkinSpace(GridPartType & gridPart,const InterfaceType commInterface=InteriorBorder_All_Interface,const CommunicationDirection commDirection=ForwardCommunication)115       explicit DiscontinuousGalerkinSpace ( GridPartType &gridPart,
116                                             const InterfaceType commInterface = InteriorBorder_All_Interface,
117                                             const CommunicationDirection commDirection = ForwardCommunication )
118         : BaseType( gridPart, makeBasisFunctionSets( gridPart ), commInterface, commDirection )
119       {}
120 
interpolation() const121       InterpolationType interpolation () const
122       {
123         return InterpolationType( *this );
124       }
125 
126       [[deprecated]]
interpolation(const EntityType & entity) const127       InterpolationType interpolation ( const EntityType &entity ) const
128       {
129         return interpolation ();
130       }
131 
localInterpolation(const EntityType & entity) const132       InterpolationType localInterpolation ( const EntityType &entity ) const
133       {
134         return interpolation ();
135       }
136 
137     private:
makeBasisFunctionSets(const GridPartType & gridPart)138       static BasisFunctionSetsType makeBasisFunctionSets ( const GridPartType &gridPart )
139       {
140         typedef typename BasisFunctionSetsType::ShapeFunctionSetsType ShapeFunctionSetsType;
141         ShapeFunctionSetsType shapeFunctionSets( gridPart );
142         return BasisFunctionSetsType( std::move( shapeFunctionSets ) );
143       }
144     };
145 
146 
147 
148     namespace Capabilities
149     {
150 
151       template< class FunctionSpace, class GridPart, int polOrder, class Storage >
152       struct hasFixedPolynomialOrder< DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
153       {
154         static const bool v = true;
155       };
156 
157       template< class FunctionSpace, class GridPart, int polOrder, class Storage >
158       struct hasStaticPolynomialOrder< DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
159       {
160         static const bool v = true;
161         static const int order = polOrder;
162       };
163 
164       template< class FunctionSpace, class GridPart, int polOrder, class Storage >
165       struct isContinuous< DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
166       {
167         static const bool v = false;
168       };
169 
170       template< class FunctionSpace, class GridPart, int polOrder, class Storage >
171       struct isLocalized< DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
172       {
173         static const bool v = true;
174       };
175 
176       template< class FunctionSpace, class GridPart, int polOrder, class Storage >
177       struct isAdaptive< DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
178       {
179         static const bool v = true;
180       };
181 
182       template< class FunctionSpace, class GridPart, int polOrder, class Storage >
183       struct threadSafe< DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
184       {
185         static const bool v = false;
186       };
187 
188       template< class FunctionSpace, class GridPart, int polOrder, class Storage >
189       struct viewThreadSafe< DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
190       {
191         static const bool v = true;
192       };
193 
194       template< class FunctionSpace, class GridPart, int polOrder, class Storage >
195       struct isHierarchic< DiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
196       {
197         static const bool v = true;
198       };
199 
200     } // namespace Capabilities
201 
202   } // namespace Fem
203 
204 } // namespace Dune
205 
206 #endif // #ifndef DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_SPACE_HH
207