DUNE-FEM (unstable)

pointprovider.hh
1#ifndef DUNE_FEM_POINTPROVIDER_HH
2#define DUNE_FEM_POINTPROVIDER_HH
3
4//- System includes
5#include <vector>
6#include <map>
7#include <unordered_map>
8
9//- Dune includes
10#include <dune/common/math.hh>
11
12#include <dune/fem/storage/singleton.hh>
13
14//- Local includes
15#include "pointmapper.hh"
16
17namespace Dune
18{
19
20 namespace Fem
21 {
22
23 template< class ct, int dim, int codim >
24 class PointProvider
25 {
26 static_assert( (codim >= 0) && (codim <= 1),
27 "PointProvider exists only for codimension 0 and 1." );
28 };
29
30 template <class ct, int dim>
31 class PointProvider<ct, dim, 0>
32 {
33 typedef PointProvider<ct, dim, 0> ThisType;
34
35 typedef CachingTraits<ct, dim> Traits;
36
37 public:
38 typedef typename Traits::QuadratureType QuadratureType;
39 typedef typename Traits::PointVectorType GlobalPointVectorType;
40 typedef typename Traits::QuadratureKeyType QuadratureKeyType;
41
42 public:
43 inline
44 static void registerQuadrature(const QuadratureType& quad)
45 {
46 instance().registerQuadratureImpl( quad );
47 }
48
49 inline
50 static const GlobalPointVectorType& getPoints(const size_t id,
51 const GeometryType& elementGeo)
52 {
53 return instance().getPointsImpl( id, elementGeo );
54 }
55
56 PointProvider() : threadPool_( MPIManager::threadPool() ), points_() {}
57
58 private:
59 PointProvider( const PointProvider& ) = delete;
60
61 inline void registerQuadratureImpl(const QuadratureType& quad);
62
63 inline const GlobalPointVectorType& getPointsImpl(const size_t id,
64 const GeometryType& elementGeo);
65
66 typedef std::unordered_map<QuadratureKeyType, GlobalPointVectorType> PointContainerType;
67 typedef typename PointContainerType::iterator PointIteratorType;
68
69 // points container holding quadrature points
70 const typename MPIManager::ThreadPoolType& threadPool_;
71 PointContainerType points_;
72
73 static ThisType& instance()
74 {
76 }
77 };
78
79 // * Add elemGeo later
80 template <class ct, int dim>
81 class PointProvider<ct, dim, 1>
82 {
83 typedef PointProvider<ct, dim, 1> ThisType;
84
85 enum { codim = 1 };
86 typedef CachingTraits<ct, dim-codim> Traits;
87
88 public:
89 typedef typename Traits::QuadratureType QuadratureType;
90 typedef typename Traits::PointType LocalPointType;
91 typedef typename Traits::PointVectorType LocalPointVectorType;
92 typedef typename Traits::MapperType MapperType;
93 typedef typename Traits::MapperVectorType MapperVectorType;
94 typedef FieldVector<ct, dim> GlobalPointType;
95 typedef std::vector<GlobalPointType> GlobalPointVectorType;
96 typedef typename Traits::QuadratureKeyType QuadratureKeyType;
97 typedef std::pair< MapperVectorType, MapperVectorType > MapperVectorPairType;
98
99 private:
100 typedef std::map<const QuadratureKeyType, GlobalPointVectorType> PointContainerType;
101 typedef std::map<const QuadratureKeyType, MapperVectorPairType > MapperContainerType;
102
103 typedef typename PointContainerType::iterator PointIteratorType;
104 typedef typename MapperContainerType::iterator MapperIteratorType;
105
106 public:
107 inline
108 static const MapperVectorPairType& getMappers(const QuadratureType& quad,
109 const GeometryType& elementGeo)
110 {
111 return instance().getMappersImpl( quad, elementGeo );
112 }
113
114 // Access for non-symmetric quadratures
115 inline
116 static const MapperVectorPairType& getMappers(const QuadratureType& quad,
117 const LocalPointVectorType& pts,
118 const GeometryType& elementGeo)
119 {
120 return instance().getMappersImpl( quad, pts, elementGeo );
121 }
122
123 inline
124 static const GlobalPointVectorType& getPoints(const size_t id,
125 const GeometryType& elementGeo)
126 {
127 return instance().getPointsImpl( id, elementGeo );
128 }
129
130 inline
131 const GlobalPointVectorType& getPointsImpl(const size_t id,
132 const GeometryType& elementGeo);
133
134 inline const MapperVectorPairType& getMappersImpl(const QuadratureType& quad,
135 const GeometryType&
136 elementGeo);
137
138 inline
139 const MapperVectorPairType& getMappersImpl(const QuadratureType& quad,
140 const LocalPointVectorType& pts,
141 const GeometryType& elementGeo);
142
143 private:
144 inline
145 static MapperIteratorType addEntry(const QuadratureType& quad,
146 const LocalPointVectorType& pts,
147 GeometryType elementGeo)
148 {
149 instance().addEntryImpl(quad, pts, elementGeo);
150 }
151
152 inline
153 MapperIteratorType addEntryImpl(const QuadratureType& quad,
154 const LocalPointVectorType& pts,
155 GeometryType elementGeo);
156
157 private:
158 const typename MPIManager::ThreadPoolType& threadPool_;
159 // points container holding quadrature points
160 PointContainerType points_;
161 // mapper container holding mapping info
162 MapperContainerType mappers_;
163
164 PointProvider( const PointProvider& ) = delete;
165 public:
166 // this should only be called from the Singleton class
167 PointProvider() : threadPool_( MPIManager::threadPool() ), points_(), mappers_() {}
168
169 static ThisType& instance()
170 {
172 }
173 };
174
175 } // namespace Fem
176
177} // namespace Dune
178
179#include "pointprovider.cc"
180
181#endif // #ifndef DUNE_FEM_POINTPROVIDER_HH
static DUNE_EXPORT Object & instance(Args &&... args)
return singleton instance of given Object type.
Definition: singleton.hh:123
Some useful basic math stuff.
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)