dune-fem  2.4.1-rc
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  const Dune::ReferenceElement< ctype, dimension > &refSon
56  = Dune::ReferenceElements< ctype, dimension >::general( son.type() );
57 
58  const LagrangePointSet &pointSet = lagrangePointSet( father );
59 
60  const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
61  for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
62  {
63  const unsigned int dof = *sit;
64  const DomainVector &pointInFather = pointSet.point( dof );
65  const DomainVector pointInSon = geometryInFather.local( pointInFather );
66  if( refSon.checkInside( pointInSon ) )
67  {
68  typename LFSon::RangeType phi;
69  lfSon.evaluate( pointInSon, phi );
70  for( int coordinate = 0; coordinate < dimRange; ++coordinate )
71  lfFather[ dimRange * dof + coordinate ] = phi[ coordinate ];
72  }
73  }
74  }
75 
76 
77  template< class LFFather, class LFSon, class LocalGeometry >
78  void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
79  const LocalGeometry &geometryInFather, bool initialize ) const
80  {
81  static const int dimRange = LFFather::dimRange;
82 
83  const Entity &son = lfSon.entity();
84 
85  const LagrangePointSet &pointSet = lagrangePointSet( son );
86 
87  const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
88  for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
89  {
90  const unsigned int dof = *sit;
91  const DomainVector &pointInSon = pointSet.point( dof );
92  const DomainVector pointInFather = geometryInFather.global( pointInSon );
93 
94  typename LFFather::RangeType phi;
95  lfFather.evaluate( pointInFather, phi );
96  for( int coordinate = 0; coordinate < dimRange; ++coordinate )
97  {
98  const int idx = dimRange * dof + coordinate ;
99  lfSon[ idx ] = phi[ coordinate ];
100  }
101  }
102  }
103 
104  template< class ArgLocal, class DestLocal >
105  void localInterpolation ( const ArgLocal &argLocal,
106  DestLocal &destLocal ) const
107  {
108  static const int dimRange = DestLocal::dimRange;
109 
110  const Entity &entity = destLocal.entity();
111 
112  const LagrangePointSet &pointSet = lagrangePointSet( entity );
113 
114  const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
115  for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
116  {
117  const unsigned int dof = *sit;
118  const DomainVector &localPoint = pointSet.point( dof );
119 
120  typename ArgLocal::RangeType phi;
121  argLocal.evaluate( localPoint, phi );
122  for( int coordinate = 0; coordinate < dimRange; ++coordinate )
123  {
124  const int idx = dimRange * dof + coordinate ;
125  destLocal[ idx ] = phi[ coordinate ];
126  }
127  }
128  }
129 
130  bool needCommunication () const { return false; }
131 
132  const LagrangePointSet &lagrangePointSet ( const Entity &entity ) const
133  {
134  return lpsProvider_.lagrangePointSet( entity );
135  }
136 
137  protected:
138  const LagrangePointSetProvider& lpsProvider_;
139  };
140 
141  } // namespace Fem
142 
143 } // namespace Dune
144 
145 #endif // #ifndef DUNE_FEM_SPACE_PADAPTIVE_RESTRICTPROLONG_HH
void prolongLocal(const LFFather &lfFather, LFSon &lfSon, const LocalGeometry &geometryInFather, bool initialize) const
Definition: padaptivespace/restrictprolong.hh:78
LagrangePointSetProvider::LagrangePointSetType LagrangePointSet
Definition: padaptivespace/restrictprolong.hh:30
PLagrangeLocalRestrictProlong(const LagrangePointSetProvider &lpsProvider)
Definition: padaptivespace/restrictprolong.hh:39
void restrictLocal(LFFather &lfFather, const LFSon &lfSon, const LocalGeometry &geometryInFather, bool initialize) const
Definition: padaptivespace/restrictprolong.hh:47
static const int dimension
Definition: padaptivespace/restrictprolong.hh:25
bool needCommunication() const
Definition: padaptivespace/restrictprolong.hh:130
G Grid
Definition: padaptivespace/restrictprolong.hh:22
Definition: padaptivespace/restrictprolong.hh:20
Definition: coordinate.hh:4
void setFatherChildWeight(const DomainField &weight)
Definition: padaptivespace/restrictprolong.hh:44
void localInterpolation(const ArgLocal &argLocal, DestLocal &destLocal) const
Definition: padaptivespace/restrictprolong.hh:105
Grid::ctype ctype
Definition: padaptivespace/restrictprolong.hh:24
Grid::template Codim< 0 >::Entity Entity
Definition: padaptivespace/restrictprolong.hh:28
FieldVector< ctype, dimension > DomainVector
Definition: padaptivespace/restrictprolong.hh:26
const LagrangePointSetProvider & lpsProvider_
Definition: padaptivespace/restrictprolong.hh:138
static const Point & coordinate(const Point &x)
Definition: coordinate.hh:11
const LagrangePointSet & lagrangePointSet(const Entity &entity) const
Definition: padaptivespace/restrictprolong.hh:132