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 d = 0; d < DisplacementDim; ++d)
45 {
46 for (int i = 0; i < NPOINTS; ++i)
47 {
48 g_matrix(d + 0 * DisplacementDim, i + 0 * NPOINTS) =
49 dNdx(d, i);
50 g_matrix(d + 1 * DisplacementDim, i + 1 * NPOINTS) =
51 dNdx(d, i);
52 g_matrix(d + 2 * DisplacementDim, i + 2 * NPOINTS) =
53 dNdx(d, i);
54 }
55 }
56 break;
57 case 2:
58 // The gradient coordinates are organized in the following order:
59 // (1,1), (1,2)
60 // (2,1), (2,2)
61 // (3,3)
62 for (int d = 0; d < DisplacementDim; ++d)
63 {
64 for (int i = 0; i < NPOINTS; ++i)
65 {
66 g_matrix(d, i) = dNdx(d, i);
67 g_matrix(d + DisplacementDim, i + NPOINTS) = dNdx(d, i);
68 }
69 }
70 if (is_axially_symmetric)
71 {
72 for (int i = 0; i < NPOINTS; ++i)
73 {
74 g_matrix(4, i) = N[i] / radius;
75 }
76 }
77 break;
78 default:
79 break;
80 }
81}
82
83} // namespace Deformation
84} // 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