OGS
NonLinearBMatrix.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <cmath>
14
16
17namespace ProcessLib
18{
19namespace NonLinearBMatrix
20{
23template <int DisplacementDim,
24 int NPOINTS,
25 typename BMatrixType,
26 typename GradientVectorType,
27 typename N_Type,
28 typename DNDX_Type>
29BMatrixType computeBMatrix(DNDX_Type const& dNdx,
30 N_Type const& N,
31 GradientVectorType const& grad_u,
32 const double radius,
33 const bool is_axially_symmetric)
34{
35 static_assert(0 < DisplacementDim && DisplacementDim <= 3,
36 "NonLinearBMatrix::computeBMatrix: DisplacementDim must be "
37 "in range [1,3].");
38
39 BMatrixType B = BMatrixType::Zero(
41 NPOINTS * DisplacementDim);
42
43 switch (DisplacementDim)
44 {
45 case 3:
46 for (int i = 0; i < NPOINTS; ++i)
47 {
48 B(0, i) = dNdx(0, i) * grad_u[0];
49 B(1, i) = dNdx(1, i) * grad_u[1];
50 B(2, i) = dNdx(2, i) * grad_u[2];
51
52 B(0, NPOINTS + i) = dNdx(0, i) * grad_u[3];
53 B(1, NPOINTS + i) = dNdx(1, i) * grad_u[4];
54 B(2, NPOINTS + i) = dNdx(2, i) * grad_u[5];
55
56 B(0, 2 * NPOINTS + i) = dNdx(0, i) * grad_u[6];
57 B(1, 2 * NPOINTS + i) = dNdx(1, i) * grad_u[7];
58 B(2, 2 * NPOINTS + i) = dNdx(2, i) * grad_u[8];
59
60 B(3, i) = (dNdx(1, i) * grad_u[0] + dNdx(0, i) * grad_u[1]) /
61 std::sqrt(2);
62 B(4, i) = (dNdx(2, i) * grad_u[1] + dNdx(1, i) * grad_u[2]) /
63 std::sqrt(2);
64 B(5, i) = (dNdx(2, i) * grad_u[0] + dNdx(0, i) * grad_u[2]) /
65 std::sqrt(2);
66
67 B(3, NPOINTS + i) =
68 (dNdx(1, i) * grad_u[3] + dNdx(0, i) * grad_u[4]) /
69 std::sqrt(2);
70 B(4, NPOINTS + i) =
71 (dNdx(2, i) * grad_u[4] + dNdx(1, i) * grad_u[5]) /
72 std::sqrt(2);
73 B(5, NPOINTS + i) =
74 (dNdx(2, i) * grad_u[3] + dNdx(0, i) * grad_u[5]) /
75 std::sqrt(2);
76
77 B(3, 2 * NPOINTS + i) =
78 (dNdx(1, i) * grad_u[6] + dNdx(0, i) * grad_u[7]) /
79 std::sqrt(2);
80 B(4, 2 * NPOINTS + i) =
81 (dNdx(2, i) * grad_u[7] + dNdx(1, i) * grad_u[8]) /
82 std::sqrt(2);
83 B(5, 2 * NPOINTS + i) =
84 (dNdx(2, i) * grad_u[6] + dNdx(0, i) * grad_u[8]) /
85 std::sqrt(2);
86 }
87 break;
88 case 2:
89 for (int i = 0; i < NPOINTS; ++i)
90 {
91 B(0, i) = dNdx(0, i) * grad_u[0];
92 B(1, i) = dNdx(1, i) * grad_u[1];
93 // B(2, i) = 0;
94
95 B(0, NPOINTS + i) = dNdx(0, i) * grad_u[2];
96 B(1, NPOINTS + i) = dNdx(1, i) * grad_u[3];
97 // B(2, NPOINTS + i) = 0;
98
99 B(3, i) = (dNdx(1, i) * grad_u[0] + dNdx(0, i) * grad_u[1]) /
100 std::sqrt(2);
101 B(3, NPOINTS + i) =
102 (dNdx(1, i) * grad_u[2] + dNdx(0, i) * grad_u[3]) /
103 std::sqrt(2);
104 }
105 if (is_axially_symmetric)
106 {
107 for (int i = 0; i < NPOINTS; ++i)
108 {
109 B(2, i) = grad_u[4] * N[i] / radius;
110 }
111 }
112 break;
113 default:
114 break;
115 }
116
117 return B;
118}
119} // namespace NonLinearBMatrix
120} // namespace ProcessLib
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
BMatrixType computeBMatrix(DNDX_Type const &dNdx, N_Type const &N, GradientVectorType const &grad_u, const double radius, const bool is_axially_symmetric)