dune-fem  2.8-git
lagrange/space.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_LAGRANGE_SPACE_HH
2 #define DUNE_FEM_SPACE_LAGRANGE_SPACE_HH
3 
4 // C++ includes
5 #include <vector>
6 
7 // dune-common includes
8 #include <dune/common/exceptions.hh>
9 
10 // dune-geometry includes
11 #include <dune/geometry/type.hh>
12 
13 // dune-fem includes
15 
29 
30 // local includes
31 #include "adaptmanager.hh"
32 #include "capabilities.hh"
33 #include "interpolation.hh"
34 #include "lagrangepoints.hh"
35 #include "shapefunctionset.hh"
36 #include "storage.hh"
37 
38 
39 namespace Dune
40 {
41 
42  namespace Fem
43  {
44 
45  // Forward declaration
46  // -------------------
47 
48  template< class FunctionSpace, class GridPart, int maxPolOrder, class Storage = CachingStorage >
49  class LagrangeDiscreteFunctionSpace;
50 
51 
52 
53  // LagrangeDiscreteFunctionSpaceTraits
54  // -----------------------------------
55 
56  template< class FunctionSpace, class GridPart, int maxPolOrder, class Storage >
58  {
60 
61  // we take 6 as the maximal polynomial order for the dynamic space
62  static const int maxPolynomialOrder = ( maxPolOrder < 0 ) ? -maxPolOrder : maxPolOrder;
63  static const int minPolynomialOrder = ( maxPolOrder < 0 ) ? 1 : maxPolOrder;
64 
65  typedef GridPart GridPartType;
67 
69  std::conditional_t< Dune::Capabilities::isCartesian< typename GridPart::GridType >::v,
72 
74 
75  static const int codimension = 0;
76 
77  private:
78  typedef typename GridPartType::template Codim< codimension >::EntityType EntityType;
79  static const int dimLocal = GridPartType::dimension;
80  typedef typename FunctionSpaceType::ScalarFunctionSpaceType ScalarFunctionSpaceType;
81  typedef typename ToNewDimDomainFunctionSpace< ScalarFunctionSpaceType, dimLocal >::Type ShapeFunctionSpaceType;
82 
83  public:
86 
89 
91 
92  template< class DiscreteFunction, class Operation = Dune::Fem::DFCommunicationOperation::Add >
94  {
95  // type of data handle
97  // type of operation to perform on scatter
98  typedef Operation OperationType;
99  };
100  };
101 
102 
103 
120  // LagrangeDiscreteFunctionSpace
121  // -----------------------------
122 
128  template< class FunctionSpace, class GridPart, int maxPolOrder, class Storage >
130  : public DiscreteFunctionSpaceDefault< LagrangeDiscreteFunctionSpaceTraits< FunctionSpace, GridPart, maxPolOrder, Storage > >
131  {
132 
135 
136  public:
137  typedef typename BaseType::Traits Traits;
140 
141  static_assert( (maxPolynomialOrder > 0), "LagrangeDiscreteFunctionSpace only defined for polOrder > 0" );
142 
144 
146  typedef typename BaseType::GridType GridType;
150 
153 
155 
159 
161 
162  private:
165 
168 
174 
175  // static const InterfaceType defaultInterface = InteriorBorder_InteriorBorder_Interface;
176  static const InterfaceType defaultInterface = GridPart::indexSetInterfaceType;
177  static const CommunicationDirection defaultDirection = ForwardCommunication;
178 
179 
180  template < int pOrd >
181  struct Initialize
182  {
184  {
185  public:
186  static ScalarShapeFunctionSetType *createObject ( const GeometryType &type )
187  {
188  typedef typename Traits :: LagrangeShapeFunctionSetType LagrangeShapeFunctionSetType;
189  return new ScalarShapeFunctionSetType( type, LagrangeShapeFunctionSetType( type, pOrd ) );
190  }
191 
192  static void deleteObject ( ScalarShapeFunctionSetType *object ) { delete object; }
193  };
194 
195  static void apply ( ScalarShapeFunctionSetStorageType& scalarShapeFunctionSets,
196  const int polynomialOrder,
197  const GeometryType &type )
198  {
199  if( polynomialOrder == pOrd )
200  {
202  scalarShapeFunctionSets.template insert< SingletonProviderType >( type );
203  }
204  }
205  };
206 
207 
208  public:
210  // Interface methods //
212 
213  using BaseType::order;
214 
216  const InterfaceType commInterface,
217  const CommunicationDirection commDirection )
218  : LagrangeDiscreteFunctionSpace( gridPart, minPolynomialOrder, commInterface, commDirection )
219  {}
220 
222  const int polOrder = minPolynomialOrder,
223  const InterfaceType commInterface = defaultInterface,
224  const CommunicationDirection commDirection = defaultDirection )
225  : BaseType( gridPart, commInterface, commDirection ),
226  blockMapper_(),
228  // when min == max polynomial order the dynamic choice is off
230  {
231  const IndexSetType &indexSet = gridPart.indexSet();
232 
234  const std::vector< GeometryType > &geometryTypes = allGeometryTypes.geomTypes( 0 );
235 
236  // create shape function sets
237  for( unsigned int i = 0; i < geometryTypes.size(); ++i )
238  {
240  apply( scalarShapeFunctionSets_, polynomialOrder_, geometryTypes[ i ] );
241  }
242 
245  assert( blockMapper_ );
246  }
247 
250  {
251  return LagrangeSpace_id;
252  }
253 
255  const BasisFunctionSetType basisFunctionSet ( const EntityType &entity ) const
256  {
257  return BasisFunctionSetType( entity, shapeFunctionSet( entity ) );
258  }
259 
261  bool continuous () const
262  {
263  return true;
264  }
265 
267  bool continuous ( const IntersectionType &intersection ) const
268  {
269  return intersection.conforming();
270  }
271 
273  int order () const
274  {
275  return polynomialOrder_;
276  }
277 
280  {
281  assert( blockMapper_ );
282  return *blockMapper_;
283  }
284 
286  // Non-interface methods //
288 
292  {
293  return InterpolationType( *this );
294  }
295 
300  [[deprecated]]
302  {
304  }
305 
311  {
313  }
314 
323  {
324  return shapeFunctionSet( entity.type() );
325  }
326 
334  ShapeFunctionSetType shapeFunctionSet ( const GeometryType &type ) const
335  {
337  }
338 
340  ThisType &operator= ( const ThisType & ) = delete;
341 
342  protected:
343  std::unique_ptr< BlockMapperType, typename BlockMapperProviderType::Deleter> blockMapper_;
346  const int polynomialOrder_;
347  };
348 
349  } // namespace Fem
350 
351 } // namespace Dune
352 
353 #endif // #ifndef DUNE_FEM_SPACE_LAGRANGE_SPACE_HH
Provides a proxy class for pointers to a shape function set.
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:94
@ LagrangeSpace_id
id for Lagrange Space
Definition: discretefunctionspace.hh:101
Definition: bindguard.hh:11
typename Impl::GridFunctionSpace< GridPart, T >::Type GridFunctionSpace
Definition: functionspace.hh:317
static DUNE_PRIVATE void apply(Args &&... args)
Definition: forloop.hh:23
Definition: hybrid.hh:86
Lagrange discrete function space.
Definition: lagrange/space.hh:131
BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType
Definition: lagrange/space.hh:151
ScalarShapeFunctionSetStorageType scalarShapeFunctionSets_
Definition: lagrange/space.hh:344
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: lagrange/space.hh:261
BaseType::FunctionSpaceType FunctionSpaceType
Definition: lagrange/space.hh:141
const BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
get basis function set for given entity
Definition: lagrange/space.hh:255
ShapeFunctionSetType shapeFunctionSet(const EntityType &entity) const
return shape function set for given entity
Definition: lagrange/space.hh:322
LagrangePointSetContainerType lagrangePointSetContainer_
Definition: lagrange/space.hh:345
ShapeFunctionSetType shapeFunctionSet(const GeometryType &type) const
return shape unique function set for geometry type
Definition: lagrange/space.hh:334
int order() const
get global order of space
Definition: lagrange/space.hh:273
bool continuous(const IntersectionType &intersection) const
returns true if the space contains only globally continuous functions
Definition: lagrange/space.hh:267
ThisType & operator=(const ThisType &)=delete
BaseType::IntersectionType IntersectionType
Definition: lagrange/space.hh:149
BaseType::BlockMapperType BlockMapperType
Definition: lagrange/space.hh:154
BaseType::BasisFunctionSetType BasisFunctionSetType
Definition: lagrange/space.hh:152
BaseType::Traits Traits
Definition: lagrange/space.hh:137
LocalInterpolationWrapper< ThisType > InterpolationType
Definition: lagrange/space.hh:160
DFSpaceIdentifier type() const
return type identifier of discrete function space
Definition: lagrange/space.hh:249
static const int maxPolynomialOrder
Definition: lagrange/space.hh:138
InterpolationType interpolation() const
return interpolation object
Definition: lagrange/space.hh:291
LocalInterpolationType localInterpolation(const EntityType &entity) const
return local interpolation for given entity
Definition: lagrange/space.hh:310
const int polynomialOrder_
Definition: lagrange/space.hh:346
LocalInterpolationType interpolation(const EntityType &entity) const
return local interpolation for given entity
Definition: lagrange/space.hh:301
BaseType::GridType GridType
Definition: lagrange/space.hh:146
BaseType::IndexSetType IndexSetType
Definition: lagrange/space.hh:147
BaseType::GridPartType GridPartType
Definition: lagrange/space.hh:145
std::unique_ptr< BlockMapperType, typename BlockMapperProviderType::Deleter > blockMapper_
Definition: lagrange/space.hh:343
LagrangeDiscreteFunctionSpace(GridPartType &gridPart, const int polOrder=minPolynomialOrder, const InterfaceType commInterface=defaultInterface, const CommunicationDirection commDirection=defaultDirection)
Definition: lagrange/space.hh:221
LagrangePointSet< GridPartType, maxPolynomialOrder > LagrangePointSetType
Definition: lagrange/space.hh:156
LagrangeDiscreteFunctionSpace(const ThisType &)=delete
BlockMapperType & blockMapper() const
get a reference to the block mapper
Definition: lagrange/space.hh:279
LocalInterpolationType InterpolationImplType
Definition: lagrange/space.hh:158
BaseType::EntityType EntityType
Definition: lagrange/space.hh:148
LagrangeDiscreteFunctionSpace(GridPartType &gridPart, const InterfaceType commInterface, const CommunicationDirection commDirection)
Definition: lagrange/space.hh:215
LagrangeLocalInterpolation< GridPartType, maxPolynomialOrder, BasisFunctionSetType > LocalInterpolationType
Definition: lagrange/space.hh:157
static const int minPolynomialOrder
Definition: lagrange/space.hh:139
Definition: space/basisfunctionset/default.hh:52
default implementation uses method geomTypes of given index set. Used in DiscreteFunctionSpaces.
Definition: allgeomtypes.hh:99
const std ::vector< GeometryType > & geomTypes(unsigned int codim) const
returns vector with geometry tpyes this index set has indices for
Definition: allgeomtypes.hh:171
const CompiledLocalKeyType & compiledLocalKey(const GeometryType &type, const int order) const
provide access to the compiled local keys for a geometry type and polynomial order
Definition: basesetlocalkeystorage.hh:299
const LocalKeyStorageType & compiledLocalKeys(const int order) const
provide access to all compiled local keys for a given polynomial order
Definition: basesetlocalkeystorage.hh:285
Default communication handler for discrete functions.
Definition: defaultcommhandler.hh:29
Traits ::FunctionSpaceType FunctionSpaceType
type of function space
Definition: discretefunctionspace.hh:193
GridPartType ::IntersectionType IntersectionType
type of the intersections
Definition: discretefunctionspace.hh:225
Traits ::BasisFunctionSetType BasisFunctionSetType
type of basis function set of this space
Definition: discretefunctionspace.hh:200
This is the class with default implementations for discrete function. The methods not marked with hav...
Definition: discretefunctionspace.hh:628
const IndexSetType & indexSet() const
Get a reference to the associated index set.
Definition: discretefunctionspace.hh:751
convert functions space to space with new dim domain
Definition: functionspace.hh:246
Definition: common/localinterpolation.hh:74
Definition: dofmappercode.hh:58
Definition: lagrange/interpolation.hh:21
Definition: lagrangepoints.hh:685
Lagrange shape function set.
Definition: lagrange/shapefunctionset.hh:169
Definition: lagrange/space.hh:58
IndexSetDofMapper< GridPartType, std::conditional_t< Dune::Capabilities::isCartesian< typename GridPart::GridType >::v, DefaultLocalDofMapping< GridPart >, LagrangeLocalDofMapping< GridPart > > > BlockMapperType
Definition: lagrange/space.hh:71
static const int codimension
Definition: lagrange/space.hh:75
Dune::Fem::DefaultBasisFunctionSet< EntityType, ShapeFunctionSetType > BasisFunctionSetType
Definition: lagrange/space.hh:90
ShapeFunctionSetProxy< ScalarShapeFunctionSetType > ScalarShapeFunctionSetProxyType
Definition: lagrange/space.hh:87
GridFunctionSpace< GridPartType, FunctionSpace > FunctionSpaceType
Definition: lagrange/space.hh:66
Hybrid::IndexRange< int, FunctionSpaceType::dimRange > LocalBlockIndices
Definition: lagrange/space.hh:73
LagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, maxPolOrder, Storage > DiscreteFunctionSpaceType
Definition: lagrange/space.hh:59
LagrangeShapeFunctionSet< ShapeFunctionSpaceType, maxPolynomialOrder > LagrangeShapeFunctionSetType
Definition: lagrange/space.hh:84
VectorialShapeFunctionSet< ScalarShapeFunctionSetProxyType, typename FunctionSpaceType::RangeType > ShapeFunctionSetType
Definition: lagrange/space.hh:88
SelectCachingShapeFunctionSet< LagrangeShapeFunctionSetType, Storage > ScalarShapeFunctionSetType
Definition: lagrange/space.hh:85
static const int minPolynomialOrder
Definition: lagrange/space.hh:63
static const int maxPolynomialOrder
Definition: lagrange/space.hh:62
GridPart GridPartType
Definition: lagrange/space.hh:65
Operation OperationType
Definition: lagrange/space.hh:98
Dune::Fem::DefaultCommunicationHandler< DiscreteFunction, Operation > Type
Definition: lagrange/space.hh:96
static void deleteObject(ScalarShapeFunctionSetType *object)
Definition: lagrange/space.hh:192
static ScalarShapeFunctionSetType * createObject(const GeometryType &type)
Definition: lagrange/space.hh:186
Definition: storage.hh:19
Definition: indexsetdofmapper.hh:32
Definition: indexsetdofmapper.hh:655
Definition: proxy.hh:35
Definition: selectcaching.hh:26
Definition: shapefunctionset/vectorial.hh:447
Singleton list for key/object pairs.
Definition: singletonlist.hh:53
static auto getObject(const KeyType &key, Args &&... args) -> std::enable_if_t< std::is_same< decltype(FactoryType::createObject(key, std::forward< Args >(args)...)), ObjectType * >::value, ObjectType & >
Definition: singletonlist.hh:94
Interface for shape function sets.