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] Clean up retention response #12392

Merged
merged 10 commits into from
May 22, 2024

Conversation

avdg81
Copy link
Contributor

@avdg81 avdg81 commented May 21, 2024

📝 Description
Cleaned up several things related to the calculation of the retention response.

🆕 Changelog

  • When calculating the values at integration points, only call the relevant functions rather than CalculateRetentionResponse (which calculates all retention parameters). This saves us from calculating (and storing) unnecessary data.
  • Consequently, it was no longer needed to calculate the effective saturation as part of CalculateRetentionResponse.
  • Removed members FluidPressure and EffectiveSaturation from struct UPwSmallStrainElement::ElementVariables, since they had become redundant. Their usages have been replaced by adopting local variables. In a similar way, members FluidPressure and Density have been removed from struct SmallStrainUPwDiffOrderElement::ElementVariables.
  • Removed two unused using statements.

avdg81 added 8 commits May 21, 2024 09:31
`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.
@avdg81 avdg81 requested review from rfaasse and WPK4FEM May 21, 2024 11:16
@avdg81 avdg81 self-assigned this May 21, 2024
WPK4FEM
WPK4FEM previously approved these changes May 21, 2024
Copy link
Contributor

@WPK4FEM WPK4FEM left a 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.

Comment on lines 527 to 538
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);
Copy link
Contributor

Choose a reason for hiding this comment

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

These are mutually exclusive.

Copy link
Contributor Author

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.

Comment on lines 729 to 731
noalias(TotalStressVector) = mStressVector[GPoint];
noalias(TotalStressVector) += PORE_PRESSURE_SIGN_FACTOR * Variables.BiotCoefficient *
Variables.BishopCoefficient * Variables.FluidPressure * VoigtVector;
bishop_coefficient * fluid_pressure * VoigtVector;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Comment on lines 1101 to 1103
const auto fluid_pressure =
GeoTransportEquationUtilities::CalculateFluidPressure(Variables.Np, Variables.PressureVector);
RetentionParameters.SetFluidPressure(Variables.FluidPressure);
RetentionParameters.SetFluidPressure(fluid_pressure);
Copy link
Contributor

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));

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 thought it might be somewhat too long of an expression. But clearly, your perception is different, so I'll change it :-)

Comment on lines 1640 to 1643
const auto fluid_pressure =
GeoTransportEquationUtilities::CalculateFluidPressure(rVariables.Np, rVariables.PressureVector);
rRetentionParameters.SetFluidPressure(rVariables.FluidPressure);
rRetentionParameters.SetFluidPressure(fluid_pressure);

Copy link
Contributor

Choose a reason for hiding this comment

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

See previous comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 926 to 929
const auto fluid_pressure = GeoTransportEquationUtilities::CalculateFluidPressure(
Variables.Np, Variables.PressureVector);
RetentionParameters.SetFluidPressure(Variables.FluidPressure);
RetentionParameters.SetFluidPressure(fluid_pressure);

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

rfaasse
rfaasse previously approved these changes May 22, 2024
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.

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.
@avdg81 avdg81 dismissed stale reviews from rfaasse and WPK4FEM via 85da166 May 22, 2024 08:26
@avdg81 avdg81 requested a review from WPK4FEM May 22, 2024 08:28
Copy link
Contributor

@WPK4FEM WPK4FEM left a comment

Choose a reason for hiding this comment

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

Fine for me.

@avdg81 avdg81 enabled auto-merge (squash) May 22, 2024 09:56
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.

Ready to go!

@avdg81 avdg81 merged commit fd1f38f into master May 22, 2024
11 checks passed
@avdg81 avdg81 deleted the geo/clean-up-retention-response branch May 22, 2024 10:06
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.

3 participants