dune-fem  2.8-git
powerlocalrestrictprolong.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_COMBINEDSPACE_POWERLOCALRESTRICPROLONG_HH
2 #define DUNE_FEM_SPACE_COMBINEDSPACE_POWERLOCALRESTRICPROLONG_HH
3 
4 #include <algorithm>
5 
6 #include <dune/common/exceptions.hh>
7 
12 
13 namespace Dune
14 {
15 
16  namespace Fem
17  {
18 
19  // PowerLocalRestricProlong
20  // ------------------------
21 
22  template< class DiscreteFunctionSpace, int N >
24  {
26 
27  // type of contained DefaultLocalRestrictProlong
29 
30  public:
31  // type of DomainField
32  typedef typename LocalRestrictProlongType::DomainFieldType DomainFieldType;
33 
35  : localRestrictProlong_( space )
36  {}
37 
38  void setFatherChildWeight ( const DomainFieldType &weight )
39  {
40  localRestrictProlong_.setFatherChildWeight( weight );
41  }
42 
44  template< class LFFather, class LFSon, class LocalGeometry >
45  void restrictLocal ( LFFather &lfFather, const LFSon &lfSon,
46  const LocalGeometry &geometryInFather, bool initialize ) const
47  {
50 
51  typedef typename LFSon::BasisFunctionSetType::ScalarBasisFunctionSetType SubSonBasisFunctionSetType;
52  typedef typename LFFather::BasisFunctionSetType::ScalarBasisFunctionSetType SubFatherBasisFunctionSetType;
53 
54  SubFatherBasisFunctionSetType subFatherBasisFunctionSet = lfFather.basisFunctionSet().scalarBasisFunctionSet();
55  SubSonBasisFunctionSetType subSonBasisFunctionSet = lfSon.basisFunctionSet().scalarBasisFunctionSet();
56 
57  for( std::size_t i = 0; i < N; ++i )
58  {
59  std::size_t sonBasisSetSize = subSonBasisFunctionSet.size();
60  std::size_t fatherBasisSetsize = subFatherBasisFunctionSet.size();
61 
62  SubDofVectorTypeSon sonSubDofVector( lfSon.localDofVector(), OffsetSubMapper( sonBasisSetSize, sonBasisSetSize * i ) );
63  SubDofVectorTypeFather fatherSubDofVector( lfFather.localDofVector(),
64  OffsetSubMapper( fatherBasisSetsize, fatherBasisSetsize * i ) );
65 
66  BasicConstLocalFunction< SubSonBasisFunctionSetType, SubDofVectorTypeSon > subLFSon( subSonBasisFunctionSet, sonSubDofVector );
68  fatherSubDofVector );
69 
70  localRestrictProlong_.restrictLocal( subLFFather, subLFSon, geometryInFather, initialize );
71  }
72  }
73 
74 
75  template< class LFFather, class LFSon, class LocalGeometry >
76  void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
77  const LocalGeometry &geometryInFather, bool initialize ) const
78  {
81 
82  typedef typename LFSon::BasisFunctionSetType::ScalarBasisFunctionSetType SubSonBasisFunctionSetType;
83  typedef typename LFFather::BasisFunctionSetType::ScalarBasisFunctionSetType SubFatherBasisFunctionSetType;
84 
85  SubSonBasisFunctionSetType subSonBasisFunctionSet = lfSon.basisFunctionSet().scalarBasisFunctionSet();
86  SubFatherBasisFunctionSetType subFatherBasisFunctionSet = lfFather.basisFunctionSet().scalarBasisFunctionSet();
87 
88  for( std::size_t i = 0; i < N; ++i )
89  {
90  std::size_t sonBasisSetSize = subSonBasisFunctionSet.size();
91  std::size_t fatherBasisSetsize = subFatherBasisFunctionSet.size();
92 
93  SubDofVectorTypeSon sonSubDofVector( lfSon.localDofVector(), OffsetSubMapper( sonBasisSetSize, sonBasisSetSize * i ) );
94  SubDofVectorTypeFather fatherSubDofVector( lfFather.localDofVector(),
95  OffsetSubMapper( fatherBasisSetsize, fatherBasisSetsize * i ) );
96 
97  LocalFunction< SubSonBasisFunctionSetType, SubDofVectorTypeSon > subLFSon( subSonBasisFunctionSet, sonSubDofVector );
99  fatherSubDofVector );
100 
101  localRestrictProlong_.prolongLocal( subLFFather, subLFSon, geometryInFather, initialize );
102  }
103  }
104 
105  template <class LFFather>
106  void restrictFinalize ( LFFather &lfFather ) const
107  {
108  DUNE_THROW(Dune::NotImplemented,"PowerLocalRestrictProlong::restrictFinalize is missing!");
109  }
110 
111  bool needCommunication () const
112  {
113  return localRestrictProlong_.needCommunication();
114  }
115 
116  private:
117  LocalRestrictProlongType localRestrictProlong_;
118  };
119 
120  } // namespace Fem
121 
122 } // namespace Dune
123 
124 #endif // #ifndef DUNE_FEM_SPACE_COMBINEDSPACE_POWERLOCALRESTRICPROLONG_HH
Definition: bindguard.hh:11
Definition: const.hh:36
interface for local functions
Definition: localfunction.hh:77
Definition: powerlocalrestrictprolong.hh:24
void restrictLocal(LFFather &lfFather, const LFSon &lfSon, const LocalGeometry &geometryInFather, bool initialize) const
restrict data to father
Definition: powerlocalrestrictprolong.hh:45
bool needCommunication() const
Definition: powerlocalrestrictprolong.hh:111
void restrictFinalize(LFFather &lfFather) const
Definition: powerlocalrestrictprolong.hh:106
LocalRestrictProlongType::DomainFieldType DomainFieldType
Definition: powerlocalrestrictprolong.hh:32
void setFatherChildWeight(const DomainFieldType &weight)
Definition: powerlocalrestrictprolong.hh:38
PowerLocalRestrictProlong(const DiscreteFunctionSpace &space)
Definition: powerlocalrestrictprolong.hh:34
void prolongLocal(const LFFather &lfFather, LFSon &lfSon, const LocalGeometry &geometryInFather, bool initialize) const
Definition: powerlocalrestrictprolong.hh:76
Definition: common/localrestrictprolong.hh:16
An implementation of DenseVector to extract a portion, not necessarly contiguos, of a vector.
Definition: subvector.hh:161
size_type size() const
Definition: subvector.hh:214
Index mapper which simply adds an offset to the index.
Definition: subvector.hh:83
discrete function space