Rheolef  7.2
an efficient C++ finite element environment
basis_raw.h
Go to the documentation of this file.
1 #ifndef _RHEO_BASIS_RAW_H
2 #define _RHEO_BASIS_RAW_H
23 #include "rheolef/reference_element.h"
24 #include "rheolef/point.h"
25 #include "rheolef/tensor.h"
26 #include "rheolef/smart_pointer.h"
27 #include "rheolef/space_constant.h"
28 #include "rheolef/compiler_eigen.h"
29 #include "rheolef/rheostream.h"
30 
31 namespace rheolef {
32 // ---------------------------------------------------
33 // rep
34 // ---------------------------------------------------
35 template<class T>
37 public:
39  typedef T value_type;
41 
42  basis_raw_rep (std::string name = "");
43  void reset (std::string& name);
44  virtual ~basis_raw_rep() {}
45 
46  // accessors:
47  virtual std::string family_name() const = 0;
48  virtual size_type degree() const { return _degree; }
49  std::string name() const { return family_name() + std::to_string(degree()); }
50  virtual size_type ndof (reference_element hat_K) const = 0;
51  virtual bool is_hierarchical() const { return false; }
52  virtual valued_type valued_tag() const { return space_constant::scalar; }
53  const std::string& valued() const { return space_constant::valued_name (valued_tag()); }
54 
55  // evaluate:
56  virtual void evaluate (
57  reference_element hat_K,
58  const point_basic<T>& hat_x,
59  Eigen::Matrix<T,Eigen::Dynamic,1>& value) const = 0;
60 
61  // evaluate the gradient:
62  virtual void grad_evaluate (
63  reference_element hat_K,
64  const point_basic<T>& hat_x,
65  Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& value) const = 0;
66 
67  void put (std::ostream& os, reference_element hat_K) const;
68 
69  static basis_raw_rep* make_ptr (std::string name);
70 
71 // internals:
72 
73  void _clear() const;
74 
75 protected:
76  void _initialize_guard (reference_element hat_K) const;
77  virtual void _initialize (reference_element hat_K) const = 0;
78 
79 // data:
81  mutable std::array<bool,
83 };
84 // ----------------------------------------------------------------------------
85 // inlined
86 // ----------------------------------------------------------------------------
87 template <class T>
88 inline
89 void
91 {
92  if (_have_initialize [hat_K.variant()]) return;
93  _have_initialize [hat_K.variant()] = true;
94  _initialize (hat_K);
95 }
96 template<class T>
97 inline
98 void
100 {
101  _have_initialize.fill (false);
102 }
103 // ---------------------------------------------------
104 // interface class
105 // ---------------------------------------------------
106 template<class T>
107 class basis_raw_basic : public smart_pointer<basis_raw_rep<T> > {
108 public:
109 
110 // typedefs:
111 
114  typedef typename rep::size_type size_type;
115  typedef typename rep::value_type value_type;
116  typedef typename rep::valued_type valued_type;
117 
118 // allocators:
119 
120  basis_raw_basic (std::string name = "");
121  void reset (std::string& name);
122 
123 // accessors:
124 
125  std::string family_name() const;
126  size_type degree() const;
127  std::string name() const;
128  size_type ndof (reference_element hat_K) const;
129  bool is_hierarchical() const;
130 
131  valued_type valued_tag() const;
132  const std::string& valued() const;
133 
134  void evaluate (
135  reference_element hat_K,
136  const point_basic<T>& hat_x,
137  Eigen::Matrix<T,Eigen::Dynamic,1>& value) const;
138 
139 // evaluate the gradient:
140 
141  void grad_evaluate (
142  reference_element hat_K,
143  const point_basic<T>& hat_x,
144  Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& value) const; // scalar-valued
145 
146 // output:
147 
148  void put (std::ostream& os, reference_element hat_K) const;
149 
150 protected:
151 // internals:
152 
153  void _clear() const;
154 };
155 typedef basis_raw_basic<Float> basis_raw;
156 //>basis:
157 // -----------------------------------------------------------
158 // inlined
159 // -----------------------------------------------------------
160 template<class T>
161 inline
163  : base()
164 {
165  reset (name);
166 }
167 template<class T>
168 inline
169 void
171 {
172  return base::data()._clear();
173 }
174 template<class T>
175 inline
176 std::string
178 {
179  return base::data().family_name();
180 }
181 template<class T>
182 inline
185 {
186  return base::data().degree();
187 }
188 template<class T>
189 inline
190 std::string
192 {
193  return base::data().name();
194 }
195 template<class T>
196 inline
199 {
200  return base::data().ndof (hat_K);
201 }
202 template<class T>
203 inline
204 bool
206 {
207  return base::data().is_hierarchical();
208 }
209 template<class T>
210 inline
213 {
214  return base::data().valued_tag();
215 }
216 template<class T>
217 inline
218 const std::string&
220 {
221  return base::data().valued();
222 }
223 template<class T>
224 inline
225 void
227  reference_element hat_K,
228  const point_basic<T>& hat_x,
229  Eigen::Matrix<T,Eigen::Dynamic,1>& value) const
230 {
231  return base::data().evaluate (hat_K, hat_x, value);
232 }
233 template<class T>
234 inline
235 void
237  reference_element hat_K,
238  const point_basic<T>& hat_x,
239  Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& value) const
240 {
241  base::data().grad_evaluate (hat_K, hat_x, value);
242 }
243 template<class T>
244 inline
245 void
246 basis_raw_basic<T>::put (std::ostream& os, reference_element hat_K) const
247 {
248  base::data().put (os, hat_K);
249 }
250 
251 }// namespace rheolef
252 #endif // _RHEO_BASIS_RAW_H
std::string name() const
Definition: basis_raw.h:191
valued_type valued_tag() const
Definition: basis_raw.h:212
rep::value_type value_type
Definition: basis_raw.h:115
size_type ndof(reference_element hat_K) const
Definition: basis_raw.h:198
void evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< T, Eigen::Dynamic, 1 > &value) const
Definition: basis_raw.h:226
rep::valued_type valued_type
Definition: basis_raw.h:116
smart_pointer< rep > base
Definition: basis_raw.h:113
void grad_evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &value) const
Definition: basis_raw.h:236
size_type degree() const
Definition: basis_raw.h:184
void put(std::ostream &os, reference_element hat_K) const
Definition: basis_raw.h:246
bool is_hierarchical() const
Definition: basis_raw.h:205
rep::size_type size_type
Definition: basis_raw.h:114
const std::string & valued() const
Definition: basis_raw.h:219
std::string family_name() const
Definition: basis_raw.h:177
basis_raw_rep< T > rep
Definition: basis_raw.h:112
basis_raw_basic(std::string name="")
Definition: basis_raw.h:162
void reset(std::string &name)
Definition: basis_get.cc:150
std::array< bool, reference_element::max_variant > _have_initialize
Definition: basis_raw.h:82
virtual size_type ndof(reference_element hat_K) const =0
virtual std::string family_name() const =0
std::string name() const
Definition: basis_raw.h:49
virtual valued_type valued_tag() const
Definition: basis_raw.h:52
virtual size_type degree() const
Definition: basis_raw.h:48
reference_element::size_type size_type
Definition: basis_raw.h:38
const std::string & valued() const
Definition: basis_raw.h:53
space_constant::valued_type valued_type
Definition: basis_raw.h:40
static basis_raw_rep * make_ptr(std::string name)
virtual void grad_evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &value) const =0
basis_raw_rep(std::string name="")
Definition: basis_raw.cc:30
virtual void evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< T, Eigen::Dynamic, 1 > &value) const =0
virtual ~basis_raw_rep()
Definition: basis_raw.h:44
virtual bool is_hierarchical() const
Definition: basis_raw.h:51
void put(std::ostream &os, reference_element hat_K) const
void reset(std::string &name)
void _clear() const
Definition: basis_raw.h:99
void _initialize_guard(reference_element hat_K) const
Definition: basis_raw.h:90
virtual void _initialize(reference_element hat_K) const =0
see the reference_element page for the full documentation
static const variant_type max_variant
variant_type variant() const
std::vector< int >::size_type size_type
see the smart_pointer page for the full documentation
rheolef::std value
basis_raw_basic< Float > basis_raw
Definition: basis_raw.h:155
Expr1::float_type T
Definition: field_expr.h:230
const std::string & valued_name(valued_type valued_tag)
This file is part of Rheolef.