Skip to content
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

Merged

Conversation

rfaasse
Copy link
Contributor

@rfaasse rfaasse commented Jul 10, 2024

📝 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:

  1. The TrussConstitutiveLaw now adds the initial stress and initial strain to the calculation of the PK2 stress vector if the ConstitutiveLaw::InitialState is set in CalculateMaterialResponsePK2. This is very similar to how it is done in the ElasticIsotropic3D::CalculateMaterialResponsePK2.
  2. The TrussLinearElement3D2N is now able to calculate the PK2_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.

Copy link
Contributor

@avdg81 avdg81 left a 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.

@rfaasse rfaasse marked this pull request as ready for review July 11, 2024 11:07
@rfaasse rfaasse requested a review from a team as a code owner July 11, 2024 11:07
@rfaasse rfaasse changed the title [DRAFT] Add initial state and stress calculation to truss element and constitutive law [StructuralMechanicsApplication] Add initial state and stress calculation to truss element and constitutive law Jul 11, 2024
@philbucher
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no initial strains? :)

Copy link
Contributor Author

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noalias

Copy link
Contributor Author

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();
Copy link
Member

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() ?

Copy link
Member

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();

Copy link
Contributor Author

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();
Copy link
Member

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();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

@rfaasse rfaasse left a 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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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();
Copy link
Contributor Author

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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@rfaasse rfaasse requested a review from AlejandroCornejo July 12, 2024 07:25
@rfaasse rfaasse self-assigned this Jul 16, 2024
@rfaasse
Copy link
Contributor Author

rfaasse commented Jul 16, 2024

@AlejandroCornejo Thank you for your review, I processed the comments, could you re-review the updated state of the branch?

@avdg81
Copy link
Contributor

avdg81 commented Jul 25, 2024

@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.

@rfaasse
Copy link
Contributor Author

rfaasse commented Sep 3, 2024

@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!

Copy link
Member

@AlejandroCornejo AlejandroCornejo left a 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...

@rfaasse rfaasse merged commit d21311e into master Sep 4, 2024
9 of 11 checks passed
@rfaasse rfaasse deleted the geo/12496-add-initial-state-and-stress-calculation-to-trusses branch September 4, 2024 08:36
avdg81 added a commit that referenced this pull request Dec 6, 2024
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GeoMechanicsApplication] Adopt truss element 'reset displacement' approach with structural elements
4 participants