dune-fem  2.4.1-rc
lagrange/restrictprolong.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_LAGRANGE_RESTRICTPROLONG_HH
2 #define DUNE_FEM_SPACE_LAGRANGE_RESTRICTPROLONG_HH
3 
4 // C++ includes
5 #include <map>
6 
7 // dune-geometry includes
8 #include <dune/geometry/referenceelements.hh>
9 #include <dune/geometry/type.hh>
10 
11 // dune-fem includes
13 
14 // local includes
15 #include "lagrangepoints.hh"
16 
17 
18 namespace Dune
19 {
20 
21  namespace Fem
22  {
23 
24  template< class G, int ord >
26  {
27  typedef G GridType;
28 
29  typedef typename GridType::ctype ctype;
30  static const int dimension = GridType::dimension;
31 
32  typedef FieldVector< ctype, dimension > DomainVector;
33 
35 
36  private:
37  typedef typename LagrangePointSetType::template Codim< 0 >::SubEntityIteratorType
38  EntityDofIterator;
39 
40  typedef std::map< const GeometryType, const LagrangePointSetType * > LagrangePointSetMapType;
41 
42  public:
44  {
45  typedef typename LagrangePointSetMapType::iterator Iterator;
46  const Iterator end = lagrangePointSet_.end();
47  for( Iterator it = lagrangePointSet_.begin(); it != end; ++it )
48  delete it->second;
49  }
50 
51  template< class DomainField >
52  void setFatherChildWeight ( const DomainField &weight ) {}
53 
54  template< class LFFather, class LFSon, class LocalGeometry >
55  void restrictLocal ( LFFather &lfFather,
56  const LFSon &lfSon,
57  const LocalGeometry &geometryInFather,
58  const bool initialize ) const
59  {
60  static const int dimRange = LFSon::dimRange;
61 
62  const Dune::ReferenceElement< ctype, dimension > &refSon
63  = Dune::ReferenceElements< ctype, dimension >::general( lfSon.entity().type() );
64 
65  const LagrangePointSetType &pointSet = lagrangePointSet( lfFather.entity() );
66 
67  const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
68  for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
69  {
70  const unsigned int dof = *sit;
71  const DomainVector &pointInFather = pointSet.point( dof );
72  const DomainVector pointInSon = geometryInFather.local( pointInFather );
73  if( refSon.checkInside( pointInSon ) )
74  {
75  typename LFSon::RangeType phi;
76  lfSon.evaluate( pointInSon, phi );
77  for( int coordinate = 0; coordinate < dimRange; ++coordinate )
78  lfFather[ dimRange * dof + coordinate ] = phi[ coordinate ];
79  }
80  }
81  }
82 
83  template< class LFFather, class LFSon, class LocalGeometry >
84  void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
85  const LocalGeometry &geometryInFather,
86  bool initialize ) const
87  {
88  static const int dimRange = LFFather::dimRange;
89 
90  const LagrangePointSetType &pointSet = lagrangePointSet( lfSon.entity() );
91 
92  const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
93  for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
94  {
95  const unsigned int dof = *sit;
96  const DomainVector &pointInSon = pointSet.point( dof );
97  const DomainVector pointInFather = geometryInFather.global( pointInSon );
98 
99  typename LFFather::RangeType phi;
100  lfFather.evaluate( pointInFather, phi );
101  for( int coordinate = 0; coordinate < dimRange; ++coordinate )
102  lfSon[ dimRange * dof + coordinate ] = phi[ coordinate ];
103  }
104  }
105 
106  bool needCommunication () const { return false; }
107 
108  protected:
109  template< class Entity >
110  const LagrangePointSetType &lagrangePointSet ( const Entity &entity ) const
111  {
112  return lagrangePointSet( entity.type() );
113  }
114 
115  const LagrangePointSetType &lagrangePointSet ( const GeometryType &type ) const
116  {
117  typedef typename LagrangePointSetMapType::iterator Iterator;
118  Iterator it = lagrangePointSet_.find( type );
119  if( it == lagrangePointSet_.end() )
120  it = lagrangePointSet_.insert( it, std::make_pair( type, new LagrangePointSetType( type, ord ) ) );
121  assert( it->second != 0 );
122  return *(it->second);
123  }
124 
125  private:
126  mutable LagrangePointSetMapType lagrangePointSet_;
127  };
128 
129  } // namespace Fem
130 
131 } // namespace Dune
132 
133 #endif // #ifndef DUNE_FEM_SPACE_LAGRANGE_RESTRICTPROLONG_HH
GridType::ctype ctype
Definition: lagrange/restrictprolong.hh:29
const LagrangePointSetType & lagrangePointSet(const GeometryType &type) const
Definition: lagrange/restrictprolong.hh:115
LagrangePointSet< LeafGridPart< GridType >, ord > LagrangePointSetType
Definition: lagrange/restrictprolong.hh:34
void prolongLocal(const LFFather &lfFather, LFSon &lfSon, const LocalGeometry &geometryInFather, bool initialize) const
Definition: lagrange/restrictprolong.hh:84
Definition: lagrange/restrictprolong.hh:25
const LagrangePointSetType & lagrangePointSet(const Entity &entity) const
Definition: lagrange/restrictprolong.hh:110
~LagrangeLocalRestrictProlong()
Definition: lagrange/restrictprolong.hh:43
Definition: coordinate.hh:4
static const int dimension
Definition: lagrange/restrictprolong.hh:30
void setFatherChildWeight(const DomainField &weight)
Definition: lagrange/restrictprolong.hh:52
void restrictLocal(LFFather &lfFather, const LFSon &lfSon, const LocalGeometry &geometryInFather, const bool initialize) const
Definition: lagrange/restrictprolong.hh:55
G GridType
Definition: lagrange/restrictprolong.hh:27
FieldVector< ctype, dimension > DomainVector
Definition: lagrange/restrictprolong.hh:32
bool needCommunication() const
Definition: lagrange/restrictprolong.hh:106
Definition: lagrangepoints.hh:461
static const Point & coordinate(const Point &x)
Definition: coordinate.hh:11