1#ifndef _RHEOLEF_FIELD_EXPR_VARIATIONAL_TERMINAL_H
2#define _RHEOLEF_FIELD_EXPR_VARIATIONAL_TERMINAL_H
40#include "rheolef/field_expr.h"
41#include "rheolef/test.h"
42#include "rheolef/test_component.h"
89 "grad(.): unexpected " <<
get_vf_space().get_basis().name()
90 <<
" discontinuous approximation (HINT: consider grad_h(.))");
120 _expr.initialize (pops, iopt);
127 _expr.initialize (
gh, pops, iopt);
129 template<
class Result>
134 Eigen::Matrix<Result,Eigen::Dynamic,Eigen::Dynamic>& value)
const
136 _expr.template evaluate<Result,details::differentiate_option::gradient> (omega_K, K,
_gopt, value);
138 template<
class Result>
144 Eigen::Matrix<Result,Eigen::Dynamic,Eigen::Dynamic>& value,
145 bool do_local_component_assembly)
const
147 _expr.template evaluate_on_side<Result,details::differentiate_option::gradient> (omega_K, K, sid,
_gopt, value, do_local_component_assembly);
149 template<
class Value>
155 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value0,
156 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value1,
157 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
159 _expr.local_dg_merge_on_side (omega_K, S, K0, K1, value0, value1, value);
161 template<
class Result>
163 _expr.template grad_valued_check<Result>();
184 return details::field_expr_v2_variational_grad <Expr> (expr);
191 details::is_field_expr_v2_variational_arg<Expr>::value
192 ,details::field_expr_v2_variational_grad<Expr>
196 details::differentiate_option opt;
198 return details::field_expr_v2_variational_grad <Expr> (expr, opt);
205 details::is_field_expr_v2_variational_arg<Expr>::value
206 ,details::field_expr_v2_variational_grad<Expr>
210 details::differentiate_option opt;
212 return details::field_expr_v2_variational_grad <Expr> (expr, opt);
219 details::is_field_expr_v2_variational_arg<Expr>::value
220 ,details::field_expr_v2_variational_grad<Expr>
224 details::differentiate_option opt;
225 opt.symmetrized =
true;
226 return details::field_expr_v2_variational_grad <Expr> (expr, opt);
233 details::is_field_expr_v2_variational_arg<Expr>::value
234 ,details::field_expr_v2_variational_grad<Expr>
238 details::differentiate_option opt;
239 opt.symmetrized =
true;
241 return details::field_expr_v2_variational_grad <Expr> (expr, opt);
248 details::is_field_expr_v2_variational_arg<Expr>::value
249 ,details::field_expr_v2_variational_grad<Expr>
253 details::differentiate_option opt;
254 opt.symmetrized =
true;
256 return details::field_expr_v2_variational_grad <Expr> (expr, opt);
290 "div(.): unexpected " <<
get_vf_space().get_basis().name()
291 <<
" discontinuous approximation (HINT: consider div_h(.))");
314 _expr.initialize (pops, iopt);
317 _expr.initialize (
gh, pops, iopt);
319 template<
class Result>
323 Eigen::Matrix<Result,Eigen::Dynamic,Eigen::Dynamic>& value)
const
325 _expr.template evaluate<Result,details::differentiate_option::divergence> (omega_K, K,
_gopt, value);
327 template<
class Result>
332 Eigen::Matrix<Result,Eigen::Dynamic,Eigen::Dynamic>& value,
333 bool do_local_component_assembly)
const
335 _expr.template evaluate_on_side<Result,details::differentiate_option::divergence> (omega_K, K, sid,
_gopt, value, do_local_component_assembly);
337 template<
class Result>
339 _expr.template div_valued_check<Result>();
341 template<
class Value>
347 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value0,
348 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value1,
349 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
351 _expr.local_dg_merge_on_side (omega_K, S, K0, K1, value0, value1, value);
372 return details::field_expr_v2_variational_div <Expr> (expr);
379 details::is_field_expr_v2_variational_arg<Expr>::value
380 ,details::field_expr_v2_variational_div<Expr>
384 details::differentiate_option opt;
386 return details::field_expr_v2_variational_div <Expr> (expr, opt);
393 details::is_field_expr_v2_variational_arg<Expr>::value
394 ,details::field_expr_v2_variational_div<Expr>
398 details::differentiate_option opt;
400 return details::field_expr_v2_variational_div <Expr> (expr, opt);
436 "curl(.): unexpected " <<
get_vf_space().get_basis().name()
437 <<
" discontinuous approximation (HINT: consider curl_h(.))");
462 _expr.initialize (pops, iopt);
465 _expr.initialize (
gh, pops, iopt);
467 template<
class Result>
471 Eigen::Matrix<Result,Eigen::Dynamic,Eigen::Dynamic>& value)
const
473 _expr.template evaluate<Result,details::differentiate_option::curl> (omega_K, K,
_gopt, value);
475 template<
class Value>
481 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value0,
482 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value1,
483 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
485 _expr.local_dg_merge_on_side (omega_K, S, K0, K1, value0, value1, value);
488 _expr.template valued_check<point_basic<scalar_type> >();
490 check_macro (
d==2,
"unexpected "<<
d<<
"D physical dimension for the scalar-valued curl() operator");
494 check_macro (
d==2 ||
d==3,
"unexpected "<<
d<<
"D physical dimension for the vector-valued curl() operator");
496 _expr.template valued_check<scalar_type>();
498 _expr.template valued_check<point_basic<scalar_type> >();
502 fatal_macro (
"unexpected tensor-valued result for the curl() operator");
504 template<
class Result>
527 return details::field_expr_v2_variational_curl <Expr> (expr);
534 details::is_field_expr_v2_variational_arg<Expr>::value
535 ,details::field_expr_v2_variational_curl<Expr>
539 details::differentiate_option opt;
540 opt.batchelor_curl =
true;
541 return details::field_expr_v2_variational_curl <Expr> (expr, opt);
804 _expr0.initialize (pops, iopt);
805 _expr1.initialize (pops, iopt);
811 fatal_macro (
"unsupported discontinuous Galerkin on a band");
813 template<
class Result>
817 Eigen::Matrix<Result,Eigen::Dynamic,Eigen::Dynamic>& value)
const;
819 template<
class Result>
822 "unexpected continuous test-function in space " <<
get_vf_space().name()
823 <<
" for jump or average operator (HINT: omit jump or average)");
824 _expr0.template valued_check<Result>();
859template<
class Result>
864 Eigen::Matrix<Result,Eigen::Dynamic,Eigen::Dynamic>& value)
const
867 check_macro (_bgd_omega == omega_K.get_background_geo().get_background_geo(),
868 "discontinuous Galerkin: incompatible integration domain "<<omega_K.name() <<
" and test function in "
869 << get_vf_space().name());
873 check_macro (L_dis_ie0 != std::numeric_limits<size_type>::max(),
875 const geo_element& L0 = _bgd_omega.dis_get_geo_element (L_map_d, L_dis_ie0);
878 if (L_dis_ie1 == std::numeric_limits<size_type>::max()) {
880 bool do_local_component_assembly =
true;
882 _expr0.evaluate_on_side (omega_K, L0, sid0, value, do_local_component_assembly);
885 const geo_element& L1 = _bgd_omega.dis_get_geo_element (L_map_d, L_dis_ie1);
888 Eigen::Matrix<Result,Eigen::Dynamic,Eigen::Dynamic> value0, value1;
889 bool do_local_component_assembly =
false;
890 _expr0.evaluate_on_side (omega_K, L0, sid0, value0, do_local_component_assembly);
891 _expr1.evaluate_on_side (omega_K, L1, sid1, value1, do_local_component_assembly);
892 for (
size_type loc_inod = 0, loc_nnod = value0.rows(); loc_inod < loc_nnod; ++loc_inod) {
893 for (
size_type loc_idof = 0, loc_ndof = value0.cols(); loc_idof < loc_ndof; ++loc_idof) {
894 value0 (loc_inod,loc_idof) = _c0*value0 (loc_inod,loc_idof);
896 for (
size_type loc_inod = 0, loc_nnod = value1.rows(); loc_inod < loc_nnod; ++loc_inod) {
897 for (
size_type loc_idof = 0, loc_ndof = value1.cols(); loc_idof < loc_ndof; ++loc_idof) {
898 value1 (loc_inod,loc_idof) = _c1*value1 (loc_inod,loc_idof);
902 _expr0.local_dg_merge_on_side (omega_K, K, L0, L1, value0, value1, value);
911#define _RHEOLEF_make_field_expr_v2_variational_dg(op,c0,c1) \
912template<class Expr> \
916 details::is_field_expr_v2_variational_arg<Expr>::value \
917 ,details::field_expr_v2_variational_dg<Expr> \
919op (const Expr& expr) \
921 return details::field_expr_v2_variational_dg <Expr> (expr, c0, c1); \
928#undef _RHEOLEF_make_field_expr_v2_variational_dg
field gh(Float epsilon, Float t, const field &uh, const test &v)
field_expr_v2_variational_curl(const Expr &expr, const differentiate_option &gopt=differentiate_option())
space_basic< scalar_type, memory_type > space_type
void _valued_check_internal(const tensor_basic< scalar_type > &) const
undeterminated_basic< scalar_type > value_type
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
void initialize(const band_basic< float_type, memory_type > &gh, const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
differentiate_option _gopt
scalar_traits< typenameExpr::value_type >::type scalar_type
void valued_check() const
field_expr_v2_variational_curl< typename Expr::dual_self_type > dual_self_type
void _valued_check_internal(const point_basic< scalar_type > &) const
static const space_constant::valued_type valued_hint
size_type n_derivative() const
details::dual_vf_tag< vf_tag_type >::type vf_dual_tag_type
void local_dg_merge_on_side(const geo_basic< float_type, memory_type > &omega_K, const geo_element &S, const geo_element &K0, const geo_element &K1, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value0, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value1, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
void _valued_check_internal(const scalar_type &) const
float_traits< scalar_type >::type float_type
Expr::memory_type memory_type
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, Eigen::Matrix< Result, Eigen::Dynamic, Eigen::Dynamic > &value) const
field_expr_v2_variational_curl< Expr > self_type
Expr::vf_tag_type vf_tag_type
geo_element::size_type size_type
space_constant::valued_type valued_tag() const
const space_type & get_vf_space() const
geo_basic< float_type, memory_type > _bgd_omega
reference_element _tilde1_L1
reference_element _tilde0_L0
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
typename details::dual_vf_tag< vf_tag_type >::type vf_dual_tag_type
field_expr_v2_variational_dg(const Expr &expr, const float_type &c0, const float_type &c1)
void initialize(const band_basic< float_type, memory_type > &gh, const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
field_expr_v2_variational_dg< typename Expr::dual_self_type > dual_self_type
typename Expr::size_type size_type
typename Expr::scalar_type scalar_type
void valued_check() const
typename Expr::memory_type memory_type
static const space_constant::valued_type valued_hint
size_type n_derivative() const
std::false_type is_elementwise
field_expr_v2_variational_dg< Expr > self_type
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, Eigen::Matrix< Result, Eigen::Dynamic, Eigen::Dynamic > &value) const
typename Expr::value_type value_type
typename Expr::space_type space_type
typename Expr::float_type float_type
typename Expr::vf_tag_type vf_tag_type
space_constant::valued_type valued_tag() const
const space_type & get_vf_space() const
space_basic< scalar_type, memory_type > space_type
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
space_constant::rank_down< typenameExpr::value_type >::type value_type
field_expr_v2_variational_div< Expr > self_type
void initialize(const band_basic< float_type, memory_type > &gh, const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
differentiate_option _gopt
scalar_traits< typenameExpr::value_type >::type scalar_type
field_expr_v2_variational_div(const Expr &expr, const differentiate_option &gopt=differentiate_option())
void valued_check() const
static const space_constant::valued_type valued_hint
size_type n_derivative() const
details::dual_vf_tag< vf_tag_type >::type vf_dual_tag_type
void local_dg_merge_on_side(const geo_basic< float_type, memory_type > &omega_K, const geo_element &S, const geo_element &K0, const geo_element &K1, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value0, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value1, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
float_traits< scalar_type >::type float_type
Expr::memory_type memory_type
void evaluate_on_side(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, const side_information_type &sid, Eigen::Matrix< Result, Eigen::Dynamic, Eigen::Dynamic > &value, bool do_local_component_assembly) const
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, Eigen::Matrix< Result, Eigen::Dynamic, Eigen::Dynamic > &value) const
field_expr_v2_variational_div< typename Expr::dual_self_type > dual_self_type
Expr::vf_tag_type vf_tag_type
geo_element::size_type size_type
space_constant::valued_type valued_tag() const
const space_type & get_vf_space() const
field_expr_v2_variational_grad(const field_expr_v2_variational_grad< Expr > &x)
space_basic< scalar_type, memory_type > space_type
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
field_expr_v2_variational_grad(const Expr &expr, const differentiate_option &gopt=differentiate_option())
field_expr_v2_variational_grad< typename Expr::dual_self_type > dual_self_type
void initialize(const band_basic< float_type, memory_type > &gh, const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
field_expr_v2_variational_grad< Expr > self_type
differentiate_option _gopt
scalar_traits< typenameExpr::value_type >::type scalar_type
void valued_check() const
static const space_constant::valued_type valued_hint
size_type n_derivative() const
details::dual_vf_tag< vf_tag_type >::type vf_dual_tag_type
void local_dg_merge_on_side(const geo_basic< float_type, memory_type > &omega_K, const geo_element &S, const geo_element &K0, const geo_element &K1, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value0, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value1, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
float_traits< scalar_type >::type float_type
space_constant::rank_up< typenameExpr::value_type >::type value_type
Expr::memory_type memory_type
void evaluate_on_side(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, const side_information_type &sid, Eigen::Matrix< Result, Eigen::Dynamic, Eigen::Dynamic > &value, bool do_local_component_assembly) const
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, Eigen::Matrix< Result, Eigen::Dynamic, Eigen::Dynamic > &value) const
Expr::vf_tag_type vf_tag_type
geo_element::size_type size_type
space_constant::valued_type valued_tag() const
const space_type & get_vf_space() const
generic mesh with rerefence counting
see the geo_element page for the full documentation
reference_element::size_type size_type
size_type dimension() const
size_type master(bool i) const
orientation_type get_side_informations(const geo_element &S, size_type &loc_isid, size_type &shift) const
see the integrate_option page for the full documentation
see the reference_element page for the full documentation
#define trace_macro(message)
#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)")
#define _RHEOLEF_make_field_expr_v2_variational_dg(op, c0, c1)
const std::string & valued_name(valued_type valued_tag)
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_s(const Expr &expr)
grad_s(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 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.
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
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_h(const Expr &expr)
div_h(uh): see the expression page for the full documentation
std::enable_if< details::is_field_expr_v2_variational_arg< Expr >::value, details::field_expr_v2_variational_curl< Expr > >::type bcurl(const Expr &expr)
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
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_h(const Expr &expr)
grad_h(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 Dh(const Expr &expr)
Dh(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::divergence > >::type div_s(const Expr &expr)
div_s(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 Ds(const Expr &expr)
Ds(uh): see the expression page for the full documentation.
undeterminated_basic< typename scalar_traits< T >::type > type
point_basic< typename scalar_traits< T >::type > type
helper for generic field value_type: T, point_basic<T> or tensor_basic<T>