Rheolef  7.1
an efficient C++ finite element environment
memorized_value.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_MEMORIZED_VALUE_H
2 #define _RHEOLEF_MEMORIZED_VALUE_H
3 //
24 // utility:
25 // use internal data area: avoid repetitive memory allocation
26 //
27 // internal data area accessor: return
28 // _scalar_val
29 // _vector_val
30 // _tensor_val
31 // depending upon Value template parameter
32 // => allows generic programmation vs Value
33 //
34 // implementation note:
35 // template specialized accessor: use class-specialization
36 // since specialization is neither available for func and class-member
37 //
38 // ----------------------------------------------------------------------------
39 #include "rheolef/compiler_eigen.h"
40 
41 namespace rheolef { namespace details {
42 
43 
44 // ----------------------------------------------------------------------------
45 // vector-valued data
46 // ----------------------------------------------------------------------------
47 template <class T, class Value> struct memorized_vector {};
48 
49 
50 #define _RHEOLEF_class_specialization(VALUE,MEMBER) \
51 template<class T> \
52 struct memorized_vector<T,VALUE> { \
53  template <class Object> \
54  Eigen::Matrix<VALUE,Eigen::Dynamic,1>& \
55  get (const Object& obj, const reference_element& hat_K) const { \
56  return obj.MEMBER [hat_K.variant()]; \
57  } \
58 }; \
59 
65 #undef _RHEOLEF_class_specialization
66 
67 // ----------------------------------------------------------------------------
68 // matrix-valued data
69 // ----------------------------------------------------------------------------
70 template <class T, class Value> struct memorized_matrix {};
71 
72 #define _RHEOLEF_class_specialization(VALUE,MEMBER) \
73 template<class T> \
74 struct memorized_matrix<T,VALUE> { \
75  template <class Object> \
76  Eigen::Matrix<VALUE,Eigen::Dynamic,Eigen::Dynamic>& \
77  get (const Object& obj, const reference_element& hat_K) const { \
78  return obj.MEMBER [hat_K.variant()]; \
79  } \
80 }; \
81 
87 #undef _RHEOLEF_class_specialization
88 
89 // ----------------------------------------------------------
90 // similar accessors for values on sides
91 // ----------------------------------------------------------
92 template <class T, class Value> struct memorized_side_value {};
93 
94 #define _RHEOLEF_class_specialization(VALUE,MEMBER) \
95 template<class T> \
96 struct memorized_side_value<T,VALUE> { \
97  template <class Object> \
98  Eigen::Matrix<VALUE,Eigen::Dynamic,Eigen::Dynamic>& \
99  get ( \
100  const Object& obj, \
101  const reference_element& hat_K, \
102  const side_information_type& sid) const { \
103  size_t ori_idx = (sid.orient == 1) ? 0 : 1; \
104  return obj.MEMBER [hat_K.variant()] [sid.loc_isid] [ori_idx] [sid.shift]; \
105  } \
106 }; \
107 
113 #undef _RHEOLEF_class_specialization
114 
115 }} // namespace rheolef::details
116 #endif // _RHEOLEF_MEMORIZED_VALUE_H
rheolef::point_basic
Definition: point.h:87
rheolef::tensor4_basic
Definition: tensor4.h:80
rheolef::tensor_basic
Definition: tensor.h:90
rheolef::tensor3_basic
Definition: tensor3.h:73
rheolef::details::memorized_matrix
Definition: memorized_value.h:70
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::details::memorized_vector
Definition: memorized_value.h:47
rheolef::details::_RHEOLEF_class_specialization
_RHEOLEF_class_specialization(T, _scalar_val) _RHEOLEF_class_specialization(point_basic< T >
T
Expr1::float_type T
Definition: field_expr.h:261
rheolef::details::memorized_side_value
Definition: memorized_value.h:92