rheolef  6.5
space_constant.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_SPACE_CONSTANT_H
2 #define _RHEOLEF_SPACE_CONSTANT_H
3 
4 #include "rheolef/distributed.h"
5 #include "rheolef/undeterminated.h"
6 
7 
8 namespace rheolef { namespace details {
9 
10 template <class T1, class T2> struct is_equal : mpl::false_ {};
11 template <class T> struct is_equal<T,T> : mpl::true_ {};
12 
13 template<class T> struct is_scalar : boost::mpl::false_ {};
14 template<> struct is_scalar<int> : boost::mpl::true_ {};
15 template<> struct is_scalar<const int> : boost::mpl::true_ {};
16 template<> struct is_scalar<size_t> : boost::mpl::true_ {};
17 template<> struct is_scalar<Float> : boost::mpl::true_ {};
18 
19 template<class T> struct is_point : boost::mpl::false_ {};
20 template<class T> struct is_point<point_basic<T> > : boost::mpl::true_ {};
21 
22 template<class T> struct is_tensor : boost::mpl::false_ {};
23 template<class T> struct is_tensor<tensor_basic<T> > : boost::mpl::true_ {};
24 
25 template<class T> struct is_tensor3 : boost::mpl::false_ {};
26 template<class T> struct is_tensor3<tensor3_basic<T> > : boost::mpl::true_ {};
27 
28 template<class T> struct is_tensor4 : boost::mpl::false_ {};
29 template<class T> struct is_tensor4<tensor4_basic<T> > : boost::mpl::true_ {};
30 
31 }} // namespace rheolef::details
32 
33 namespace rheolef { namespace space_constant {
34 
35 typedef size_t size_type;
36 
37 typedef enum {
38  cartesian = 0,
43 
44 coordinate_type coordinate_system (std::string sys_coord);
47 
48 typedef enum {
49  scalar = 0,
50  vector = 1,
51  tensor = 2, // symmetric, D_ij
53  tensor3 = 4, // unsymmetric, G_ijk
54  tensor4 = 5, // symmetric, A_ijkl
55  mixed = 6,
57 } valued_type;
58 
59 const std::string& valued_name (valued_type tag);
60 valued_type valued_tag (const std::string& name);
61 
64  size_type d,
65  coordinate_type sys_coord);
66 
68  const std::string& valued,
69  size_type d,
70  coordinate_type sys_coord);
71 
72 // size_t tag = valued_tag_traits<T>::value;
73 template<class T> struct valued_tag_traits { static const valued_type value = scalar; };
74 template<class T> struct valued_tag_traits<point_basic<T> > { static const valued_type value = vector; };
75 template<class T> struct valued_tag_traits<tensor_basic<T> > { static const valued_type value = tensor; };
76 template<class T> struct valued_tag_traits<tensor3_basic<T> > { static const valued_type value = tensor3; };
77 template<class T> struct valued_tag_traits<tensor4_basic<T> > { static const valued_type value = tensor4; };
78 template<class T> struct valued_tag_traits<undeterminated_basic<T> > { static const valued_type value = last_valued; };
79 
80 // typedef typename valued_type_traits<tag,T>::type valued_t;
81 template<int Tag, class T> struct valued_type_traits { typedef undeterminated_basic<T> type; };
82 template<class T> struct valued_type_traits<scalar,T> { typedef T type; };
83 template<class T> struct valued_type_traits<vector,T> { typedef point_basic<T> type; };
84 template<class T> struct valued_type_traits<tensor,T> { typedef tensor_basic<T> type; };
85 template<class T> struct valued_type_traits<tensor3,T> { typedef tensor3_basic<T> type; };
86 template<class T> struct valued_type_traits<tensor4,T> { typedef tensor4_basic<T> type; };
87 template<class T> struct valued_type_traits<last_valued,T> { typedef undeterminated_basic<T> type; };
88 
90 template<class T> struct rank_down<point_basic<T> > { typedef T type; };
91 template<class T> struct rank_down<tensor_basic<T> > { typedef point_basic<T> type; };
92 template<class T> struct rank_down<tensor3_basic<T> > { typedef tensor_basic<T> type; };
93 template<class T> struct rank_down<tensor4_basic<T> > { typedef tensor3_basic<T> type; };
94 
95 template<class T> struct rank_up { typedef point_basic<typename scalar_traits<T>::type> type; };
96 template<class T> struct rank_up<point_basic<T> > { typedef tensor_basic<T> type; };
97 template<class T> struct rank_up<tensor_basic<T> > { typedef tensor3_basic<T> type; };
98 template<class T> struct rank_up<tensor3_basic<T> > { typedef tensor4_basic<T> type; };
100 
101 template<class T>
102 T contract_product (const T& a, const T& b) { return a*b; }
103 template<class T>
104 T contract_product (const point_basic<T>& a, const point_basic<T>& b) { return dot(a,b); }
105 template<class T>
106 T contract_product (const tensor_basic<T>& a, const tensor_basic<T>& b) { return ddot(a,b); }
107 
110  coordinate_type sys_coord,
111  size_type i,
112  size_type j);
113 
115  std::string valued,
116  std::string sys_coord,
117  size_type i,
118  size_type j);
119 
120 std::pair<size_type,size_type>
123  coordinate_type sys_coord,
124  size_type i_comp);
125 
126 std::string
129  coordinate_type sys_coord,
130  size_type i_comp);
131 
132 std::pair<size_type,size_type>
134  std::string valued,
135  std::string sys_coord,
136  size_type i_comp);
137 
138 std::string
140  std::string valued,
141  std::string sys_coord,
142  size_type i_comp);
143 
144 size_type
146  valued_type valued,
147  coordinate_type sys_coord,
148  size_type i,
149  size_type j,
150  size_type k,
151  size_type l);
152 
153 size_type
155  std::string valued,
156  std::string sys_coord,
157  size_type i,
158  size_type j,
159  size_type k,
160  size_type l);
161 
162 std::pair<std::pair<size_type,size_type>, std::pair<size_type,size_type> >
164  valued_type valued,
165  coordinate_type sys_coord,
166  size_type i_comp);
167 
168 std::string
170  valued_type valued,
171  coordinate_type sys_coord,
172  size_type i_comp);
173 
174 std::pair<std::pair<size_type,size_type>, std::pair<size_type,size_type> >
176  std::string valued,
177  std::string sys_coord,
178  size_type i_comp);
179 
180 std::string
182  std::string valued,
183  std::string sys_coord,
184  size_type i_comp);
185 
186 // field*field & field/field valued_type computed at run time
189 
190 
191 }} // namespace rheolef::space_constant
192 #endif // _RHEOLEF_SPACE_CONSTITUTION_H
193