rheolef  7.0
form.h
Go to the documentation of this file.
1 # ifndef _RHEOLEF_FORM_H
2 # define _RHEOLEF_FORM_H
3 
4 #include "rheolef/csr.h"
5 #include "rheolef/field.h"
6 #include "rheolef/quadrature.h"
7 #include "rheolef/integrate_option.h"
8 namespace rheolef {
9 
10 template <class T, class M> class form_concat_value;
11 template <class T, class M> class form_concat_line;
12 
13 template <class T, class M> class band_basic;
14 
97 template<class T, class M>
98 class form_basic {
99 public :
100 
101  typedef typename csr<T,M>::size_type size_type;
102  typedef T value_type;
106 
107 // allocator/deallocator:
108 
109  form_basic ();
110  form_basic (const form_basic<T,M>&);
112 
113 
114 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
115  form_basic (const std::initializer_list<form_concat_value<T,M> >& init_list);
116  form_basic (const std::initializer_list<form_concat_line <T,M> >& init_list);
117 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
118 
119 
120  const space_type& get_first_space() const;
121  const space_type& get_second_space() const;
122  const geo_type& get_geo() const;
123 
124  const communicator& comm() const;
125 
126 
130  form_basic<T,M>& operator*= (const T& lambda);
132  field_basic<T,M> trans_mult (const field_basic<T,M>& yh) const;
133  float_type operator () (const field_basic<T,M>& uh, const field_basic<T,M>& vh) const;
134 
135 
136  odiststream& put (odiststream& ops, bool show_partition = true) const;
137  void dump (std::string name) const;
138 
139 
140  const csr<T,M>& uu() const { return _uu; }
141  const csr<T,M>& ub() const { return _ub; }
142  const csr<T,M>& bu() const { return _bu; }
143  const csr<T,M>& bb() const { return _bb; }
144  csr<T,M>& set_uu() { return _uu; }
145  csr<T,M>& set_ub() { return _ub; }
146  csr<T,M>& set_bu() { return _bu; }
147  csr<T,M>& set_bb() { return _bb; }
148 
149 protected:
150  space_type _X;
151  space_type _Y;
156 
157 public:
158  template <class Expr>
159  void assembly_internal (
160  const geo_basic<T,M>& dom,
161  const geo_basic<T,M>& band,
162  const band_basic<T,M>& gh,
163  const Expr& expr,
164  const integrate_option& fopt,
165  bool is_on_band);
166  template <class Expr>
167  void assembly (
168  const geo_basic<T,M>& domain,
169  const Expr& expr,
170  const integrate_option& fopt);
171  template <class Expr>
172  void assembly (
173  const band_basic<T,M>& gh,
174  const Expr& expr,
175  const integrate_option& fopt);
176 
177  form_basic (const space_type& X, const space_type& Y,
178  const std::string& name = "",
179  const quadrature_option& qopt = quadrature_option());
180 
181  form_basic (const space_type& X, const space_type& Y,
182  const std::string& name,
183  const field_basic<T,M>& weight,
184  const quadrature_option& qopt = quadrature_option());
185 
186  template<class Function>
187  form_basic (const space_type& X, const space_type& Y,
188  const std::string& name,
189  Function weight,
190  const quadrature_option& qopt = quadrature_option());
191 
192  form_basic (const space_type& X, const space_type& Y,
193  const std::string& name,
194  const geo_basic<T,M>& gamma,
195  const quadrature_option& qopt = quadrature_option());
196 
197  form_basic (const space_type& X, const space_type& Y,
198  const std::string& name,
199  const geo_basic<T,M>& gamma,
200  const field_basic<T,M>& weight,
201  const quadrature_option& qopt = quadrature_option());
202 
203  template<class Function>
204  form_basic (
205  const space_type& X,
206  const space_type& Y,
207  const std::string& name,
208  const geo_basic<T,M>& gamma,
209  Function weight,
210  const quadrature_option& qopt = quadrature_option());
211 protected:
212  template<class WeightFunction>
213  void form_init (
214  const std::string& name,
215  bool has_weight,
216  WeightFunction weight,
217  const quadrature_option& qopt);
218  template<class WeightFunction>
219  void form_init_on_domain (
220  const std::string& name,
221  const geo_basic<T,M>& gamma,
222  bool has_weight,
223  WeightFunction weight,
224  const geo_basic<T,M>& w_omega, // the domain where the fct weight is defined
225  const quadrature_option& qopt);
226 };
227 template<class T, class M> form_basic<T,M> trans (const form_basic<T,M>& a);
228 template<class T, class M> field_basic<T,M> diag (const form_basic<T,M>& a);
229 template<class T, class M> form_basic<T,M> diag (const field_basic<T,M>& dh);
231 @endcode
232 
233 
234 template<class T, class M>
235 inline
237 : _X(), _Y(), _uu(), _ub(), _bu(), _bb()
238 {
239 }
240 template<class T, class M>
241 inline
243 : _X(a._X), _Y(a._Y), _uu(a._uu), _ub(a._ub), _bu(a._bu), _bb(a._bb)
244 {
245 }
246 template<class T, class M>
247 inline
250 {
251  _X.operator= (a._X);
252  _Y.operator= (a._Y);
253  _uu.operator= (a._uu);
254  _ub.operator= (a._ub);
255  _bu.operator= (a._bu);
256  _bb.operator= (a._bb);
257  return *this;
258 }
259 template<class T, class M>
260 inline
261 const typename form_basic<T,M>::space_type&
263 {
264  return _X;
265 }
266 template<class T, class M>
267 inline
268 const typename form_basic<T,M>::space_type&
270 {
271  return _Y;
272 }
273 template<class T, class M>
274 inline
275 const typename form_basic<T,M>::geo_type&
277 {
278  return _X.get_geo();
279 }
280 template<class T, class M>
281 inline
282 const communicator&
284 {
285  return get_geo().comm();
286 }
287 template<class T, class M>
288 inline
291 {
293  c._uu = _uu + b._uu;
294  c._ub = _ub + b._ub;
295  c._bu = _bu + b._bu;
296  c._bb = _bb + b._bb;
297  return c;
298 }
299 template<class T, class M>
300 inline
303 {
305  c._uu = _uu - b._uu;
306  c._ub = _ub - b._ub;
307  c._bu = _bu - b._bu;
308  c._bb = _bb - b._bb;
309  return c;
310 }
311 template<class T, class M>
312 inline
315 {
317  c._uu = _uu*b._uu + _ub*b._bu;
318  c._ub = _uu*b._ub + _ub*b._bb;
319  c._bu = _bu*b._uu + _bb*b._bu;
320  c._bb = _bu*b._ub + _bb*b._bb;
321  return c;
322 }
323 template<class T, class M>
324 inline
327 {
328  _uu *= lambda;
329  _ub *= lambda;
330  _bu *= lambda;
331  _bb *= lambda;
332  return *this;
333 }
334 template<class T, class M>
335 inline
337 operator* (const T& lambda, const form_basic<T,M>& a)
338 {
339  form_basic<T,M> b = a;
340  b *= lambda;
341  return b;
342 }
343 template<class T, class M>
344 inline
347 {
348  return T(-1)*a;
349 }
350 
351 }// namespace rheolef
352 # endif /* _RHEOLEF_FORM_H */
band - compute the band around a level set
Definition: band.h:45
field - piecewise polynomial finite element field
csr< T, M > & set_uu()
Definition: form.h:144
scalar_traits< T >::type float_type
Definition: form.h:103
const csr< T, M > & bu() const
Definition: form.h:142
csr< T, M >::size_type size_type
Definition: form.h:101
odiststream & put(odiststream &ops, bool show_partition=true) const
Definition: form.cc:191
idiststream, odiststream - distributed interface for large data streams
Definition: diststream.h:68
form_basic< Float, rheo_default_memory_model > form
Definition: form.h:230
field_basic< T, M > xh
form_basic< T, M > operator+(const form_basic< T, M > &b) const
Definition: form.h:290
quadrature_option - send options to the integrate function
form_basic< T, M > & operator*=(const T &lambda)
Definition: form.h:326
void form_init(const std::string &name, bool has_weight, WeightFunction weight, const quadrature_option &qopt)
csr< T, M > _bu
Definition: form.h:154
irheostream, orheostream - large data streams
Definition: compiler.h:7
void assembly(const geo_basic< T, M > &domain, const Expr &expr, const integrate_option &fopt)
csr< T, M > diag(const vec< T, M > &d)
Definition: csr.cc:33
field_basic< T, M > trans_mult(const field_basic< T, M > &yh) const
Definition: form.cc:96
csr< T, M > _bb
Definition: form.h:155
space_basic< float_type, M > space_type
Definition: form.h:105
csr< T, M > _ub
Definition: form.h:153
void dump(std::string name) const
Definition: form.cc:217
space_type _X
Definition: form.h:150
rheolef::std Function
space_type _Y
Definition: form.h:151
const csr< T, M > & ub() const
Definition: form.h:141
csr< T, M > & set_ub()
Definition: form.h:145
void form_init_on_domain(const std::string &name, const geo_basic< T, M > &gamma, bool has_weight, WeightFunction weight, const geo_basic< T, M > &w_omega, const quadrature_option &qopt)
geo_basic< float_type, M > geo_type
Definition: form.h:104
const csr< T, M > & uu() const
Definition: form.h:140
const communicator & comm() const
Definition: form.h:283
form_basic< T, M > & operator=(const form_basic< T, M > &)
Definition: form.h:249
const space_type & get_second_space() const
Definition: form.h:269
const csr< T, M > & bb() const
Definition: form.h:143
form - representation of a finite element bilinear form
Definition: form.h:98
csr< T, sequential > trans(const csr< T, sequential > &a)
Definition: csr.h:381
csr< T, M > & set_bb()
Definition: form.h:147
form_basic< T, M > operator-(const form_basic< T, M > &b) const
Definition: form.h:302
float_type operator()(const field_basic< T, M > &uh, const field_basic< T, M > &vh) const
Definition: form.cc:105
csr< T, M > _uu
Definition: form.h:152
form_basic< T, M > operator*(const form_basic< T, M > &b) const
Definition: form.h:314
void assembly_internal(const geo_basic< T, M > &dom, const geo_basic< T, M > &band, const band_basic< T, M > &gh, const Expr &expr, const integrate_option &fopt, bool is_on_band)
const space_type & get_first_space() const
Definition: form.h:262
csr< T, M > & set_bu()
Definition: form.h:146
const geo_type & get_geo() const
Definition: form.h:276
csr - compressed sparse row matrix
Definition: asr.h:8
integrate_option - send options to the integrate function