1# ifndef _RHEOLEF_FORM_WEIGHTED_H
2# define _RHEOLEF_FORM_WEIGHTED_H
26#include "rheolef/form.h"
27#include "rheolef/field_expr_variational.h"
28#include "rheolef/form_expr_variational.h"
29#include "rheolef/form_vf_assembly.h"
40form_expr_quadrature_on_element<Expr>
42 return form_expr_quadrature_on_element<Expr>(e);
45template<
class T,
class M,
class WeightFunction>
50 const std::string& name,
53 const quadrature_option& qopt)
62 switch (a.get_first_space().valued_tag()) {
64 if (!has_weight) a.do_integrate (dom, expr(
u*v), qopt);
65 else a.do_integrate (dom, expr(w*(
u*v)), qopt);
68 if (!has_weight) a.do_integrate (dom, expr(
dot(
u,v)), qopt);
69 else fatal_macro (
"unsupported vectorial mass with weight (HINT: use integrate())");
74 if (!has_weight) a.do_integrate (dom, expr(
ddot(
u,v)), qopt);
75 else fatal_macro (
"unsupported tensorial mass with weight (HINT: use integrate())");
80 }
else if (name ==
"inv_mass") {
82 check_macro (!has_weight,
"unsupported weighted "<<name<<
" form (HINT: use integrate())");
85 switch (a.get_first_space().valued_tag()) {
92 }
else if (name ==
"lumped_mass") {
94 check_macro (!has_weight,
"unsupported weighted "<<name<<
" form (HINT: use integrate())");
97 switch (a.get_first_space().valued_tag()) {
104 }
else if (name ==
"grad") {
106 if (!has_weight) a.do_integrate (dom, expr(
dot(
grad(
u),v)), qopt);
107 else a.do_integrate (dom, expr(
dot(w*
grad(
u),v)), qopt);
110 }
else if (name ==
"div") {
112 check_macro (!has_weight,
"unsupported weighted "<<name<<
" form (HINT: use integrate())");
113 a.do_integrate (dom, expr(
div(
u)*v), qopt);
116 }
else if (name ==
"2D") {
118 if (!has_weight) a.do_integrate (dom, expr(2.*
ddot(
D(
u),v)), qopt);
119 else a.do_integrate (dom, expr(2.*
ddot(w*
D(
u),v)), qopt);
122 }
else if (name ==
"grad_grad") {
124 switch (a.get_first_space().valued_tag()) {
126 if (!has_weight) a.do_integrate (dom, expr(
dot(
grad(
u),
grad(v))), qopt);
127 else a.do_integrate (dom, expr(
dot(w*
grad(
u),
grad(v))), qopt);
131 if (!has_weight) a.do_integrate (dom, expr(
ddot(
grad(
u),
grad(v))), qopt);
132 else a.do_integrate (dom, expr(
ddot(w*
grad(
u),
grad(v))), qopt);
136 }
else if (name ==
"2D_D") {
138 if (!has_weight) a.do_integrate (dom, expr(2.*
ddot(
D(
u),
D(v))), qopt);
139 else a.do_integrate (dom, expr(2.*
ddot(w*
D(
u),
D(v))), qopt);
142 }
else if (name ==
"div_div") {
144 check_macro (!has_weight,
"unsupported weighted "<<name<<
" form (HINT: use integrate())");
145 a.do_integrate (dom, expr(
div(
u)*
div(v)), qopt);
148 }
else if (name ==
"curl") {
150 check_macro (!has_weight,
"unsupported weighted "<<name<<
" form (HINT: use integrate())");
151 if (
u.get_vf_space().get_geo().dimension() == 2 &&
153 a.do_integrate (dom, expr(
curl(
u)*v), qopt);
154 else a.do_integrate (dom, expr(
dot(
curl(
u),v)), qopt);
162template<
class T,
class M>
163template<
class WeightFunction>
166 const std::string& name,
169 const quadrature_option& qopt)
171 if (name ==
"" || name ==
"nul" || name ==
"null") {
173 _uu.resize (_Y.iu_ownership(), _X.iu_ownership());
174 _ub.resize (_Y.iu_ownership(), _X.ib_ownership());
175 _bu.resize (_Y.ib_ownership(), _X.iu_ownership());
176 _bb.resize (_Y.ib_ownership(), _X.ib_ownership());
181 check_macro (_X.get_geo().get_background_geo() == _Y.get_geo().get_background_geo(),
182 "form("<<name<<
") between incompatible geo " << _X.get_geo().name() <<
" and " << _Y.get_geo().name());
186 if ((!X_is_on_domain && ! Y_is_on_domain) || (X_is_on_domain && Y_is_on_domain)) {
188 }
else if (X_is_on_domain) {
189 dom = _X.get_geo().get_background_domain();
191 dom = _Y.get_geo().get_background_domain();
196 fatal_macro (
"unsupported form name: \""<<name<<
"\" (HINT: use integrate())");
198template<
class T,
class M>
199template<
class Function>
204 const std::string& name,
206 const quadrature_option& qopt)
219template<
class T,
class M>
220template<
class WeightFunction>
223 const std::string& name,
228 const quadrature_option& qopt)
234 fatal_macro (
"unsupported form name: \""<<name<<
"\"");
236template<
class T,
class M>
237template<
class Function>
241 const std::string& name,
244 const quadrature_option& qopt)
abstract base interface class
generic mesh with rerefence counting
see the integrate_option page for the full documentation
#define fatal_macro(message)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
bool form_named_init(form_basic< T, M > &a, const geo_basic< T, M > &dom, const std::string &name, bool has_weight, WeightFunction w, const quadrature_option &qopt)
rheolef::details::is_vec dot
This file is part of Rheolef.
std::enable_if< details::has_field_rdof_interface< Expr >::value, details::field_expr_v2_nonlinear_terminal_field< typenameExpr::scalar_type, typenameExpr::memory_type, details::differentiate_option::gradient > >::type grad(const Expr &expr)
grad(uh): see the expression page for the full documentation
std::enable_if< details::has_field_rdof_interface< Expr >::value, details::field_expr_v2_nonlinear_terminal_field< typenameExpr::scalar_type, typenameExpr::memory_type, details::differentiate_option::gradient > >::type D(const Expr &expr)
D(uh): see the expression page for the full documentation.
T ddot(const tensor_basic< T > &a, const tensor_basic< T > &b)
ddot(x,y): see the expression page for the full documentation
std::enable_if< details::has_field_rdof_interface< Expr >::value, details::field_expr_v2_nonlinear_terminal_field< typenameExpr::scalar_type, typenameExpr::memory_type, details::differentiate_option::divergence > >::type div(const Expr &expr)
div(uh): see the expression page for the full documentation
geo_basic< T, M > compact(const geo_basic< T, M > &gamma)
std::enable_if< details::has_field_rdof_interface< Expr >::value, details::field_expr_v2_nonlinear_terminal_field< typenameExpr::scalar_type, typenameExpr::memory_type, details::differentiate_option::curl > >::type curl(const Expr &expr)
curl(uh): see the expression page for the full documentation