DUNE-FEM (unstable)

space.hh
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
9 
10 // dune-geometry includes
11 #include <dune/geometry/type.hh>
12 
13 // dune-fem includes
14 #include <dune/fem/common/hybrid.hh>
15 
16 #include <dune/fem/space/basisfunctionset/default.hh>
17 #include <dune/fem/space/common/localinterpolation.hh>
18 #include <dune/fem/space/common/allgeomtypes.hh>
19 #include <dune/fem/space/common/basesetlocalkeystorage.hh>
20 #include <dune/fem/space/common/defaultcommhandler.hh>
21 #include <dune/fem/space/common/discretefunctionspace.hh>
22 #include <dune/fem/space/common/functionspace.hh>
23 #include <dune/fem/space/mapper/indexsetdofmapper.hh>
24 #include <dune/fem/space/mapper/nonblockmapper.hh>
26 #include <dune/fem/space/shapefunctionset/selectcaching.hh>
27 #include <dune/fem/space/shapefunctionset/vectorial.hh>
28 #include <dune/fem/storage/singletonlist.hh>
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 >
57  struct LagrangeDiscreteFunctionSpaceTraits
58  {
59  typedef LagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, maxPolOrder, Storage > DiscreteFunctionSpaceType;
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;
66  typedef GridFunctionSpace< GridPartType, FunctionSpace > FunctionSpaceType;
67 
68  typedef IndexSetDofMapper< GridPartType,
69  std::conditional_t< Dune::Capabilities::isCartesian< typename GridPart::GridType >::v,
70  DefaultLocalDofMapping< GridPart >,
71  LagrangeLocalDofMapping< GridPart > > > BlockMapperType;
72 
73  typedef Hybrid::IndexRange< int, FunctionSpaceType::dimRange > LocalBlockIndices;
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:
84  typedef LagrangeShapeFunctionSet< ShapeFunctionSpaceType, maxPolynomialOrder > LagrangeShapeFunctionSetType;
85  typedef SelectCachingShapeFunctionSet< LagrangeShapeFunctionSetType, Storage > ScalarShapeFunctionSetType;
86 
87  typedef ShapeFunctionSetProxy< ScalarShapeFunctionSetType > ScalarShapeFunctionSetProxyType;
88  typedef VectorialShapeFunctionSet< ScalarShapeFunctionSetProxyType, typename FunctionSpaceType::RangeType > ShapeFunctionSetType;
89 
91 
92  template< class DiscreteFunction, class Operation = Dune::Fem::DFCommunicationOperation::Add >
93  struct CommDataHandle
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;
138  static const int maxPolynomialOrder = Traits :: maxPolynomialOrder;
139  static const int minPolynomialOrder = Traits :: minPolynomialOrder;
140 
141  static_assert( (maxPolynomialOrder > 0), "LagrangeDiscreteFunctionSpace only defined for polOrder > 0" );
142 
143  typedef typename BaseType::FunctionSpaceType FunctionSpaceType;
144 
145  typedef typename BaseType::GridPartType GridPartType;
146  typedef typename BaseType::GridType GridType;
147  typedef typename BaseType::IndexSetType IndexSetType;
148  typedef typename BaseType::EntityType EntityType;
149  typedef typename BaseType::IntersectionType IntersectionType;
150 
151  typedef typename BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType;
152  typedef typename BaseType::BasisFunctionSetType BasisFunctionSetType;
153 
154  typedef typename BaseType::BlockMapperType BlockMapperType;
155 
156  typedef LagrangePointSet< GridPartType, maxPolynomialOrder > LagrangePointSetType;
157  typedef LagrangeLocalInterpolation< GridPartType, maxPolynomialOrder, BasisFunctionSetType > LocalInterpolationType;
158  typedef LocalInterpolationType InterpolationImplType;
159 
160  typedef LocalInterpolationWrapper< ThisType > InterpolationType;
161 
162  private:
163  typedef typename Traits::ScalarShapeFunctionSetType ScalarShapeFunctionSetType;
165 
168 
169  typedef LagrangeMapperSingletonKey< GridPartType, LocalKeyStorageType >
170  MapperSingletonKeyType;
171  typedef LagrangeMapperSingletonFactory< MapperSingletonKeyType, BlockMapperType >
172  BlockMapperSingletonFactoryType;
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  {
183  struct ScalarShapeFunctionSetFactory
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 
215  explicit LagrangeDiscreteFunctionSpace ( GridPartType &gridPart,
216  const InterfaceType commInterface,
217  const CommunicationDirection commDirection )
218  : LagrangeDiscreteFunctionSpace( gridPart, minPolynomialOrder, commInterface, commDirection )
219  {}
220 
221  explicit LagrangeDiscreteFunctionSpace ( GridPartType &gridPart,
222  const int polOrder = minPolynomialOrder,
223  const InterfaceType commInterface = defaultInterface,
224  const CommunicationDirection commDirection = defaultDirection )
225  : BaseType( gridPart, commInterface, commDirection ),
226  blockMapper_(),
227  lagrangePointSetContainer_( gridPart ),
228  // when min == max polynomial order the dynamic choice is off
229  polynomialOrder_( ( minPolynomialOrder == maxPolynomialOrder ) ? minPolynomialOrder : polOrder )
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  {
239  Fem::ForLoop< Initialize, minPolynomialOrder, maxPolynomialOrder >::
240  apply( scalarShapeFunctionSets_, polynomialOrder_, geometryTypes[ i ] );
241  }
242 
243  MapperSingletonKeyType key( gridPart, lagrangePointSetContainer_.compiledLocalKeys( polynomialOrder_ ), polynomialOrder_ );
244  blockMapper_.reset( &BlockMapperProviderType::getObject( key ) );
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 
279  BlockMapperType &blockMapper () const
280  {
281  assert( blockMapper_ );
282  return *blockMapper_;
283  }
284 
286  // Non-interface methods //
288 
291  InterpolationType interpolation () const
292  {
293  return InterpolationType( *this );
294  }
295 
300  [[deprecated]]
301  LocalInterpolationType interpolation ( const EntityType &entity ) const
302  {
303  return LocalInterpolationType( lagrangePointSetContainer_.compiledLocalKey( entity.type(), polynomialOrder_ ), basisFunctionSet( entity ) );
304  }
305 
310  LocalInterpolationType localInterpolation ( const EntityType &entity ) const
311  {
312  return LocalInterpolationType( lagrangePointSetContainer_.compiledLocalKey( entity.type(), polynomialOrder_ ), basisFunctionSet( entity ) );
313  }
314 
322  ShapeFunctionSetType shapeFunctionSet ( const EntityType &entity ) const
323  {
324  return shapeFunctionSet( entity.type() );
325  }
326 
334  ShapeFunctionSetType shapeFunctionSet ( const GeometryType &type ) const
335  {
336  return ShapeFunctionSetType( &scalarShapeFunctionSets_[ type ] );
337  }
338 
339  LagrangeDiscreteFunctionSpace ( const ThisType & ) = delete;
340  ThisType &operator= ( const ThisType & ) = delete;
341 
342  protected:
343  std::unique_ptr< BlockMapperType, typename BlockMapperProviderType::Deleter> blockMapper_;
344  ScalarShapeFunctionSetStorageType scalarShapeFunctionSets_;
345  LagrangePointSetContainerType lagrangePointSetContainer_;
346  const int polynomialOrder_;
347  };
348 
349  } // namespace Fem
350 
351 } // namespace Dune
352 
353 #endif // #ifndef DUNE_FEM_SPACE_LAGRANGE_SPACE_HH
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
Definition: default.hh:53
Default communication handler for discrete functions.
Definition: defaultcommhandler.hh:38
This is the class with default implementations for discrete function. The methods not marked with hav...
Definition: discretefunctionspace.hh:649
const IndexSetType & indexSet() const
Get a reference to the associated index set.
Definition: discretefunctionspace.hh:772
Traits ::FunctionSpaceType FunctionSpaceType
type of function space
Definition: discretefunctionspace.hh:194
GridPartType ::IntersectionType IntersectionType
type of the intersections
Definition: discretefunctionspace.hh:226
Traits ::BasisFunctionSetType BasisFunctionSetType
type of basis function set of this space
Definition: discretefunctionspace.hh:201
VectorSpaceTraits< DomainField, RangeField, dimD, dimR > ::ScalarFunctionSpaceType ScalarFunctionSpaceType
corresponding scalar function space
Definition: functionspaceinterface.hh:83
A vector valued function space.
Definition: functionspace.hh:60
Lagrange discrete function space.
Definition: space.hh:131
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: space.hh:261
const BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
get basis function set for given entity
Definition: space.hh:255
ShapeFunctionSetType shapeFunctionSet(const EntityType &entity) const
return shape function set for given entity
Definition: space.hh:322
ShapeFunctionSetType shapeFunctionSet(const GeometryType &type) const
return shape unique function set for geometry type
Definition: space.hh:334
int order() const
get global order of space
Definition: space.hh:273
bool continuous(const IntersectionType &intersection) const
returns true if the space contains only globally continuous functions
Definition: space.hh:267
DFSpaceIdentifier type() const
return type identifier of discrete function space
Definition: space.hh:249
InterpolationType interpolation() const
return interpolation object
Definition: space.hh:291
LocalInterpolationType localInterpolation(const EntityType &entity) const
return local interpolation for given entity
Definition: space.hh:310
LocalInterpolationType interpolation(const EntityType &entity) const
return local interpolation for given entity
Definition: space.hh:301
BlockMapperType & blockMapper() const
get a reference to the block mapper
Definition: space.hh:279
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
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
A few common exception classes.
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:95
@ LagrangeSpace_id
id for Lagrange Space
Definition: discretefunctionspace.hh:102
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:171
Dune namespace.
Definition: alignedallocator.hh:13
Provides a proxy class for pointers to a shape function set.
Interface for shape function sets.
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)