dune-fem 2.8.0
Loading...
Searching...
No Matches
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
18namespace 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 auto &refSon = Dune::ReferenceElements< ctype, dimension >::general( lfSon.entity().type() );
63
64 const LagrangePointSetType &pointSet = lagrangePointSet( lfFather.entity(), lfFather.order() );
65
66 const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
67 for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
68 {
69 const unsigned int dof = *sit;
70 const DomainVector &pointInFather = pointSet.point( dof );
71 const DomainVector pointInSon = geometryInFather.local( pointInFather );
72 if( refSon.checkInside( pointInSon ) )
73 {
74 typename LFSon::RangeType phi;
75 lfSon.evaluate( pointInSon, phi );
76 for( int coordinate = 0; coordinate < dimRange; ++coordinate )
77 lfFather[ dimRange * dof + coordinate ] = phi[ coordinate ];
78 }
79 }
80 }
81 template< class LFFather >
82 void restrictFinalize ( LFFather &lfFather ) const
83 {}
84
85 template< class LFFather, class LFSon, class LocalGeometry >
86 void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
87 const LocalGeometry &geometryInFather,
88 bool initialize ) const
89 {
90 static const int dimRange = LFFather::dimRange;
91
92 const LagrangePointSetType &pointSet = lagrangePointSet( lfSon.entity(), lfSon.order() );
93
94 const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
95 for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
96 {
97 const unsigned int dof = *sit;
98 const DomainVector &pointInSon = pointSet.point( dof );
99 const DomainVector pointInFather = geometryInFather.global( pointInSon );
100
101 typename LFFather::RangeType phi;
102 lfFather.evaluate( pointInFather, phi );
103 for( int coordinate = 0; coordinate < dimRange; ++coordinate )
104 lfSon[ dimRange * dof + coordinate ] = phi[ coordinate ];
105 }
106 }
107
108 bool needCommunication () const { return true; }
109
110 protected:
111 template< class Entity >
112 const LagrangePointSetType &lagrangePointSet ( const Entity &entity, const int order ) const
113 {
114 return lagrangePointSet( entity.type(), order );
115 }
116
117 const LagrangePointSetType &lagrangePointSet ( const GeometryType &type, const int order ) const
118 {
119 typedef typename LagrangePointSetMapType::iterator Iterator;
120 Iterator it = lagrangePointSet_.find( type );
121 if( it == lagrangePointSet_.end() )
122 it = lagrangePointSet_.insert( it, std::make_pair( type, new LagrangePointSetType( type, order ) ) );
123 assert( it->second != 0 );
124 return *(it->second);
125 }
126
127 private:
128 mutable LagrangePointSetMapType lagrangePointSet_;
129 };
130
131 } // namespace Fem
132
133} // namespace Dune
134
135#endif // #ifndef DUNE_FEM_SPACE_LAGRANGE_RESTRICTPROLONG_HH
Definition: bindguard.hh:11
static const Point & coordinate(const Point &x)
Definition: coordinate.hh:14
Definition: lagrangepoints.hh:685
Definition: lagrange/restrictprolong.hh:26
bool needCommunication() const
Definition: lagrange/restrictprolong.hh:108
void restrictFinalize(LFFather &lfFather) const
Definition: lagrange/restrictprolong.hh:82
~LagrangeLocalRestrictProlong()
Definition: lagrange/restrictprolong.hh:43
static const int dimension
Definition: lagrange/restrictprolong.hh:30
const LagrangePointSetType & lagrangePointSet(const GeometryType &type, const int order) const
Definition: lagrange/restrictprolong.hh:117
GridType::ctype ctype
Definition: lagrange/restrictprolong.hh:29
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
LagrangePointSet< LeafGridPart< GridType >, ord > LagrangePointSetType
Definition: lagrange/restrictprolong.hh:34
FieldVector< ctype, dimension > DomainVector
Definition: lagrange/restrictprolong.hh:32
void setFatherChildWeight(const DomainField &weight)
Definition: lagrange/restrictprolong.hh:52
void prolongLocal(const LFFather &lfFather, LFSon &lfSon, const LocalGeometry &geometryInFather, bool initialize) const
Definition: lagrange/restrictprolong.hh:86
const LagrangePointSetType & lagrangePointSet(const Entity &entity, const int order) const
Definition: lagrange/restrictprolong.hh:112