rheolef  6.3
form_weighted.h
Go to the documentation of this file.
1 # ifndef _RHEOLEF_FORM_WEIGHTED_H
2 # define _RHEOLEF_FORM_WEIGHTED_H
3 #include "rheolef/form.h"
4 namespace rheolef {
5 
6 template<class T, class M>
7 template<class WeightFunction>
8 void
10  const std::string& name,
11  bool has_weight,
12  WeightFunction weight,
13  const quadrature_option_type& qopt)
14 {
15  if (name == "" || name == "nul" || name == "null") {
16  // empty name => nul form, but with declared csr matrix sizes
17  _uu.resize (_Y.iu_ownership(), _X.iu_ownership());
18  _ub.resize (_Y.iu_ownership(), _X.ib_ownership());
19  _bu.resize (_Y.ib_ownership(), _X.iu_ownership());
20  _bb.resize (_Y.ib_ownership(), _X.ib_ownership());
21  return;
22  }
23  typedef typename form_basic<T,M>::float_type float_type;
24  bool X_is_on_domain = (_X.get_geo().data().variant() == geo_abstract_base_rep<float_type>::geo_domain);
25  bool Y_is_on_domain = (_Y.get_geo().data().variant() == geo_abstract_base_rep<float_type>::geo_domain);
26  geo_basic<T,M> omega;
27  if (X_is_on_domain == Y_is_on_domain) {
28  omega = _X.get_geo();
29  } else {
30  omega = _X.get_geo().get_background_geo();
31  }
32  form_element<T,M> form_e (name, _X, _Y, omega, qopt);
33 
34  if (has_weight) form_e.set_weight (weight);
35 
36  if (X_is_on_domain == Y_is_on_domain) {
37  assembly (form_e, _X.get_geo(), _Y.get_geo());
38  } else if (X_is_on_domain) {
39  check_macro (_X.get_geo().get_background_geo() == _Y.get_geo(),
40  "form between incompatible geo " << _X.get_geo().name() << " and " << _Y.get_geo().name());
41  const geo_basic<T,M>& Y_gamma = _X.get_geo().get_background_domain();
42  bool X_geo_is_background = false;
43  assembly (form_e, _X.get_geo(), Y_gamma, X_geo_is_background);
44  } else { // Y_is_on_domain
45  check_macro (_Y.get_geo().get_background_geo() == _X.get_geo(),
46  "form between incompatible geo " << _X.get_geo().name() << " and " << _Y.get_geo().name());
47  const geo_basic<T,M>& X_gamma = _Y.get_geo().get_background_domain();
48  bool X_geo_is_background = true;
49  assembly (form_e, X_gamma, _Y.get_geo(), X_geo_is_background);
50  }
51 }
52 template<class T, class M>
53 template<class Function>
54 inline
56  const space_type& X,
57  const space_type& Y,
58  const std::string& name,
59  Function weight,
60  const quadrature_option_type& qopt)
61  : _X(X),
62  _Y(Y),
63  _uu(),
64  _ub(),
65  _bu(),
66  _bb()
67 {
68  form_init (name, true, weight, qopt);
69 }
70 template<class T, class M>
71 template<class WeightFunction>
72 void
74  const std::string& name,
75  const geo_basic<T,M>& gamma,
76  bool has_weight,
77  WeightFunction weight,
78  const geo_basic<T,M>& w_omega,
79  const quadrature_option_type& qopt)
80 {
81  const geo_basic<T,M>& omega = _X.get_geo().get_background_geo();
82  form_element<T,M> form_e (name, _X, _Y, omega, qopt);
83  if (has_weight) form_e.set_weight (weight, w_omega);
84  assembly (form_e, gamma, gamma);
85 }
86 template<class T, class M>
87 template<class Function>
89  const space_type& X,
90  const space_type& Y,
91  const std::string& name,
92  const geo_basic<T,M>& gamma,
93  Function weight,
94  const quadrature_option_type& qopt)
95  : _X(X),
96  _Y(Y),
97  _uu(),
98  _ub(),
99  _bu(),
100  _bb()
101 {
102  form_init_on_domain (name, gamma, true, weight, compact(gamma), qopt);
103 }
104 
105 }// namespace rheolef
106 # endif /* _RHEOLEF_FORM_WEIGHTED_H */
107