DUNE-FEM (unstable)

restrictprolong.hh
1#ifndef DUNE_FEM_SPACE_PADAPTIVE_RESTRICTPROLONG_HH
2#define DUNE_FEM_SPACE_PADAPTIVE_RESTRICTPROLONG_HH
3
4#include <dune/geometry/referenceelements.hh>
5
6#include <dune/fem/function/localfunction/localfunction.hh>
7#include <dune/fem/space/lagrange/lagrangepoints.hh>
8
9
10namespace Dune
11{
12
13 namespace Fem
14 {
15
16 // PLagrangeLocalRestrictProlong
17 // -----------------------------
18
19 template< class G, class LagrangePointSetProvider >
20 struct PLagrangeLocalRestrictProlong
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
static constexpr int dimension
The dimension of the grid.
Definition: grid.hh:387
ct ctype
Define type used for coordinates in grid module.
Definition: grid.hh:518
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)