OGS
GMatrix.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 <cmath>
7
8namespace ProcessLib
9{
10namespace Deformation
11{
13template <int DisplacementDim,
14 int NPOINTS,
15 typename N_Type,
16 typename DNDX_Type,
17 typename GMatrixType>
18void computeGMatrix(DNDX_Type const& dNdx,
19 GMatrixType& g_matrix,
20 const bool is_axially_symmetric,
21 N_Type const& N,
22 const double radius)
23{
24 static_assert(0 < DisplacementDim && DisplacementDim <= 3,
25 "LinearGMatrix::computeGMatrix: DisplacementDim must be in "
26 "range [1,3].");
27
28 g_matrix.setZero();
29
30 switch (DisplacementDim)
31 {
32 case 3:
33 // The gradient coordinates are organized in the following order:
34 // (1,1), (1,2), (1,3)
35 // (2,1), (2,2), (2,3)
36 // (3,1), (3,2), (3,3)
37 for (int i = 0; i < NPOINTS; ++i)
38 {
39 auto G_col0 = g_matrix.col(i);
40 auto G_col1 = g_matrix.col(i + NPOINTS);
41 auto G_col2 = g_matrix.col(i + 2 * NPOINTS);
42 auto const dNidx = dNdx.col(i);
43
44 G_col0.template segment<DisplacementDim>(0).noalias() = dNidx;
45 G_col1.template segment<DisplacementDim>(DisplacementDim)
46 .noalias() = dNidx;
47 G_col2.template segment<DisplacementDim>(2 * DisplacementDim)
48 .noalias() = dNidx;
49 }
50
51 break;
52 case 2:
53 // The gradient coordinates are organized in the following order:
54 // (1,1), (1,2)
55 // (2,1), (2,2)
56 // (3,3)
57 for (int i = 0; i < NPOINTS; ++i)
58 {
59 auto G_col0 = g_matrix.col(i);
60 auto G_col1 = g_matrix.col(i + NPOINTS);
61 auto const dNidx = dNdx.col(i);
62
63 G_col0.template segment<DisplacementDim>(0).noalias() = dNidx;
64 G_col1.template segment<DisplacementDim>(DisplacementDim)
65 .noalias() = dNidx;
66
67 if (is_axially_symmetric)
68 {
69 G_col0[4] = N[i] / radius;
70 }
71 }
72 break;
73 default:
74 break;
75 }
76}
77
78} // namespace Deformation
79} // 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:18