Skip to content

Commit 4c3b43b

Browse files
committed
Fix 3D stress output for 2D elements
1 parent d0e305f commit 4c3b43b

File tree

5 files changed

+66
-56
lines changed

5 files changed

+66
-56
lines changed

src/solid_3D_ele/4C_solid_3D_ele_calc.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,11 @@ void Discret::Elements::SolidEleCalc<celltype, ElementFormulation>::calculate_st
421421
{
422422
std::vector<char>& serialized_stress_data = stressIO.mutable_data;
423423
std::vector<char>& serialized_strain_data = strainIO.mutable_data;
424-
Core::LinAlg::SerialDenseMatrix stress_data(stiffness_matrix_integration_.num_points(), num_str_);
425-
Core::LinAlg::SerialDenseMatrix strain_data(stiffness_matrix_integration_.num_points(), num_str_);
424+
constexpr std::size_t num_str_for_output = 6;
425+
Core::LinAlg::SerialDenseMatrix stress_data(
426+
stiffness_matrix_integration_.num_points(), num_str_for_output);
427+
Core::LinAlg::SerialDenseMatrix strain_data(
428+
stiffness_matrix_integration_.num_points(), num_str_for_output);
426429

427430
const ElementNodes<celltype> nodal_coordinates =
428431
evaluate_element_nodes<celltype>(ele, discretization, lm);

src/solid_3D_ele/4C_solid_3D_ele_calc_lib_io.hpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,30 @@ namespace Discret::Elements
4242
const Core::LinAlg::SymmetricTensor<double, size, size>& tensor,
4343
Core::LinAlg::SerialDenseMatrix& data, const int row)
4444
{
45-
for (unsigned i = 0; i < tensor.container().size(); ++i)
46-
data(row, static_cast<int>(i)) = tensor.data()[i];
45+
FOUR_C_ASSERT(data.num_rows() > row,
46+
"The given row index {} is out of bounds for the given data matrix with {} rows.", row,
47+
data.num_rows());
48+
FOUR_C_ASSERT(data.num_cols() == 6,
49+
"This function expects a matrix with 6 columns. Given matrix has {} columns.",
50+
data.num_cols());
51+
52+
if constexpr (size == 2)
53+
{
54+
// We need to map it to the 3D space here
55+
// Note: Currently, we do not support the out-of-plane components that might be implicitly
56+
// non-zero
57+
data(row, 0) = tensor(0, 0);
58+
data(row, 1) = tensor(1, 1);
59+
data(row, 2) = 0.0;
60+
data(row, 3) = tensor(0, 1);
61+
data(row, 4) = 0.0;
62+
data(row, 5) = 0.0;
63+
}
64+
else
65+
{
66+
for (unsigned i = 0; i < tensor.container().size(); ++i)
67+
data(row, static_cast<int>(i)) = tensor.data()[i];
68+
}
4769
}
4870
} // namespace Internal
4971

src/solid_scatra_3D_ele/4C_solid_scatra_3D_ele_calc.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,11 @@ void Discret::Elements::SolidScatraEleCalc<celltype, SolidFormulation>::calculat
716716
{
717717
std::vector<char>& serialized_stress_data = stressIO.mutable_data;
718718
std::vector<char>& serialized_strain_data = strainIO.mutable_data;
719-
Core::LinAlg::SerialDenseMatrix stress_data(stiffness_matrix_integration_.num_points(), num_str_);
720-
Core::LinAlg::SerialDenseMatrix strain_data(stiffness_matrix_integration_.num_points(), num_str_);
719+
constexpr std::size_t num_str_for_output = 6;
720+
Core::LinAlg::SerialDenseMatrix stress_data(
721+
stiffness_matrix_integration_.num_points(), num_str_for_output);
722+
Core::LinAlg::SerialDenseMatrix strain_data(
723+
stiffness_matrix_integration_.num_points(), num_str_for_output);
721724

722725
const ElementNodes<celltype> nodal_coordinates =
723726
evaluate_element_nodes<celltype>(ele, discretization, la[0].lm_);

tests/input_files/solid_runtime_vtk_2d.4C.yaml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,19 @@ NODE COORDS:
9696
- "NODE 24 COORD 2.5000000000000000e-01 1.0000000000000000e+00 0.0000000000000000e+00"
9797
- "NODE 25 COORD 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00"
9898
STRUCTURE ELEMENTS:
99-
- "1 WALL QUAD4 3 2 1 4 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
100-
- "2 WALL QUAD4 6 5 2 3 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
101-
- "3 WALL QUAD4 8 7 5 6 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
102-
- "4 WALL QUAD4 10 9 7 8 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
103-
- "5 WALL QUAD4 11 3 4 12 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
104-
- "6 WALL QUAD4 13 6 3 11 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
105-
- "7 WALL QUAD4 14 8 6 13 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
106-
- "8 WALL QUAD4 15 10 8 14 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2
107-
2"
108-
- "9 WALL QUAD4 16 11 12 17 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2
109-
2"
110-
- "10 WALL QUAD4 18 13 11 16 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
111-
2 2"
112-
- "11 WALL QUAD4 19 14 13 18 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
113-
2 2"
114-
- "12 WALL QUAD4 20 15 14 19 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
115-
2 2"
116-
- "13 WALL QUAD4 21 16 17 22 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
117-
2 2"
118-
- "14 WALL QUAD4 23 18 16 21 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
119-
2 2"
120-
- "15 WALL QUAD4 24 19 18 23 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
121-
2 2"
122-
- "16 WALL QUAD4 25 20 19 24 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
123-
2 2"
99+
- "1 SOLID QUAD4 3 2 1 4 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
100+
- "2 SOLID QUAD4 6 5 2 3 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
101+
- "3 SOLID QUAD4 8 7 5 6 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
102+
- "4 SOLID QUAD4 10 9 7 8 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
103+
- "5 SOLID QUAD4 11 3 4 12 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
104+
- "6 SOLID QUAD4 13 6 3 11 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
105+
- "7 SOLID QUAD4 14 8 6 13 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
106+
- "8 SOLID QUAD4 15 10 8 14 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
107+
- "9 SOLID QUAD4 16 11 12 17 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
108+
- "10 SOLID QUAD4 18 13 11 16 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
109+
- "11 SOLID QUAD4 19 14 13 18 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
110+
- "12 SOLID QUAD4 20 15 14 19 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
111+
- "13 SOLID QUAD4 21 16 17 22 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
112+
- "14 SOLID QUAD4 23 18 16 21 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
113+
- "15 SOLID QUAD4 24 19 18 23 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
114+
- "16 SOLID QUAD4 25 20 19 24 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"

tests/input_files/solid_runtime_vtk_offset.4C.yaml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,19 @@ NODE COORDS:
9797
- "NODE 24 COORD 2.5000000000000000e-01 1.0000000000000000e+00 0.0000000000000000e+00"
9898
- "NODE 25 COORD 0.0000000000000000e+00 1.0000000000000000e+00 0.0000000000000000e+00"
9999
STRUCTURE ELEMENTS:
100-
- "1 WALL QUAD4 3 2 1 4 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
101-
- "2 WALL QUAD4 6 5 2 3 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
102-
- "3 WALL QUAD4 8 7 5 6 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
103-
- "4 WALL QUAD4 10 9 7 8 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
104-
- "5 WALL QUAD4 11 3 4 12 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
105-
- "6 WALL QUAD4 13 6 3 11 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
106-
- "7 WALL QUAD4 14 8 6 13 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2 2"
107-
- "8 WALL QUAD4 15 10 8 14 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2
108-
2"
109-
- "9 WALL QUAD4 16 11 12 17 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP 2
110-
2"
111-
- "10 WALL QUAD4 18 13 11 16 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
112-
2 2"
113-
- "11 WALL QUAD4 19 14 13 18 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
114-
2 2"
115-
- "12 WALL QUAD4 20 15 14 19 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
116-
2 2"
117-
- "13 WALL QUAD4 21 16 17 22 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
118-
2 2"
119-
- "14 WALL QUAD4 23 18 16 21 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
120-
2 2"
121-
- "15 WALL QUAD4 24 19 18 23 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
122-
2 2"
123-
- "16 WALL QUAD4 25 20 19 24 MAT 1 KINEM nonlinear EAS none THICK 1.0 STRESS_STRAIN plane_stress GP
124-
2 2"
100+
- "1 SOLID QUAD4 3 2 1 4 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
101+
- "2 SOLID QUAD4 6 5 2 3 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
102+
- "3 SOLID QUAD4 8 7 5 6 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
103+
- "4 SOLID QUAD4 10 9 7 8 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
104+
- "5 SOLID QUAD4 11 3 4 12 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
105+
- "6 SOLID QUAD4 13 6 3 11 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
106+
- "7 SOLID QUAD4 14 8 6 13 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
107+
- "8 SOLID QUAD4 15 10 8 14 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
108+
- "9 SOLID QUAD4 16 11 12 17 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
109+
- "10 SOLID QUAD4 18 13 11 16 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
110+
- "11 SOLID QUAD4 19 14 13 18 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
111+
- "12 SOLID QUAD4 20 15 14 19 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
112+
- "13 SOLID QUAD4 21 16 17 22 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
113+
- "14 SOLID QUAD4 23 18 16 21 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
114+
- "15 SOLID QUAD4 24 19 18 23 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"
115+
- "16 SOLID QUAD4 25 20 19 24 MAT 1 KINEM nonlinear THICKNESS 1.0 PLANE_ASSUMPTION plane_strain"

0 commit comments

Comments
 (0)