-
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 biot coefficient calculation #12398
[GeoMechanicsApplication] Extract biot coefficient calculation #12398
Conversation
…ficients` and renamed it `CalculateBiotModulusInverse`
…tead of ElementVariables
… instead of ElementVariables and input the properties as an argument
… to diff order (i.e. extract lists for biot coefficients and use utility function)
…iot-coefficient-calculation
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 might be a point of discussion if we want all transport_equation_utilities tests in a single file
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 clean and clear extraction of functionality, which makes the code more readable and easier to understand. Well done! I have a few minor suggestions and a question for you.
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/U_Pw_small_strain_element.hpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_elements/small_strain_U_Pw_diff_order_element.cpp
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/custom_utilities/transport_equation_utilities.hpp
Outdated
Show resolved
Hide resolved
const double derivative_of_saturation = 0.2; | ||
|
||
const double expected_value = -0.09999992485; | ||
KRATOS_EXPECT_DOUBLE_EQ(GeoTransportEquationUtilities::CalculateBiotModulusInverse( |
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.
Wouldn't KRATOS_EXPECT_NEAR
be more robust?
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.
Depends on the tolerance of course, under the hood this macro does: KRATOS_EXPECT_NEAR(a,b,std::numeric_limits<double>::epsilon()
. Do we prefer a different tolerance? Problem is, with the currnet numbers we need to be quite precise to check that the results are actually okay (no 1e-16, but 1e-9 is needed).
applications/GeoMechanicsApplication/tests/cpp_tests/test_transport_equation_utilities.cpp
Outdated
Show resolved
Hide resolved
biot_coefficient, degree_of_saturation, derivative_of_saturation, properties) > large_number) | ||
} | ||
|
||
KRATOS_TEST_CASE_IN_SUITE(CalculateBiotModulusInverse_DoesNotThrow_ForEmptyProperties, KratosGeoMechanicsFastSuite) |
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.
Is this desired behavior, since it would require me to test the returned value before actually using it ...?
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 question is exactly the reason I wanted to make the current behavior (this has just moved) explicit in this test. I don't know exactly what the desired behavior is. E.g. do we want to always check if all the properties are set with physical values inside this function, or do we assume it's okay? It is user input though (via the MaterialParameters), so it could indeed result in NaN now if the wrong inputs are given.
I can of course add checks and throw (and UT for that), what's 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.
I would suggest to not change the behavior yet, since that would be beyond the scope of this PR. However, I would like you to add an issue to the product backlog about it, so we can revisit it later. Now it has been documented through a unit test, which is a first step in the right direction, so thanks for that.
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.
Dear Richard,
The purpose of creating lists for the BiotCoefficient alpha and Biot Modulus Inverse 1/Q is fulfilled here. Good. However, I strongly think that the computation should be done directly on given material input and not on a constitutive matrix.
We can discuss whether that should be in this PR or in a next one.
Regards, Wijtze Pieter
(rVariables.BiotCoefficient - rProp[POROSITY]) / rProp[BULK_MODULUS_SOLID] + | ||
rProp[POROSITY] / rProp[BULK_MODULUS_FLUID]; | ||
// calculate Bulk modulus from stiffness matrix | ||
return 1.0 - CalculateBulkModulus(rConstitutiveMatrix) / rProp[BULK_MODULUS_SOLID]; |
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.
Contents of CalculateBUlkModulus:
return ConstitutiveMatrix(0, 0) - (4.0 / 3.0) * ConstitutiveMatrix(IndexG, IndexG);
The ConstitutiveMatrix is computed (relevant entries only)as:
const Properties& r_material_properties = rValues.GetMaterialProperties();
const auto E = r_material_properties[YOUNG_MODULUS];
const auto NU = r_material_properties[POISSON_RATIO];
const double c1 = (1.0 - NU) * c0;
const double c3 = this->GetConsiderDiagonalEntriesOnlyAndNoShear() ? 0.0 : (0.5 - NU) * c0;
C(INDEX_2D_PLANE_STRAIN_XX, INDEX_2D_PLANE_STRAIN_XX) = c1;
C(INDEX_2D_PLANE_STRAIN_XY, INDEX_2D_PLANE_STRAIN_XY) = c3;
I strongly think that the input of CalculateBulkModulus should be rProp and no a constitutive matrix. That changed the argument lists of all functions calling CalculateBulkModulus. Further CalculateBulkModulus should be in a utility thing and functionality like CalculateBiotCoefficient as well. E.g. both in the transport equation utilities.
You may argue that it is out of scope for this PR, but the above indicates where I would like to end.
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 completely agree that here it is a lot of overkill to go through all the calculations (the b matrices, deformation gradients, strains and constitutive matrix), in some cases just to calculate a bulk modulus that we could derive from the material.
I will move the CalculateBulkModulus and CalculateBiotCoefficient(s) to the transport equation utilities (and add some tests), I agree we should make this more generic and not have more than one implementation and it shouldn't be a lot of work.
However, taking a simpler approach for deriving the bulk modulus out of material parameters and also do the testing that this works for all constitutive laws (and not only for this linear elastic example) is in my opinion indeed out of scope for this refactoring PR.
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 took the elastic constitutive thing, because I think that it is always the elastic matrix and not some plastic or otherwise nonlinear thing. That is why I'm hammering on taking it from material parameters. There are no objections against doing that in a different PR.
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 all efforts, I can live with this implementation
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 one is good to go.
biot_coefficient, degree_of_saturation, derivative_of_saturation, properties) > large_number) | ||
} | ||
|
||
KRATOS_TEST_CASE_IN_SUITE(CalculateBiotModulusInverse_DoesNotThrow_ForEmptyProperties, KratosGeoMechanicsFastSuite) |
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 would suggest to not change the behavior yet, since that would be beyond the scope of this PR. However, I would like you to add an issue to the product backlog about it, so we can revisit it later. Now it has been documented through a unit test, which is a first step in the right direction, so thanks for that.
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.
Remains good to go.
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'm very satisfied with the result of this PR. Let's merge it.
📝 Description
This PR extracts pre-calculated lists for the biot coefficients and creates a utility function (used by diff order and non-diff order) to calculate the biot modulus inverse for a single integration point (including unit tests). In a next PR, the extraction of the element-wide list for the biot modulus inverse will be done, that is out of scope for this one.
Changes: