DUNE-FEM (unstable)

restrictprolong.hh
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>
10
11// dune-fem includes
12#include <dune/fem/gridpart/leafgridpart.hh>
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 >
25 struct LagrangeLocalRestrictProlong
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
34 typedef LagrangePointSet< LeafGridPart< GridType >, ord > LagrangePointSetType;
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:
43 ~LagrangeLocalRestrictProlong ()
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
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  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)