OGS
LocalAssemblerTraits.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <cassert>
14#include <type_traits>
15
17
18namespace ProcessLib
19{
20
21namespace detail
22{
23
35template <typename ShpPol, unsigned NNodes, unsigned NodalDOF, int Dim>
37{
38private:
39 template <int N, int M>
40 using Matrix = typename ShpPol::template MatrixType<N, M>;
41 template <int N>
42 using Vector = typename ShpPol::template VectorType<N>;
43
44public:
45 using ShapeMatrices = typename ShpPol::ShapeMatrices;
46
49
50 // TODO That only works if all process variables are single component
51 // and use the same shape functions.
58
62
66
69 template <typename Mat>
70 static auto blockDimDim(Mat const& mat, unsigned top, unsigned left,
71 unsigned nrows, unsigned ncols)
72 {
73 if constexpr (NodalDOF != 0)
74 {
75 assert(nrows == Dim && ncols == Dim);
76 (void)nrows;
77 (void)ncols;
78 return mat.template block<Dim, Dim>(top, left);
79 }
80 else
81 {
82 assert(nrows == ncols);
83 return mat.block(top, left, nrows, ncols);
84 }
85 }
86
89 template <typename Mat>
90 static auto blockDimDim(Mat& mat, unsigned top, unsigned left,
91 unsigned nrows, unsigned ncols)
92 {
93 if constexpr (NodalDOF != 0)
94 {
95 assert(nrows == Dim && ncols == Dim);
96 (void)nrows;
97 (void)ncols;
98 return mat.template block<Dim, Dim>(top, left);
99 }
100 else
101 {
102 assert(nrows == ncols);
103 return mat.block(top, left, nrows, ncols);
104 }
105 }
106
109 template <typename Mat>
110 static auto blockShpShp(Mat const& mat, unsigned top, unsigned left,
111 unsigned nrows, unsigned ncols)
112 {
113 if constexpr (NodalDOF != 0)
114 {
115 assert(nrows == NNodes && ncols == NNodes);
116 (void)nrows;
117 (void)ncols;
118 return mat.template block<NNodes, NNodes>(top, left);
119 }
120 else
121 {
122 assert(nrows == ncols);
123 return mat.block(top, left, nrows, ncols);
124 }
125 }
126
129 template <typename Mat>
130 static auto blockShpShp(Mat& mat, unsigned top, unsigned left,
131 unsigned nrows, unsigned ncols)
132 {
133 if constexpr (NodalDOF != 0)
134 {
135 assert(nrows == NNodes && ncols == NNodes);
136 (void)nrows;
137 (void)ncols;
138 return mat.template block<NNodes, NNodes>(top, left);
139 }
140 else
141 {
142 assert(nrows == ncols);
143 return mat.block(top, left, nrows, ncols);
144 }
145 }
146
148 template <typename Vec>
149 static auto blockShp(Vec const& vec, unsigned top, unsigned nrows)
150 {
151 if constexpr (NodalDOF != 0)
152 {
153 assert(nrows == NNodes);
154 (void)nrows;
155 return vec.template block<NNodes, 1>(top, 0);
156 }
157 else
158 {
159 return vec.block(top, 0, nrows, 1);
160 }
161 }
162
164 template <typename Vec>
165 static auto blockShp(Vec& vec, unsigned top, unsigned nrows)
166 {
167 if constexpr (NodalDOF != 0)
168 {
169 assert(nrows == NNodes);
170 (void)nrows;
171 return vec.template block<NNodes, 1>(top, 0);
172 }
173 else
174 {
175 return vec.block(top, 0, nrows, 1);
176 }
177 }
178};
179
180} // namespace detail
181
182#ifndef OGS_EIGEN_DYNAMIC_SHAPE_MATRICES
183
184template <typename ShpPol, unsigned NNodes, unsigned NodalDOF, int Dim>
187
189 "Inconsistent use of the macro OGS_EIGEN_DYNAMIC_SHAPE_MATRICES."
190 " Maybe you forgot to include some header file.");
191#else
192
193template <typename ShpPol, unsigned NNodes, unsigned NodalDOF, int Dim>
196
198 "Inconsistent use of the macro OGS_EIGEN_DYNAMIC_SHAPE_MATRICES."
199 " Maybe you forgot to include some header file.");
200#endif
201
202} // namespace ProcessLib
const unsigned OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG
static auto blockShp(Vec &vec, unsigned top, unsigned nrows)
Get a block NNodes x 1 starting at the top'th row.
Matrix< Dim *NodalDOF, Dim *NodalDOF > LaplaceMatrix
static auto blockDimDim(Mat const &mat, unsigned top, unsigned left, unsigned nrows, unsigned ncols)
static auto blockShp(Vec const &vec, unsigned top, unsigned nrows)
Get a block NNodes x 1 starting at the top'th row.
Matrix< Dim, Dim > MatrixDimDim
Square matrix of the given space dimensionality.
static auto blockShpShp(Mat const &mat, unsigned top, unsigned left, unsigned nrows, unsigned ncols)
static auto blockShpShp(Mat &mat, unsigned top, unsigned left, unsigned nrows, unsigned ncols)
Matrix< NNodes *NodalDOF, NNodes *NodalDOF > LocalMatrix
typename ShpPol::template VectorType< N > Vector
typename ShpPol::template MatrixType< N, M > Matrix
static auto blockDimDim(Mat &mat, unsigned top, unsigned left, unsigned nrows, unsigned ncols)