-
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 CalculateFluidPressure function #12381
Conversation
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.
A small and clear PR that removes several duplicated blocks of code. Thank you so much for the work done here. I have only a few minor suggestions and a question where I would like to have @WPK4FEM 's opinion.
N(0) = 1.0; | ||
N(1) = 2.0; | ||
N(2) = 3.0; | ||
N(3) = 4.0; | ||
N(4) = 5.0; |
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 believe these assignments can be simplified by using operator <<=
(after including header boost/numeric/ublas/assignment.hpp
):
N(0) = 1.0; | |
N(1) = 2.0; | |
N(2) = 3.0; | |
N(3) = 4.0; | |
N(4) = 5.0; | |
N <<= 1.0, 2.0, 3.0, 4.0, 5.0; |
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.
Many thanks! Copilot was not able to point to the header file.
pressure_vector(0) = 0.5; | ||
pressure_vector(1) = 0.7; | ||
pressure_vector(2) = 0.8; | ||
pressure_vector(3) = 0.9; | ||
pressure_vector(4) = 0.4; |
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.
In the same way, you can simplify these assignments:
pressure_vector(0) = 0.5; | |
pressure_vector(1) = 0.7; | |
pressure_vector(2) = 0.8; | |
pressure_vector(3) = 0.9; | |
pressure_vector(4) = 0.4; | |
pressure_vector <<= 0.5, 0.7, 0.8, 0.9, 0.4; |
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
@@ -84,20 +82,19 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |||
return mFluidPressure.value(); | |||
} | |||
|
|||
const ProcessInfo& GetProcessInfo() const | |||
[[nodiscard]] static double CalculateFluidPressure(const Vector& rN, const Vector& rPressureVector) |
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 fully agree with the idea to move this functionality to a single location, rather than it being scattered across several elements (as it used to be). I doubt, however, whether this nested class is the best possible location. Perhaps we should consult @WPK4FEM. I can imagine that class GeoElementUtilities
might be a good alternative. What do you think gentlemen?
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 think we discussed it briefly. Otherwise I would place the function in transport_..._utilities. GeoElementUtilities includes a lot of various functions right now. @WPK4FEM , what is your opinion?
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.
Computing an interpolated value of a nodal variable uses the interpolation polynomials. These belong to the element and not to constitutive laws nor to retention laws. Therefore GeoElementUtilities sounds like a good place. utilities for retention laws or constitutive models is a bad place. Transport Equation utilities is also a good place, because it handles element matrices for the water pressure part.
As interpolation by definition is the inner product or shape functions and nodal variables, just writing inner_prod is fine. Naming this operation specifically for the water pressures is better, because the name of the function is explaining what the intention is.
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 the detailed answer. The function has been moved to transport_equation_utilities.
Variables.FluidPressure = | ||
RetentionLaw::Parameters::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 have fixed the missing assignment a few minutes ago on master
by merging one of my pending PRs. Please update this branch by merging master
into it (you will probably need to a resolve a merge conflict, since we have touched the same lines).
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.
You are right there were merge conflicts.
# Conflicts: # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_interface_element.cpp # applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_interface_element.hpp # applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp # applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_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.
Anne, thank you for the comments.
Variables.FluidPressure = | ||
RetentionLaw::Parameters::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.
You are right there were merge conflicts.
@@ -84,20 +82,19 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |||
return mFluidPressure.value(); | |||
} | |||
|
|||
const ProcessInfo& GetProcessInfo() const | |||
[[nodiscard]] static double CalculateFluidPressure(const Vector& rN, const Vector& rPressureVector) |
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 think we discussed it briefly. Otherwise I would place the function in transport_..._utilities. GeoElementUtilities includes a lot of various functions right now. @WPK4FEM , what is your opinion?
N(0) = 1.0; | ||
N(1) = 2.0; | ||
N(2) = 3.0; | ||
N(3) = 4.0; | ||
N(4) = 5.0; |
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.
Many thanks! Copilot was not able to point to the header file.
pressure_vector(0) = 0.5; | ||
pressure_vector(1) = 0.7; | ||
pressure_vector(2) = 0.8; | ||
pressure_vector(3) = 0.9; | ||
pressure_vector(4) = 0.4; |
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
@@ -84,20 +82,19 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |||
return mFluidPressure.value(); | |||
} | |||
|
|||
const ProcessInfo& GetProcessInfo() const | |||
[[nodiscard]] static double CalculateFluidPressure(const Vector& rN, const Vector& rPressureVector) |
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.
Computing an interpolated value of a nodal variable uses the interpolation polynomials. These belong to the element and not to constitutive laws nor to retention laws. Therefore GeoElementUtilities sounds like a good place. utilities for retention laws or constitutive models is a bad place. Transport Equation utilities is also a good place, because it handles element matrices for the water pressure part.
As interpolation by definition is the inner product or shape functions and nodal variables, just writing inner_prod is fine. Naming this operation specifically for the water pressures is better, because the name of the function is explaining what the intention is.
KRATOS_TEST_CASE_IN_SUITE(CalculateFluidPressureGivesCorrectResults, KratosGeoMechanicsFastSuite) | ||
{ | ||
Vector N(5); | ||
N <<= 1.0, 2.0, 3.0, 4.0, 5.0; |
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.
For an real interpolation function based on 5 nodes, these values are strange. However, for testing they are fine.
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.
It is just for testing. Put something into and to get this later back.
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.
No need to change.
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.
Wijtse-Pieter, many thanks.
@@ -84,20 +82,19 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |||
return mFluidPressure.value(); | |||
} | |||
|
|||
const ProcessInfo& GetProcessInfo() const | |||
[[nodiscard]] static double CalculateFluidPressure(const Vector& rN, const Vector& rPressureVector) |
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 the detailed answer. The function has been moved to transport_equation_utilities.
KRATOS_TEST_CASE_IN_SUITE(CalculateFluidPressureGivesCorrectResults, KratosGeoMechanicsFastSuite) | ||
{ | ||
Vector N(5); | ||
N <<= 1.0, 2.0, 3.0, 4.0, 5.0; |
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.
It is just for testing. Put something into and to get this later back.
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 for me.
KRATOS_TEST_CASE_IN_SUITE(CalculateFluidPressureGivesCorrectResults, KratosGeoMechanicsFastSuite) | ||
{ | ||
Vector N(5); | ||
N <<= 1.0, 2.0, 3.0, 4.0, 5.0; |
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.
No need to change.
📝 Description