dune-fem  2.8-git
padaptivespace/restrictprolong.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_PADAPTIVE_RESTRICTPROLONG_HH
2 #define DUNE_FEM_SPACE_PADAPTIVE_RESTRICTPROLONG_HH
3 
4 #include <dune/geometry/referenceelements.hh>
5 
8 
9 
10 namespace Dune
11 {
12 
13  namespace Fem
14  {
15 
16  // PLagrangeLocalRestrictProlong
17  // -----------------------------
18 
19  template< class G, class LagrangePointSetProvider >
21  {
22  typedef G Grid;
23 
24  typedef typename Grid::ctype ctype;
25  static const int dimension = Grid::dimension;
26  typedef FieldVector< ctype, dimension > DomainVector;
27 
28  typedef typename Grid::template Codim< 0 >::Entity Entity;
29 
30  typedef typename LagrangePointSetProvider :: LagrangePointSetType LagrangePointSet;
31 
32  private:
33  typedef typename Entity::LocalGeometry LocalGeometry;
34 
35  typedef typename LagrangePointSet::template Codim< 0 >::SubEntityIteratorType
36  EntityDofIterator;
37 
38  public:
39  PLagrangeLocalRestrictProlong ( const LagrangePointSetProvider &lpsProvider )
40  : lpsProvider_( lpsProvider )
41  {}
42 
43  template< class DomainField >
44  void setFatherChildWeight ( const DomainField &weight ) {}
45 
46  template< class LFFather, class LFSon, class LocalGeometry >
47  void restrictLocal ( LFFather &lfFather, const LFSon &lfSon,
48  const LocalGeometry &geometryInFather, bool initialize ) const
49  {
50  static const int dimRange = LFSon::dimRange;
51 
52  const Entity &father = lfFather.entity();
53  const Entity &son = lfSon.entity();
54 
55  auto refSon = referenceElement< ctype, dimension >( son.type() );
56 
57  const LagrangePointSet &pointSet = lagrangePointSet( father );
58 
59  const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
60  for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
61  {
62  const unsigned int dof = *sit;
63  const DomainVector &pointInFather = pointSet.point( dof );
64  const DomainVector pointInSon = geometryInFather.local( pointInFather );
65  if( refSon.checkInside( pointInSon ) )
66  {
67  typename LFSon::RangeType phi;
68  lfSon.evaluate( pointInSon, phi );
69  for( int coordinate = 0; coordinate < dimRange; ++coordinate )
70  lfFather[ dimRange * dof + coordinate ] = phi[ coordinate ];
71  }
72  }
73  }
74  template< class LFFather >
75  void restrictFinalize ( LFFather &lfFather ) const
76  {}
77 
78 
79  template< class LFFather, class LFSon, class LocalGeometry >
80  void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
81  const LocalGeometry &geometryInFather, bool initialize ) const
82  {
83  static const int dimRange = LFFather::dimRange;
84 
85  const Entity &son = lfSon.entity();
86 
87  const LagrangePointSet &pointSet = lagrangePointSet( son );
88 
89  const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
90  for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
91  {
92  const unsigned int dof = *sit;
93  const DomainVector &pointInSon = pointSet.point( dof );
94  const DomainVector pointInFather = geometryInFather.global( pointInSon );
95 
96  typename LFFather::RangeType phi;
97  lfFather.evaluate( pointInFather, phi );
98  for( int coordinate = 0; coordinate < dimRange; ++coordinate )
99  {
100  const int idx = dimRange * dof + coordinate ;
101  lfSon[ idx ] = phi[ coordinate ];
102  }
103  }
104  }
105 
106  template< class ArgLocal, class DestLocal >
107  void localInterpolation ( const ArgLocal &argLocal,
108  DestLocal &destLocal ) const
109  {
110  static const int dimRange = DestLocal::dimRange;
111 
112  const Entity &entity = destLocal.entity();
113 
114  const LagrangePointSet &pointSet = lagrangePointSet( entity );
115 
116  const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
117  for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
118  {
119  const unsigned int dof = *sit;
120  const DomainVector &localPoint = pointSet.point( dof );
121 
122  typename ArgLocal::RangeType phi;
123  argLocal.evaluate( localPoint, phi );
124  for( int coordinate = 0; coordinate < dimRange; ++coordinate )
125  {
126  const int idx = dimRange * dof + coordinate ;
127  destLocal[ idx ] = phi[ coordinate ];
128  }
129  }
130  }
131 
132  bool needCommunication () const { return false; }
133 
134  const LagrangePointSet &lagrangePointSet ( const Entity &entity ) const
135  {
136  return lpsProvider_.lagrangePointSet( entity );
137  }
138 
139  protected:
140  const LagrangePointSetProvider& lpsProvider_;
141  };
142 
143  } // namespace Fem
144 
145 } // namespace Dune
146 
147 #endif // #ifndef DUNE_FEM_SPACE_PADAPTIVE_RESTRICTPROLONG_HH
Definition: bindguard.hh:11
static const Point & coordinate(const Point &x)
Definition: coordinate.hh:14
Definition: padaptivespace/restrictprolong.hh:21
LagrangePointSetProvider ::LagrangePointSetType LagrangePointSet
Definition: padaptivespace/restrictprolong.hh:30
Grid::ctype ctype
Definition: padaptivespace/restrictprolong.hh:24
PLagrangeLocalRestrictProlong(const LagrangePointSetProvider &lpsProvider)
Definition: padaptivespace/restrictprolong.hh:39
void prolongLocal(const LFFather &lfFather, LFSon &lfSon, const LocalGeometry &geometryInFather, bool initialize) const
Definition: padaptivespace/restrictprolong.hh:80
bool needCommunication() const
Definition: padaptivespace/restrictprolong.hh:132
const LagrangePointSetProvider & lpsProvider_
Definition: padaptivespace/restrictprolong.hh:140
void restrictFinalize(LFFather &lfFather) const
Definition: padaptivespace/restrictprolong.hh:75
FieldVector< ctype, dimension > DomainVector
Definition: padaptivespace/restrictprolong.hh:26
void localInterpolation(const ArgLocal &argLocal, DestLocal &destLocal) const
Definition: padaptivespace/restrictprolong.hh:107
Grid::template Codim< 0 >::Entity Entity
Definition: padaptivespace/restrictprolong.hh:28
const LagrangePointSet & lagrangePointSet(const Entity &entity) const
Definition: padaptivespace/restrictprolong.hh:134
void restrictLocal(LFFather &lfFather, const LFSon &lfSon, const LocalGeometry &geometryInFather, bool initialize) const
Definition: padaptivespace/restrictprolong.hh:47
void setFatherChildWeight(const DomainField &weight)
Definition: padaptivespace/restrictprolong.hh:44
static const int dimension
Definition: padaptivespace/restrictprolong.hh:25
G Grid
Definition: padaptivespace/restrictprolong.hh:22