Skip to content

Commit b54b29d

Browse files
authored
Merge pull request #1947 from amgebauer/small-fixes-to-2d-solid-continua
Small fixes/extensions to 2d solid continua
2 parents cf31240 + 8ccf127 commit b54b29d

File tree

7 files changed

+102
-36
lines changed

7 files changed

+102
-36
lines changed

src/solid_3D_ele/4C_solid_3D_ele_calc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,10 @@ void Discret::Elements::SolidEleCalc<celltype, ElementFormulation>::calculate_st
461461
evaluate_material_stress<celltype>(solid_material, element_properties_,
462462
deformation_gradient, gl_strain, params, context, gp, ele.id());
463463

464-
assemble_strain_type_to_matrix_row<celltype>(
465-
gl_strain, deformation_gradient, strainIO.type, strain_data, gp);
466-
assemble_stress_type_to_matrix_row(
467-
deformation_gradient, stress, stressIO.type, stress_data, gp);
464+
assemble_strain_type_to_matrix_row<celltype>(element_properties_, gl_strain,
465+
deformation_gradient, strainIO.type, strain_data, gp);
466+
assemble_stress_type_to_matrix_row(element_properties_, deformation_gradient, stress,
467+
stressIO.type, stress_data, gp);
468468
});
469469
});
470470

src/solid_3D_ele/4C_solid_3D_ele_calc_lib_io.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace Discret::Elements
113113
* @param row (in) : Matrix row
114114
*/
115115
template <Core::FE::CellType celltype>
116-
void assemble_strain_type_to_matrix_row(
116+
void assemble_strain_type_to_matrix_row(const ElementProperties<celltype>& element_properties,
117117
const Core::LinAlg::SymmetricTensor<double, Core::FE::dim<celltype>, Core::FE::dim<celltype>>&
118118
gl_strain,
119119
const Core::LinAlg::Tensor<double, Core::FE::dim<celltype>, Core::FE::dim<celltype>>& defgrd,
@@ -131,15 +131,16 @@ namespace Discret::Elements
131131
{
132132
const Core::LinAlg::SymmetricTensor<double, Core::FE::dim<celltype>,
133133
Core::FE::dim<celltype>>
134-
ea = Solid::Utils::green_lagrange_to_euler_almansi(gl_strain, defgrd);
134+
ea = Solid::Utils::green_lagrange_to_euler_almansi(
135+
element_properties, gl_strain, defgrd);
135136
Internal::assemble_symmetric_tensor_to_matrix_row(ea, data, row);
136137
return;
137138
}
138139
case Inpar::Solid::strain_log:
139140
{
140141
const Core::LinAlg::SymmetricTensor<double, Core::FE::dim<celltype>,
141142
Core::FE::dim<celltype>>
142-
log_strain = Solid::Utils::green_lagrange_to_log_strain(gl_strain);
143+
log_strain = Solid::Utils::green_lagrange_to_log_strain(element_properties, gl_strain);
143144
Internal::assemble_symmetric_tensor_to_matrix_row(log_strain, data, row);
144145
return;
145146
}
@@ -163,7 +164,7 @@ namespace Discret::Elements
163164
* @param row (in) : Matrix row
164165
*/
165166
template <Core::FE::CellType celltype>
166-
void assemble_stress_type_to_matrix_row(
167+
void assemble_stress_type_to_matrix_row(const ElementProperties<celltype>& element_properties,
167168
const Core::LinAlg::Tensor<double, Core::FE::dim<celltype>, Core::FE::dim<celltype>>& defgrd,
168169
const Stress<celltype>& stress, const Inpar::Solid::StressType stress_type,
169170
Core::LinAlg::SerialDenseMatrix& data, const int row)
@@ -178,7 +179,7 @@ namespace Discret::Elements
178179
case Inpar::Solid::stress_cauchy:
179180
{
180181
Core::LinAlg::SymmetricTensor<double, Core::FE::dim<celltype>, Core::FE::dim<celltype>>
181-
cauchy = Solid::Utils::pk2_to_cauchy(stress.pk2_, defgrd);
182+
cauchy = Solid::Utils::pk2_to_cauchy(element_properties, stress.pk2_, defgrd);
182183
Internal::assemble_symmetric_tensor_to_matrix_row(cauchy, data, row);
183184
return;
184185
}

src/solid_3D_ele/4C_solid_3D_ele_line.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ std::shared_ptr<Core::Elements::Element> Discret::Elements::SolidLineType<dim>::
3535
return nullptr;
3636
}
3737

38+
39+
template <unsigned dim>
40+
Discret::Elements::SolidLine<dim>::SolidLine(const Discret::Elements::SolidLine<dim>& old) noexcept
41+
: Core::Elements::FaceElement(old), num_dof_per_node_(old.num_dof_per_node_)
42+
{
43+
}
44+
3845
template <unsigned dim>
3946
Discret::Elements::SolidLine<dim>::SolidLine(int id, int owner, int nnode, const int* nodeids,
4047
Core::Nodes::Node** nodes, Core::Elements::Element* parent, const int lline)
@@ -43,6 +50,15 @@ Discret::Elements::SolidLine<dim>::SolidLine(int id, int owner, int nnode, const
4350
set_node_ids(nnode, nodeids);
4451
build_nodal_pointers(nodes);
4552
set_parent_master_element(parent, lline);
53+
54+
num_dof_per_node_ = parent_element()->num_dof_per_node(*SolidLine::nodes()[0]);
55+
// Safety check if all nodes have the same number of dofs!
56+
for (int nlid = 1; nlid < num_node(); ++nlid)
57+
{
58+
if (num_dof_per_node_ != parent_master_element()->num_dof_per_node(*SolidLine::nodes()[nlid]))
59+
FOUR_C_THROW("You need different NumDofPerNode for each node on this solid line? ({} != {})",
60+
num_dof_per_node_, parent_master_element()->num_dof_per_node(*SolidLine::nodes()[nlid]));
61+
}
4662
}
4763

4864
template <unsigned dim>
@@ -72,6 +88,18 @@ Core::FE::CellType Discret::Elements::SolidLine<dim>::shape() const
7288
});
7389
}
7490

91+
template <unsigned dim>
92+
void Discret::Elements::SolidLine<dim>::pack(Core::Communication::PackBuffer& data) const
93+
{
94+
data.add_to_pack(num_dof_per_node_);
95+
}
96+
97+
template <unsigned dim>
98+
void Discret::Elements::SolidLine<dim>::unpack(Core::Communication::UnpackBuffer& buffer)
99+
{
100+
buffer.extract_from_pack(num_dof_per_node_);
101+
}
102+
75103
template <unsigned dim>
76104
void Discret::Elements::SolidLine<dim>::print(std::ostream& os) const
77105
{

src/solid_3D_ele/4C_solid_3D_ele_line.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,24 @@ namespace Discret::Elements
6868
SolidLine(int id, int owner, int nnode, const int* nodeids, Core::Nodes::Node** nodes,
6969
Core::Elements::Element* parent, const int lline);
7070

71+
explicit SolidLine(const SolidLine<dim>& old) noexcept;
72+
7173
[[nodiscard]] Core::Elements::Element* clone() const override;
7274

7375
[[nodiscard]] inline int unique_par_object_id() const override
7476
{
7577
return SolidLineType<dim>::instance().unique_par_object_id();
7678
}
7779

78-
void pack(Core::Communication::PackBuffer& data) const override {};
80+
void pack(Core::Communication::PackBuffer& data) const override;
7981

80-
void unpack(Core::Communication::UnpackBuffer& buffer) override {};
82+
void unpack(Core::Communication::UnpackBuffer& buffer) override;
8183

8284
[[nodiscard]] Core::FE::CellType shape() const override;
8385

8486
[[nodiscard]] inline int num_dof_per_node(const Core::Nodes::Node& node) const override
8587
{
86-
return dim;
88+
return num_dof_per_node_;
8789
}
8890

8991
[[nodiscard]] inline int num_dof_per_element() const override { return 0; }
@@ -99,6 +101,9 @@ namespace Discret::Elements
99101
const Core::Conditions::Condition& condition, std::vector<int>& lm,
100102
Core::LinAlg::SerialDenseVector& elevec1,
101103
Core::LinAlg::SerialDenseMatrix* elemat1 = nullptr) override;
104+
105+
private:
106+
int num_dof_per_node_ = 0;
102107
};
103108
} // namespace Discret::Elements
104109

src/solid_3D_ele/4C_solid_3D_ele_utils.hpp

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "4C_linalg_symmetric_tensor.hpp"
1818
#include "4C_linalg_symmetric_tensor_eigen.hpp"
1919
#include "4C_linalg_tensor_generators.hpp"
20+
#include "4C_solid_3D_ele_calc_lib.hpp"
2021
#include "4C_solid_3D_ele_properties.hpp"
2122

2223
#include <cmath>
@@ -36,12 +37,18 @@ namespace Solid::Utils
3637
* @param defgrd (in) : Deformation gradient
3738
* @return Cauchy stress tensor
3839
*/
39-
template <std::size_t dim>
40+
template <std::size_t dim, Core::FE::CellType celltype>
4041
Core::LinAlg::SymmetricTensor<double, dim, dim> pk2_to_cauchy(
42+
const Discret::Elements::ElementProperties<celltype>& element_properties,
4143
const Core::LinAlg::SymmetricTensor<double, dim, dim>& pk2,
4244
const Core::LinAlg::Tensor<double, dim, dim>& defgrd)
4345
{
44-
FOUR_C_ASSERT_ALWAYS(dim == 3, "Converting stress measures is only available in 3D");
46+
if constexpr (dim == 2)
47+
{
48+
FOUR_C_ASSERT_ALWAYS(
49+
element_properties.plane_assumption == Discret::Elements::PlaneAssumption::plane_strain,
50+
"Cauchy stress output for 2D continua is only available for plane strain elements!");
51+
}
4552
return Core::LinAlg::assume_symmetry(defgrd * pk2 * Core::LinAlg::transpose(defgrd)) /
4653
Core::LinAlg::det(defgrd);
4754
}
@@ -53,12 +60,19 @@ namespace Solid::Utils
5360
* @param gl (in) : Green Lagrange strain tensor
5461
* @return Core::LinAlg::Matrix<6, 1> : Euler-Almansi strain tensor
5562
*/
56-
template <std::size_t dim>
63+
template <std::size_t dim, Core::FE::CellType celltype>
5764
Core::LinAlg::SymmetricTensor<double, dim, dim> green_lagrange_to_euler_almansi(
65+
const Discret::Elements::ElementProperties<celltype>& element_properties,
5866
const Core::LinAlg::SymmetricTensor<double, dim, dim>& gl,
5967
const Core::LinAlg::Tensor<double, dim, dim>& defgrd)
6068
{
61-
FOUR_C_ASSERT_ALWAYS(dim == 3, "Converting strain measures is only available in 3D");
69+
if constexpr (dim == 2)
70+
{
71+
FOUR_C_ASSERT_ALWAYS(
72+
element_properties.plane_assumption == Discret::Elements::PlaneAssumption::plane_strain,
73+
"Euler Almansi strain output for 2D continua is only available for plane strain "
74+
"elements!");
75+
}
6276
Core::LinAlg::Tensor<double, dim, dim> invdefgrd = Core::LinAlg::inv(defgrd);
6377

6478
return Core::LinAlg::assume_symmetry(Core::LinAlg::transpose(invdefgrd) * gl * invdefgrd);
@@ -71,11 +85,18 @@ namespace Solid::Utils
7185
* @param gl (in) : Green Lagrange strain tensor
7286
* @return Core::LinAlg::Matrix<6, 1> : Logarithmic strain tensor
7387
*/
74-
template <std::size_t dim>
88+
template <std::size_t dim, Core::FE::CellType celltype>
7589
Core::LinAlg::SymmetricTensor<double, dim, dim> green_lagrange_to_log_strain(
90+
const Discret::Elements::ElementProperties<celltype>& element_properties,
7691
const Core::LinAlg::SymmetricTensor<double, dim, dim>& gl)
7792
{
78-
FOUR_C_ASSERT_ALWAYS(dim == 3, "Converting strain measures is only available in 3D");
93+
if constexpr (dim == 2)
94+
{
95+
FOUR_C_ASSERT_ALWAYS(
96+
element_properties.plane_assumption == Discret::Elements::PlaneAssumption::plane_strain,
97+
"Logarithmic strain output for 2D continua is only available for plane strain "
98+
"elements!");
99+
}
79100
auto [eigenvalues, eigenvectors] = Core::LinAlg::eig(gl);
80101

81102
// compute principal logarithmic strains

src/solid_scatra_3D_ele/4C_solid_scatra_3D_ele_calc.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ void Discret::Elements::SolidScatraEleCalc<celltype,
359359
params.isParameter("total time") ? &params.get<double>("total time") : nullptr;
360360
const double* time_step_size =
361361
params.isParameter("delta time") ? &params.get<double>("delta time") : nullptr;
362-
for_each_gauss_point(nodal_coordinates, {}, stiffness_matrix_integration_,
362+
for_each_gauss_point(nodal_coordinates, element_properties_, stiffness_matrix_integration_,
363363
[&](const Core::LinAlg::Tensor<double, Core::FE::dim<celltype>>& xi,
364364
const ShapeFunctionsAndDerivatives<celltype>& shape_functions,
365365
const JacobianMapping<celltype>& jacobian_mapping, double integration_factor, int gp)
@@ -383,8 +383,9 @@ void Discret::Elements::SolidScatraEleCalc<celltype,
383383
.time_step_size = time_step_size,
384384
.xi = &xi,
385385
.ref_coords = &gp_ref_coord};
386-
const Stress<celltype> stress = evaluate_material_stress<celltype>(solid_material, {},
387-
deformation_gradient, gl_strain, params, context, gp, ele.id());
386+
const Stress<celltype> stress =
387+
evaluate_material_stress<celltype>(solid_material, element_properties_,
388+
deformation_gradient, gl_strain, params, context, gp, ele.id());
388389

389390
if constexpr (has_condensed_contribution<SolidFormulation>)
390391
{
@@ -443,7 +444,7 @@ void Discret::Elements::SolidScatraEleCalc<celltype,
443444
{
444445
// integrate mass matrix
445446
FOUR_C_ASSERT(element_mass > 0, "It looks like the element mass is 0.0");
446-
for_each_gauss_point<celltype>(nodal_coordinates, {}, mass_matrix_integration_,
447+
for_each_gauss_point<celltype>(nodal_coordinates, element_properties_, mass_matrix_integration_,
447448
[&](const Core::LinAlg::Tensor<double, Core::FE::dim<celltype>>& xi,
448449
const ShapeFunctionsAndDerivatives<celltype>& shape_functions,
449450
const JacobianMapping<celltype>& jacobian_mapping, double integration_factor, int gp)
@@ -496,7 +497,7 @@ void Discret::Elements::SolidScatraEleCalc<celltype, SolidFormulation>::evaluate
496497
params.isParameter("total time") ? &params.get<double>("total time") : nullptr;
497498
const double* time_step_size =
498499
params.isParameter("delta time") ? &params.get<double>("delta time") : nullptr;
499-
for_each_gauss_point(nodal_coordinates, {}, stiffness_matrix_integration_,
500+
for_each_gauss_point(nodal_coordinates, element_properties_, stiffness_matrix_integration_,
500501
[&](const Core::LinAlg::Tensor<double, Core::FE::dim<celltype>>& xi,
501502
const ShapeFunctionsAndDerivatives<celltype>& shape_functions,
502503
const JacobianMapping<celltype>& jacobian_mapping, double integration_factor, int gp)
@@ -610,7 +611,8 @@ void Discret::Elements::SolidScatraEleCalc<celltype, SolidFormulation>::update(
610611
params.isParameter("total time") ? &params.get<double>("total time") : nullptr;
611612
const double* time_step_size =
612613
params.isParameter("delta time") ? &params.get<double>("delta time") : nullptr;
613-
Discret::Elements::for_each_gauss_point(nodal_coordinates, {}, stiffness_matrix_integration_,
614+
Discret::Elements::for_each_gauss_point(nodal_coordinates, element_properties_,
615+
stiffness_matrix_integration_,
614616
[&](const Core::LinAlg::Tensor<double, Core::FE::dim<celltype>>& xi,
615617
const ShapeFunctionsAndDerivatives<celltype>& shape_functions,
616618
const JacobianMapping<celltype>& jacobian_mapping, double integration_factor, int gp)
@@ -672,7 +674,8 @@ double Discret::Elements::SolidScatraEleCalc<celltype, SolidFormulation>::calcul
672674
params.isParameter("total time") ? &params.get<double>("total time") : nullptr;
673675
const double* time_step_size =
674676
params.isParameter("delta time") ? &params.get<double>("delta time") : nullptr;
675-
Discret::Elements::for_each_gauss_point(nodal_coordinates, {}, stiffness_matrix_integration_,
677+
Discret::Elements::for_each_gauss_point(nodal_coordinates, element_properties_,
678+
stiffness_matrix_integration_,
676679
[&](const Core::LinAlg::Tensor<double, Core::FE::dim<celltype>>& xi,
677680
const ShapeFunctionsAndDerivatives<celltype>& shape_functions,
678681
const JacobianMapping<celltype>& jacobian_mapping, double integration_factor, int gp)
@@ -738,7 +741,8 @@ void Discret::Elements::SolidScatraEleCalc<celltype, SolidFormulation>::calculat
738741
params.isParameter("total time") ? &params.get<double>("total time") : nullptr;
739742
const double* time_step_size =
740743
params.isParameter("delta time") ? &params.get<double>("delta time") : nullptr;
741-
Discret::Elements::for_each_gauss_point(nodal_coordinates, {}, stiffness_matrix_integration_,
744+
Discret::Elements::for_each_gauss_point(nodal_coordinates, element_properties_,
745+
stiffness_matrix_integration_,
742746
[&](const Core::LinAlg::Tensor<double, Core::FE::dim<celltype>>& xi,
743747
const ShapeFunctionsAndDerivatives<celltype>& shape_functions,
744748
const JacobianMapping<celltype>& jacobian_mapping, double integration_factor, int gp)
@@ -762,13 +766,14 @@ void Discret::Elements::SolidScatraEleCalc<celltype, SolidFormulation>::calculat
762766
.time_step_size = time_step_size,
763767
.xi = &xi,
764768
.ref_coords = &gp_ref_coord};
765-
const Stress<celltype> stress = evaluate_material_stress<celltype>(solid_material, {},
766-
deformation_gradient, gl_strain, params, context, gp, ele.id());
767-
768-
assemble_strain_type_to_matrix_row<celltype>(
769-
gl_strain, deformation_gradient, strainIO.type, strain_data, gp);
770-
assemble_stress_type_to_matrix_row(
771-
deformation_gradient, stress, stressIO.type, stress_data, gp);
769+
const Stress<celltype> stress =
770+
evaluate_material_stress<celltype>(solid_material, element_properties_,
771+
deformation_gradient, gl_strain, params, context, gp, ele.id());
772+
773+
assemble_strain_type_to_matrix_row<celltype>(element_properties_, gl_strain,
774+
deformation_gradient, strainIO.type, strain_data, gp);
775+
assemble_stress_type_to_matrix_row(element_properties_, deformation_gradient, stress,
776+
stressIO.type, stress_data, gp);
772777
});
773778
});
774779

unittests/solid_3D_ele/4C_solid_3D_ele_utils_test.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "4C_solid_3D_ele_utils.hpp"
1111

12+
#include "4C_fem_general_cell_type.hpp"
1213
#include "4C_linalg_symmetric_tensor.hpp"
1314
#include "4C_unittest_utils_assertions_test.hpp"
1415

@@ -37,7 +38,9 @@ namespace
3738
}});
3839

3940
Core::LinAlg::SymmetricTensor<double, 3, 3> euler_almansi_strain =
40-
Solid::Utils::green_lagrange_to_euler_almansi(green_lagrange_strain, get_f());
41+
Solid::Utils::green_lagrange_to_euler_almansi(
42+
Discret::Elements::ElementProperties<Core::FE::CellType::hex8>{}, green_lagrange_strain,
43+
get_f());
4144

4245
Core::LinAlg::SymmetricTensor<double, 3, 3> euler_almansi_strain_ref =
4346
Core::LinAlg::assume_symmetry(Core::LinAlg::Tensor<double, 3, 3>{
@@ -58,7 +61,9 @@ namespace
5861
}});
5962

6063
Core::LinAlg::SymmetricTensor<double, 3, 3> log_strain =
61-
Solid::Utils::green_lagrange_to_log_strain(green_lagrange_strain);
64+
Solid::Utils::green_lagrange_to_log_strain(
65+
Discret::Elements::ElementProperties<Core::FE::CellType::hex8>{},
66+
green_lagrange_strain);
6267

6368
Core::LinAlg::SymmetricTensor<double, 3, 3> log_strain_ref = Core::LinAlg::assume_symmetry(
6469
Core::LinAlg::Tensor<double, 3, 3>{{{0.039139830823291, 0.10941610441855, 0.20047008079560},
@@ -76,7 +81,8 @@ namespace
7681
{142.72731871521245, 195.86721709838096, 182.86374040756576},
7782
{278.020938548381, 182.86374040756576, 202.01904686970775}}});
7883

79-
Core::LinAlg::SymmetricTensor<double, 3, 3> cauchy = Solid::Utils::pk2_to_cauchy(pk2, get_f());
84+
Core::LinAlg::SymmetricTensor<double, 3, 3> cauchy = Solid::Utils::pk2_to_cauchy(
85+
Discret::Elements::ElementProperties<Core::FE::CellType::hex8>{}, pk2, get_f());
8086

8187
Core::LinAlg::SymmetricTensor<double, 3, 3> cauchy_ref =
8288
Core::LinAlg::assume_symmetry(Core::LinAlg::Tensor<double, 3, 3>{

0 commit comments

Comments
 (0)