[GeoMechanicsApplication] Clean up and extract calculation of deformation gradients#12341
[GeoMechanicsApplication] Clean up and extract calculation of deformation gradients#12341
Conversation
There were no `override`s provided for them.
Members `CalculateDeformationGradient` now return a `Matrix` object rather than updating `ElementVariables::F`, which is passed as an output argument to these functions.
- The members `CalculateDeformationGradient` have been made `const`. - In member `CalculateAll`, compute the deformation gradients upfront.
If the determinant of the deformation gradient is needed (or when we are not sure whether it is needed), compute it separately after computing the deformation gradient.
Members `CalculateDeformationGradient` no longer use the `ElementVariables` data structure, so it has been removed from their interfaces.
Just `clear` the vector and `emplace_back` the elements that are to be returned. Also removed a few comments that had no additional value.
Changes include: - There was no need to use the `ElementVariables` data structure. - Eliminated some redundant resizing. - Removed a few comments that had no additional value.
When computing the Green-Lagrange strains, avoid storing temporary results in data structure `ElementVariables`. Also removed some unnecessary resize operations.
The `resize` operation itself checks whether the container already has the desired size.
For `UPwSmallStrainElement`, the deformation gradients were extracted from the main loop in member `CalculateAll`. However, it did not replace a call to `CalculateDeformationGradient` elsewhere. To actually do that, member `CalculateStrain` also needs to be refactored. Since that is beyond the scope of this PR, I have reverted the extraction.
WPK4FEM
left a comment
There was a problem hiding this comment.
Looked together at this. To me it is consistent.
| rOutput.resize(mConstitutiveLawVector.size()); | ||
|
|
||
| ElementVariables Variables; | ||
| this->InitializeElementVariables(Variables, rCurrentProcessInfo); | ||
|
|
||
| // Loop over integration points | ||
| rOutput.clear(); | ||
| for (unsigned int GPoint = 0; GPoint < mConstitutiveLawVector.size(); ++GPoint) { | ||
| this->CalculateDeformationGradient(Variables, GPoint); | ||
| rOutput[GPoint] = Variables.detF; | ||
| rOutput.emplace_back(MathUtils<>::Det(this->CalculateDeformationGradient(GPoint))); |
There was a problem hiding this comment.
With the removal of InitializeELementVariables this functionality may have changed from an initial configuration F_0 to a current cofiguration F.
This is a wrong interpretation. It would lead to F = I
Together with Anne we looked through.
markelov208
left a comment
There was a problem hiding this comment.
Anne, a very good work. A lot of redundant lines are removed. I have made comments mainly for my knowledge.
applications/GeoMechanicsApplication/custom_elements/U_Pw_updated_lagrangian_FIC_element.cpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp
Outdated
Show resolved
Hide resolved
rfaasse
left a comment
There was a problem hiding this comment.
This looks like a nice and clear clean-up. No further comments from my side! I didn't go through all the functions to see whether any state of ElementVariables could lead to diffs, but since you and @WPK4FEM already looked at this, that shouldn't block this PR.
markelov208
left a comment
There was a problem hiding this comment.
Many thanks for the clarifications
📝 Description
Reduced the use of
ElementVariablesin the context of calculating the deformation gradients. This improves local reasoning. Furthermore, the code was simplified significantly, which eases understanding.🆕 Changelog
CalculateDeformationGradient:virtual, since no overrides were defined.Matrixto return the result.ElementVariables, since the result is now returned using the return type rather than a member of the output argument.const, since no other members need to be modified.CalculateDeformationGradientnow only compute the deformation gradient itself, and no longer its determinant as well. To be on the safe side, the determinant is computed explicitly in a few places where it was not obvious whether the determinant is being used or not.ElementVariableshad become redundant as a result of simplifying the code (i.e. after eliminating usages of members ofElementVariables). In most cases, we could use temporaries.resizeoperation of the container already takes care of that.CalculateKinematics(which only became apparent after carrying out the above changes).