rheolef  6.3
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/form_element.h"
7 #include "rheolef/quadrature.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>&);
111 
112  form_basic (const space_type& X, const space_type& Y,
113  const std::string& name = "",
115 
116  form_basic (const space_type& X, const space_type& Y,
117  const std::string& name,
118  const field_basic<T,M>& weight,
120 
121  form_basic (const space_type& X, const space_type& Y,
122  const std::string& name,
123  const band_basic<T,M>& bh,
125 
126  template<class Function>
127  form_basic (const space_type& X, const space_type& Y,
128  const std::string& name,
129  Function weight,
131 
132  form_basic (const space_type& X, const space_type& Y,
133  const std::string& name,
134  const geo_basic<T,M>& gamma,
136 
137  form_basic (const space_type& X, const space_type& Y,
138  const std::string& name,
139  const geo_basic<T,M>& gamma,
140  const field_basic<T,M>& weight,
142 
143  template<class Function>
144  form_basic (
145  const space_type& X,
146  const space_type& Y,
147  const std::string& name,
148  const geo_basic<T,M>& gamma,
149  Function weight,
151 
152 
153 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
154  form_basic (const std::initializer_list<form_concat_value<T,M> >& init_list);
155  form_basic (const std::initializer_list<form_concat_line <T,M> >& init_list);
156 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
157 
158 
159  const space_type& get_first_space() const;
160  const space_type& get_second_space() const;
161  const geo_type& get_geo() const;
162 
163  const communicator& comm() const;
164 
165 
169  form_basic<T,M>& operator*= (const T& lambda);
171  field_basic<T,M> trans_mult (const field_basic<T,M>& yh) const;
172  float_type operator () (const field_basic<T,M>& uh, const field_basic<T,M>& vh) const;
173 
174 
175  odiststream& put (odiststream& ops, bool show_partition = true) const;
176  void dump (std::string name) const;
177 
178 
179  const csr<T,M>& uu() const { return _uu; }
180  const csr<T,M>& ub() const { return _ub; }
181  const csr<T,M>& bu() const { return _bu; }
182  const csr<T,M>& bb() const { return _bb; }
183  csr<T,M>& set_uu() { return _uu; }
184  csr<T,M>& set_ub() { return _ub; }
185  csr<T,M>& set_bu() { return _bu; }
186  csr<T,M>& set_bb() { return _bb; }
187 
188 protected:
195 
196  void assembly (const form_element<T,M>& form_e,
197  const geo_basic<T,M>& X_geo,
198  const geo_basic<T,M>& Y_geo,
199  bool X_geo_is_background = true);
200 
201  template<class WeightFunction>
202  void form_init (
203  const std::string& name,
204  bool has_weight,
205  WeightFunction weight,
206  const quadrature_option_type& qopt);
207  template<class WeightFunction>
208  void form_init_on_domain (
209  const std::string& name,
210  const geo_basic<T,M>& gamma,
211  bool has_weight,
212  WeightFunction weight,
213  const geo_basic<T,M>& w_omega, // the domain where the fct weight is defined
214  const quadrature_option_type& qopt);
215 };
216 template<class T, class M> form_basic<T,M> trans (const form_basic<T,M>& a);
217 template<class T, class M> field_basic<T,M> diag (const form_basic<T,M>& a);
218 template<class T, class M> form_basic<T,M> diag (const field_basic<T,M>& dh);
220 @endcode
221 
222 
223 template<class T, class M>
224 inline
226 : _X(), _Y(), _uu(), _ub(), _bu(), _bb()
227 {
228 }
229 template<class T, class M>
230 inline
232 : _X(a._X), _Y(a._Y), _uu(a._uu), _ub(a._ub), _bu(a._bu), _bb(a._bb)
233 {
234 }
235 template<class T, class M>
236 inline
237 const typename form_basic<T,M>::space_type&
239 {
240  return _X;
241 }
242 template<class T, class M>
243 inline
244 const typename form_basic<T,M>::space_type&
246 {
247  return _Y;
248 }
249 template<class T, class M>
250 inline
251 const typename form_basic<T,M>::geo_type&
253 {
254  return _X.get_geo();
255 }
256 template<class T, class M>
257 inline
258 const communicator&
260 {
261  return get_geo().comm();
262 }
263 template<class T, class M>
264 inline
267 {
268  form_basic<T,M> c (get_first_space(), get_second_space());
269  c._uu = _uu + b._uu;
270  c._ub = _ub + b._ub;
271  c._bu = _bu + b._bu;
272  c._bb = _bb + b._bb;
273  return c;
274 }
275 template<class T, class M>
276 inline
279 {
280  form_basic<T,M> c (get_first_space(), get_second_space());
281  c._uu = _uu - b._uu;
282  c._ub = _ub - b._ub;
283  c._bu = _bu - b._bu;
284  c._bb = _bb - b._bb;
285  return c;
286 }
287 template<class T, class M>
288 inline
291 {
292  form_basic<T,M> c (b.get_first_space(), get_second_space());
293  c._uu = _uu*b._uu + _ub*b._bu;
294  c._ub = _uu*b._ub + _ub*b._bb;
295  c._bu = _bu*b._uu + _bb*b._bu;
296  c._bb = _bu*b._ub + _bb*b._bb;
297  return c;
298 }
299 template<class T, class M>
300 inline
303 {
304  _uu *= lambda;
305  _ub *= lambda;
306  _bu *= lambda;
307  _bb *= lambda;
308  return *this;
309 }
310 template<class T, class M>
311 inline
313 operator* (const T& lambda, const form_basic<T,M>& a)
314 {
315  form_basic<T,M> b = a;
316  b *= lambda;
317  return b;
318 }
319 template<class T, class M>
320 inline
321 form_basic<T,M>
323 {
324  return T(-1)*a;
325 }
326 
327 }// namespace rheolef
328 # endif /* _RHEOLEF_FORM_H */
329