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] extract CalculateFluidPressure function #12381

Merged
merged 5 commits into from
May 16, 2024

Conversation

markelov208
Copy link
Contributor

@markelov208 markelov208 commented May 14, 2024

📝 Description

  • CalculateFluidPressure function is placed in transport_equation_utilities as static.
  • A unit test is added.
  • Very sorry, retention_law.h is changed with clang format.

Copy link
Contributor

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

Comment on lines 25 to 29
N(0) = 1.0;
N(1) = 2.0;
N(2) = 3.0;
N(3) = 4.0;
N(4) = 5.0;
Copy link
Contributor

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

Suggested change
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;

Copy link
Contributor Author

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.

Comment on lines 32 to 36
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;
Copy link
Contributor

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:

Suggested change
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;

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

@@ -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)
Copy link
Contributor

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?

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 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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Comment on lines 1026 to 1027
Variables.FluidPressure =
RetentionLaw::Parameters::CalculateFluidPressure(Variables.Np, Variables.PressureVector);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Gennady Markelov added 2 commits May 15, 2024 14:09
# 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
Copy link
Contributor Author

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

Comment on lines 1026 to 1027
Variables.FluidPressure =
RetentionLaw::Parameters::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.

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

Comment on lines 25 to 29
N(0) = 1.0;
N(1) = 2.0;
N(2) = 3.0;
N(3) = 4.0;
N(4) = 5.0;
Copy link
Contributor Author

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.

Comment on lines 32 to 36
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;
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

@@ -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)
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change.

Copy link
Contributor Author

@markelov208 markelov208 left a 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)
Copy link
Contributor Author

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;
Copy link
Contributor Author

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.

@markelov208 markelov208 requested review from WPK4FEM and avdg81 May 15, 2024 13:43
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.

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change.

@markelov208 markelov208 merged commit 9364c39 into master May 16, 2024
11 checks passed
@markelov208 markelov208 deleted the geo/extract-calculate-fluid-pressure branch May 16, 2024 07:23
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.

[GeoMechanicsApplication] Extract a static utility function for the calculation of the Stiffness Matrix (K)
3 participants