OGS
LinearBMatrix.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <cmath>
14
16
17namespace ProcessLib
18{
19namespace LinearBMatrix
20{
21namespace detail
22{
23template <int NPOINTS, typename DNDX_Type, typename BMatrixType>
24void fillBMatrix2DCartesianPart(DNDX_Type const& dNdx, BMatrixType& B)
25{
26 for (int i = 0; i < NPOINTS; ++i)
27 {
28 B(1, NPOINTS + i) = dNdx(1, i);
29 B(3, i) = dNdx(1, i) / std::sqrt(2);
30 B(3, NPOINTS + i) = dNdx(0, i) / std::sqrt(2);
31 B(0, i) = dNdx(0, i);
32 }
33}
34} // namespace detail
35
37template <int DisplacementDim,
38 int NPOINTS,
39 typename BMatrixType,
40 typename N_Type,
41 typename DNDX_Type>
42BMatrixType computeBMatrix(DNDX_Type const& dNdx,
43 N_Type const& N,
44 const double radius,
45 const bool is_axially_symmetric)
46{
47 static_assert(0 < DisplacementDim && DisplacementDim <= 3,
48 "LinearBMatrix::computeBMatrix: DisplacementDim must be in "
49 "range [1,3].");
50
51 BMatrixType B = BMatrixType::Zero(
53 NPOINTS * DisplacementDim);
54
55 switch (DisplacementDim)
56 {
57 case 3:
58 for (int i = 0; i < NPOINTS; ++i)
59 {
60 B(2, 2 * NPOINTS + i) = dNdx(2, i);
61 B(4, NPOINTS + i) = dNdx(2, i) / std::sqrt(2);
62 B(4, 2 * NPOINTS + i) = dNdx(1, i) / std::sqrt(2);
63 B(5, i) = dNdx(2, i) / std::sqrt(2);
64 B(5, 2 * NPOINTS + i) = dNdx(0, i) / std::sqrt(2);
65 }
66 detail::fillBMatrix2DCartesianPart<NPOINTS>(dNdx, B);
67 break;
68 case 2:
69 detail::fillBMatrix2DCartesianPart<NPOINTS>(dNdx, B);
70 if (is_axially_symmetric)
71 {
72 for (int i = 0; i < NPOINTS; ++i)
73 {
74 B(2, i) = N[i] / radius;
75 }
76 }
77 break;
78 default:
79 break;
80 }
81
82 return B;
83}
84} // namespace LinearBMatrix
85} // namespace ProcessLib
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
void fillBMatrix2DCartesianPart(DNDX_Type const &dNdx, BMatrixType &B)
BMatrixType computeBMatrix(DNDX_Type const &dNdx, N_Type const &N, const double radius, const bool is_axially_symmetric)
Fills a B-matrix based on given shape function dN/dx values.