Rheolef  7.1
an efficient C++ finite element environment
form.h
Go to the documentation of this file.
1 # ifndef _RHEOLEF_FORM_H
2 # define _RHEOLEF_FORM_H
3 //
4 // This file is part of Rheolef.
5 //
6 // Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7 //
8 // Rheolef is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Rheolef is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Rheolef; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //
22 // =========================================================================
23 // AUTHOR: Pierre.Saramito@imag.fr
24 // DATE: 2 july 1997
25 
26 namespace rheolef {
124 } // namespace rheolef
125 
126 #include "rheolef/csr.h"
127 #include "rheolef/field.h"
128 #include "rheolef/quadrature.h"
129 #include "rheolef/integrate_option.h"
130 namespace rheolef {
131 
132 namespace details {
133 // these classes are used for allocator from the std::initializer_list
134 template <class T, class M> class form_concat_value;
135 template <class T, class M> class form_concat_line;
136 } // namespace details
137 
138 // forward declaration:
139 template <class T, class M> class band_basic;
140 
141 
142 // [verbatim_form_basic]
143 template<class T, class M>
144 class form_basic {
145 public :
146 // typedefs:
147 
148  typedef typename csr<T,M>::size_type size_type;
149  typedef T value_type;
153 
154 // allocator/deallocator:
155 
156  form_basic ();
157  form_basic (const form_basic<T,M>&);
159 
160 // allocators from initializer list (c++ 2011):
161 
162  form_basic (const std::initializer_list<details::form_concat_value<T,M> >& init_list);
163  form_basic (const std::initializer_list<details::form_concat_line <T,M> >& init_list);
164 
165 // accessors:
166 
167  const space_type& get_first_space() const;
168  const space_type& get_second_space() const;
169  const geo_type& get_geo() const;
170  bool is_symmetric() const;
171  void set_symmetry (bool is_symm) const;
172 
173  const communicator& comm() const;
174 
175 // linear algebra:
176 
182  field_basic<T,M> trans_mult (const field_basic<T,M>& yh) const;
183  float_type operator () (const field_basic<T,M>& uh, const field_basic<T,M>& vh) const;
184 
185 // io:
186 
187  odiststream& put (odiststream& ops, bool show_partition = true) const;
188  void dump (std::string name) const;
189 
190 // accessors & modifiers to unknown & blocked parts:
191 
192  const csr<T,M>& uu() const { return _uu; }
193  const csr<T,M>& ub() const { return _ub; }
194  const csr<T,M>& bu() const { return _bu; }
195  const csr<T,M>& bb() const { return _bb; }
196  csr<T,M>& set_uu() { return _uu; }
197  csr<T,M>& set_ub() { return _ub; }
198  csr<T,M>& set_bu() { return _bu; }
199  csr<T,M>& set_bb() { return _bb; }
200 // [verbatim_form_basic]
201 // internals:
202  int constraint_process_rank() const { return uu().constraint_process_rank(); }
203 // data
204 protected:
211 
212 // internals:
213 public:
214  // with vf expression arg
215  template <class Expr>
216  void assembly_internal (
217  const geo_basic<T,M>& dom,
218  const geo_basic<T,M>& band,
219  const band_basic<T,M>& gh,
220  const Expr& expr,
221  const integrate_option& fopt,
222  bool is_on_band);
223  template <class Expr>
224  void assembly (
225  const geo_basic<T,M>& domain,
226  const Expr& expr,
227  const integrate_option& fopt);
228  template <class Expr>
229  void assembly (
230  const band_basic<T,M>& gh,
231  const Expr& expr,
232  const integrate_option& fopt);
233 
234  // backward compat: named forms
235  form_basic (const space_type& X, const space_type& Y,
236  const std::string& name = "",
237  const quadrature_option& qopt = quadrature_option());
238 
239  form_basic (const space_type& X, const space_type& Y,
240  const std::string& name,
241  const field_basic<T,M>& weight,
242  const quadrature_option& qopt = quadrature_option());
243 
244  template<class Function>
245  form_basic (const space_type& X, const space_type& Y,
246  const std::string& name,
247  Function weight,
248  const quadrature_option& qopt = quadrature_option());
249 
250  form_basic (const space_type& X, const space_type& Y,
251  const std::string& name,
252  const geo_basic<T,M>& gamma,
253  const quadrature_option& qopt = quadrature_option());
254 
255  form_basic (const space_type& X, const space_type& Y,
256  const std::string& name,
257  const geo_basic<T,M>& gamma,
258  const field_basic<T,M>& weight,
259  const quadrature_option& qopt = quadrature_option());
260 
261  template<class Function>
262  form_basic (
263  const space_type& X,
264  const space_type& Y,
265  const std::string& name,
266  const geo_basic<T,M>& gamma,
267  Function weight,
268  const quadrature_option& qopt = quadrature_option());
269 protected:
270  // backward compat: named forms (cont.)
271  template<class WeightFunction>
272  void form_init (
273  const std::string& name,
274  bool has_weight,
275  WeightFunction weight,
276  const quadrature_option& qopt);
277  template<class WeightFunction>
278  void form_init_on_domain (
279  const std::string& name,
280  const geo_basic<T,M>& gamma,
281  bool has_weight,
282  WeightFunction weight,
283  const geo_basic<T,M>& w_omega, // the domain where the fct weight is defined
284  const quadrature_option& qopt);
285 // [verbatim_form_basic_cont]
286 };
287 template<class T, class M> form_basic<T,M> trans (const form_basic<T,M>& a);
288 template<class T, class M> field_basic<T,M> diag (const form_basic<T,M>& a);
289 template<class T, class M> form_basic<T,M> diag (const field_basic<T,M>& dh);
290 // [verbatim_form_basic_cont]
291 
292 // [verbatim_form]
294 // [verbatim_form]
295 
296 // ------------ inline'd -----------------------------------
297 
298 template<class T, class M>
299 inline
301 : _X(), _Y(), _uu(), _ub(), _bu(), _bb()
302 {
303 }
304 template<class T, class M>
305 inline
307 : _X(a._X), _Y(a._Y), _uu(a._uu), _ub(a._ub), _bu(a._bu), _bb(a._bb)
308 {
309 }
310 template<class T, class M>
311 inline
314 {
315  _X.operator= (a._X);
316  _Y.operator= (a._Y);
317  _uu.operator= (a._uu);
318  _ub.operator= (a._ub);
319  _bu.operator= (a._bu);
320  _bb.operator= (a._bb);
321  return *this;
322 }
323 template<class T, class M>
324 inline
325 const typename form_basic<T,M>::space_type&
327 {
328  return _X;
329 }
330 template<class T, class M>
331 inline
332 const typename form_basic<T,M>::space_type&
334 {
335  return _Y;
336 }
337 template<class T, class M>
338 inline
339 const typename form_basic<T,M>::geo_type&
341 {
342  return _X.get_geo();
343 }
344 template<class T, class M>
345 inline
346 const communicator&
348 {
349  return get_geo().comm();
350 }
351 // ----------------
352 // linear albebra
353 // ----------------
354 template<class T, class M>
355 inline
358 {
359  form_basic<T,M> c (get_first_space(), get_second_space());
360  c._uu = _uu + b._uu;
361  c._ub = _ub + b._ub;
362  c._bu = _bu + b._bu;
363  c._bb = _bb + b._bb;
364  return c;
365 }
366 template<class T, class M>
367 inline
370 {
371  form_basic<T,M> c (get_first_space(), get_second_space());
372  c._uu = _uu - b._uu;
373  c._ub = _ub - b._ub;
374  c._bu = _bu - b._bu;
375  c._bb = _bb - b._bb;
376  return c;
377 }
378 template<class T, class M>
379 inline
382 {
383  form_basic<T,M> c (b.get_first_space(), get_second_space());
384  c._uu = _uu*b._uu + _ub*b._bu;
385  c._ub = _uu*b._ub + _ub*b._bb;
386  c._bu = _bu*b._uu + _bb*b._bu;
387  c._bb = _bu*b._ub + _bb*b._bb;
388  return c;
389 }
390 template<class T, class M>
391 inline
394 {
395  _uu *= lambda;
396  _ub *= lambda;
397  _bu *= lambda;
398  _bb *= lambda;
399  return *this;
400 }
401 template<class T, class M>
402 inline
405 {
406  form_basic<T,M> b = a;
407  b *= lambda;
408  return b;
409 }
410 template<class T, class M>
411 inline
412 form_basic<T,M>
414 {
415  return T(-1)*a;
416 }
417 template<class T, class M>
418 inline
419 bool
421 {
422  return _uu.is_symmetric() && _bb.is_symmetric();
423 }
424 template<class T, class M>
425 inline
426 void
427 form_basic<T,M>::set_symmetry (bool is_symm) const
428 {
429  _uu.set_symmetry(is_symm);
430  _bb.set_symmetry(is_symm);
431 }
432 
433 }// namespace rheolef
434 # endif /* _RHEOLEF_FORM_H */
rheolef::geo_basic< float_type, M >
rheolef::domain
geo domain
Definition: geo_domain_indirect.h:58
rheolef::form_basic::_ub
csr< T, M > _ub
Definition: form.h:208
rheolef::form_basic::form_init_on_domain
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)
Definition: form_weighted.h:222
rheolef::form_basic::_bb
csr< T, M > _bb
Definition: form.h:210
rheolef::form_basic::operator*
form_basic< T, M > operator*(const form_basic< T, M > &b) const
Definition: form.h:381
gh
field gh(Float epsilon, Float t, const field &uh, const test &v)
Definition: burgers_diffusion_operators.icc:37
mkgeo_ball.expr
expr
Definition: mkgeo_ball.sh:361
rheolef::form_basic::space_type
space_basic< float_type, M > space_type
Definition: form.h:152
rheolef::form_basic::ub
const csr< T, M > & ub() const
Definition: form.h:193
rheolef::diag
csr< T, M > diag(const vec< T, M > &d)
Definition: csr.cc:56
rheolef::form_basic::bb
const csr< T, M > & bb() const
Definition: form.h:195
rheolef::form_basic::bu
const csr< T, M > & bu() const
Definition: form.h:194
rheolef::operator*
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition: csr.h:437
rheolef::space_basic< float_type, M >
band
see the band page for the full documentation
rheolef::form_basic::uu
const csr< T, M > & uu() const
Definition: form.h:192
rheolef::form_basic::float_type
scalar_traits< T >::type float_type
Definition: form.h:150
mkgeo_ball.c
c
Definition: mkgeo_ball.sh:153
rheolef::form_basic::set_bb
csr< T, M > & set_bb()
Definition: form.h:199
rk::gamma
Float gamma[][pmax+1]
Definition: runge_kutta_semiimplicit.icc:70
rheolef::details::form_concat_value
Definition: form.h:134
rheolef::form_basic::get_second_space
const space_type & get_second_space() const
Definition: form.h:333
rheolef::form_basic::get_first_space
const space_type & get_first_space() const
Definition: form.h:326
rheolef::form_basic::form_basic
form_basic()
Definition: form.h:300
rheolef::integrate_option
see the integrate_option page for the full documentation
Definition: integrate_option.h:125
rheolef::form_basic::assembly
void assembly(const geo_basic< T, M > &domain, const Expr &expr, const integrate_option &fopt)
Definition: form_vf_assembly.h:241
a
Definition: diffusion_isotropic.h:25
rheolef::details::form_concat_line
Definition: form.h:135
rheolef::operator-
csr< T, sequential > operator-(const csr< T, sequential > &a)
Definition: csr.h:447
rheolef::form_basic::is_symmetric
bool is_symmetric() const
Definition: form.h:420
rheolef::form_basic::_Y
space_type _Y
Definition: form.h:206
rheolef::field_basic
Definition: field_expr_utilities.h:38
rheolef::form_basic::operator()
float_type operator()(const field_basic< T, M > &uh, const field_basic< T, M > &vh) const
Definition: form.cc:143
rheolef::form_basic::operator=
form_basic< T, M > & operator=(const form_basic< T, M > &)
Definition: form.h:313
rheolef::form_basic::form_init
void form_init(const std::string &name, bool has_weight, WeightFunction weight, const quadrature_option &qopt)
Definition: form_weighted.h:165
rheolef::csr
see the csr page for the full documentation
Definition: asr.h:31
rheolef::form_basic::operator+
form_basic< T, M > operator+(const form_basic< T, M > &b) const
Definition: form.h:357
rheolef::form
form_basic< Float, rheo_default_memory_model > form
Definition: form.h:293
rheolef::band_basic
Definition: band.h:95
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::form_basic::operator*=
form_basic< T, M > & operator*=(const T &lambda)
Definition: form.h:393
rheolef::Function
rheolef::std Function
rheolef::form_basic::set_ub
csr< T, M > & set_ub()
Definition: form.h:197
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::form_basic::geo_type
geo_basic< float_type, M > geo_type
Definition: form.h:151
rheolef::form_basic::_bu
csr< T, M > _bu
Definition: form.h:209
rheolef::form_basic
Definition: form.h:144
mkgeo_ball.b
b
Definition: mkgeo_ball.sh:152
mkgeo_ball.a
a
Definition: mkgeo_ball.sh:151
rheolef::scalar_traits::type
T type
Definition: point.h:324
rheolef::form_basic::constraint_process_rank
int constraint_process_rank() const
Definition: form.h:202
rheolef::form_basic::operator-
form_basic< T, M > operator-(const form_basic< T, M > &b) const
Definition: form.h:369
rheolef::form_basic::set_uu
csr< T, M > & set_uu()
Definition: form.h:196
rheolef::form_basic::get_geo
const geo_type & get_geo() const
Definition: form.h:340
rheolef::form_basic::value_type
T value_type
Definition: form.h:149
rheolef::form_basic::size_type
csr< T, M >::size_type size_type
Definition: form.h:148
get_geo
void get_geo(istream &in, my_geo &omega)
Definition: field2gmsh_pos.cc:126
rheolef::form_basic::_X
space_type _X
Definition: form.h:205
rheolef::form_basic::set_symmetry
void set_symmetry(bool is_symm) const
Definition: form.h:427
rheolef::form_basic::comm
const communicator & comm() const
Definition: form.h:347
rheolef::trans
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
Definition: csr.h:455
rheolef::form_basic::put
odiststream & put(odiststream &ops, bool show_partition=true) const
Definition: form.cc:235
rheolef::form_basic::trans_mult
field_basic< T, M > trans_mult(const field_basic< T, M > &yh) const
Definition: form.cc:134
rheolef::quadrature_option
integrate_option quadrature_option
Definition: integrate_option.h:186
mkgeo_contraction.name
name
Definition: mkgeo_contraction.sh:133
rheolef::form_basic::set_bu
csr< T, M > & set_bu()
Definition: form.h:198
rheolef::form_basic::_uu
csr< T, M > _uu
Definition: form.h:207
rheolef::form_basic::dump
void dump(std::string name) const
Definition: form.cc:262
T
Expr1::float_type T
Definition: field_expr.h:218
lambda
Definition: yield_slip_circle.h:34
rheolef::form_basic::assembly_internal
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)
Definition: form_vf_assembly.h:87