DUNE-FEM (unstable)

restrictprolong.hh
1#ifndef DUNE_FEM_SPACE_LAGRANGE_RESTRICTPROLONG_HH
2#define DUNE_FEM_SPACE_LAGRANGE_RESTRICTPROLONG_HH
3
4#if __GNUC__ >= 13
5#pragma GCC diagnostic push
6#pragma GCC diagnostic ignored "-Wdangling-reference"
7#endif
8
9// C++ includes
10#include <map>
11
12// dune-geometry includes
13#include <dune/geometry/referenceelements.hh>
14#include <dune/geometry/type.hh>
15
16// dune-fem includes
17#include <dune/fem/gridpart/leafgridpart.hh>
18
19// local includes
20#include "lagrangepoints.hh"
21
22
23namespace Dune
24{
25
26 namespace Fem
27 {
28
29 template< class G, int ord >
30 struct LagrangeLocalRestrictProlong
31 {
32 typedef G GridType;
33
34 typedef typename GridType::ctype ctype;
35 static const int dimension = GridType::dimension;
36
37 typedef FieldVector< ctype, dimension > DomainVector;
38
39 typedef LagrangePointSet< LeafGridPart< GridType >, ord > LagrangePointSetType;
40
41 private:
42 typedef typename LagrangePointSetType::template Codim< 0 >::SubEntityIteratorType
43 EntityDofIterator;
44
45 typedef std::map< const GeometryType, const LagrangePointSetType * > LagrangePointSetMapType;
46
47 public:
48 ~LagrangeLocalRestrictProlong ()
49 {
50 typedef typename LagrangePointSetMapType::iterator Iterator;
51 const Iterator end = lagrangePointSet_.end();
52 for( Iterator it = lagrangePointSet_.begin(); it != end; ++it )
53 delete it->second;
54 }
55
56 template< class DomainField >
57 void setFatherChildWeight ( const DomainField &weight ) {}
58
59 template< class LFFather, class LFSon, class LocalGeometry >
60 void restrictLocal ( LFFather &lfFather,
61 const LFSon &lfSon,
62 const LocalGeometry &geometryInFather,
63 const bool initialize ) const
64 {
65 static const int dimRange = LFSon::dimRange;
66
67 const auto &refSon = Dune::ReferenceElements< ctype, dimension >::general( lfSon.entity().type() );
68
69 const LagrangePointSetType &pointSet = lagrangePointSet( lfFather.entity(), lfFather.order() );
70
71 const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
72 for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
73 {
74 const unsigned int dof = *sit;
75 const DomainVector &pointInFather = pointSet.point( dof );
76 const DomainVector pointInSon = geometryInFather.local( pointInFather );
77 if( refSon.checkInside( pointInSon ) )
78 {
79 typename LFSon::RangeType phi;
80 lfSon.evaluate( pointInSon, phi );
81 for( int coordinate = 0; coordinate < dimRange; ++coordinate )
82 lfFather[ dimRange * dof + coordinate ] = phi[ coordinate ];
83 }
84 }
85 }
86 template< class LFFather >
87 void restrictFinalize ( LFFather &lfFather ) const
88 {}
89
90 template< class LFFather, class LFSon, class LocalGeometry >
91 void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
92 const LocalGeometry &geometryInFather,
93 bool initialize ) const
94 {
95 static const int dimRange = LFFather::dimRange;
96
97 const LagrangePointSetType &pointSet = lagrangePointSet( lfSon.entity(), lfSon.order() );
98
99 const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
100 for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
101 {
102 const unsigned int dof = *sit;
103 const DomainVector &pointInSon = pointSet.point( dof );
104 const DomainVector pointInFather = geometryInFather.global( pointInSon );
105
106 typename LFFather::RangeType phi;
107 lfFather.evaluate( pointInFather, phi );
108 for( int coordinate = 0; coordinate < dimRange; ++coordinate )
109 lfSon[ dimRange * dof + coordinate ] = phi[ coordinate ];
110 }
111 }
112
113 bool needCommunication () const { return true; }
114
115 protected:
116 template< class Entity >
117 const LagrangePointSetType &lagrangePointSet ( const Entity &entity, const int order ) const
118 {
119 return lagrangePointSet( entity.type(), order );
120 }
121
122 const LagrangePointSetType &lagrangePointSet ( const GeometryType &type, const int order ) const
123 {
124 typedef typename LagrangePointSetMapType::iterator Iterator;
125 Iterator it = lagrangePointSet_.find( type );
126 if( it == lagrangePointSet_.end() )
127 it = lagrangePointSet_.insert( it, std::make_pair( type, new LagrangePointSetType( type, order ) ) );
128 assert( it->second != 0 );
129 return *(it->second);
130 }
131
132 private:
133 mutable LagrangePointSetMapType lagrangePointSet_;
134 };
135
136 } // namespace Fem
137
138} // namespace Dune
139
140#if __GNUC__ >= 13
141#pragma GCC diagnostic pop
142#endif
143
144#endif // #ifndef DUNE_FEM_SPACE_LAGRANGE_RESTRICTPROLONG_HH
Dune namespace.
Definition: alignedallocator.hh:13
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 25, 22:36, 2025)