23namespace LinearBMatrix
27template <
int NPOINTS,
typename DNDX_Type,
typename BMatrixType>
30 for (
int i = 0; i < NPOINTS; ++i)
32 B(1, NPOINTS + i) = dNdx(1, i);
33 B(3, i) = dNdx(1, i) / std::sqrt(2);
34 B(3, NPOINTS + i) = dNdx(0, i) / std::sqrt(2);
41template <
int DisplacementDim,
49 const bool is_axially_symmetric)
51 static_assert(0 < DisplacementDim && DisplacementDim <= 3,
52 "LinearBMatrix::computeBMatrix: DisplacementDim must be in "
55 BMatrixType B = BMatrixType::Zero(
57 NPOINTS * DisplacementDim);
59 switch (DisplacementDim)
62 for (
int i = 0; i < NPOINTS; ++i)
64 B(2, 2 * NPOINTS + i) = dNdx(2, i);
65 B(4, NPOINTS + i) = dNdx(2, i) / std::sqrt(2);
66 B(4, 2 * NPOINTS + i) = dNdx(1, i) / std::sqrt(2);
67 B(5, i) = dNdx(2, i) / std::sqrt(2);
68 B(5, 2 * NPOINTS + i) = dNdx(0, i) / std::sqrt(2);
74 if (is_axially_symmetric)
76 for (
int i = 0; i < NPOINTS; ++i)
78 B(2, i) = N[i] / radius;
89template <
int DisplacementDim,
int NPOINTS,
typename ShapeFunction,
90 typename BBarMatrixType,
typename ShapeMatricesType,
typename IpData>
92 std::vector<IpData, Eigen::aligned_allocator<IpData>>
const& ip_data,
95 const bool is_axially_symmetric)
97 unsigned const n_integration_points =
100 BBarMatrixType B_bar = BBarMatrixType::Zero(3, ShapeFunction::NPOINTS);
104 for (
unsigned ip = 0; ip < n_integration_points; ip++)
106 auto const& w = ip_data[ip].integration_weight;
110 for (
int i = 0; i < NPOINTS; i++)
112 auto B_bar_i = B_bar.col(i);
113 for (
unsigned ip = 0; ip < n_integration_points; ip++)
115 auto const& N = ip_data[ip].N_u;
116 auto const& dNdx = ip_data[ip].dNdx_u;
118 auto const dNidx = dNdx.col(i);
120 auto const& w = ip_data[ip].integration_weight;
121 B_bar_i.template segment<DisplacementDim>(0) += dNidx * w;
123 if (is_axially_symmetric)
127 ShapeMatricesType>(element,
129 B_bar_i[2] += w * N(i) / x_coord;
134 return B_bar / volume;
139template <
int DisplacementDim,
int NPOINTS,
typename BBarMatrixType,
140 typename BMatrixType>
141void applyBbar(BBarMatrixType
const& B_bar, BMatrixType& B,
142 const bool is_axially_symmetric)
144 if constexpr (DisplacementDim == 3)
146 for (
int i = 0; i < NPOINTS; ++i)
148 auto const B_bar_i = B_bar.col(i);
154 for (
int k = 0; k < 3; k++)
157 auto B_i_k = B.col(k * NPOINTS + i);
159 B_i_k.template segment<3>(0) -=
160 Eigen::Vector3d::Constant((B_i_k[k] - B_bar_i[k]) / 3.0);
168 for (
int i = 0; i < NPOINTS; ++i)
170 auto B_i_0 = B.col(i);
171 auto B_i_1 = B.col(NPOINTS + i);
173 auto const B_bar_i = B_bar.col(i);
175 if (is_axially_symmetric)
177 double const b0_dil_pertubation =
178 (B_i_0[0] - B_bar_i[0] + B_i_0[2] - B_bar_i[2]);
179 B_i_0.template segment<3>(0) -=
180 Eigen::Vector3d::Constant((b0_dil_pertubation) / 3.);
181 B_i_1.template segment<3>(0) -=
182 Eigen::Vector3d::Constant((B_i_1[1] - B_bar_i[1]) / 3.);
187 B_i_0.template segment<2>(0) -=
188 Eigen::Vector2d::Constant((B_i_0[0] - B_bar_i[0]) / 2.);
189 B_i_1.template segment<2>(0) -=
190 Eigen::Vector2d::Constant((B_i_1[1] - B_bar_i[1]) / 2.);
196template <
int DisplacementDim,
int NPOINTS,
typename BBarMatrixType,
197 typename BMatrixType,
typename N_Type,
typename DNDX_Type>
199 DNDX_Type
const& dNdx,
201 std::optional<BBarMatrixType>
const& B_dil_bar,
203 const bool is_axially_symmetric)
205 auto B =
computeBMatrix<DisplacementDim, NPOINTS, BMatrixType, N_Type,
206 DNDX_Type>(dNdx, N, radius, is_axially_symmetric);
214 *B_dil_bar, B, is_axially_symmetric);
unsigned getNumberOfPoints() const
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
double interpolateXCoordinate(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
void fillBMatrix2DCartesianPart(DNDX_Type const &dNdx, BMatrixType &B)
void applyBbar(BBarMatrixType const &B_bar, BMatrixType &B, const bool is_axially_symmetric)
BBarMatrixType computeDilatationalBbar(std::vector< IpData, Eigen::aligned_allocator< IpData > > const &ip_data, MeshLib::Element const &element, NumLib::GenericIntegrationMethod const &integration_method, const bool is_axially_symmetric)
BMatrixType computeBMatrixPossiblyWithBbar(DNDX_Type const &dNdx, N_Type const &N, std::optional< BBarMatrixType > const &B_dil_bar, const double radius, const bool is_axially_symmetric)
Fills a B matrix, or a B bar matrix if required.
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.