Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
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"
32namespace rheolef { namespace details {
33
34// ----------------------------------------------------------
35// define tag: pair of compile-time booleans
36// that expresses the linearity with respect to each variable
37// ----------------------------------------------------------
38struct vf_tag_nonlinear {};
39typedef std::pair<std::false_type,std::false_type> vf_tag_00;
40typedef std::pair<std::false_type,std::true_type > vf_tag_01;
41typedef std::pair<std::true_type, std::true_type > vf_tag_11;
42typedef 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// ------------------------------------------------
47template <class G>
48struct dual_vf_tag { typedef vf_tag_nonlinear type; };
49
50template<> struct dual_vf_tag<vf_tag_01> { typedef vf_tag_10 type; };
51template<> struct dual_vf_tag<vf_tag_10> { typedef vf_tag_01 type; };
52template<> struct dual_vf_tag<vf_tag_00> { typedef vf_tag_00 type; };
53template<> 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// --------------------------------------------------------------------
58template <class Op, class G>
59struct 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// --------------------------------------------------------------------
66template <class Op, class G1, class G2>
67struct 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// -----------------------------
75template<class Tag> struct bf_vf_tag<plus, Tag,Tag> { typedef Tag type; };
76template<class Tag> struct bf_vf_tag<minus,Tag,Tag> { typedef Tag type; };
77
78// -----------------------------
79// multiplies
80// -----------------------------
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
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