-
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
Changes from 1 commit
5be8639
d04250f
dd7040b
1f6eea2
1bbad67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,27 +24,30 @@ | |
#include "includes/serializer.h" | ||
#include <optional> | ||
|
||
namespace Kratos { | ||
namespace Kratos | ||
{ | ||
|
||
/** | ||
* Base class of retention laws. | ||
*/ | ||
class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | ||
class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw | ||
{ | ||
public: | ||
/** | ||
* Type definitions | ||
* NOTE: geometries are assumed to be of type Node for all problems | ||
*/ | ||
using ProcessInfoType = ProcessInfo; | ||
using SizeType = std::size_t; | ||
using GeometryType = Geometry<Node>; | ||
using SizeType = std::size_t; | ||
using GeometryType = Geometry<Node>; | ||
|
||
/** | ||
* Counted pointer of RetentionLaw | ||
*/ | ||
KRATOS_CLASS_POINTER_DEFINITION(RetentionLaw); | ||
|
||
class Parameters { | ||
class Parameters | ||
{ | ||
KRATOS_CLASS_POINTER_DEFINITION(Parameters); | ||
|
||
/** | ||
|
@@ -64,17 +67,12 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |
*/ | ||
|
||
public: | ||
Parameters(const Properties& rMaterialProperties, | ||
const ProcessInfo& rCurrentProcessInfo) | ||
: mrCurrentProcessInfo(rCurrentProcessInfo), | ||
mrMaterialProperties(rMaterialProperties){}; | ||
Parameters(const Properties& rMaterialProperties, const ProcessInfo& rCurrentProcessInfo) | ||
: mrCurrentProcessInfo(rCurrentProcessInfo), mrMaterialProperties(rMaterialProperties){}; | ||
|
||
~Parameters() = default; | ||
|
||
void SetFluidPressure(double FluidPressure) | ||
{ | ||
mFluidPressure = FluidPressure; | ||
}; | ||
void SetFluidPressure(double FluidPressure) { mFluidPressure = FluidPressure; }; | ||
|
||
double GetFluidPressure() const | ||
{ | ||
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||
{ | ||
return mrCurrentProcessInfo; | ||
return inner_prod(rN, rPressureVector); | ||
} | ||
|
||
const Properties& GetMaterialProperties() const | ||
{ | ||
return mrMaterialProperties; | ||
} | ||
const ProcessInfo& GetProcessInfo() const { return mrCurrentProcessInfo; } | ||
|
||
const Properties& GetMaterialProperties() const { return mrMaterialProperties; } | ||
|
||
private: | ||
std::optional<double> mFluidPressure; | ||
const ProcessInfo& mrCurrentProcessInfo; | ||
const Properties& mrMaterialProperties; | ||
const ProcessInfo& mrCurrentProcessInfo; | ||
const Properties& mrMaterialProperties; | ||
|
||
}; // class Parameters end | ||
|
||
|
@@ -121,9 +118,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |
* @param rValue a reference to the returned value | ||
* @param rValue output: the value of the specified variable | ||
*/ | ||
virtual double& CalculateValue(Parameters& rParameters, | ||
const Variable<double>& rThisVariable, | ||
double& rValue) = 0; | ||
virtual double& CalculateValue(Parameters& rParameters, const Variable<double>& rThisVariable, double& rValue) = 0; | ||
|
||
virtual double CalculateSaturation(Parameters& rParameters) = 0; | ||
|
||
|
@@ -143,9 +138,9 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |
* @param rElementGeometry the geometry of the current element | ||
* @param rCurrentProcessInfo process info | ||
*/ | ||
virtual void InitializeMaterial(const Properties& rMaterialProperties, | ||
virtual void InitializeMaterial(const Properties& rMaterialProperties, | ||
const GeometryType& rElementGeometry, | ||
const Vector& rShapeFunctionsValues); | ||
const Vector& rShapeFunctionsValues); | ||
|
||
virtual void Initialize(Parameters& rParameters); | ||
|
||
|
@@ -175,9 +170,9 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |
* @param rShapeFunctionsValues the shape functions values in the current integration point | ||
* @param the current ProcessInfo instance | ||
*/ | ||
virtual void ResetMaterial(const Properties& rMaterialProperties, | ||
virtual void ResetMaterial(const Properties& rMaterialProperties, | ||
const GeometryType& rElementGeometry, | ||
const Vector& rShapeFunctionsValues); | ||
const Vector& rShapeFunctionsValues); | ||
|
||
/** | ||
* This function is designed to be called once to perform all the checks | ||
|
@@ -188,8 +183,7 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |
* @param rCurrentProcessInfo | ||
* @return | ||
*/ | ||
virtual int Check(const Properties& rMaterialProperties, | ||
const ProcessInfo& rCurrentProcessInfo) = 0; | ||
virtual int Check(const Properties& rMaterialProperties, const ProcessInfo& rCurrentProcessInfo) = 0; | ||
|
||
/** | ||
* @brief This method is used to check that two Retention Laws are the same type (references) | ||
|
@@ -212,22 +206,13 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) RetentionLaw { | |
} | ||
|
||
/// Turn back information as a string. | ||
virtual std::string Info() const | ||
{ | ||
return "RetentionLaw"; | ||
} | ||
virtual std::string Info() const { return "RetentionLaw"; } | ||
|
||
/// Print information about this object. | ||
virtual void PrintInfo(std::ostream& rOStream) const | ||
{ | ||
rOStream << Info(); | ||
} | ||
virtual void PrintInfo(std::ostream& rOStream) const { rOStream << Info(); } | ||
|
||
/// Print object's data. | ||
virtual void PrintData(std::ostream& rOStream) const | ||
{ | ||
rOStream << "RetentionLaw has no data"; | ||
} | ||
virtual void PrintData(std::ostream& rOStream) const { rOStream << "RetentionLaw has no data"; } | ||
|
||
private: | ||
friend class Serializer; | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||||||||||
// KRATOS___ | ||||||||||||||
// // ) ) | ||||||||||||||
// // ___ ___ | ||||||||||||||
// // ____ //___) ) // ) ) | ||||||||||||||
// // / / // // / / | ||||||||||||||
// ((____/ / ((____ ((___/ / MECHANICS | ||||||||||||||
// | ||||||||||||||
// License: geo_mechanics_application/license.txt | ||||||||||||||
// | ||||||||||||||
// Main authors: Gennady Markelov | ||||||||||||||
// | ||||||||||||||
|
||||||||||||||
#include "custom_retention/retention_law.h" | ||||||||||||||
#include "includes/checks.h" | ||||||||||||||
#include "testing/testing.h" | ||||||||||||||
|
||||||||||||||
using namespace Kratos; | ||||||||||||||
|
||||||||||||||
namespace Kratos::Testing | ||||||||||||||
{ | ||||||||||||||
|
||||||||||||||
KRATOS_TEST_CASE_IN_SUITE(CalculateFluidPressureGivesCorrectResults, KratosGeoMechanicsFastSuite) | ||||||||||||||
{ | ||||||||||||||
Vector N(5); | ||||||||||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I believe these assignments can be simplified by using operator
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many thanks! Copilot was not able to point to the header file. |
||||||||||||||
|
||||||||||||||
Vector pressure_vector(5); | ||||||||||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. In the same way, you can simplify these assignments:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||||
|
||||||||||||||
auto fluid_pressure = RetentionLaw::Parameters::CalculateFluidPressure(N, pressure_vector); | ||||||||||||||
double expected_value = 9.9; | ||||||||||||||
KRATOS_CHECK_NEAR(fluid_pressure, expected_value, 1e-12); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
} // namespace Kratos::Testing |
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 mergingmaster
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.