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 
16 namespace 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:
62  Orders();
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 
94 namespace std {
95 
96  template<int number>
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 {
110  const concepts::Orders<number>& y) const {
111  return x == y;
112  }
113  };
114 } // namespace std
115 
116 namespace 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 
207  protected:
208  virtual std::ostream& info(std::ostream& os) const;
209  private:
212 
217  static typename std::unordered_map<Orders<type>, Real*,
218  std::hash<Orders<type> >,
220 
222  bool cache_;
223  };
224 
225 
226 
227 
228 
229 
230 
231 } // namespace concepts
232 
233 #endif // karniadakis_hh
bool operator<(const Orders< number > &o) const
< operator
Definition: karniadakis.hh:82
Karniadakis(const Karniadakis< type, mode > &arg)
Copy constructor.
size_t hash_value(const concepts::Index &i)
Computes a hash for i.
int p_[number]
Polynomial orders.
Definition: karniadakis.hh:89
int p(const uint i) const
Returns ith polynomial degree.
Definition: karniadakis.hh:68
static void clearCache()
Definition: karniadakis.hh:204
Orders()
Default constructor.
Orders(const int p0, const int P, const int p1=0, const int p2=0)
Constructor.
Karniadakis(const int P, const Real *xP, const int NxP, const int Q=0, const int R=0, const bool cache=true)
Constructor.
bool operator==(const Orders< number > &o) const
Equality operator.
Definition: karniadakis.hh:74
bool operator()(const concepts::Orders< number > &x, const concepts::Orders< number > &y) const
Definition: karniadakis.hh:109
concepts::Real arg(const concepts::Point< concepts::Real, 2 > &p)
Returns the phase angle of a real 2D vector.
Class combining polynomial order and number of quadrature points.
Definition: karniadakis.hh:40
size_t operator()(const concepts::Orders< number > &o) const
Definition: karniadakis.hh:101
Class containing number of quadrature points.
Definition: karniadakis.hh:24
Karniadakis(const int P, int NxP, const Real *values, const int Q=0, const int R=0)
Value copy constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
std::ostream & operator<<(std::ostream &os, const Level< dim > &c)
Name traits for number types.
Definition: typedefs.hh:68
Key equal function class.
Definition: karniadakis.hh:108
int P_
Number of quadrature points.
Definition: karniadakis.hh:36
const Real * values() const
Returns the values of the shape functions.
OrdersBase()
Default constructor.
Definition: karniadakis.hh:27
static std::unordered_map< Orders< type >, Real *, std::hash< Orders< type > >, std::OrdersEqual< type > > principal_H
Hash of the already computed values of the principal function of this type.
Definition: karniadakis.hh:219
OrdersBase(const int P)
Constructor.
Definition: karniadakis.hh:30
Orders< type > orders_
Combines polynomial degrees and number of quadrature points.
Definition: karniadakis.hh:211
bool cache_
Cache the results of the computations in principal_H if set to true.
Definition: karniadakis.hh:222
Abstract class for 1D shape function.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
int P() const
Returns number of quadrature points.
Definition: karniadakis.hh:33
Part of the multidimensional expansion bases for the shape functions of Karniadakis and Sherwin.
Definition: karniadakis.hh:163
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich