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 8 #include <dune/fem/function/localfunction/const.hh> 9 #include <dune/fem/function/localfunction/localfunction.hh> 10 #include <dune/fem/space/common/localrestrictprolong.hh> 11 #include <dune/fem/storage/subvector.hh> 12 13 namespace Dune 14 { 15 16 namespace Fem 17 { 18 19 // PowerLocalRestricProlong 20 // ------------------------ 21 22 template< class DiscreteFunctionSpace, int N > 23 class PowerLocalRestrictProlong 24 { 25 typedef PowerLocalRestrictProlong< DiscreteFunctionSpace, N > ThisType; 26 27 // type of contained DefaultLocalRestrictProlong 28 typedef DefaultLocalRestrictProlong< DiscreteFunctionSpace > LocalRestrictProlongType; 29 30 public: 31 // type of DomainField 32 typedef typename LocalRestrictProlongType::DomainFieldType DomainFieldType; 33 PowerLocalRestrictProlong(const DiscreteFunctionSpace & space)34 PowerLocalRestrictProlong ( const DiscreteFunctionSpace &space ) 35 : localRestrictProlong_( space ) 36 {} 37 setFatherChildWeight(const DomainFieldType & weight)38 void setFatherChildWeight ( const DomainFieldType &weight ) 39 { 40 localRestrictProlong_.setFatherChildWeight( weight ); 41 } 42 43 //! restrict data to father 44 template< class LFFather, class LFSon, class LocalGeometry > restrictLocal(LFFather & lfFather,const LFSon & lfSon,const LocalGeometry & geometryInFather,bool initialize) const45 void restrictLocal ( LFFather &lfFather, const LFSon &lfSon, 46 const LocalGeometry &geometryInFather, bool initialize ) const 47 { 48 typedef SubVector< const typename LFSon::LocalDofVectorType, OffsetSubMapper > SubDofVectorTypeSon; 49 typedef SubVector< typename LFFather::LocalDofVectorType, OffsetSubMapper > SubDofVectorTypeFather; 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 ); 67 LocalFunction< SubFatherBasisFunctionSetType, SubDofVectorTypeFather > subLFFather( subFatherBasisFunctionSet, 68 fatherSubDofVector ); 69 70 localRestrictProlong_.restrictLocal( subLFFather, subLFSon, geometryInFather, initialize ); 71 } 72 } 73 74 75 template< class LFFather, class LFSon, class LocalGeometry > prolongLocal(const LFFather & lfFather,LFSon & lfSon,const LocalGeometry & geometryInFather,bool initialize) const76 void prolongLocal ( const LFFather &lfFather, LFSon &lfSon, 77 const LocalGeometry &geometryInFather, bool initialize ) const 78 { 79 typedef SubVector< typename LFSon::LocalDofVectorType, OffsetSubMapper > SubDofVectorTypeSon; 80 typedef SubVector< const typename LFFather::LocalDofVectorType, OffsetSubMapper > SubDofVectorTypeFather; 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 ); 98 BasicConstLocalFunction< SubFatherBasisFunctionSetType, SubDofVectorTypeFather > subLFFather( subFatherBasisFunctionSet, 99 fatherSubDofVector ); 100 101 localRestrictProlong_.prolongLocal( subLFFather, subLFSon, geometryInFather, initialize ); 102 } 103 } 104 105 template <class LFFather> restrictFinalize(LFFather & lfFather) const106 void restrictFinalize ( LFFather &lfFather ) const 107 { 108 DUNE_THROW(Dune::NotImplemented,"PowerLocalRestrictProlong::restrictFinalize is missing!"); 109 } 110 needCommunication() const111 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 125