field_expr_variational_tag.h
Go to the documentation of this file.
#ifndef _RHEOLEF_FIELD_EXPR_VARIATIONAL_TAG_H
#define _RHEOLEF_FIELD_EXPR_VARIATIONAL_TAG_H
//
// in a variational formulation we define things like that:
// a(u,v) = integrate(expr...);
// where expr should be linear with respect to u and v
// => define tag: pair of compile-time booleans
// that expresses the linearity with respect to each variable
//
// vf_tag is used to determine at compile time when a binary
// variationnal expression as : u*u, u*v, f*v, v*v*u, etc...
// is linear which respect to u or v, where:
// trial u;
// test v;
//
// SUMLMARY:
// 1. concept
// 2. duality
// 3. unary operators and functions
// 4. binary operators and functions
//
#include "rheolef/compiler.h"
#include "rheolef/expression.h"
namespace rheolef { namespace details {
// ----------------------------------------------------------
// 1. concept: a pair of compile-time booleans
// ----------------------------------------------------------
struct vf_tag_nonlinear {};
typedef std::pair <std::false_type,std::false_type> vf_tag_00;
typedef std::pair <std::false_type,std::true_type > vf_tag_01;
typedef std::pair <std::true_type, std::true_type > vf_tag_11;
typedef std::pair <std::true_type, std::false_type> vf_tag_10;
// ------------------------------------------------
// 2. duality
// ------------------------------------------------
// vf tag: 01 <--> 10 i.e. swap test and trial
template<class T> struct dual_vf_tag { typedef vf_tag_nonlinear type; };
template<> struct dual_vf_tag <vf_tag_01> { typedef vf_tag_10 type; };
template<> struct dual_vf_tag <vf_tag_10> { typedef vf_tag_01 type; };
template<> struct dual_vf_tag <vf_tag_00> { typedef vf_tag_00 type; };
template<> struct dual_vf_tag <vf_tag_11> { typedef vf_tag_11 type; };
// --------------------------------------------------------------------
// 3. unary operators and functions
// --------------------------------------------------------------------
// default is nonlinear with respect to each variable
template <class F, class T> struct uf_vf_tag { typedef vf_tag_nonlinear type; };
template<class Tag> struct uf_vf_tag <unary_plus, Tag> { typedef Tag type; };
template<class Tag> struct uf_vf_tag <negate, Tag> { typedef Tag type; };
// --------------------------------------------------------------------
// 4. binary operators and functions
// --------------------------------------------------------------------
// default is nonlinear with respect to each variable
template <class F, class T1, class T2> struct bf_vf_tag { typedef vf_tag_nonlinear type; };
// plus/minus
template<class Tag> struct bf_vf_tag <plus, Tag,Tag> { typedef Tag type; };
template<class Tag> struct bf_vf_tag <minus,Tag,Tag> { typedef Tag type; };
// multiplies
template<> struct bf_vf_tag <multiplies,vf_tag_00,vf_tag_00> { typedef vf_tag_00 type; };
template<> struct bf_vf_tag <multiplies,vf_tag_00,vf_tag_01> { typedef vf_tag_01 type; };
template<> struct bf_vf_tag <multiplies,vf_tag_01,vf_tag_00> { typedef vf_tag_01 type; };
template<> struct bf_vf_tag <multiplies,vf_tag_00,vf_tag_10> { typedef vf_tag_10 type; };
template<> struct bf_vf_tag <multiplies,vf_tag_10,vf_tag_00> { typedef vf_tag_10 type; };
template<> struct bf_vf_tag <multiplies,vf_tag_01,vf_tag_10> { typedef vf_tag_11 type; };
template<> struct bf_vf_tag <multiplies,vf_tag_10,vf_tag_01> { typedef vf_tag_11 type; };
template<> struct bf_vf_tag <multiplies,vf_tag_00,vf_tag_11> { typedef vf_tag_11 type; };
template<> struct bf_vf_tag <multiplies,vf_tag_11,vf_tag_00> { typedef vf_tag_11 type; };
}} // namespace rheolef::details
#endif // _RHEOLEF_FIELD_EXPR_VARIATIONAL_TAG_H
rheolef::details::uf_vf_tag< unary_plus, Tag >::type
Tag type
Definition: field_expr_variational_tag.h:68
rheolef::details::vf_tag_01
std::pair< std::false_type, std::true_type > vf_tag_01
Definition: field_expr_variational_tag.h:51
rheolef::details::dual_vf_tag
Definition: field_expr_variational_tag.h:58
rheolef::details::uf_vf_tag::type
vf_tag_nonlinear type
Definition: field_expr_variational_tag.h:67
rheolef::details::dual_vf_tag::type
vf_tag_nonlinear type
Definition: field_expr_variational_tag.h:58
rheolef::details::bf_vf_tag
Definition: field_expr_variational_tag.h:74
rheolef::details::dual_vf_tag< vf_tag_00 >::type
vf_tag_00 type
Definition: field_expr_variational_tag.h:61
rheolef::details::bf_vf_tag< multiplies, vf_tag_10, vf_tag_00 >::type
vf_tag_10 type
Definition: field_expr_variational_tag.h:87
rheolef::details::bf_vf_tag< multiplies, vf_tag_00, vf_tag_01 >::type
vf_tag_01 type
Definition: field_expr_variational_tag.h:83
rheolef::details::minus
Definition: expression.h:543
rheolef::details::bf_vf_tag< multiplies, vf_tag_01, vf_tag_00 >::type
vf_tag_01 type
Definition: field_expr_variational_tag.h:84
rheolef::details::bf_vf_tag< multiplies, vf_tag_00, vf_tag_00 >::type
vf_tag_00 type
Definition: field_expr_variational_tag.h:81
rheolef::details::dual_vf_tag< vf_tag_11 >::type
vf_tag_11 type
Definition: field_expr_variational_tag.h:62
rheolef::details::bf_vf_tag< plus, Tag, Tag >::type
Tag type
Definition: field_expr_variational_tag.h:77
rheolef::details::dual_vf_tag< vf_tag_01 >::type
vf_tag_10 type
Definition: field_expr_variational_tag.h:59
rheolef::details::bf_vf_tag< multiplies, vf_tag_01, vf_tag_10 >::type
vf_tag_11 type
Definition: field_expr_variational_tag.h:89
rheolef::details::vf_tag_10
std::pair< std::true_type, std::false_type > vf_tag_10
Definition: field_expr_variational_tag.h:53
rheolef::details::uf_vf_tag< negate, Tag >::type
Tag type
Definition: field_expr_variational_tag.h:69
rheolef::details::bf_vf_tag< multiplies, vf_tag_00, vf_tag_11 >::type
vf_tag_11 type
Definition: field_expr_variational_tag.h:91
rheolef::details::vf_tag_nonlinear
Definition: field_expr_variational_tag.h:49
rheolef::details::plus
Definition: expression.h:456
rheolef::details::unary_plus
Definition: expression.h:208
rheolef::details::uf_vf_tag
Definition: field_expr_variational_tag.h:67
rheolef::details::multiplies
Definition: expression.h:745
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::details::bf_vf_tag::type
vf_tag_nonlinear type
Definition: field_expr_variational_tag.h:74
rheolef::details::bf_vf_tag< multiplies, vf_tag_00, vf_tag_10 >::type
vf_tag_10 type
Definition: field_expr_variational_tag.h:86
rheolef::details::bf_vf_tag< multiplies, vf_tag_10, vf_tag_01 >::type
vf_tag_11 type
Definition: field_expr_variational_tag.h:90
rheolef::details::bf_vf_tag< minus, Tag, Tag >::type
Tag type
Definition: field_expr_variational_tag.h:78
rheolef::details::bf_vf_tag< multiplies, vf_tag_11, vf_tag_00 >::type
vf_tag_11 type
Definition: field_expr_variational_tag.h:92
rheolef::details::vf_tag_11
std::pair< std::true_type, std::true_type > vf_tag_11
Definition: field_expr_variational_tag.h:52
rheolef::details::negate
Definition: expression.h:230
rheolef::details::vf_tag_00
std::pair< std::false_type, std::false_type > vf_tag_00
Definition: field_expr_variational_tag.h:50
rheolef::details::dual_vf_tag< vf_tag_10 >::type
vf_tag_01 type
Definition: field_expr_variational_tag.h:60