1 #ifndef _RHEOLEF_FIELD_EXPR_QUADRATURE_H
2 #define _RHEOLEF_FIELD_EXPR_QUADRATURE_H
43 #include "rheolef/field_expr_variational.h"
44 #include "rheolef/field_expr_variational_terminal.h"
45 #include "rheolef/init_expr_quadrature.h"
88 template<class Sfinae = typename std::enable_if<is_field_expr_v2_variational_arg<Expr>::value, Expr>
::type>
101 template<
class Value>
105 Eigen::Matrix<Value,Eigen::Dynamic,1>& lk)
const;
107 template<
class Value>
122 template<
class Sfinae>
137 _pops.initialize (omega_K.get_piola_basis(), quad, new_iopt);
138 _expr.initialize (_pops, new_iopt);
148 _pops.initialize (
gh.band().get_piola_basis(), quad, new_iopt);
149 _expr.initialize (
gh, _pops, new_iopt);
152 template<
class Value>
157 Eigen::Matrix<Value,Eigen::Dynamic,1>& lk)
const
159 Eigen::Matrix<float_type,Eigen::Dynamic,Eigen::Dynamic> phij_xi;
160 const Eigen::Matrix<float_type,Eigen::Dynamic,1>& w = _pops.get_weight (omega_K, K);
161 _expr.evaluate (omega_K, K, phij_xi);
163 size_t ni = phij_xi.rows();
164 size_t nj = phij_xi.cols();
166 for (
size_t j = 0; j < nj; ++j) {
168 for (
size_t i = 0; i < ni; ++i) {
169 sum += w[i] * phij_xi(i,j);
204 template<class Sfinae = typename std::enable_if<is_field_expr_v2_variational_arg<Expr>::value, Expr>
::type>
217 template<
class Value>
221 Eigen::Matrix<Value,Eigen::Dynamic,1>&
value)
const;
223 template<
class Value>
234 mutable Eigen::Matrix<float_type,Eigen::Dynamic,Eigen::Dynamic>
_value_i;
244 template<
class Sfinae>
249 _ignore_sys_coord(false),
263 _pops.initialize (omega_K.get_piola_basis(), quad, new_iopt);
264 _expr.initialize (_pops, new_iopt);
274 _pops.initialize (
gh.band().get_piola_basis(), quad, new_iopt);
275 _expr.initialize (
gh, _pops, new_iopt);
276 fatal_macro(
"on_local_sides: banded level set not yet supported, sorry");
279 template<
class Value>
284 Eigen::Matrix<Value,Eigen::Dynamic,1>&
value)
const
286 bool do_local_component_assembly =
true;
290 const geo_element& S = omega_K.dis_get_geo_element (sid_dim, dis_isid);
293 _expr.evaluate_on_side (omega_K, K, sid, _value_i, do_local_component_assembly);
294 const Eigen::Matrix<float_type,Eigen::Dynamic,1>& w = _pops.get_weight (omega_K, S);
296 size_t ni = _value_i.rows();
297 size_t nj = _value_i.cols();
299 value = Eigen::Matrix<Value,Eigen::Dynamic,1>::Zero(nj, 1);
301 for (
size_t j = 0; j < nj; ++j) {
303 for (
size_t i = 0; i < ni; ++i) {
304 sum += w[i] * _value_i(i,j);
334 template<
class UnaryFunction,
class Expr>
335 class field_expr_quadrature_unary {
341 typedef typename details::generic_unary_traits<UnaryFunction>::template result_hint<
342 typename Expr::value_type>
::type result_hint;
343 typedef typename details::generic_unary_traits<UnaryFunction>::template hint<
344 typename Expr::value_type
348 typedef space_basic<scalar_type,memory_type> space_type;
349 typedef typename Expr::vf_tag_type vf_tag_type;
352 typedef field_expr_quadrature_unary<UnaryFunction,Expr> self_type;
353 typedef field_expr_quadrature_unary<UnaryFunction, typename Expr::dual_self_type>
360 template<class Sfinae = typename std::enable_if<is_field_expr_quadrature_arg<Expr>::value, Expr>
::type>
361 field_expr_quadrature_unary (
const UnaryFunction&
f,
const Expr& expr)
362 :
_f(
f), _expr(expr) {}
366 const space_type& get_vf_space()
const {
return _expr.get_vf_space(); }
367 size_type n_derivative()
const {
return _expr.n_derivative(); }
371 void initialize (
const geo_basic<float_type,memory_type>& omega_K,
const integrate_option& iopt)
const {
372 return _expr.initialize (omega_K, iopt); }
373 void initialize (
const band_basic<float_type,memory_type>&
gh,
const integrate_option& iopt)
const {
374 return _expr.initialize (
gh, iopt); }
376 template<
class Value>
377 void evaluate (
const geo_element& K, Eigen::Matrix<Value,Eigen::Dynamic,1>&
value)
const {
379 _expr.evaluate (K,
value);
385 template<
class Value>
388 if (! is_undeterminated<A1>::value) { _expr.template valued_check<A1>(); }
395 template<
class F,
class Expr>
struct is_field_expr_quadrature_arg <field_expr_quadrature_unary<F,Expr> > : std::true_type {};
402 #define _RHEOLEF_make_field_expr_quadrature_unary(FUNCTION,FUNCTOR) \
403 template<class Expr> \
407 details::is_field_expr_quadrature_arg<Expr>::value \
408 ,details::field_expr_quadrature_unary< \
413 FUNCTION (const Expr& expr) \
415 return details::field_expr_quadrature_unary <FUNCTOR,Expr> (FUNCTOR(), expr); \
418 _RHEOLEF_make_field_expr_quadrature_unary (
operator+, details::unary_plus)
419 _RHEOLEF_make_field_expr_quadrature_unary (
operator-, details::negate)
420 #undef _RHEOLEF_make_field_expr_quadrature_unary
433 template<
class BinaryFunction,
class Expr1,
class Expr2>
442 typename Expr1::value_type
445 typename Expr1::value_type
446 ,
typename Expr2::value_type
452 typename Expr1::vf_tag_type,
458 typename Expr2::dual_self_type>
464 template<
class Sfinae
465 =
typename std::enable_if<
483 _expr1.initialize (omega_K, iopt);
484 _expr2.initialize (omega_K, iopt);
490 template<
class Value>
494 Eigen::Matrix<Value,Eigen::Dynamic,1>&
value)
const
501 Eigen::Matrix<A2,Eigen::Dynamic,1> value2 (
value.size());
503 _expr2.evaluate (omega_K, K, value2);
508 template<
class Value>
532 #define _RHEOLEF_field_expr_quadrature_binary(FUNCTION,FUNCTOR) \
533 template <class Expr1, class Expr2> \
537 details::is_field_expr_quadrature_arg <Expr1>::value \
538 && details::is_field_expr_quadrature_arg <Expr2>::value \
539 ,details::field_expr_quadrature_binary< \
545 FUNCTION (const Expr1& expr1, const Expr2& expr2) \
547 return details::field_expr_quadrature_binary \
548 <FUNCTOR, Expr1, Expr2> \
549 (FUNCTOR(), expr1, expr2); \
551 template <class Expr1, class ExprVar2> \
555 details::is_field_expr_quadrature_arg <Expr1>::value \
556 && details::is_field_expr_v2_variational_arg <ExprVar2>::value \
557 ,details::field_expr_quadrature_binary< \
560 ,details::field_expr_quadrature_on_element<ExprVar2> \
563 FUNCTION (const Expr1& expr1, const ExprVar2& expr_var2) \
565 using Expr2 = details::field_expr_quadrature_on_element<ExprVar2>; \
566 return details::field_expr_quadrature_binary \
567 <FUNCTOR, Expr1, Expr2> \
568 (FUNCTOR(), expr1, Expr2(expr_var2)); \
570 template <class ExprVar1, class Expr2> \
574 details::is_field_expr_v2_variational_arg <ExprVar1>::value \
575 && details::is_field_expr_quadrature_arg <Expr2>::value \
576 ,details::field_expr_quadrature_binary< \
578 ,details::field_expr_quadrature_on_element<ExprVar1> \
582 FUNCTION (const ExprVar1& expr_var1, const Expr2& expr2) \
584 using Expr1 = details::field_expr_quadrature_on_element<ExprVar1>; \
585 return details::field_expr_quadrature_binary \
586 <FUNCTOR, Expr1, Expr2> \
587 (FUNCTOR(), Expr1(expr_var1), expr2); \
593 #undef _RHEOLEF_field_expr_quadrature_binary
605 template<
class Expr1,
class Expr2,
class Sfinae =
void>
606 struct is_field_expr_quadrature_binary_multiplies_divides_constant_left : std::false_type {};
608 template<
class Expr1,
class Expr2>
609 struct is_field_expr_quadrature_binary_multiplies_divides_constant_left <
614 is_rheolef_arithmetic <Expr1>::value
615 && is_field_expr_quadrature_arg<Expr2>::value
621 template<
class Expr1,
class Expr2>
622 struct is_field_expr_quadrature_binary_multiplies_divides_constant_right
623 : is_field_expr_quadrature_binary_multiplies_divides_constant_left <Expr2,Expr1> {};
627 #define _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant_left(FUNCTION,FUNCTOR) \
628 template<class Expr1, class Expr2> \
632 details::is_field_expr_quadrature_binary_multiplies_divides_constant_left <Expr1,Expr2>::value \
633 ,details::field_expr_quadrature_unary< \
634 details::binder_first <FUNCTOR, Expr1> \
638 FUNCTION (const Expr1& expr1, const Expr2& expr2) \
640 return details::field_expr_quadrature_unary \
641 <details::binder_first <FUNCTOR,Expr1>, Expr2> \
642 (details::binder_first <FUNCTOR,Expr1> (FUNCTOR(), expr1), expr2); \
645 #define _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant_right(FUNCTION,FUNCTOR) \
646 template<class Expr1, class Expr2> \
650 details::is_field_expr_quadrature_binary_multiplies_divides_constant_right <Expr1,Expr2>::value \
651 ,details::field_expr_quadrature_unary< \
652 details::binder_second <FUNCTOR, Expr2> \
656 FUNCTION (const Expr1& expr1, const Expr2& expr2) \
658 return details::field_expr_quadrature_unary \
659 <details::binder_second <FUNCTOR,Expr2>, Expr1> \
660 (details::binder_second <FUNCTOR,Expr2> (FUNCTOR(), expr2), expr1); \
663 #define _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant(FUNCTION,FUNCTOR) \
664 _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant_left (FUNCTION,FUNCTOR) \
665 _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant_right (FUNCTION,FUNCTOR)
668 _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant (
operator*, details::multiplies)
669 _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant_right (
operator/, details::divides)
671 #undef _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant_right
672 #undef _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant_left
673 #undef _RHEOLEF_make_field_expr_quadrature_binary_operator_multiplies_divides_constant
field::size_type size_type
field gh(Float epsilon, Float t, const field &uh, const test &v)
details::generic_binary_traits< BinaryFunction >::template result_hint< typename Expr1::value_type,typename Expr2::value_type >::type result_hint
space_basic< scalar_type, memory_type > space_type
promote_memory< typename Expr1::memory_type, typename Expr2::memory_type >::type memory_type
void initialize(const geo_basic< float_type, memory_type > &omega_K, const integrate_option &iopt) const
field_expr_quadrature_binary< BinaryFunction, typename Expr1::dual_self_type, typename Expr2::dual_self_type > dual_self_type
void initialize(const band_basic< float_type, memory_type > &gh, const integrate_option &iopt) const
details::generic_binary_traits< BinaryFunction >::template hint< typename Expr1::value_type,typename Expr2::value_type,result_hint >::result_type value_type
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, Eigen::Matrix< Value, Eigen::Dynamic, 1 > &value) const
void valued_check() const
field_expr_quadrature_binary< BinaryFunction, Expr1, Expr2 > self_type
details::bf_vf_tag< BinaryFunction, typename Expr1::vf_tag_type, typename Expr2::vf_tag_type >::type vf_tag_type
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
field_expr_quadrature_binary(const BinaryFunction &f, const Expr1 &expr1, const Expr2 &expr2)
scalar_traits< value_type >::type scalar_type
const space_type & get_vf_space() const
float_traits< value_type >::type float_type
geo_element::size_type size_type
space_basic< scalar_type, memory_type > space_type
void initialize(const geo_basic< float_type, memory_type > &omega_K, const integrate_option &iopt) const
void valued_check() const
field_expr_quadrature_on_element< typename Expr::dual_self_type > dual_self_type
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
scalar_traits< value_type >::type scalar_type
field_expr_quadrature_on_element< Expr > self_type
Expr::value_type value_type
Expr::memory_type memory_type
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, Eigen::Matrix< Value, Eigen::Dynamic, 1 > &lk) const
Expr::value_type result_hint
piola_on_pointset< float_type > _pops
field_expr_quadrature_on_element(const Expr &expr)
const space_type & get_vf_space() const
Expr::vf_tag_type vf_tag_type
float_traits< value_type >::type float_type
geo_element::size_type size_type
space_basic< scalar_type, memory_type > space_type
field_expr_quadrature_on_sides(const Expr &expr)
void initialize(const geo_basic< float_type, memory_type > &omega_K, const integrate_option &iopt) const
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, Eigen::Matrix< Value, Eigen::Dynamic, 1 > &value) const
std::vector< size_type > _dis_inod_S
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
field_expr_quadrature_on_sides< Expr > self_type
tensor_basic< float_type > _DF
scalar_traits< value_type >::type scalar_type
Expr::value_type value_type
Expr::memory_type memory_type
Expr::value_type result_hint
piola_on_pointset< float_type > _pops
const space_type & get_vf_space() const
Expr::vf_tag_type vf_tag_type
Eigen::Matrix< float_type, Eigen::Dynamic, Eigen::Dynamic > _value_i
field_expr_quadrature_on_sides< typename Expr::dual_self_type > dual_self_type
float_traits< value_type >::type float_type
geo_element::size_type size_type
see the geo_element page for the full documentation
size_type edge(size_type i) const
size_type face(size_type i) const
reference_element::size_type size_type
size_type dimension() const
orientation_type get_side_informations(const geo_element &S, size_type &loc_isid, size_type &shift) const
size_type n_subgeo(size_type subgeo_dim) const
see the integrate_option page for the full documentation
bool _is_inside_on_local_sides
typename scalar_traits< value_type >::type scalar_type
typename float_traits< value_type >::type float_type
typename Expr1::memory_type memory_type
typename details::generic_binary_traits< BinaryFunction >::template result_hint< typename Expr1::result_type, typename Expr2::result_type >::type result_type
static const space_constant::valued_type valued_hint
rheolef::std BinaryFunction
rheolef::std Expr1
dot(x,y): see the expression page for the full documentation
#define fatal_macro(message)
integrate_option expr_quadrature_init_iopt(const geo_basic< T, M > &omega_K, const space_basic< T, M > &X, size_t n_derivative, const integrate_option &iopt)
This file is part of Rheolef.
std::enable_if< details::is_field_expr_v2_variational_arg< Expr >::value,details::field_expr_quadrature_on_sides< Expr > >::type on_local_sides(const Expr &expr)
on_local_sides(expr): see the expression page for the full documentation
bool valued_check() const
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt) const
void evaluate(const geo_basic< float_type, M > &omega_K, const geo_element &K, Eigen::Matrix< Result, Eigen::Dynamic, 1 > &value) const
_RHEOLEF_field_expr_quadrature_binary(operator+, details::plus) _RHEOLEF_field_expr_quadrature_binary(operator-
static const valued_type value