Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
memorized_value.h
Go to the documentation of this file.
1#ifndef _RHEOLEF_MEMORIZED_VALUE_H
2#define _RHEOLEF_MEMORIZED_VALUE_H
23//
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
41namespace rheolef { namespace details {
42
43
44// ----------------------------------------------------------------------------
45// vector-valued data
46// ----------------------------------------------------------------------------
47template <class T, class Value> struct memorized_vector {};
48
49
50#define _RHEOLEF_class_specialization(VALUE,MEMBER) \
51template<class T> \
52struct 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// ----------------------------------------------------------------------------
70template <class T, class Value> struct memorized_matrix {};
71
72#define _RHEOLEF_class_specialization(VALUE,MEMBER) \
73template<class T> \
74struct 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// ----------------------------------------------------------
92template <class T, class Value> struct memorized_side_value {};
93
94#define _RHEOLEF_class_specialization(VALUE,MEMBER) \
95template<class T> \
96struct 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
Expr1::float_type T
Definition field_expr.h:230
#define _RHEOLEF_class_specialization(VALUE, MEMBER)
This file is part of Rheolef.