dune-fem  2.4.1-rc
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/deprecated.hh>
9 #include <dune/common/exceptions.hh>
10 #include <dune/common/nullptr.hh>
11 
12 // dune-geometry includes
13 #include <dune/geometry/type.hh>
14 
15 // dune-fem includes
28 
29 // local includes
30 #include "adaptmanager.hh"
31 #include "capabilities.hh"
32 #include "interpolation.hh"
33 #include "lagrangepoints.hh"
34 #include "shapefunctionset.hh"
35 #include "storage.hh"
36 
37 
38 namespace Dune
39 {
40 
41  namespace Fem
42  {
43 
44  // Forward declaration
45  // -------------------
46 
47  template< class FunctionSpace, class GridPart, int polOrder, template< class > class Storage = CachingStorage >
48  class LagrangeDiscreteFunctionSpace;
49 
50 
51 
52  // LagrangeDiscreteFunctionSpaceTraits
53  // -----------------------------------
54 
55  template< class FunctionSpace, class GridPart, unsigned int polOrder, template< class > class Storage >
57  {
59 
61  typedef GridPart GridPartType;
62 
63  static const int polynomialOrder = polOrder;
64 
67 
68  static const int codimension = 0;
69 
70  private:
71  typedef typename GridPartType::template Codim< codimension >::EntityType EntityType;
72  static const int dimLocal = GridPartType::dimension;
74  typedef typename ToNewDimDomainFunctionSpace< ScalarFunctionSpaceType, dimLocal >::Type ShapeFunctionSpaceType;
75 
76  public:
79 
81  {
82  static ScalarShapeFunctionSetType *createObject ( const GeometryType &type )
83  {
84  return new ScalarShapeFunctionSetType( type, LagrangeShapeFunctionSetType( type ) );
85  }
86 
87  static void deleteObject ( ScalarShapeFunctionSetType *object ) { delete object; }
88  };
90 
93 
95 
96  template< class DiscreteFunction, class Operation = Dune::Fem::DFCommunicationOperation::Add >
98  {
99  // type of data handle
101  // type of operation to perform on scatter
102  typedef Operation OperationType;
103  };
104  };
105 
106 
107 
124  // LagrangeDiscreteFunctionSpace
125  // -----------------------------
126 
132  template< class FunctionSpace, class GridPart, int polOrder, template< class > class Storage >
134  : public DiscreteFunctionSpaceDefault< LagrangeDiscreteFunctionSpaceTraits< FunctionSpace, GridPart, polOrder, Storage > >
135  {
136  static_assert( (polOrder > 0), "LagrangeDiscreteFunctionSpace only defined for polOrder > 0" );
137 
140 
141  public:
142  typedef typename BaseType::Traits Traits;
143  static const int polynomialOrder = polOrder;
144 
146 
148  typedef typename BaseType::GridType GridType;
152 
153  typedef typename BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType;
155 
157 
160 
161  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  public:
181  // Interface methods //
183 
184  using BaseType::order;
185 
186  explicit LagrangeDiscreteFunctionSpace ( GridPartType &gridPart,
187  const InterfaceType commInterface = defaultInterface,
188  const CommunicationDirection commDirection = defaultDirection )
189  : BaseType( gridPart, commInterface, commDirection ),
190  blockMapper_( nullptr ),
191  lagrangePointSetContainer_( gridPart )
192  {
193  const IndexSetType &indexSet = gridPart.indexSet();
194 
195  AllGeomTypes< IndexSetType, GridType > allGeometryTypes( indexSet );
196  const std::vector< GeometryType > &geometryTypes = allGeometryTypes.geomTypes( 0 );
197  for( unsigned int i = 0; i < geometryTypes.size(); ++i )
198  {
199  const GeometryType &type = geometryTypes[ i ];
200  scalarShapeFunctionSets_.template insert< SingletonProviderType >( type );
201  }
202 
203  MapperSingletonKeyType key( gridPart, lagrangePointSetContainer_.compiledLocalKeys( polynomialOrder ), polynomialOrder );
204  blockMapper_ = &BlockMapperProviderType::getObject( key );
205  assert( blockMapper_ );
206  }
207 
209  {
210  BlockMapperProviderType::removeObject( *blockMapper_ );
211  }
212 
215  {
216  return LagrangeSpace_id;
217  }
218 
220  const BasisFunctionSetType basisFunctionSet ( const EntityType &entity ) const
221  {
222  return BasisFunctionSetType( entity, shapeFunctionSet( entity ) );
223  }
224 
226  bool continuous () const
227  {
228  return true;
229  }
230 
232  bool continuous ( const IntersectionType &intersection ) const
233  {
234  return intersection.conforming();
235  }
236 
238  int order () const
239  {
240  return polOrder;
241  }
242 
244  BlockMapperType &blockMapper () const
245  {
246  assert( blockMapper_ );
247  return *blockMapper_;
248  }
249 
251  // Non-interface methods //
253 
258  InterpolationType interpolation ( const EntityType &entity ) const
259  {
260  return InterpolationType( lagrangePointSet( entity ), basisFunctionSet( entity ) );
261  }
262 
268  template< class LocalFunction, class LocalDofVector >
269  DUNE_DEPRECATED
270  void interpolate ( const LocalFunction &localFunction, LocalDofVector &localDofVector ) const
271  {
272  const EntityType &entity = localFunction.entity();
273  const auto interpolation = this->interpolation( entity );
274  interpolation( localFunction, localDofVector );
275  }
276 
284  ShapeFunctionSetType shapeFunctionSet ( const EntityType &entity ) const
285  {
286  return shapeFunctionSet( entity.type() );
287  }
288 
296  ShapeFunctionSetType shapeFunctionSet ( const GeometryType &type ) const
297  {
298  return ShapeFunctionSetType( &scalarShapeFunctionSets_[ type ] );
299  }
300 
310  template< class EntityType >
311  const LagrangePointSetType &lagrangePointSet ( const EntityType &entity ) const
312  {
313  return lagrangePointSet( entity.type() );
314  }
315 
325  const LagrangePointSetType &lagrangePointSet ( const GeometryType &type ) const
326  {
327  return lagrangePointSetContainer_.compiledLocalKey( type, polynomialOrder );
328  }
329 
330  private:
331  // forbid copying
332  LagrangeDiscreteFunctionSpace ( const ThisType & );
333  // forbid assignment
334  ThisType &operator= ( const ThisType & );
335 
336  BlockMapperType *blockMapper_;
337  ScalarShapeFunctionSetStorageType scalarShapeFunctionSets_;
338  LagrangePointSetContainerType lagrangePointSetContainer_;
339  };
340 
341  } // namespace Fem
342 
343 } // namespace Dune
344 
345 #endif // #ifndef DUNE_FEM_SPACE_LAGRANGE_SPACE_HH
Definition: selectcaching.hh:28
LagrangeLocalInterpolation< GridPartType, polynomialOrder, BasisFunctionSetType > InterpolationType
Definition: lagrange/space.hh:159
LagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, polOrder, Storage > DiscreteFunctionSpaceType
Definition: lagrange/space.hh:58
static const int polynomialOrder
Definition: lagrange/space.hh:63
bool continuous(const IntersectionType &intersection) const
returns true if the space contains only globally continuous functions
Definition: lagrange/space.hh:232
IndexSetDofMapper< GridPartType > BlockMapperType
Definition: lagrange/space.hh:66
BaseType::IndexSetType IndexSetType
Definition: lagrange/space.hh:149
Lagrange discrete function space.
Definition: cornerstorage.hh:23
LagrangeShapeFunctionSet< ShapeFunctionSpaceType, polynomialOrder > LagrangeShapeFunctionSetType
Definition: lagrange/space.hh:77
BaseType::EntityType EntityType
Definition: lagrange/space.hh:150
A vector valued function space.
Definition: functionspace.hh:16
Dune::Fem::DefaultCommunicationHandler< DiscreteFunction, Operation > Type
Definition: lagrange/space.hh:100
ShapeFunctionSetProxy< ScalarShapeFunctionSetType > ScalarShapeFunctionSetProxyType
Definition: lagrange/space.hh:91
Default communication handler for discrete functions.
Definition: defaultcommhandler.hh:23
InterpolationType interpolation(const EntityType &entity) const
return local interpolation for given entity
Definition: lagrange/space.hh:258
Singleton list for key/object pairs.
Definition: singletonlist.hh:49
Definition: shapefunctionset/vectorial.hh:428
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:88
static void deleteObject(ScalarShapeFunctionSetType *object)
Definition: lagrange/space.hh:87
static const int localBlockSize
Definition: lagrange/space.hh:65
BaseType::BasisFunctionSetType BasisFunctionSetType
Definition: lagrange/space.hh:154
Dune::Fem::DefaultBasisFunctionSet< EntityType, ShapeFunctionSetType > BasisFunctionSetType
Definition: lagrange/space.hh:94
LagrangeDiscreteFunctionSpace(GridPartType &gridPart, const InterfaceType commInterface=defaultInterface, const CommunicationDirection commDirection=defaultDirection)
Definition: lagrange/space.hh:186
dimension of range vector space
Definition: functionspaceinterface.hh:47
BaseType::BlockMapperType BlockMapperType
Definition: lagrange/space.hh:156
ShapeFunctionSetType shapeFunctionSet(const EntityType &entity) const
return shape function set for given entity
Definition: lagrange/space.hh:284
BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType
Definition: lagrange/space.hh:153
void interpolate(const LocalFunction &localFunction, LocalDofVector &localDofVector) const
interpolate a function locally
Definition: lagrange/space.hh:270
BaseType::IntersectionType IntersectionType
Definition: lagrange/space.hh:151
interface for local functions
Definition: localfunction.hh:41
const LagrangePointSetType & lagrangePointSet(const GeometryType &type) const
provide access to the Lagrange point set for a geometry type
Definition: lagrange/space.hh:325
LagrangePointSet< GridPartType, polynomialOrder > LagrangePointSetType
Definition: lagrange/space.hh:158
Definition: shapefunctionset/proxy.hh:35
int order() const
get global order of space
Definition: lagrange/space.hh:238
Definition: lagrange/interpolation.hh:20
Definition: coordinate.hh:4
BaseType::Traits Traits
Definition: lagrange/space.hh:142
~LagrangeDiscreteFunctionSpace()
Definition: lagrange/space.hh:208
GridPart GridPartType
Definition: lagrange/space.hh:61
BaseType::GridType GridType
Definition: lagrange/space.hh:148
const EntityType & entity() const
obtain the entity, this local function lives on
Definition: localfunction.hh:285
BaseType::GridPartType GridPartType
Definition: lagrange/space.hh:147
ShapeFunctionSetType shapeFunctionSet(const GeometryType &type) const
return shape unique function set for geometry type
Definition: lagrange/space.hh:296
Provides a proxy class for pointers to a shape function set.
default implementation uses method geomTypes of given index set. Used in DiscreteFunctionSpaces.
Definition: allgeomtypes.hh:89
Definition: storage.hh:18
Lagrange shape function set.
Definition: lagrange/shapefunctionset.hh:166
SelectCachingShapeFunctionSet< LagrangeShapeFunctionSetType, Storage > ScalarShapeFunctionSetType
Definition: lagrange/space.hh:78
FunctionSpace FunctionSpaceType
Definition: lagrange/space.hh:60
DFSpaceIdentifier type() const
return type identifier of discrete function space
Definition: lagrange/space.hh:214
This is the class with default implementations for discrete function. The methods not marked with hav...
Definition: discretefunctionspace.hh:595
ScalarShapeFunctionSetFactory ScalarShapeFunctionSetFactoryType
Definition: lagrange/space.hh:89
VectorialShapeFunctionSet< ScalarShapeFunctionSetProxyType, typename FunctionSpaceType::RangeType > ShapeFunctionSetType
Definition: lagrange/space.hh:92
Definition: indexsetdofmapper.hh:743
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: lagrange/space.hh:226
GridPartType::IntersectionType IntersectionType
type of the intersections
Definition: discretefunctionspace.hh:202
BlockMapperType & blockMapper() const
get a reference to the block mapper
Definition: lagrange/space.hh:244
BaseType::FunctionSpaceType FunctionSpaceType
Definition: lagrange/space.hh:145
const BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
get basis function set for given entity
Definition: lagrange/space.hh:220
static ScalarShapeFunctionSetType * createObject(const GeometryType &type)
Definition: lagrange/space.hh:82
const std::vector< GeometryType > & geomTypes(unsigned int codim) const
returns vector with geometry tpyes this index set has indices for
Definition: allgeomtypes.hh:145
Definition: lagrange/space.hh:56
id for Lagrange Space
Definition: discretefunctionspace.hh:95
const LagrangePointSetType & lagrangePointSet(const EntityType &entity) const
provide access to the Lagrange point set for an entity
Definition: lagrange/space.hh:311
Operation OperationType
Definition: lagrange/space.hh:102
static const int codimension
Definition: lagrange/space.hh:68
convert functions space to space with new dim domain
Definition: functionspace.hh:242
Definition: lagrangepoints.hh:461
implementation of a basis function set for given entity
Definition: default.hh:46