OGS
GMatrix.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <cmath>
14
15namespace ProcessLib
16{
17namespace Deformation
18{
20template <int DisplacementDim,
21 int NPOINTS,
22 typename N_Type,
23 typename DNDX_Type,
24 typename GMatrixType>
25void computeGMatrix(DNDX_Type const& dNdx,
26 GMatrixType& g_matrix,
27 const bool is_axially_symmetric,
28 N_Type const& N,
29 const double radius)
30{
31 static_assert(0 < DisplacementDim && DisplacementDim <= 3,
32 "LinearGMatrix::computeGMatrix: DisplacementDim must be in "
33 "range [1,3].");
34
35 g_matrix.setZero();
36
37 switch (DisplacementDim)
38 {
39 case 3:
40 // The gradient coordinates are organized in the following order:
41 // (1,1), (1,2), (1,3)
42 // (2,1), (2,2), (2,3)
43 // (3,1), (3,2), (3,3)
44 for (int i = 0; i < NPOINTS; ++i)
45 {
46 auto G_col0 = g_matrix.col(i);
47 auto G_col1 = g_matrix.col(i + NPOINTS);
48 auto G_col2 = g_matrix.col(i + 2 * NPOINTS);
49 auto const dNidx = dNdx.col(i);
50
51 G_col0.template segment<DisplacementDim>(0).noalias() = dNidx;
52 G_col1.template segment<DisplacementDim>(DisplacementDim)
53 .noalias() = dNidx;
54 G_col2.template segment<DisplacementDim>(2 * DisplacementDim)
55 .noalias() = dNidx;
56 }
57
58 break;
59 case 2:
60 // The gradient coordinates are organized in the following order:
61 // (1,1), (1,2)
62 // (2,1), (2,2)
63 // (3,3)
64 for (int i = 0; i < NPOINTS; ++i)
65 {
66 auto G_col0 = g_matrix.col(i);
67 auto G_col1 = g_matrix.col(i + NPOINTS);
68 auto const dNidx = dNdx.col(i);
69
70 G_col0.template segment<DisplacementDim>(0).noalias() = dNidx;
71 G_col1.template segment<DisplacementDim>(DisplacementDim)
72 .noalias() = dNidx;
73
74 if (is_axially_symmetric)
75 {
76 G_col0[4] = N[i] / radius;
77 }
78 }
79 break;
80 default:
81 break;
82 }
83}
84
85} // namespace Deformation
86} // namespace ProcessLib
void computeGMatrix(DNDX_Type const &dNdx, GMatrixType &g_matrix, const bool is_axially_symmetric, N_Type const &N, const double radius)
Fills a G-matrix based on given shape function dN/dx values.
Definition GMatrix.h:25