Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
field_expr_variational_tag.h
Go to the documentation of this file.
1#ifndef _RHEOLEF_FIELD_EXPR_VARIATIONAL_TAG_H
2#define _RHEOLEF_FIELD_EXPR_VARIATIONAL_TAG_H
23//
24// in a variational formulation we define things like that:
25// a(u,v) = integrate(expr...);
26// where expr should be linear with respect to u and v
27// => define tag: pair of compile-time booleans
28// that expresses the linearity with respect to each variable
29//
30// vf_tag is used to determine at compile time when a binary
31// variationnal expression as : u*u, u*v, f*v, v*v*u, etc...
32// is linear which respect to u or v, where:
33// trial u;
34// test v;
35//
36// SUMLMARY:
37// 1. concept
38// 2. duality
39// 3. unary operators and functions
40// 4. binary operators and functions
41//
42#include "rheolef/compiler.h"
43#include "rheolef/expression.h"
44namespace rheolef { namespace details {
45
46// ----------------------------------------------------------
47// 1. concept: a pair of compile-time booleans
48// ----------------------------------------------------------
50typedef std::pair <std::false_type,std::false_type> vf_tag_00;
51typedef std::pair <std::false_type,std::true_type > vf_tag_01;
52typedef std::pair <std::true_type, std::true_type > vf_tag_11;
53typedef std::pair <std::true_type, std::false_type> vf_tag_10;
54// ------------------------------------------------
55// 2. duality
56// ------------------------------------------------
57// vf tag: 01 <--> 10 i.e. swap test and trial
58template<class T> struct dual_vf_tag { typedef vf_tag_nonlinear type; };
59template<> struct dual_vf_tag <vf_tag_01> { typedef vf_tag_10 type; };
60template<> struct dual_vf_tag <vf_tag_10> { typedef vf_tag_01 type; };
61template<> struct dual_vf_tag <vf_tag_00> { typedef vf_tag_00 type; };
62template<> struct dual_vf_tag <vf_tag_11> { typedef vf_tag_11 type; };
63// --------------------------------------------------------------------
64// 3. unary operators and functions
65// --------------------------------------------------------------------
66// default is nonlinear with respect to each variable
67template <class F, class T> struct uf_vf_tag { typedef vf_tag_nonlinear type; };
68template<class Tag> struct uf_vf_tag <unary_plus, Tag> { typedef Tag type; };
69template<class Tag> struct uf_vf_tag <negate, Tag> { typedef Tag type; };
70// --------------------------------------------------------------------
71// 4. binary operators and functions
72// --------------------------------------------------------------------
73// default is nonlinear with respect to each variable
74template <class F, class T1, class T2> struct bf_vf_tag { typedef vf_tag_nonlinear type; };
75
76// plus/minus
77template<class Tag> struct bf_vf_tag <plus, Tag,Tag> { typedef Tag type; };
78template<class Tag> struct bf_vf_tag <minus,Tag,Tag> { typedef Tag type; };
79
80// multiplies
81template<> struct bf_vf_tag <multiplies,vf_tag_00,vf_tag_00> { typedef vf_tag_00 type; };
82
83template<> struct bf_vf_tag <multiplies,vf_tag_00,vf_tag_01> { typedef vf_tag_01 type; };
84template<> struct bf_vf_tag <multiplies,vf_tag_01,vf_tag_00> { typedef vf_tag_01 type; };
85
86template<> struct bf_vf_tag <multiplies,vf_tag_00,vf_tag_10> { typedef vf_tag_10 type; };
87template<> struct bf_vf_tag <multiplies,vf_tag_10,vf_tag_00> { typedef vf_tag_10 type; };
88
89template<> struct bf_vf_tag <multiplies,vf_tag_01,vf_tag_10> { typedef vf_tag_11 type; };
90template<> struct bf_vf_tag <multiplies,vf_tag_10,vf_tag_01> { typedef vf_tag_11 type; };
91template<> struct bf_vf_tag <multiplies,vf_tag_00,vf_tag_11> { typedef vf_tag_11 type; };
92template<> struct bf_vf_tag <multiplies,vf_tag_11,vf_tag_00> { typedef vf_tag_11 type; };
93
94}} // namespace rheolef::details
95#endif // _RHEOLEF_FIELD_EXPR_VARIATIONAL_TAG_H
std::pair< std::false_type, std::false_type > vf_tag_00
std::pair< std::true_type, std::true_type > vf_tag_11
std::pair< std::false_type, std::true_type > vf_tag_01
std::pair< std::true_type, std::false_type > vf_tag_10
This file is part of Rheolef.