[StructuralMechanicsApplication] Add PK2_STRESS_VECTOR in LinearTrussElement2D#12915
[StructuralMechanicsApplication] Add PK2_STRESS_VECTOR in LinearTrussElement2D#12915markelov208 merged 9 commits intomasterfrom
Conversation
WPK4FEM
left a comment
There was a problem hiding this comment.
Hi Gennady,
Thank you for the implementation. On the implementation itself I have no comments, it follows what the element already is doing. Some nagging about following the style.
However, there is 1 thing to be aware of. To create also the 3D variants of this 2 and 3 node element Alejandro has a pull request pending ( #12894 ) that removes the file that you have done the implementation in. It may be wise to wait with your PR until Aljandro has merged and then put your implementation in the new file for both 2 and 3D. That would save doing it again.
Regards, Wijtze Pieter
| SystemSizeBoundedArrayType B; | ||
|
|
||
| // Loop over the integration points | ||
| for (SizeType IP = 0; IP < integration_points.size(); ++IP) { |
There was a problem hiding this comment.
The Kratos style guide ( https://github.com/KratosMultiphysics/Kratos/wiki/Style-Guide ) says lower case with underscores for local variables. Here that would result in:, c, b, integration_point i.s.o. C, B, IP
There was a problem hiding this comment.
Thank you for the comment. Fixed names and replaced C/B with longer names.
| p_element->CalculateOnIntegrationPoints(PK2_STRESS_VECTOR, stress_vector, r_process_info); | ||
| KRATOS_EXPECT_DOUBLE_EQ(expected_stress + pre_stress, stress_vector[0][0]); | ||
| } | ||
| KRATOS_TEST_CASE_IN_SUITE(LienarTrussElement2D_CalculatesPK2Stress, KratosStructuralMechanicsFastSuite) |
There was a problem hiding this comment.
Many thanks. Fixed the typo.
Hi Wijtze-Pieter, thank you for the info. In any case, this PR would be merged only when Alejandro approves it. |
rfaasse
left a comment
There was a problem hiding this comment.
Nice addition of PK2 stress to the new element with tests, I've got a few suggestions, but none of them blocking
| if (rVariable == PK2_STRESS_VECTOR) { | ||
| ConstitutiveLaw::Parameters cl_values(GetGeometry(), GetProperties(), rProcessInfo); | ||
| cl_values.GetOptions().Set(ConstitutiveLaw::COMPUTE_STRESS , true); | ||
| cl_values.GetOptions().Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); |
There was a problem hiding this comment.
Since we only need the stress vector in the end, do you know if it's possible to set COMPUTE_CONSTITUTIVE_TENSOR to false?
There was a problem hiding this comment.
yes, if the stiffness (E) is not required, you can set this to false
There was a problem hiding this comment.
Actually, if I am not wrong, the stress could be retrieved by the CalculateOnIntegrationPoints(AXIAL_FORCE, --, --) and then divided by the GetPRoperties()[CROSS_AREA] right? I mean implementing the new CalculateOnIntegrationPoints(PK2_STRESS) and calling the CalculateOnIntegrationPoints(AXIAL_FORCE, --, --) inside
There was a problem hiding this comment.
Richard, you are absolutely right.
Alejandro, thank you for the info on COMPUTE_CONSTITUTIVE_TENSOR. I also made it false for other CalculateOnIntegrationPoints functions and there are no any failed tests.
You are right it is possible to re-use CalculateOnIntegrationPoints(AXIAL_FORCE,); however, 1) I have added TRUSS_PRESTRESS_PK2, 2) I would like to keep theses functions separately because CalculateOnIntegrationPoints(AXIAL_FORCE,) could be changed in future, for example, PK2 could be replaced with other stress.
Next, Aljandro please could you advice how to get the stress vector for TImoshenko beams? As far as I can see there are two areas, CROSS_AREA and AREA_EFFECTIVE_Y.
There was a problem hiding this comment.
The Timoshenko constitutive laws compute the axial force, moment and shear forces. To obtain the stress vector one should compose the bending and axial contributions as the normal stress and the shear stresses with respecto to the shear force and shear area.
The CROSS_AREA is the area of the cross section used in axial loading. The AREA_EFFECTIVE_Y is the reduced shear area for evaluating the shear forces.
applications/StructuralMechanicsApplication/tests/cpp_tests/test_truss.cpp
Outdated
Show resolved
Hide resolved
| Model current_model; | ||
| auto &r_model_part = current_model.CreateModelPart("ModelPart",1); | ||
| r_model_part.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); | ||
| r_model_part.AddNodalSolutionStepVariable(DISPLACEMENT); | ||
|
|
||
| // Set the element properties | ||
| auto p_elem_prop = r_model_part.CreateNewProperties(0); | ||
| constexpr auto youngs_modulus = 2.0e+06; | ||
| p_elem_prop->SetValue(YOUNG_MODULUS, youngs_modulus); | ||
| const auto &r_clone_cl = KratosComponents<ConstitutiveLaw>::Get("TrussConstitutiveLaw"); | ||
| p_elem_prop->SetValue(CONSTITUTIVE_LAW, r_clone_cl.Clone()); | ||
|
|
||
| // Create the test element | ||
| constexpr double directional_length = 2.0; | ||
| auto p_node_1 = r_model_part.CreateNewNode(1, 0.0, 0.0, 0.0); | ||
| auto p_node_2 = r_model_part.CreateNewNode(2, directional_length, directional_length, directional_length); | ||
|
|
||
| AddDisplacementDofsElement(r_model_part); | ||
|
|
||
| std::vector<ModelPart::IndexType> element_nodes {1,2}; | ||
| auto p_element = r_model_part.CreateNewElement("LinearTrussElement2D2N", 1, element_nodes, p_elem_prop); | ||
| const auto& r_process_info = r_model_part.GetProcessInfo(); | ||
| p_element->Initialize(r_process_info); // Initialize the element to initialize the constitutive law | ||
|
|
||
| constexpr auto induced_strain = 0.1; | ||
| p_element->GetGeometry()[1].FastGetSolutionStepValue(DISPLACEMENT) += ScalarVector(3, induced_strain * directional_length); |
There was a problem hiding this comment.
If I'm correct, the setup of this test is almost identical to the setup of the previous unit test. I'd propose to create a setup function which takes the name of the element as an input (so "LinearTrussElement2D2N" or "TrussLinearElement3D2N"), to avoid some duplication.
There was a problem hiding this comment.
It is a very good proposal. Currently, one more test is added. Hopefully, it will be extended for Timoshenko beams.
| ConstitutiveLaw::Parameters cl_values(GetGeometry(), GetProperties(), rProcessInfo); | ||
| cl_values.GetOptions().Set(ConstitutiveLaw::COMPUTE_STRESS , true); | ||
| cl_values.GetOptions().Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); | ||
|
|
||
| const double length = CalculateLength(); | ||
|
|
||
| // Let's initialize the cl values | ||
| VectorType strain_vector(1), stress_vector(1); | ||
| MatrixType constitutive_matrix(1,1); | ||
| strain_vector.clear(); | ||
| cl_values.SetStrainVector(strain_vector); | ||
| cl_values.SetStressVector(stress_vector); | ||
| cl_values.SetConstitutiveMatrix(constitutive_matrix); | ||
| SystemSizeBoundedArrayType nodal_values(SystemSize); | ||
| GetNodalValuesVector(nodal_values); | ||
|
|
||
| SystemSizeBoundedArrayType dN_dX; | ||
|
|
||
| // Loop over the integration points | ||
| for (SizeType integration_point = 0; integration_point < integration_points.size(); ++integration_point) { | ||
| GetFirstDerivativesShapeFunctionsValues(dN_dX, length, integration_points[integration_point].X()); | ||
|
|
||
| strain_vector[0] = inner_prod(dN_dX, nodal_values); | ||
|
|
||
| mConstitutiveLawVector[integration_point]->CalculateMaterialResponsePK2(cl_values); | ||
| auto stress = cl_values.GetStressVector()[0]; | ||
| if (GetProperties().Has(TRUSS_PRESTRESS_PK2)) { | ||
| stress += GetProperties()[TRUSS_PRESTRESS_PK2]; | ||
| } | ||
|
|
||
| rOutput[integration_point] = ScalarVector(1, stress); |
There was a problem hiding this comment.
If this part of code is identical to another part in this class, we could extract a function for the common functionality
There was a problem hiding this comment.
A few lines are extracted as a function.
|
HI! I just merged the |
|
Actually, I believe that these additions should be done to the new |
| /***********************************************************************************/ | ||
| /***********************************************************************************/ | ||
|
|
||
| template<SizeType TNNodes> |
There was a problem hiding this comment.
now you'll need anothe template entry
| if (rVariable == PK2_STRESS_VECTOR) { | ||
| ConstitutiveLaw::Parameters cl_values(GetGeometry(), GetProperties(), rProcessInfo); | ||
| cl_values.GetOptions().Set(ConstitutiveLaw::COMPUTE_STRESS , true); | ||
| cl_values.GetOptions().Set(ConstitutiveLaw::COMPUTE_CONSTITUTIVE_TENSOR, true); |
There was a problem hiding this comment.
yes, if the stiffness (E) is not required, you can set this to false
# Conflicts: # applications/StructuralMechanicsApplication/custom_elements/truss_elements/linear_truss_element.cpp
markelov208
left a comment
There was a problem hiding this comment.
Hi everybody, thank you very much for the suggestions and info.
rfaasse
left a comment
There was a problem hiding this comment.
Nicely reduced the duplication, thanks for the effort! from my side this is ready to go, but I leave the approval to @AlejandroCornejo / @loumalouomega 👍
📝 Description
A brief description of the PR.
CalculateOnIntegrationPointsfunction withPK2_STRESS_VECTORandTRUSS_PRESTRESS_PK2forLinearTrussElement<3D/2D>TrussElementLinear3D2N_CalculatesPK2Stress)