-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[StructuralMechanicsApplication] Add PK2_STRESS_VECTOR in LinearTrussElement2D #12915
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lienar --> Linear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, if the stiffness (E) is not required, you can set this to false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
@@ -644,6 +644,54 @@ void LinearTrussElement2D<TNNodes>::CalculateOnIntegrationPoints( | |||
/***********************************************************************************/ | |||
/***********************************************************************************/ | |||
|
|||
template<SizeType TNNodes> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now you'll need anothe template entry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi everybody, thank you very much for the suggestions and info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
CalculateOnIntegrationPoints
function withPK2_STRESS_VECTOR
andTRUSS_PRESTRESS_PK2
forLinearTrussElement<3D/2D>
TrussElementLinear3D2N_CalculatesPK2Stress
)