Class documentation of Concepts

Loading...
Searching...
No Matches
karniadakis.hh
Go to the documentation of this file.
1
8#ifndef karniadakis_hh
9#define karniadakis_hh
10
11#include <iostream>
12#include "toolbox/hashMap.hh"
13#include "basics/typedefs.hh"
14#include "shapefunction.hh"
15
16namespace concepts {
17
18 // **************************************************************** Orders **
19
24 class OrdersBase {
25 public:
27 OrdersBase() : P_(0) {}
28
30 OrdersBase(const int P) : P_(P) {}
31
33 inline int P() const { return P_; }
34 protected:
36 int P_;
37 };
38
39 template<int number>
40 class Orders;
41
42 template<int number>
43 std::ostream& operator<< (std::ostream& os, const Orders<number>& o) {
44 for (unsigned int i = 0; i < number; ++i) {
45 os << "p(" << i << ") = " << o.p_[i] << ", ";
46 }
47 os << "P = " << o.P_;
48 return os;
49 }
50
56 template<int number>
57 class Orders : public OrdersBase {
58 friend std::ostream& operator<< <>(std::ostream& os,
59 const Orders<number>& o);
60 public:
63
65 Orders(const int p0, const int P, const int p1 = 0, const int p2 = 0);
66
68 inline int p(const uint i) const {
69 if (i < number) return p_[i];
70 else return 0;
71 }
72
74 inline bool operator==(const Orders<number>& o) const {
75 bool equal = true && (P_ == o.P_);
76 for (uint i = 0; i < number; ++i)
77 equal &= (p_[i] == o.p_[i]);
78 return equal;
79 }
80
82 inline bool operator<(const Orders<number>& o) const {
83 for (uint i = 0; i < number; ++i)
84 if (p_[i] < o.p_[i]) return true;
85 return false;
86 }
87 private:
89 int p_[number];
90 };
91
92} // namespace concepts
93
94namespace std {
95
96 template<int number>
97 size_t hash_value(const concepts::Orders<number>& o);
98
99 template<int number>
100 struct hash<concepts::Orders<number> > {
101 size_t operator()(const concepts::Orders<number>& o) const {
102 return hash_value(o);
103 }
104 };
105
107 template<int number>
108 struct OrdersEqual {
109 bool operator()(const concepts::Orders<number>& x,
110 const concepts::Orders<number>& y) const {
111 return x == y;
112 }
113 };
114} // namespace std
115
116namespace concepts {
117
118 // *********************************************************** Karniadakis **
119
162 template<int type, int mode>
163 class Karniadakis : public ShapeFunction1D<Real> {
164 public:
179 Karniadakis(const int P, const Real* xP, const int NxP,
180 const int Q = 0, const int R = 0, const bool cache = true);
181
182
183
196 Karniadakis(const int P, int NxP, const Real* values,
197 const int Q = 0, const int R = 0);
198
199
200
201
204 static void clearCache() { principal_H.clear(); }
205
206 ~Karniadakis();
207 protected:
208 virtual std::ostream& info(std::ostream& os) const;
209 private:
211 Orders<type> orders_;
212
217 static typename std::unordered_map<Orders<type>, Real*,
218 std::hash<Orders<type> >,
219 std::OrdersEqual<type> > principal_H;
220
222 bool cache_;
223 };
224
225
226
227
228
229
230
231} // namespace concepts
232
233#endif // karniadakis_hh
Karniadakis(const int P, const Real *xP, const int NxP, const int Q=0, const int R=0, const bool cache=true)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Karniadakis(const Karniadakis< type, mode > &arg)
Copy constructor.
Karniadakis(const int P, int NxP, const Real *values, const int Q=0, const int R=0)
OrdersBase()
Default constructor.
int P_
Number of quadrature points.
int P() const
Returns number of quadrature points.
OrdersBase(const int P)
Constructor.
int p(const uint i) const
Returns ith polynomial degree.
bool operator<(const Orders< number > &o) const
< operator
Orders(const int p0, const int P, const int p1=0, const int p2=0)
Constructor.
bool operator==(const Orders< number > &o) const
Equality operator.
Orders()
Default constructor.
const Real * values() const
Returns the values of the shape functions.
size_t hash_value(const concepts::Index &i)
Computes a hash for i.
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320