rheolef  7.0
integrate.h
Go to the documentation of this file.
1 #ifndef _RHEO_INTEGRATE_H
2 #define _RHEO_INTEGRATE_H
3 #include "rheolef/field_expr_v2_nonlinear.h"
4 #include "rheolef/field_expr_v2_variational.h"
5 #include "rheolef/form_expr_v2_variational.h"
6 
7 #include "rheolef/field_expr_v2_value_assembly.h"
8 #include "rheolef/field_vf_assembly.h"
9 #include "rheolef/form_vf_assembly.h"
10 
11 #include "rheolef/functor.h" // used to convert functions to functors
12 
13 namespace rheolef {
14 
99 template <class T, class M, class Expr,
101 inline
102 typename std::enable_if<
105  Result
106 >::type
107 integrate (const geo_basic<T,M>& omega, const Expr& expr, const quadrature_option& qopt,
108  Result dummy = Result())
109 {
111  if (omega.map_dimension() < omega.get_background_geo().map_dimension()) {
112  omega.get_background_geo().neighbour_guard();
113  }
114  Result result(0);
115  field_expr_v2_value_assembly (omega, wrap_t(expr), qopt, result);
116  return result;
117 }
118 template <class T, class M>
119 T
121 {
122  if (qopt.get_order() == std::numeric_limits<quadrature_option::size_type>::max()) {
123  qopt.set_order(0);
124  }
126  return integrate (omega, one, qopt);
127 }
128 // TODO: return a overdetermined<T> value that is an union of all possibilities with a valued_tag
129 template<class T, class M, class Expr>
130 inline
131 typename std::enable_if<
135 >::type
136 integrate (const geo_basic<T,M>& omega, const Expr& expr, const quadrature_option& qopt)
137 {
139  typedef typename scalar_traits<undef_t>::type scalar_type;
140  switch (expr.valued_tag()) {
141  case space_constant::scalar: {
142  return integrate (omega, expr, qopt, scalar_type());
143  }
144  default:
145  warning_macro ("Expr="<<pretty_typename_macro(Expr));
146  error_macro ("integrate: not yet for `"
147  << space_constant::valued_name (expr.valued_tag())
148  << "' valued expression");
149  return 0;
150  }
151 }
152 template <class T, class M, class Expr>
153 inline
154 typename
155 std::enable_if<
158 >::type
160  const geo_basic<T,M>& domain,
161  const Expr& expr,
162  const quadrature_option& qopt = quadrature_option())
163 {
164  field_basic<T,M> lh;
165  lh.assembly (domain, expr, qopt);
166  return lh;
167 }
168 template <class Expr>
169 inline
170 typename
171 std::enable_if<
172  details::is_field_expr_v2_variational_arg<Expr>::value
174 >::type
176  const Expr& expr,
177  const quadrature_option& qopt = quadrature_option())
178 {
180  lh.assembly (expr.get_vf_space().get_geo(), expr, qopt);
181  return lh;
182 }
183 template <class Expr>
184 inline
185 typename
186 std::enable_if<
187  details::is_field_expr_v2_variational_arg<Expr>::value
189 >::type
191  const std::string& domname,
192  const Expr& expr,
193  const quadrature_option& qopt = quadrature_option())
194 {
196  lh.assembly (expr.get_vf_space().get_geo()[domname], expr, qopt);
197  return lh;
198 }
199 template <class T, class M, class Expr>
200 inline
201 typename
202 std::enable_if<
205 >::type
207  const geo_basic<T,M>& domain,
208  const Expr& expr,
209  const integrate_option& fopt = integrate_option())
210 {
212  a.assembly (domain, expr, fopt);
213  return a;
214 }
215 template <class Expr>
216 inline
217 typename
218 std::enable_if<
219  details::is_form_expr_v2_variational_arg<Expr>::value
221 >::type
223  const Expr& expr,
224  const integrate_option& fopt = integrate_option())
225 {
227  a.assembly (expr.get_test_space().get_geo(), expr, fopt);
228  return a;
229 }
230 template <class Expr>
231 inline
232 typename
233 std::enable_if<
234  details::is_form_expr_v2_variational_arg<Expr>::value
236 >::type
238  const std::string& domname,
239  const Expr& expr,
240  const integrate_option& fopt = integrate_option())
241 {
243  a.assembly (expr.get_test_space().get_geo()[domname], expr, fopt);
244  return a;
245 }
246 template <class T, class M, class Expr>
247 inline
248 typename
249 std::enable_if<
250  details::is_field_expr_v2_variational_arg<Expr>::value
252 >::type
254  const band_basic<T,M>& gh,
255  const Expr& expr,
256  const quadrature_option& qopt = quadrature_option())
257 {
259  lh.assembly (gh, expr, qopt);
260  return lh;
261 }
262 template <class T, class M, class Expr>
263 inline
264 typename
265 std::enable_if<
266  details::is_form_expr_v2_variational_arg<Expr>::value
268 >::type
270  const band_basic<T,M>& gh,
271  const Expr& expr,
272  const integrate_option& fopt = integrate_option())
273 {
275  a.assembly (gh, expr, fopt);
276  return a;
277 }
278 
279 }// namespace rheolef
280 #endif // _RHEO_INTEGRATE_H
#define error_macro(message)
Definition: compiler.h:100
band - compute the band around a level set
Definition: band.h:45
field - piecewise polynomial finite element field
quadrature_option - send options to the integrate function
irheostream, orheostream - large data streams
Definition: compiler.h:7
void assembly(const geo_basic< T, M > &domain, const Expr &expr, const integrate_option &fopt)
std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr >::value &&! is_undeterminated< Result >::value, Result >::type integrate(const geo_basic< T, M > &omega, const Expr &expr, const quadrature_option &qopt, Result dummy=Result())
integrate - integrate a function or an expression
Definition: integrate.h:107
#define warning_macro(message)
Definition: compiler.h:102
const std::string & valued_name(valued_type valued_tag)
rheolef::std value
void field_expr_v2_value_assembly(const geo_basic< T, M > &omega, const Expr &expr, const quadrature_option &qopt, Result &result)
result_type value_type
helper for point_basic<T> & tensor_basic<T>: get basic T type
Definition: point.h:234
scalar_traits< value_type >::type scalar_type
rheolef::std type
Expr1::memory_type M
Definition: vec_expr_v2.h:310
form - representation of a finite element bilinear form
Definition: form.h:98
#define pretty_typename_macro(T)
Definition: pretty_name.h:33
integrate_option - send options to the integrate function
static iorheo::force_initialization dummy
Definition: iorheo.cc:105
void assembly(const geo_basic< T, M > &domain, const Expr &expr, const quadrature_option &qopt)