-
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] Clean up retention response #12392
Conversation
`CalculateRetentionResponse` calculates several parameters, even when not all of them are needed. In these two instances, it was clear how to replace these function calls, which makes the code easier to understand.
This eliminates two usages of member `BishopCoefficient` of struct `ElementVariables`.
Its usages could be replaced by using local variables.
It was assigned to only once, but never read from (due to earlier changes).
In this case, only the fluid pressure and the Bishop coefficient were needed.
Replaced all of its usages by local variables. Also replaced two usages of member `BishopCoefficient` by a local variable.
Its single usage has been replaced by a local variable.
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.
Short and comprehensible. Remarks are improvementpoints not requirements.
if (rVariable == DEGREE_OF_SATURATION) | ||
rOutput[GPoint] = mRetentionLawVector[GPoint]->CalculateSaturation(RetentionParameters); | ||
if (rVariable == EFFECTIVE_SATURATION) | ||
rOutput[GPoint] = mRetentionLawVector[GPoint]->CalculateEffectiveSaturation(RetentionParameters); | ||
if (rVariable == BISHOP_COEFFICIENT) | ||
rOutput[GPoint] = mRetentionLawVector[GPoint]->CalculateBishopCoefficient(RetentionParameters); | ||
if (rVariable == DERIVATIVE_OF_SATURATION) | ||
rOutput[GPoint] = Variables.DerivativeOfSaturation; | ||
rOutput[GPoint] = | ||
mRetentionLawVector[GPoint]->CalculateDerivativeOfSaturation(RetentionParameters); | ||
if (rVariable == RELATIVE_PERMEABILITY) | ||
rOutput[GPoint] = Variables.RelativePermeability; | ||
rOutput[GPoint] = | ||
mRetentionLawVector[GPoint]->CalculateRelativePermeability(RetentionParameters); |
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 are mutually exclusive.
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.
Yes, I agree with your observation. I have changed the other branches to use else if
. I would, however, argue that it would be better still to have such selections one level higher. It is no longer needed to group these variables, since we no longer call CalculateRetentionResponse
. But I would suggest to do that another time.
noalias(TotalStressVector) = mStressVector[GPoint]; | ||
noalias(TotalStressVector) += PORE_PRESSURE_SIGN_FACTOR * Variables.BiotCoefficient * | ||
Variables.BishopCoefficient * Variables.FluidPressure * VoigtVector; | ||
bishop_coefficient * fluid_pressure * VoigtVector; |
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.
sig_tot = sig_eff + p * I
is computed here. That is probably clearer written down in 1 statement.
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.
Yes, again I agree with you. I have made this calculation more straightforward and I've tried to take out any unnecessary intermediate variables.
const auto fluid_pressure = | ||
GeoTransportEquationUtilities::CalculateFluidPressure(Variables.Np, Variables.PressureVector); | ||
RetentionParameters.SetFluidPressure(Variables.FluidPressure); | ||
RetentionParameters.SetFluidPressure(fluid_pressure); |
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.
Why not like RetentionParameter.SetFluidPressure(GeoTransportEquationUtilities::CalculateFluidPressure(Variables.Np, Variables.PressureVector));
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 thought it might be somewhat too long of an expression. But clearly, your perception is different, so I'll change it :-)
const auto fluid_pressure = | ||
GeoTransportEquationUtilities::CalculateFluidPressure(rVariables.Np, rVariables.PressureVector); | ||
rRetentionParameters.SetFluidPressure(rVariables.FluidPressure); | ||
rRetentionParameters.SetFluidPressure(fluid_pressure); | ||
|
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.
See previous comment.
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.
Done.
const auto fluid_pressure = GeoTransportEquationUtilities::CalculateFluidPressure( | ||
Variables.Np, Variables.PressureVector); | ||
RetentionParameters.SetFluidPressure(Variables.FluidPressure); | ||
RetentionParameters.SetFluidPressure(fluid_pressure); | ||
|
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.
Also 3 of these changes here in this file ( see 1033, 1167, 2957). If possible, do it in 1 statement.
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.
Done.
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 a very nice and straight-forward PR and a clear improvement, I don't have anything to add 😄
Probably we can slowly but surely stop using the CalculateRetentionResponse
everywhere, but this is a nice start!
- Made some selections mutually exclusive. - Eliminated a few intermediate variables. - Made the calculation of the total stress vector more straightforward. - Removed a few unnecessary resize operations.
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.
Fine for me.
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.
Ready to go!
📝 Description
Cleaned up several things related to the calculation of the retention response.
🆕 Changelog
CalculateRetentionResponse
(which calculates all retention parameters). This saves us from calculating (and storing) unnecessary data.CalculateRetentionResponse
.FluidPressure
andEffectiveSaturation
from structUPwSmallStrainElement::ElementVariables
, since they had become redundant. Their usages have been replaced by adopting local variables. In a similar way, membersFluidPressure
andDensity
have been removed from structSmallStrainUPwDiffOrderElement::ElementVariables
.using
statements.