dune-fem  2.8-git
hpdg/space.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_HPDG_SPACE_DISCONTINUOUSGALERKIN_SPACE_HH
2 #define DUNE_FEM_HPDG_SPACE_DISCONTINUOUSGALERKIN_SPACE_HH
3 
4 #include <cstddef>
5 
6 #include <functional>
7 #include <memory>
8 #include <type_traits>
9 
10 #include <dune/common/deprecated.hh>
11 #include <dune/common/exceptions.hh>
12 
13 #include <dune/grid/common/gridenums.hh>
14 #include <dune/grid/common/partitionset.hh>
15 #include <dune/grid/common/rangegenerators.hh>
16 
20 
22 
24 
25 namespace Dune
26 {
27 
28  namespace Fem
29  {
30 
31  namespace hpDG
32  {
33 
34  // DiscontinuousGalerkinSpace
35  // --------------------------
36 
43  template< class Traits >
46  {
48 
49  public:
53  using EntityType = typename BaseType::EntityType;
54 
56  using BasisFunctionSetsType = typename Traits::BasisFunctionSetsType;
58  using KeyType = typename BasisFunctionSetsType::KeyType;
61 
64 
66 
67  protected:
69  {
70  typedef std::pair< AuxiliaryDofsType, int > ObjectType;
71 
72  static ObjectType *createObject ( std::pair< GridPartType *, BlockMapperType * > key )
73  {
74  return new ObjectType( std::piecewise_construct, std::tie( *key.first, *key.second ), std::make_tuple( -1 ) );
75  }
76 
77  static void deleteObject ( ObjectType *object ) { delete object; }
78  };
79 
81 
82 
83 
84  protected:
85  using BaseType::asImp;
86  using BaseType::gridPart_;
87 
88  private:
89  template< class DataProjection >
90  struct DataProjectionWrapper;
91 
92  typedef typename Traits::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
93  public:
96 
99 
104  template< class Function >
106  const KeyType &value, Function function,
107  const Dune::InterfaceType interface = Dune::InteriorBorder_All_Interface,
108  const Dune::CommunicationDirection direction = Dune::ForwardCommunication )
109  : BaseType( gridPart, interface, direction ),
111  blockMapper_( gridPart_, basisFunctionSets_, value, function )
112  {}
113 
115  const Dune::InterfaceType interface = Dune::InteriorBorder_All_Interface,
116  const Dune::CommunicationDirection direction = Dune::ForwardCommunication )
117  : DiscontinuousGalerkinSpace( gridPart, basisFunctionSets, value, [&value]( const EntityType &){ return value; }, interface, direction )
118  {}
119 
128 
131 
139  bool continuous () const { return false; }
140 
142  bool continuous ( const typename BaseType::IntersectionType &intersection ) const
143  {
144  return false;
145  }
146 
148  bool multipleBasisFunctionSets () const { return true; }
149 
157  int order () const { return basisFunctionSets().order(); }
158 
160  int order ( const EntityType &entity ) const
161  {
162  return basisFunctionSet( entity ).order();
163  }
164 
167  {
168  return basisFunctionSets().basisFunctionSet( entity, key( entity ) );
169  }
170 
184  {
185  return InterpolationType( static_cast< const DiscreteFunctionSpaceType& > (*this) );
186  }
187 
195  {
196  return InterpolationImplType( basisFunctionSet( entity ) );
197  }
198 
206  {
207  return InterpolationImplType( basisFunctionSet( entity ) );
208  }
209 
218 
231  const KeyType &key ( const EntityType &entity ) const
232  {
233  return blockMapper().key( entity );
234  }
235 
241  void mark ( const KeyType &key, const EntityType &entity )
242  {
243  return blockMapper_.mark( key, entity );
244  }
245 
252  KeyType getMark ( const EntityType &entity ) const
253  {
254  return blockMapper().getMark( entity );
255  }
256 
258  bool adapt () { return blockMapper_.adapt(); }
259 
261  template< class DiscreteFunctionSpace, class Implementation >
263  {
264  DataProjectionWrapper< DataProjection< DiscreteFunctionSpace, Implementation > > wrapper( basisFunctionSets(), projection );
265  return blockMapper_.adapt( wrapper );
266  }
267 
274  /* \brief return space identitifier */
276  {
277  DUNE_THROW( NotImplemented, "Method type() not implemented" );
278  }
279 
288  {
289  return basisFunctionSets_;
290  }
291 
294  protected:
297  };
298 
299 
300 
301  // DiscontinuousGalerkinSpace::DataProjectionWrapper
302  // -------------------------------------------------
303 
304  template< class Traits >
305  template< class DataProjection >
306  struct DiscontinuousGalerkinSpace< Traits >::DataProjectionWrapper
307  {
308  explicit DataProjectionWrapper ( const BasisFunctionSetsType &basisFunctionSets,
309  DataProjection &dataProjection )
311  dataProjection_( dataProjection )
312  {}
313 
314  DataProjectionWrapper ( const DataProjectionWrapper & ) = default;
315 
316  DataProjectionWrapper &operator= ( const DataProjectionWrapper & ) = default;
317 
318  void operator() ( const EntityType &entity,
319  const KeyType &prior,
320  const KeyType &present,
321  const std::vector< std::size_t > &origin,
322  const std::vector< std::size_t > &destination )
323  {
324  dataProjection_.get()( entity, basisFunctionSet( entity, prior ), basisFunctionSet( entity, present ), origin, destination );
325  }
326 
327  protected:
328  BasisFunctionSetType basisFunctionSet ( const EntityType &entity, const KeyType &key ) const
329  {
330  return basisFunctionSets_.get().basisFunctionSet( entity, key );
331  }
332 
333  std::reference_wrapper< const BasisFunctionSetsType > basisFunctionSets_;
334  std::reference_wrapper< DataProjection > dataProjection_;
335  };
336 
337  } // namespace hpDG
338 
339  } // namespace Fem
340 
341 } // namespace Dune
342 
343 #endif // #ifndef DUNE_FEM_HPDG_SPACE_DISCONTINUOUSGALERKIN_SPACE_HH
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:94
Definition: bindguard.hh:11
Abstract class representing a function.
Definition: common/function.hh:50
Abstract definition of the local restriction and prolongation of discrete functions.
Definition: dataprojection/dataprojection.hh:29
const DiscreteFunctionSpaceType & asImp() const
Definition: discretefunctionspace.hh:576
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
BaseType::BlockMapperType BlockMapperType
Definition: discretefunctionspace.hh:660
GridPartType & gridPart_
Definition: discretefunctionspace.hh:679
BaseType ::EntityType EntityType
Definition: discretefunctionspace.hh:644
BaseType::AuxiliaryDofsType AuxiliaryDofsType
Definition: discretefunctionspace.hh:661
BaseType ::GridPartType GridPartType
Definition: discretefunctionspace.hh:640
GridPartType & gridPart() const
Definition: discretefunctionspace.hh:745
Definition: common/localinterpolation.hh:74
Definition: discontinuousgalerkin/interpolation.hh:153
Generic implementation of a -adaptive discontinuous finite element space.
Definition: hpdg/space.hh:46
const DiscontinuousGalerkinSpace & operator=(const DiscontinuousGalerkinSpace &)=delete
assignment operator
LocalInterpolationWrapper< DiscreteFunctionSpaceType > InterpolationType
local interpolation type
Definition: hpdg/space.hh:98
BlockMapperType blockMapper_
Definition: hpdg/space.hh:296
BaseType::AuxiliaryDofsType AuxiliaryDofsType
Definition: hpdg/space.hh:65
InterpolationImplType localInterpolation(const EntityType &entity) const
return interpolation
Definition: hpdg/space.hh:205
typename BaseType::BlockMapperType BlockMapperType
block mapper type
Definition: hpdg/space.hh:63
typename BaseType::EntityType EntityType
entity type
Definition: hpdg/space.hh:53
DiscontinuousGalerkinLocalL2Projection< GridPartType, BasisFunctionSetType > InterpolationImplType
local interpolation type
Definition: hpdg/space.hh:95
bool multipleBasisFunctionSets() const
please doc me
Definition: hpdg/space.hh:148
DiscontinuousGalerkinSpace(GridPartType &gridPart, const BasisFunctionSetsType &basisFunctionSets, const KeyType &value, const Dune::InterfaceType interface=Dune::InteriorBorder_All_Interface, const Dune::CommunicationDirection direction=Dune::ForwardCommunication)
Definition: hpdg/space.hh:114
DiscontinuousGalerkinSpace(GridPartType &gridPart, const BasisFunctionSetsType &basisFunctionSets, const KeyType &value, Function function, const Dune::InterfaceType interface=Dune::InteriorBorder_All_Interface, const Dune::CommunicationDirection direction=Dune::ForwardCommunication)
Definition: hpdg/space.hh:105
typename Traits::BasisFunctionSetsType BasisFunctionSetsType
basis function sets type
Definition: hpdg/space.hh:56
BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
return basis function set
Definition: hpdg/space.hh:166
bool adapt(DataProjection< DiscreteFunctionSpace, Implementation > &projection)
please doc me
Definition: hpdg/space.hh:262
typename BasisFunctionSetsType::KeyType KeyType
key type identifying a basis function set
Definition: hpdg/space.hh:58
int order(const EntityType &entity) const
return polynomial order
Definition: hpdg/space.hh:160
const BasisFunctionSetsType & basisFunctionSets() const
return basis function sets
Definition: hpdg/space.hh:287
bool continuous(const typename BaseType::IntersectionType &intersection) const
please doc me
Definition: hpdg/space.hh:142
typename BaseType::GridPartType GridPartType
grid part type
Definition: hpdg/space.hh:51
BasisFunctionSetsType basisFunctionSets_
Definition: hpdg/space.hh:295
InterpolationType interpolation() const
return interpolation
Definition: hpdg/space.hh:183
const KeyType & key(const EntityType &entity) const
get identifiying basis function set key assigned to given entity
Definition: hpdg/space.hh:231
void mark(const KeyType &key, const EntityType &entity)
assign new key to given entity
Definition: hpdg/space.hh:241
bool continuous() const
please doc me
Definition: hpdg/space.hh:139
DFSpaceIdentifier type() const
Definition: hpdg/space.hh:275
InterpolationImplType interpolation(const EntityType &entity) const
return interpolation
Definition: hpdg/space.hh:194
SingletonList< std::pair< GridPartType *, BlockMapperType * >, std::pair< AuxiliaryDofsType, int >, AuxiliaryDofsFactory > AuxiliaryDofsProviderType
Definition: hpdg/space.hh:80
KeyType getMark(const EntityType &entity) const
get key to be assigned to an entity after next call to adapt()
Definition: hpdg/space.hh:252
int order() const
return polynomial order
Definition: hpdg/space.hh:157
BlockMapperType & blockMapper() const
return block mapper
Definition: hpdg/space.hh:217
DiscontinuousGalerkinSpace(const DiscontinuousGalerkinSpace &)=delete
copy constructor
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: hpdg/space.hh:60
bool adapt()
please doc me
Definition: hpdg/space.hh:258
static ObjectType * createObject(std::pair< GridPartType *, BlockMapperType * > key)
Definition: hpdg/space.hh:72
static void deleteObject(ObjectType *object)
Definition: hpdg/space.hh:77
std::pair< AuxiliaryDofsType, int > ObjectType
Definition: hpdg/space.hh:70
Singleton list for key/object pairs.
Definition: singletonlist.hh:53