-
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
[GeoMechanicsApplication] Calculate strains #12385
Conversation
# Conflicts: # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp
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 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!
Vector StressStrainUtilities::CalculateCauchyStrain(const Matrix& rB, const Vector& rDisplacements) | ||
{ | ||
return prod(rB, rDisplacements); | ||
} |
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.
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?
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.
Unit tests are added for CalculateStrains and CalculateCauchyStrain.
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; | ||
} |
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 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.
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 discussed a related question with @WPK4FEM to use both CalculateStrains and CalculateAnyOfMaterialResponse at the same time. He has suggested to keep it now.
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.
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.
# 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
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, thanks a lot for the review.
Vector StressStrainUtilities::CalculateCauchyStrain(const Matrix& rB, const Vector& rDisplacements) | ||
{ | ||
return prod(rB, rDisplacements); | ||
} |
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.
Unit tests are added for CalculateStrains and CalculateCauchyStrain.
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; | ||
} |
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 discussed a related question with @WPK4FEM to use both CalculateStrains and CalculateAnyOfMaterialResponse at the same time. He has suggested to keep it now.
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 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!
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; | ||
} |
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.
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.
📝 Description