-
Notifications
You must be signed in to change notification settings - Fork 248
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 initial state and stress calculation to truss element and constitutive law #12525
[StructuralMechanicsApplication] Add initial state and stress calculation to truss element and constitutive law #12525
Conversation
…el and added unit tests
…pe of the strain and stress vectors (since they are refs in the parameters)
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.
This looks like a clean and straightforward set of changes to me. And many thanks for adding tests that demonstrate the intended behavior (i.e. it reads like documentation). I only have a few minor suggestions, nothing blocking.
applications/StructuralMechanicsApplication/custom_elements/truss_element_linear_3D2N.cpp
Outdated
Show resolved
Hide resolved
applications/StructuralMechanicsApplication/custom_elements/truss_element_linear_3D2N.cpp
Outdated
Show resolved
Hide resolved
applications/StructuralMechanicsApplication/custom_elements/truss_element_linear_3D2N.cpp
Outdated
Show resolved
Hide resolved
applications/StructuralMechanicsApplication/custom_elements/truss_element_linear_3D2N.hpp
Outdated
Show resolved
Hide resolved
applications/StructuralMechanicsApplication/tests/cpp_tests/test_truss.cpp
Outdated
Show resolved
Hide resolved
applications/StructuralMechanicsApplication/tests/cpp_tests/test_truss.cpp
Outdated
Show resolved
Hide resolved
applications/StructuralMechanicsApplication/tests/cpp_tests/test_truss_constitutive_law.cpp
Outdated
Show resolved
Hide resolved
applications/StructuralMechanicsApplication/tests/cpp_tests/test_truss_constitutive_law.cpp
Outdated
Show resolved
Hide resolved
LGTm |
@@ -141,6 +141,7 @@ void TrussConstitutiveLaw::CalculateMaterialResponsePK2(Parameters& rValues) | |||
Vector& stress_vector = rValues.GetStressVector(); | |||
if (stress_vector.size() != 1) stress_vector.resize(1, false); | |||
stress_vector[0] = this->CalculateStressElastic(rValues); | |||
AddInitialStressVectorContribution(stress_vector); |
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.
no initial strains? :)
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.
Good point, we do not need it for our application at the moment, but added it now for completeness (as well as to the unit test)
@@ -189,20 +189,20 @@ void TrussElementLinear3D2N::WriteTransformationCoordinates( | |||
BoundedVector<double, TrussElement3D2N::msLocalSize> | |||
& rReferenceCoordinates) | |||
{ | |||
KRATOS_TRY; | |||
KRATOS_TRY | |||
rReferenceCoordinates = ZeroVector(msLocalSize); |
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.
noalias
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.
Indeed, I didn't really look into this function, just removed the redundant semi-colon, but I would actually argue, since rReferenceCoordinates is a BoundedVector of size 6 and we set all values, we don't need to initialize it with a ZeroVector again (on top of that, the only place where we use this function the input is already initialized as a ZeroVector).
I removed it for now, let me know if you agree, or if you think I should bring it back with noalias.
@@ -189,20 +189,20 @@ void TrussElementLinear3D2N::WriteTransformationCoordinates( | |||
BoundedVector<double, TrussElement3D2N::msLocalSize> | |||
& rReferenceCoordinates) | |||
{ | |||
KRATOS_TRY; | |||
KRATOS_TRY | |||
rReferenceCoordinates = ZeroVector(msLocalSize); | |||
rReferenceCoordinates[0] = GetGeometry()[0].X0(); | |||
rReferenceCoordinates[1] = GetGeometry()[0].Y0(); | |||
rReferenceCoordinates[2] = GetGeometry()[0].Z0(); |
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.
maybe create a const auto& r_geom = GetGeometry()
?
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 better call only once the .InitialPosition();
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.
Done, thanks for the suggestion!
@@ -189,20 +189,20 @@ void TrussElementLinear3D2N::WriteTransformationCoordinates( | |||
BoundedVector<double, TrussElement3D2N::msLocalSize> | |||
& rReferenceCoordinates) | |||
{ | |||
KRATOS_TRY; | |||
KRATOS_TRY | |||
rReferenceCoordinates = ZeroVector(msLocalSize); | |||
rReferenceCoordinates[0] = GetGeometry()[0].X0(); | |||
rReferenceCoordinates[1] = GetGeometry()[0].Y0(); | |||
rReferenceCoordinates[2] = GetGeometry()[0].Z0(); | |||
rReferenceCoordinates[3] = GetGeometry()[1].X0(); | |||
rReferenceCoordinates[4] = GetGeometry()[1].Y0(); |
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.
you can use const auto& r_initial_coords = GetGeometry()[0].InitialPosition();
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.
Done
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 quick review, I processed the comments, so feel free to have another look!
@@ -141,6 +141,7 @@ void TrussConstitutiveLaw::CalculateMaterialResponsePK2(Parameters& rValues) | |||
Vector& stress_vector = rValues.GetStressVector(); | |||
if (stress_vector.size() != 1) stress_vector.resize(1, false); | |||
stress_vector[0] = this->CalculateStressElastic(rValues); | |||
AddInitialStressVectorContribution(stress_vector); |
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.
Good point, we do not need it for our application at the moment, but added it now for completeness (as well as to the unit test)
@@ -189,20 +189,20 @@ void TrussElementLinear3D2N::WriteTransformationCoordinates( | |||
BoundedVector<double, TrussElement3D2N::msLocalSize> | |||
& rReferenceCoordinates) | |||
{ | |||
KRATOS_TRY; | |||
KRATOS_TRY | |||
rReferenceCoordinates = ZeroVector(msLocalSize); |
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.
Indeed, I didn't really look into this function, just removed the redundant semi-colon, but I would actually argue, since rReferenceCoordinates is a BoundedVector of size 6 and we set all values, we don't need to initialize it with a ZeroVector again (on top of that, the only place where we use this function the input is already initialized as a ZeroVector).
I removed it for now, let me know if you agree, or if you think I should bring it back with noalias.
@@ -189,20 +189,20 @@ void TrussElementLinear3D2N::WriteTransformationCoordinates( | |||
BoundedVector<double, TrussElement3D2N::msLocalSize> | |||
& rReferenceCoordinates) | |||
{ | |||
KRATOS_TRY; | |||
KRATOS_TRY | |||
rReferenceCoordinates = ZeroVector(msLocalSize); | |||
rReferenceCoordinates[0] = GetGeometry()[0].X0(); | |||
rReferenceCoordinates[1] = GetGeometry()[0].Y0(); | |||
rReferenceCoordinates[2] = GetGeometry()[0].Z0(); |
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.
Done, thanks for the suggestion!
@@ -189,20 +189,20 @@ void TrussElementLinear3D2N::WriteTransformationCoordinates( | |||
BoundedVector<double, TrussElement3D2N::msLocalSize> | |||
& rReferenceCoordinates) | |||
{ | |||
KRATOS_TRY; | |||
KRATOS_TRY | |||
rReferenceCoordinates = ZeroVector(msLocalSize); | |||
rReferenceCoordinates[0] = GetGeometry()[0].X0(); | |||
rReferenceCoordinates[1] = GetGeometry()[0].Y0(); | |||
rReferenceCoordinates[2] = GetGeometry()[0].Z0(); | |||
rReferenceCoordinates[3] = GetGeometry()[1].X0(); | |||
rReferenceCoordinates[4] = GetGeometry()[1].Y0(); |
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.
Done
@AlejandroCornejo Thank you for your review, I processed the comments, could you re-review the updated state of the branch? |
@AlejandroCornejo @KratosMultiphysics/structural-mechanics Just a friendly reminder that we would like to request you to re-review the changes made by @rfaasse in response to earlier code reviews. Thank you. |
…al-state-and-stress-calculation-to-trusses
@AlejandroCornejo @KratosMultiphysics/structural-mechanics Would it be possible to re-review the contents of this PR, since the review comments were processed on July 16th? Thank you in advance! |
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.
I'm very sorry for the delay! I did not see the notification before...
… takes into account initial state (#12902) The Timoshenko beam constitutive law now takes into account any initial state when calculating the Cauchy material response. The changes are in line with previous changes for the truss element (see #12525). Two new C++ unit tests cover the changed behavior.
📝 Description
This PR has two additions to the structural mechanics components, to allow for the GeoMechanicsApplication to reset displacements using structural elements, instead of using the geo structural elements. The following additions are being made:
TrussConstitutiveLaw
now adds the initial stress and initial strain to the calculation of the PK2 stress vector if theConstitutiveLaw::InitialState
is set in CalculateMaterialResponsePK2. This is very similar to how it is done in the ElasticIsotropic3D::CalculateMaterialResponsePK2.TrussLinearElement3D2N
is now able to calculate thePK2_STRESS_VECTOR
on the integration points.Unit tests are added for the changed functions. When no
ConstitutiveLaw::InitialState
is set for the truss constitutive law, the observed behavior is the same as before.