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

[GeoMechanicsApplication] Calculate strains #12385

Merged
merged 8 commits into from
May 17, 2024
Merged

Conversation

markelov208
Copy link
Contributor

@markelov208 markelov208 commented May 15, 2024

📝 Description

  • Moved CalculateStrain function body into CalculateStrains
  • Moved CalculateCauchyStrain to stress_strain_utilities
  • Moved CalculateStrains to stress_strain_utilities
  • Created GetVoightSize() for DiffOrder element.

@markelov208 markelov208 requested review from rfaasse, WPK4FEM and avdg81 and removed request for WPK4FEM May 16, 2024 07:17
# Conflicts:
#	applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp
Copy link
Contributor

@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 taking this up, it removes a lot of duplication. I think there is a small discussion point left about how much we will actually move to the utilities for this PR and about unit testing now that the function is moved. I don't want to block the PR (since I'm not there tomorrow), so feel free to discuss tomorrow with Anne/Wijtze Pieter and merge after!

Comment on lines +155 to +158
Vector StressStrainUtilities::CalculateCauchyStrain(const Matrix& rB, const Vector& rDisplacements)
{
return prod(rB, rDisplacements);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice we moved this one and removed the duplication in the elements. Now that it's here and the function itself is relatively straight-forward: could we add a unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unit tests are added for CalculateStrains and CalculateCauchyStrain.

Comment on lines +160 to +175
std::vector<Vector> StressStrainUtilities::CalculateStrains(const std::vector<Matrix>& rDeformationGradients,
const std::vector<Matrix>& rBs,
const Vector& rDisplacements,
bool UseHenckyStrain,
std::size_t VoigtSize)
{
std::vector<Vector> result;
std::transform(
rDeformationGradients.begin(), rDeformationGradients.end(), rBs.begin(), std::back_inserter(result),
[&rDisplacements, UseHenckyStrain, VoigtSize](const auto& rDeformationGradient, const auto& rB) {
return UseHenckyStrain ? CalculateHenckyStrain(rDeformationGradient, VoigtSize)
: CalculateCauchyStrain(rB, rDisplacements);
});

return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still not too sure if the stress strain utilities should be responsible of choosing which strain measure to calculate based on a flag (also since we only provide two possibilities here, while there are other possibilities in this file e.g. VonMisesStrain). I was probably a bit ambiguous during our discussion. Maybe it's good to double check this with @WPK4FEM and @avdg81?

I do agree that we put the choice directly in the transform instead of as a separate function though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I discussed a related question with @WPK4FEM to use both CalculateStrains and CalculateAnyOfMaterialResponse at the same time. He has suggested to keep it now.

Copy link
Contributor

Choose a reason for hiding this comment

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

To not delay this PR, let's keep it the way it is for now. We may want to revisit this functionality later when we'd like to add support for more strain measures.

Gennady Markelov added 3 commits May 16, 2024 17:04
# Conflicts:
#	applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_FIC_element.cpp
#	applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp
#	applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.cpp
#	applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_element.cpp
#	applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp
#	applications/GeoMechanicsApplication/custom_elements/updated_lagrangian_U_Pw_diff_order_element.cpp
Copy link
Contributor Author

@markelov208 markelov208 left a comment

Choose a reason for hiding this comment

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

Richard, thanks a lot for the review.

Comment on lines +155 to +158
Vector StressStrainUtilities::CalculateCauchyStrain(const Matrix& rB, const Vector& rDisplacements)
{
return prod(rB, rDisplacements);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unit tests are added for CalculateStrains and CalculateCauchyStrain.

Comment on lines +160 to +175
std::vector<Vector> StressStrainUtilities::CalculateStrains(const std::vector<Matrix>& rDeformationGradients,
const std::vector<Matrix>& rBs,
const Vector& rDisplacements,
bool UseHenckyStrain,
std::size_t VoigtSize)
{
std::vector<Vector> result;
std::transform(
rDeformationGradients.begin(), rDeformationGradients.end(), rBs.begin(), std::back_inserter(result),
[&rDisplacements, UseHenckyStrain, VoigtSize](const auto& rDeformationGradient, const auto& rB) {
return UseHenckyStrain ? CalculateHenckyStrain(rDeformationGradient, VoigtSize)
: CalculateCauchyStrain(rB, rDisplacements);
});

return result;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I discussed a related question with @WPK4FEM to use both CalculateStrains and CalculateAnyOfMaterialResponse at the same time. He has suggested to keep it now.

@markelov208 markelov208 requested a review from rfaasse May 17, 2024 09:36
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 is yet another step towards cleaner and clearer code. What I like in particular is that the size of the element classes has been reduced by moving some of its members to utility functions. Thank you so much for the work done, Gennady!

Comment on lines +160 to +175
std::vector<Vector> StressStrainUtilities::CalculateStrains(const std::vector<Matrix>& rDeformationGradients,
const std::vector<Matrix>& rBs,
const Vector& rDisplacements,
bool UseHenckyStrain,
std::size_t VoigtSize)
{
std::vector<Vector> result;
std::transform(
rDeformationGradients.begin(), rDeformationGradients.end(), rBs.begin(), std::back_inserter(result),
[&rDisplacements, UseHenckyStrain, VoigtSize](const auto& rDeformationGradient, const auto& rB) {
return UseHenckyStrain ? CalculateHenckyStrain(rDeformationGradient, VoigtSize)
: CalculateCauchyStrain(rB, rDisplacements);
});

return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

To not delay this PR, let's keep it the way it is for now. We may want to revisit this functionality later when we'd like to add support for more strain measures.

@markelov208 markelov208 merged commit 94f272a into master May 17, 2024
11 checks passed
@markelov208 markelov208 deleted the geo/calculate-strains branch May 17, 2024 13:34
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] Extract a static utility function for the calculation of the Stiffness Matrix (K)
3 participants