OGS
LocalAssemblerTraits.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <cassert>
7#include <type_traits>
8
10
11namespace ProcessLib
12{
13
14namespace detail
15{
16
28template <typename ShpPol, unsigned NNodes, unsigned NodalDOF, int Dim>
30{
31private:
32 template <int N, int M>
33 using Matrix = typename ShpPol::template MatrixType<N, M>;
34 template <int N>
35 using Vector = typename ShpPol::template VectorType<N>;
36
37public:
38 using ShapeMatrices = typename ShpPol::ShapeMatrices;
39
42
43 // TODO That only works if all process variables are single component
44 // and use the same shape functions.
51
55
59
62 template <typename Mat>
63 static auto blockDimDim(Mat const& mat, unsigned top, unsigned left,
64 unsigned nrows, unsigned ncols)
65 {
66 if constexpr (NodalDOF != 0)
67 {
68 assert(nrows == Dim && ncols == Dim);
69 (void)nrows;
70 (void)ncols;
71 return mat.template block<Dim, Dim>(top, left);
72 }
73 else
74 {
75 assert(nrows == ncols);
76 return mat.block(top, left, nrows, ncols);
77 }
78 }
79
82 template <typename Mat>
83 static auto blockDimDim(Mat& mat, unsigned top, unsigned left,
84 unsigned nrows, unsigned ncols)
85 {
86 if constexpr (NodalDOF != 0)
87 {
88 assert(nrows == Dim && ncols == Dim);
89 (void)nrows;
90 (void)ncols;
91 return mat.template block<Dim, Dim>(top, left);
92 }
93 else
94 {
95 assert(nrows == ncols);
96 return mat.block(top, left, nrows, ncols);
97 }
98 }
99
102 template <typename Mat>
103 static auto blockShpShp(Mat const& mat, unsigned top, unsigned left,
104 unsigned nrows, unsigned ncols)
105 {
106 if constexpr (NodalDOF != 0)
107 {
108 assert(nrows == NNodes && ncols == NNodes);
109 (void)nrows;
110 (void)ncols;
111 return mat.template block<NNodes, NNodes>(top, left);
112 }
113 else
114 {
115 assert(nrows == ncols);
116 return mat.block(top, left, nrows, ncols);
117 }
118 }
119
122 template <typename Mat>
123 static auto blockShpShp(Mat& mat, unsigned top, unsigned left,
124 unsigned nrows, unsigned ncols)
125 {
126 if constexpr (NodalDOF != 0)
127 {
128 assert(nrows == NNodes && ncols == NNodes);
129 (void)nrows;
130 (void)ncols;
131 return mat.template block<NNodes, NNodes>(top, left);
132 }
133 else
134 {
135 assert(nrows == ncols);
136 return mat.block(top, left, nrows, ncols);
137 }
138 }
139
141 template <typename Vec>
142 static auto blockShp(Vec const& vec, unsigned top, unsigned nrows)
143 {
144 if constexpr (NodalDOF != 0)
145 {
146 assert(nrows == NNodes);
147 (void)nrows;
148 return vec.template block<NNodes, 1>(top, 0);
149 }
150 else
151 {
152 return vec.block(top, 0, nrows, 1);
153 }
154 }
155
157 template <typename Vec>
158 static auto blockShp(Vec& vec, unsigned top, unsigned nrows)
159 {
160 if constexpr (NodalDOF != 0)
161 {
162 assert(nrows == NNodes);
163 (void)nrows;
164 return vec.template block<NNodes, 1>(top, 0);
165 }
166 else
167 {
168 return vec.block(top, 0, nrows, 1);
169 }
170 }
171};
172
173} // namespace detail
174
175#ifndef OGS_EIGEN_DYNAMIC_SHAPE_MATRICES
176
177template <typename ShpPol, unsigned NNodes, unsigned NodalDOF, int Dim>
180
182 "Inconsistent use of the macro OGS_EIGEN_DYNAMIC_SHAPE_MATRICES."
183 " Maybe you forgot to include some header file.");
184#else
185
186template <typename ShpPol, unsigned NNodes, unsigned NodalDOF, int Dim>
189
191 "Inconsistent use of the macro OGS_EIGEN_DYNAMIC_SHAPE_MATRICES."
192 " Maybe you forgot to include some header file.");
193#endif
194
195} // namespace ProcessLib
const unsigned OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG
detail::LocalAssemblerTraitsFixed< ShpPol, NNodes, NodalDOF, Dim > LocalAssemblerTraits
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)