Rheolef  7.1
an efficient C++ finite element environment
vf_tag.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_VF_TAG_H
2 #define _RHEOLEF_VF_TAG_H
23 //
24 // vf_tag is used to determine at compile time when a binary
25 // variationnal expression as : u*u, u*v, f*v, v*v*u, etc...
26 // is linear which respect to u or v, where: trial u; test v;
27 //
28 #include "rheolef/compiler.h"
29 #include "rheolef/expression.h"
30 //#include "rheolef/field_nonlinear_expr.h"
31 //#include "rheolef/field_nonlinear_expr_ops.h"
32 namespace rheolef { namespace details {
33 
34 // ----------------------------------------------------------
35 // define tag: pair of compile-time booleans
36 // that expresses the linearity with respect to each variable
37 // ----------------------------------------------------------
38 struct vf_tag_nonlinear {};
39 typedef std::pair<std::false_type,std::false_type> vf_tag_00;
40 typedef std::pair<std::false_type,std::true_type > vf_tag_01;
41 typedef std::pair<std::true_type, std::true_type > vf_tag_11;
42 typedef std::pair<std::true_type, std::false_type> vf_tag_10;
43 
44 // ------------------------------------------------
45 // dual vf tag: 01 <--> 10 i.e. swap test and trial
46 // ------------------------------------------------
47 template <class G>
48 struct dual_vf_tag { typedef vf_tag_nonlinear type; };
49 
50 template<> struct dual_vf_tag<vf_tag_01> { typedef vf_tag_10 type; };
51 template<> struct dual_vf_tag<vf_tag_10> { typedef vf_tag_01 type; };
52 template<> struct dual_vf_tag<vf_tag_00> { typedef vf_tag_00 type; };
53 template<> struct dual_vf_tag<vf_tag_11> { typedef vf_tag_11 type; };
54 
55 // --------------------------------------------------------------------
56 // unary operator: default is nonlinear with respect to each variable
57 // --------------------------------------------------------------------
58 template <class Op, class G>
59 struct uf_vf_tag { typedef vf_tag_nonlinear type; };
60 
61 // TODO: unary +-
62 
63 // --------------------------------------------------------------------
64 // binary operator: default is nonlinear with respect to each variable
65 // --------------------------------------------------------------------
66 template <class Op, class G1, class G2>
67 struct bf_vf_tag { typedef vf_tag_nonlinear type; };
68 
69 // Note: operators plus, multiples, etc are defined in field_nonlinear_expr_ops.h
70 // they should be grouped in one separated file with vf_tag, or tag defined for each
71 // operator in field_nonlinear_expr_ops_make.cc ?
72 // -----------------------------
73 // plus/minus
74 // -----------------------------
75 template<class Tag> struct bf_vf_tag<plus, Tag,Tag> { typedef Tag type; };
76 template<class Tag> struct bf_vf_tag<minus,Tag,Tag> { typedef Tag type; };
77 
78 // -----------------------------
79 // multiplies
80 // -----------------------------
81 template<> struct bf_vf_tag<multiplies,vf_tag_00,vf_tag_00> { typedef vf_tag_00 type; };
82 
83 template<> struct bf_vf_tag<multiplies,vf_tag_00,vf_tag_01> { typedef vf_tag_01 type; };
84 template<> struct bf_vf_tag<multiplies,vf_tag_01,vf_tag_00> { typedef vf_tag_01 type; };
85 
86 template<> struct bf_vf_tag<multiplies,vf_tag_00,vf_tag_10> { typedef vf_tag_10 type; };
87 template<> struct bf_vf_tag<multiplies,vf_tag_10,vf_tag_00> { typedef vf_tag_10 type; };
88 
89 template<> struct bf_vf_tag<multiplies,vf_tag_01,vf_tag_10> { typedef vf_tag_11 type; };
90 template<> struct bf_vf_tag<multiplies,vf_tag_10,vf_tag_01> { typedef vf_tag_11 type; };
91 template<> struct bf_vf_tag<multiplies,vf_tag_00,vf_tag_11> { typedef vf_tag_11 type; };
92 template<> struct bf_vf_tag<multiplies,vf_tag_11,vf_tag_00> { typedef vf_tag_11 type; };
93 
94 
95 }} // namespace rheolef::details
96 #endif // _RHEOLEF_VF_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.
vf_tag_nonlinear type
Definition: vf_tag.h:67
vf_tag_nonlinear type
Definition: vf_tag.h:48
vf_tag_nonlinear type
Definition: vf_tag.h:59