-
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
[GeoMechanicsApplication] Extract pre-calculated lists for strain vectors and (determinants of) deformation gradients #12363
Conversation
…Strain` to return a vector and takes relevant inputs instead of variables
…rn a vector and takes relevant inputs instead of variables
…) to return a vector instead of using the ElementVariables
…rmation gradient, instead of getting it from ElementVariables
…deformation gradient, instead of getting it from ElementVariables
…train-vector-calculations
…trix, displacements and UseHenckyStrainFlag instead of using ElementVariables
…b matrix, displacements and UseHenckyStrainFlag instead of using ElementVariables
…train-vector-calculations
…sed it to calculate lists up front
…element, and used it to calculate lists up front
…culate lists up front
…minants and strain vectors to 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.
Richard, thank you for the next step. The code is getting to be shorter and clear. My comments about movement of some functions to utilities. After changes made they look very similar for different elements.
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp
Outdated
Show resolved
Hide resolved
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.
Hi Richard,
After you explained the capture lists to me, most is clear.
Now that this has taken the strain, F and detF computations out of the integration point loops, I expect that Variables.B can be removed. Variables.B only has a purpose for the strain computation and that has be handled already.
Regards, Wijtze Pieter
const auto determinants_of_deformation_gradients = | ||
CalculateDeterminantsOfDeformationGradients(deformation_gradients); | ||
const auto strain_vectors = CalculateStrains( | ||
deformation_gradients, b_matrices, Variables.DisplacementVector, Variables.UseHenckyStrain); | ||
|
||
// Loop over integration points | ||
for (unsigned int GPoint = 0; GPoint < NumGPoints; ++GPoint) { | ||
this->CalculateKinematics(Variables, GPoint); | ||
Variables.B = b_matrices[GPoint]; | ||
|
||
// Compute infinitesimal strain |
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.
These comments are now not true anymore.
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.
True, I could still remove them in this PR, or wait for the next, what do you prefer?
@@ -1568,6 +1571,22 @@ Vector UPwSmallStrainElement<TDim, TNumNodes>::CalculateStrain(const Matrix& rDe | |||
: this->CalculateCauchyStrain(rB, rDisplacements); | |||
} | |||
|
|||
template <unsigned int TDim, unsigned int TNumNodes> | |||
std::vector<Vector> UPwSmallStrainElement<TDim, TNumNodes>::CalculateStrains(const std::vector<Matrix>& rDeformationGradients, |
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 wondered if only the s of strains would be enough to indicate that this is for all integration points ( e.g. for all components. ) CalculateStrain already is for all components in 1 integration point.
I don't know a better name, they soon become very long.
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 also not too sure about better naming unfortunately
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.
On second thought, would CalculateStrainVectors be a more suitable name?
@@ -547,11 +556,9 @@ void SmallStrainUPwDiffOrderElement::FinalizeSolutionStep(const ProcessInfo& rCu | |||
Variables.B = b_matrices[GPoint]; |
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.
Now that strains are computed outside the loop, I expect that the B matrices can be removed from Variables already.
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.
Just to document what we already discussed: it is still used in the calculation of the stiffness matrix, so it unfortunately cannot be removed yet:
template <unsigned int TDim, unsigned int TNumNodes>
void UPwSmallStrainElement<TDim, TNumNodes>::CalculateAndAddStiffnessMatrix(MatrixType& rLeftHandSideMatrix,
ElementVariables& rVariables)
{
KRATOS_TRY
noalias(rVariables.UVoigtMatrix) = prod(trans(rVariables.B), rVariables.ConstitutiveMatrix);
noalias(rVariables.UUMatrix) = prod(rVariables.UVoigtMatrix, rVariables.B) * rVariables.IntegrationCoefficient;
// Distribute stiffness block matrix into the elemental matrix
GeoElementUtilities::AssembleUUBlockMatrix(rLeftHandSideMatrix, rVariables.UUMatrix);
KRATOS_CATCH("")
}
…train-and-F-lists
…for calculating the determinants of a list of matrices
…train-and-F-lists
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, thank you for the quick changes.
Variables.StrainVector = this->CalculateStrain( | ||
Variables.F, Variables.B, Variables.DisplacementVector, Variables.UseHenckyStrain); | ||
permeability_update_factors.push_back(this->CalculatePermeabilityUpdateFactor(Variables.StrainVector)); | ||
permeability_update_factors.push_back(this->CalculatePermeabilityUpdateFactor(strain_vectors[GPoint])); |
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.
Ah, this could be a transform 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.
Good to go.
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 nice improvement to me. I have no further suggestions.
const auto deformation_gradients = CalculateDeformationGradients(); | ||
rOutput = CalculateStrains(deformation_gradients, b_matrices, Variables.DisplacementVector, | ||
Variables.UseHenckyStrain); |
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 cleanup :-)
📝 Description
This PR starts to extract element-wide lists (all integration point at the same time) for:
Although we add some duplication, which later we would like to remove when compressing diff-order/normal upw element into one, we start seeing here already we can start removing quite a bit of code because of this restructuring.