From c7a6e6f1573ba4c790922195688119cc37db033a Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 11:34:04 +0200 Subject: [PATCH 01/18] added HasFrictionAngle and ValidateFrictionAngle --- .../apply_k0_procedure_process.cpp | 62 +++++++------------ .../apply_k0_procedure_process.h | 5 +- .../constitutive_law_utilities.cpp | 36 +++++++++++ .../constitutive_law_utilities.h | 2 + .../test_apply_k0_procedure_process.cpp | 1 + 5 files changed, 63 insertions(+), 43 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index 8a3b12fc8c3b..cc9f4bb0d3cd 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -83,8 +83,8 @@ int ApplyK0ProcedureProcess::Check() CheckSufficientMaterialParameters(r_properties, rElement.Id()); CheckOCRorPOP(r_properties, rElement.Id()); CheckPoissonUnloadingReloading(r_properties, rElement.Id()); - CheckPhi(r_properties, rElement.Id()); CheckK0(r_properties, rElement.Id()); + ConstitutiveLawUtilities::ValidateFrictionAngle(r_properties, rElement.Id()); }); } @@ -122,27 +122,9 @@ void ApplyK0ProcedureProcess::CheckK0(const Properties& rProperties, IndexType E } } -void ApplyK0ProcedureProcess::CheckPhi(const Properties& rProperties, IndexType ElementId) -{ - if (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS)) { - const auto phi_index = rProperties[INDEX_OF_UMAT_PHI_PARAMETER]; - const auto number_of_umat_parameters = static_cast(rProperties[UMAT_PARAMETERS].size()); - - KRATOS_ERROR_IF(phi_index < 1 || phi_index > number_of_umat_parameters) - << "INDEX_OF_UMAT_PHI_PARAMETER (" << phi_index - << ") is not in range 1, size of UMAT_PARAMETERS for element " << ElementId << "." << std::endl; - - const double phi = rProperties[UMAT_PARAMETERS][phi_index - 1]; - KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) - << "Phi (" << phi << ") should be between 0 and 90 degrees for element " << ElementId - << "." << std::endl; - } -} - void ApplyK0ProcedureProcess::CheckOCRorPOP(const Properties& rProperties, IndexType ElementId) { - if (rProperties.Has(K0_NC) || - (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS))) { + if (rProperties.Has(K0_NC) || ConstitutiveLawUtilities::HasFrictionAngle(rProperties)) { if (rProperties.Has(OCR)) { const auto ocr = rProperties[OCR]; KRATOS_ERROR_IF(ocr < 1.0) << "OCR (" << ocr << ") should be in the range [1.0,-> for element " @@ -177,8 +159,7 @@ void ApplyK0ProcedureProcess::CheckPoissonUnloadingReloading(const Properties& r void ApplyK0ProcedureProcess::CheckSufficientMaterialParameters(const Properties& rProperties, IndexType ElementId) { KRATOS_ERROR_IF_NOT( - rProperties.Has(K0_NC) || - (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS)) || + rProperties.Has(K0_NC) || ConstitutiveLawUtilities::HasFrictionAngle(rProperties) || (rProperties.Has(K0_VALUE_XX) && rProperties.Has(K0_VALUE_YY) && rProperties.Has(K0_VALUE_ZZ))) << "Insufficient material data for K0 procedure process for element " << ElementId << ". No K0_NC, " << "(INDEX_OF_UMAT_PHI_PARAMETER and UMAT_PARAMETERS) or (K0_VALUE_XX, _YY and _ZZ found)." @@ -206,19 +187,19 @@ bool ApplyK0ProcedureProcess::UseStandardProcedure() const return !mSettings.Has(setting_name) || mSettings[setting_name].GetBool(); } -array_1d ApplyK0ProcedureProcess::CreateK0Vector(const Element::PropertiesType& rProp) +array_1d ApplyK0ProcedureProcess::CreateK0Vector(const Element::PropertiesType& rProperties) { // Check for alternative K0 specifications array_1d k0_vector; - if (rProp.Has(K0_NC)) { - std::fill(k0_vector.begin(), k0_vector.end(), rProp[K0_NC]); - } else if (rProp.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProp.Has(UMAT_PARAMETERS)) { + if (rProperties.Has(K0_NC)) { + std::fill(k0_vector.begin(), k0_vector.end(), rProperties[K0_NC]); + } else if (ConstitutiveLawUtilities::HasFrictionAngle(rProperties)) { std::ranges::fill(k0_vector, ConstitutiveLawUtilities::CalculateK0NCFromFrictionAngleInRadians( - ConstitutiveLawUtilities::GetFrictionAngleInRadians(rProp))); + ConstitutiveLawUtilities::GetFrictionAngleInRadians(rProperties))); } else { - k0_vector[0] = rProp[K0_VALUE_XX]; - k0_vector[1] = rProp[K0_VALUE_YY]; - k0_vector[2] = rProp[K0_VALUE_ZZ]; + k0_vector[0] = rProperties[K0_VALUE_XX]; + k0_vector[1] = rProperties[K0_VALUE_YY]; + k0_vector[2] = rProperties[K0_VALUE_ZZ]; } return k0_vector; @@ -227,25 +208,26 @@ array_1d ApplyK0ProcedureProcess::CreateK0Vector(const Element::Prope void ApplyK0ProcedureProcess::CalculateK0Stresses(Element& rElement, const ProcessInfo& rProcessInfo) { // Get K0 material parameters of this element ( probably there is something more efficient ) - const Element::PropertiesType& rProp = rElement.GetProperties(); - const auto k0_main_direction = rProp[K0_MAIN_DIRECTION]; + const Element::PropertiesType& r_properties = rElement.GetProperties(); + const auto k0_main_direction = r_properties[K0_MAIN_DIRECTION]; - auto k0_vector = CreateK0Vector(rProp); + auto k0_vector = CreateK0Vector(r_properties); // Corrections on k0_vector by OCR or POP - const auto PoissonUR = rProp.Has(POISSON_UNLOADING_RELOADING) ? rProp[POISSON_UNLOADING_RELOADING] : 0.; + const auto PoissonUR = + r_properties.Has(POISSON_UNLOADING_RELOADING) ? r_properties[POISSON_UNLOADING_RELOADING] : 0.; const auto PoissonURfactor = PoissonUR / (1. - PoissonUR); double POP_value = 0.0; - if (rProp.Has(K0_NC) || rProp.Has(INDEX_OF_UMAT_PHI_PARAMETER)) { - if (rProp.Has(OCR)) { + if (r_properties.Has(K0_NC) || ConstitutiveLawUtilities::HasFrictionAngle(r_properties)) { + if (r_properties.Has(OCR)) { // Determine OCR dependent K0 values ( constant per element! ) - k0_vector *= rProp[OCR]; - const array_1d correction(3, PoissonURfactor * (rProp[OCR] - 1.0)); + k0_vector *= r_properties[OCR]; + const array_1d correction(3, PoissonURfactor * (r_properties[OCR] - 1.0)); k0_vector -= correction; - } else if (rProp.Has(POP)) { + } else if (r_properties.Has(POP)) { // POP is entered as positive value, convention here is compression negative. - POP_value = -rProp[POP]; + POP_value = -r_properties[POP]; } } // Get element stress vectors diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.h b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.h index 036402216da5..1729852b65ad 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.h +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.h @@ -40,13 +40,12 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) ApplyK0ProcedureProcess : public Pro [[nodiscard]] std::string Info() const override; private: - [[nodiscard]] bool UseStandardProcedure() const; - [[nodiscard]] static array_1d CreateK0Vector(const Element::PropertiesType& rProp); + [[nodiscard]] bool UseStandardProcedure() const; + [[nodiscard]] static array_1d CreateK0Vector(const Element::PropertiesType& rProperties); static void CalculateK0Stresses(Element& rElement, const ProcessInfo& rProcessInfo); static void CheckK0(const Properties& rProperties, IndexType ElementId); static void CheckK0MainDirection(const Properties& rProperties, IndexType ElementId); static void CheckOCRorPOP(const Properties& rProperties, IndexType ElementId); - static void CheckPhi(const Properties& rProperties, IndexType ElementId); static void CheckPoissonUnloadingReloading(const Properties& rProperties, IndexType ElementId); static void CheckSufficientMaterialParameters(const Properties& rProperties, IndexType ElementId); diff --git a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp index 51cc0042fe4b..700c957e1a14 100644 --- a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp @@ -83,6 +83,42 @@ double ConstitutiveLawUtilities::GetCohesion(const Properties& rProperties) } } +bool ConstitutiveLawUtilities::HasFrictionAngle(const Properties& rProperties) +{ + // Friction angle can be supplied either directly via GEO_FRICTION_ANGLE + // or via UMAT parameters + INDEX_OF_UMAT_PHI_PARAMETER. + return rProperties.Has(GEO_FRICTION_ANGLE) || + (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS)); +} + +void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperties, IndexType ElementId) +{ + // If UMAT-route is used, validate index and the stored angle in UMAT parameters (degrees) + if (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS)) { + const auto phi_index = rProperties[INDEX_OF_UMAT_PHI_PARAMETER]; + const auto number_of_umat_parameters = static_cast(rProperties[UMAT_PARAMETERS].size()); + + KRATOS_ERROR_IF(phi_index < 1 || phi_index > number_of_umat_parameters) + << "INDEX_OF_UMAT_PHI_PARAMETER (" << phi_index + << ") is not in range 1, size of UMAT_PARAMETERS for element " << ElementId << "." << std::endl; + + const double phi = rProperties[UMAT_PARAMETERS][phi_index - 1]; + KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) + << "Phi (" << phi << ") should be between 0 and 90 degrees for element " << ElementId + << "." << std::endl; + } + // If GEO_FRICTION_ANGLE is provided directly, validate its range (degrees) + else if (rProperties.Has(GEO_FRICTION_ANGLE)) { + const double phi = rProperties[GEO_FRICTION_ANGLE]; + KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) + << "GEO_FRICTION_ANGLE (" << phi << ") should be between 0 and 90 degrees for element " + << ElementId << "." << std::endl; + } else { + KRATOS_ERROR << "Properties of element ( " << ElementId + << ") does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER." << std::endl; + } +} + double ConstitutiveLawUtilities::GetFrictionAngleInDegrees(const Properties& rProperties) { if (rProperties.Has(GEO_FRICTION_ANGLE)) { diff --git a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.h b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.h index 266f02a0c5d2..4f4f8cc2d213 100644 --- a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.h +++ b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.h @@ -35,6 +35,8 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) ConstitutiveLawUtilities double detF); static double GetCohesion(const Properties& rProperties); + static bool HasFrictionAngle(const Properties& rProperties); + static void ValidateFrictionAngle(const Properties& rProperties, IndexType ElementId); static double GetFrictionAngleInDegrees(const Properties& rProperties); static double GetFrictionAngleInRadians(const Properties& rProperties); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp index ba320e76d1fc..108923bc3075 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp @@ -589,6 +589,7 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, Krat "K0_NC (-0.5) should be in the range [0.0,-> for element 1.") p_element->GetProperties().SetValue(K0_NC, 0.5); + p_element->GetProperties().SetValue(GEO_FRICTION_ANGLE, 35.0); KRATOS_EXPECT_EQ(process.Check(), 0); } From 25d93dc424522e509ed51c08192f7475595dfba5 Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 11:53:43 +0200 Subject: [PATCH 02/18] added unit tests for HasFrictionAngle and ValidateFrictionAngle --- .../constitutive_law_utilities.cpp | 3 +- .../test_apply_k0_procedure_process.cpp | 6 +- .../test_constitutive_law_utilities.cpp | 95 +++++++++++++++++++ 3 files changed, 100 insertions(+), 4 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp index 700c957e1a14..9e62b881dcfc 100644 --- a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp @@ -100,7 +100,8 @@ void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperti KRATOS_ERROR_IF(phi_index < 1 || phi_index > number_of_umat_parameters) << "INDEX_OF_UMAT_PHI_PARAMETER (" << phi_index - << ") is not in range 1, size of UMAT_PARAMETERS for element " << ElementId << "." << std::endl; + << ") is not in range [1, size of UMAT_PARAMETERS] for element " << ElementId << "." + << std::endl; const double phi = rProperties[UMAT_PARAMETERS][phi_index - 1]; KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp index 108923bc3075..6031e6600787 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp @@ -562,9 +562,9 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, Krat Vector umat_parameters{1}; umat_parameters[0] = -30.0; p_element->GetProperties().SetValue(UMAT_PARAMETERS, umat_parameters); - KRATOS_EXPECT_EXCEPTION_IS_THROWN( - process.Check(), - "INDEX_OF_UMAT_PHI_PARAMETER (2) is not in range 1, size of UMAT_PARAMETERS for element 1") + KRATOS_EXPECT_EXCEPTION_IS_THROWN(process.Check(), + "INDEX_OF_UMAT_PHI_PARAMETER (2) is not in range [1, size of " + "UMAT_PARAMETERS] for element 1") p_element->GetProperties().SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 1); KRATOS_EXPECT_EXCEPTION_IS_THROWN(process.Check(), diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp index e050c5ae7ea0..554fed73721c 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp @@ -183,4 +183,99 @@ KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_CalculateK0NCFromFrictionAngl 1.0 - 0.5 * std::numbers::sqrt3, Defaults::absolute_tolerance); } +KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_HasFrictionAngle, KratosGeoMechanicsFastSuiteWithoutKernel) +{ + // 1) GEO_FRICTION_ANGLE provided + { + auto properties = Properties{}; + properties.SetValue(GEO_FRICTION_ANGLE, 30.0); + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), true); + } + + // 2) UMAT_PARAMETERS + INDEX_OF_UMAT_PHI_PARAMETER provided + { + auto properties = Properties{}; + const auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), true); + } + + // 3) only INDEX_OF_UMAT_PHI_PARAMETER provided -> should be false + { + auto properties = Properties{}; + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 1); + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); + } + + // 4) only UMAT_PARAMETERS provided -> should be false + { + auto properties = Properties{}; + const auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); + } + + // 5) neither provided -> false + { + auto properties = Properties{}; + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); + } +} + +KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_ValidateFrictionAngle, KratosGeoMechanicsFastSuiteWithoutKernel) +{ + constexpr std::size_t element_id = 1; + + // Valid: GEO_FRICTION_ANGLE provided + { + auto properties = Properties{}; + properties.SetValue(GEO_FRICTION_ANGLE, 30.0); + EXPECT_NO_THROW(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id)); + } + + // Valid: UMAT_PARAMETERS + INDEX_OF_UMAT_PHI_PARAMETER provided + { + auto properties = Properties{}; + const auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); + EXPECT_NO_THROW(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id)); + } + + // Missing both -> error + { + auto properties = Properties{}; + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "Properties of element ( 1) does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER."); + } + + // GEO_FRICTION_ANGLE out of range -> error + { + auto properties = Properties{}; + properties.SetValue(GEO_FRICTION_ANGLE, -1.0); + KRATOS_EXPECT_EXCEPTION_IS_THROWN( + ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), + "GEO_FRICTION_ANGLE (-1) should be between 0 and 90 degrees for element 1."); + } + + // UMAT phi value out of range -> error + { + auto properties = Properties{}; + const auto umat_parameters = UblasUtilities::CreateVector({2.0, -5.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); + KRATOS_EXPECT_EXCEPTION_IS_THROWN( + ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), + "Phi (-5) should be between 0 and 90 degrees for element 1."); + } + + // INDEX_OF_UMAT_PHI_PARAMETER out of bounds -> error + { + auto properties = Properties{}; + const auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 3); + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "INDEX_OF_UMAT_PHI_PARAMETER (3) is not in range [1, size of UMAT_PARAMETERS] for element 1."); + } +} } // namespace Kratos::Testing From 6f94227eb128477fc87bff5a44acee68e92d6e2e Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 12:03:43 +0200 Subject: [PATCH 03/18] changed order of getting friction angle --- .../constitutive_law_utilities.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp index 9e62b881dcfc..c5aaaf4dffc5 100644 --- a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp @@ -93,8 +93,15 @@ bool ConstitutiveLawUtilities::HasFrictionAngle(const Properties& rProperties) void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperties, IndexType ElementId) { + // If GEO_FRICTION_ANGLE is provided directly, validate its range (degrees) + if (rProperties.Has(GEO_FRICTION_ANGLE)) { + const double phi = rProperties[GEO_FRICTION_ANGLE]; + KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) + << "GEO_FRICTION_ANGLE (" << phi << ") should be between 0 and 90 degrees for element " + << ElementId << "." << std::endl; + } // If UMAT-route is used, validate index and the stored angle in UMAT parameters (degrees) - if (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS)) { + else if (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS)) { const auto phi_index = rProperties[INDEX_OF_UMAT_PHI_PARAMETER]; const auto number_of_umat_parameters = static_cast(rProperties[UMAT_PARAMETERS].size()); @@ -107,13 +114,6 @@ void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperti KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) << "Phi (" << phi << ") should be between 0 and 90 degrees for element " << ElementId << "." << std::endl; - } - // If GEO_FRICTION_ANGLE is provided directly, validate its range (degrees) - else if (rProperties.Has(GEO_FRICTION_ANGLE)) { - const double phi = rProperties[GEO_FRICTION_ANGLE]; - KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) - << "GEO_FRICTION_ANGLE (" << phi << ") should be between 0 and 90 degrees for element " - << ElementId << "." << std::endl; } else { KRATOS_ERROR << "Properties of element ( " << ElementId << ") does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER." << std::endl; From f42558aaf0cec9ef7e0925a0ed306005c2be89fd Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 12:04:02 +0200 Subject: [PATCH 04/18] updated README.md --- applications/GeoMechanicsApplication/custom_processes/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/README.md b/applications/GeoMechanicsApplication/custom_processes/README.md index 98e8835105a0..ed53e26d83ab 100644 --- a/applications/GeoMechanicsApplication/custom_processes/README.md +++ b/applications/GeoMechanicsApplication/custom_processes/README.md @@ -85,7 +85,7 @@ When set to true, the material used for the modelpart used for the $K_0$ procedu When the stress computation is completed, the original constitutive law is restored. Depending on the given input parameters, the following scheme is adapted for computation of the $K_0$ value. -$K_0^{nc}$ is gotten from either "K0_NC" the material input file or by computation from input of "INDEX_OF_UMAT_PHI_PARAMETER" and "UMAT_PARAMETERS": +$K_0^{nc}$ is gotten from either "K0_NC" the material input file or by computation from input of "GEO_FRICTION_ANGLE" or "INDEX_OF_UMAT_PHI_PARAMETER" and "UMAT_PARAMETERS": $$K_0^{nc} = 1.0 - \sin \phi$$ From 7ded4eaddd0e50e0d8531da757031180b45a4797 Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 13:21:21 +0200 Subject: [PATCH 05/18] excluded check of friction angle when k0 values are available --- .../custom_processes/apply_k0_procedure_process.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index cc9f4bb0d3cd..98467d7bc4d2 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -84,7 +84,9 @@ int ApplyK0ProcedureProcess::Check() CheckOCRorPOP(r_properties, rElement.Id()); CheckPoissonUnloadingReloading(r_properties, rElement.Id()); CheckK0(r_properties, rElement.Id()); - ConstitutiveLawUtilities::ValidateFrictionAngle(r_properties, rElement.Id()); + if (!(r_properties.Has(K0_NC) || (r_properties.Has(K0_VALUE_XX) && r_properties.Has(K0_VALUE_YY) && + r_properties.Has(K0_VALUE_ZZ)))) + ConstitutiveLawUtilities::ValidateFrictionAngle(r_properties, rElement.Id()); }); } From f273ae9e25f0975437158564575f2226d8eea216 Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 20:17:46 +0200 Subject: [PATCH 06/18] removed {} in unit tests --- .../test_constitutive_law_utilities.cpp | 109 +++++++----------- 1 file changed, 43 insertions(+), 66 deletions(-) diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp index 554fed73721c..b3125f12039c 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp @@ -186,41 +186,31 @@ KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_CalculateK0NCFromFrictionAngl KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_HasFrictionAngle, KratosGeoMechanicsFastSuiteWithoutKernel) { // 1) GEO_FRICTION_ANGLE provided - { - auto properties = Properties{}; - properties.SetValue(GEO_FRICTION_ANGLE, 30.0); - KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), true); - } + auto properties = Properties{}; + properties.SetValue(GEO_FRICTION_ANGLE, 30.0); + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), true); // 2) UMAT_PARAMETERS + INDEX_OF_UMAT_PHI_PARAMETER provided - { - auto properties = Properties{}; - const auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); - properties.SetValue(UMAT_PARAMETERS, umat_parameters); - properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); - KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), true); - } + properties = Properties{}; + auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), true); // 3) only INDEX_OF_UMAT_PHI_PARAMETER provided -> should be false - { - auto properties = Properties{}; - properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 1); - KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); - } + properties = Properties{}; + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 1); + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); // 4) only UMAT_PARAMETERS provided -> should be false - { - auto properties = Properties{}; - const auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); - properties.SetValue(UMAT_PARAMETERS, umat_parameters); - KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); - } + properties = Properties{}; + umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); // 5) neither provided -> false - { - auto properties = Properties{}; - KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); - } + properties = Properties{}; + KRATOS_EXPECT_EQ(ConstitutiveLawUtilities::HasFrictionAngle(properties), false); } KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_ValidateFrictionAngle, KratosGeoMechanicsFastSuiteWithoutKernel) @@ -228,54 +218,41 @@ KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_ValidateFrictionAngle, Kratos constexpr std::size_t element_id = 1; // Valid: GEO_FRICTION_ANGLE provided - { - auto properties = Properties{}; - properties.SetValue(GEO_FRICTION_ANGLE, 30.0); - EXPECT_NO_THROW(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id)); - } + auto properties = Properties{}; + properties.SetValue(GEO_FRICTION_ANGLE, 30.0); + EXPECT_NO_THROW(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id)); // Valid: UMAT_PARAMETERS + INDEX_OF_UMAT_PHI_PARAMETER provided - { - auto properties = Properties{}; - const auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); - properties.SetValue(UMAT_PARAMETERS, umat_parameters); - properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); - EXPECT_NO_THROW(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id)); - } + properties = Properties{}; + auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); + EXPECT_NO_THROW(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id)); // Missing both -> error - { - auto properties = Properties{}; - KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "Properties of element ( 1) does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER."); - } + properties = Properties{}; + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "Properties of element ( 1) does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER."); // GEO_FRICTION_ANGLE out of range -> error - { - auto properties = Properties{}; - properties.SetValue(GEO_FRICTION_ANGLE, -1.0); - KRATOS_EXPECT_EXCEPTION_IS_THROWN( - ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), - "GEO_FRICTION_ANGLE (-1) should be between 0 and 90 degrees for element 1."); - } + properties = Properties{}; + properties.SetValue(GEO_FRICTION_ANGLE, -1.0); + KRATOS_EXPECT_EXCEPTION_IS_THROWN( + ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), + "GEO_FRICTION_ANGLE (-1) should be between 0 and 90 degrees for element 1."); // UMAT phi value out of range -> error - { - auto properties = Properties{}; - const auto umat_parameters = UblasUtilities::CreateVector({2.0, -5.0}); - properties.SetValue(UMAT_PARAMETERS, umat_parameters); - properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); - KRATOS_EXPECT_EXCEPTION_IS_THROWN( - ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), - "Phi (-5) should be between 0 and 90 degrees for element 1."); - } + properties = Properties{}; + umat_parameters = UblasUtilities::CreateVector({2.0, -5.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), + "Phi (-5) should be between 0 and 90 degrees for element 1."); // INDEX_OF_UMAT_PHI_PARAMETER out of bounds -> error - { - auto properties = Properties{}; - const auto umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); - properties.SetValue(UMAT_PARAMETERS, umat_parameters); - properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 3); - KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "INDEX_OF_UMAT_PHI_PARAMETER (3) is not in range [1, size of UMAT_PARAMETERS] for element 1."); - } + properties = Properties{}; + umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); + properties.SetValue(UMAT_PARAMETERS, umat_parameters); + properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 3); + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "INDEX_OF_UMAT_PHI_PARAMETER (3) is not in range [1, size of UMAT_PARAMETERS] for element 1."); } } // namespace Kratos::Testing From 47273e733870eb896790140bddb4b85aab9c4bcc Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 20:30:31 +0200 Subject: [PATCH 07/18] used Kratos style for local variables --- .../apply_k0_procedure_process.cpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index 98467d7bc4d2..b302962579b0 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -32,9 +32,10 @@ using namespace std::string_literals; void SetConsiderDiagonalEntriesOnlyAndNoShear(ModelPart::ElementsContainerType& rElements, bool Whether) { block_for_each(rElements, [Whether](Element& rElement) { - auto pLinearElasticLaw = + auto p_linear_elastic_law = dynamic_cast(rElement.GetProperties().GetValue(CONSTITUTIVE_LAW).get()); - if (pLinearElasticLaw) pLinearElasticLaw->SetConsiderDiagonalEntriesOnlyAndNoShear(Whether); + if (p_linear_elastic_law) + p_linear_elastic_law->SetConsiderDiagonalEntriesOnlyAndNoShear(Whether); }); } @@ -216,16 +217,16 @@ void ApplyK0ProcedureProcess::CalculateK0Stresses(Element& rElement, const Proce auto k0_vector = CreateK0Vector(r_properties); // Corrections on k0_vector by OCR or POP - const auto PoissonUR = + const auto poisson_u_r = r_properties.Has(POISSON_UNLOADING_RELOADING) ? r_properties[POISSON_UNLOADING_RELOADING] : 0.; - const auto PoissonURfactor = PoissonUR / (1. - PoissonUR); + const auto poisson_u_r_factor = poisson_u_r / (1. - poisson_u_r); double POP_value = 0.0; if (r_properties.Has(K0_NC) || ConstitutiveLawUtilities::HasFrictionAngle(r_properties)) { if (r_properties.Has(OCR)) { // Determine OCR dependent K0 values ( constant per element! ) k0_vector *= r_properties[OCR]; - const array_1d correction(3, PoissonURfactor * (r_properties[OCR] - 1.0)); + const array_1d correction(3, poisson_u_r_factor * (r_properties[OCR] - 1.0)); k0_vector -= correction; } else if (r_properties.Has(POP)) { // POP is entered as positive value, convention here is compression negative. @@ -233,23 +234,23 @@ void ApplyK0ProcedureProcess::CalculateK0Stresses(Element& rElement, const Proce } } // Get element stress vectors - std::vector rStressVectors; - rElement.CalculateOnIntegrationPoints(CAUCHY_STRESS_VECTOR, rStressVectors, rProcessInfo); + std::vector stress_vectors; + rElement.CalculateOnIntegrationPoints(CAUCHY_STRESS_VECTOR, stress_vectors, rProcessInfo); // Loop over integration point stress vectors - for (auto& rStressVector : rStressVectors) { + for (auto& r_stress_vector : stress_vectors) { // Apply K0 procedure for (int i_dir = 0; i_dir <= 2; ++i_dir) { if (i_dir != k0_main_direction) { - rStressVector[i_dir] = k0_vector[i_dir] * (rStressVector[k0_main_direction] + POP_value) - - PoissonURfactor * POP_value; + r_stress_vector[i_dir] = k0_vector[i_dir] * (r_stress_vector[k0_main_direction] + POP_value) - + poisson_u_r_factor * POP_value; } } // Erase shear stresses - std::fill(rStressVector.begin() + 3, rStressVector.end(), 0.0); + std::fill(r_stress_vector.begin() + 3, r_stress_vector.end(), 0.0); } // Set element integration point stress tensors - rElement.SetValuesOnIntegrationPoints(CAUCHY_STRESS_VECTOR, rStressVectors, rProcessInfo); + rElement.SetValuesOnIntegrationPoints(CAUCHY_STRESS_VECTOR, stress_vectors, rProcessInfo); } } // namespace Kratos From cd932d061ea27a25542d85f90814fe7e94f28863 Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 20:47:45 +0200 Subject: [PATCH 08/18] added unit test K0ProcedureIsAppliedCorrectlyWithK0_Values_3D --- .../test_apply_k0_procedure_process.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp index 6031e6600787..4008692bc233 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp @@ -488,6 +488,24 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureIsAppliedCorrectlyWithK0_NCandPOPandNu_UR_3 KRATOS_EXPECT_VECTOR_NEAR(actual_stress_vector, expected_stress_vector, Defaults::absolute_tolerance); } +KRATOS_TEST_CASE_IN_SUITE(K0ProcedureIsAppliedCorrectlyWithK0_Values_3D, KratosGeoMechanicsFastSuiteWithoutKernel) +{ + // Arrange + auto p_properties = std::make_shared(); + p_properties->SetValue(K0_VALUE_XX, 0.5); + p_properties->SetValue(K0_VALUE_YY, 0.5); + p_properties->SetValue(K0_VALUE_ZZ, 1.0); + p_properties->SetValue(K0_MAIN_DIRECTION, 2); + const auto initial_stress_vector = UblasUtilities::CreateVector({0.0, -10.0, -10.0, 27.0, 10.0, 5.0}); + + // Act + const auto actual_stress_vector = ApplyK0ProcedureOnStubElement(p_properties, initial_stress_vector); + + // Assert + const auto expected_stress_vector = UblasUtilities::CreateVector({-5, -5, -10, 0, 0, 0}); + KRATOS_EXPECT_VECTOR_NEAR(actual_stress_vector, expected_stress_vector, Defaults::absolute_tolerance); +} + KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, KratosGeoMechanicsFastSuiteWithoutKernel) { // Arrange From a650c0d44bce81f3c2e74ab1c4439f7ad4ab70ac Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 23:34:51 +0200 Subject: [PATCH 09/18] minor changes --- .../custom_processes/apply_k0_procedure_process.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index b302962579b0..de336dcd256e 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -13,7 +13,6 @@ #include "apply_k0_procedure_process.h" #include -#include #include "containers/model.h" #include "custom_constitutive/linear_elastic_law.h" @@ -32,7 +31,7 @@ using namespace std::string_literals; void SetConsiderDiagonalEntriesOnlyAndNoShear(ModelPart::ElementsContainerType& rElements, bool Whether) { block_for_each(rElements, [Whether](Element& rElement) { - auto p_linear_elastic_law = + const auto p_linear_elastic_law = dynamic_cast(rElement.GetProperties().GetValue(CONSTITUTIVE_LAW).get()); if (p_linear_elastic_law) p_linear_elastic_law->SetConsiderDiagonalEntriesOnlyAndNoShear(Whether); @@ -73,7 +72,7 @@ int ApplyK0ProcedureProcess::Check() { for (const auto& r_model_part : mrModelParts) { KRATOS_ERROR_IF(r_model_part.get().Elements().empty()) - << "ApplyK0ProcedureProces has no elements in modelpart " << r_model_part.get().Name() + << "ApplyK0ProcedureProcess has no elements in modelpart " << r_model_part.get().Name() << std::endl; } @@ -195,7 +194,7 @@ array_1d ApplyK0ProcedureProcess::CreateK0Vector(const Element::Prope // Check for alternative K0 specifications array_1d k0_vector; if (rProperties.Has(K0_NC)) { - std::fill(k0_vector.begin(), k0_vector.end(), rProperties[K0_NC]); + std::ranges::fill(k0_vector, rProperties[K0_NC]); } else if (ConstitutiveLawUtilities::HasFrictionAngle(rProperties)) { std::ranges::fill(k0_vector, ConstitutiveLawUtilities::CalculateK0NCFromFrictionAngleInRadians( ConstitutiveLawUtilities::GetFrictionAngleInRadians(rProperties))); From 0e767b799c3c935fab334686623dbb42517dc3f2 Mon Sep 17 00:00:00 2001 From: markelov Date: Fri, 10 Apr 2026 23:36:06 +0200 Subject: [PATCH 10/18] fixed typo --- .../custom_processes/test_apply_k0_procedure_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp index 4008692bc233..b7173f96c479 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp @@ -620,7 +620,7 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfModelPartHasElements, KratosGeoMech k0_settings.AddString("model_part_name", "dummy"); KRATOS_EXPECT_EXCEPTION_IS_THROWN((ApplyK0ProcedureProcess{model, k0_settings}.Check()), - "ApplyK0ProcedureProces has no elements in modelpart dummy") + "ApplyK0ProcedureProcess has no elements in modelpart dummy") } KRATOS_TEST_CASE_IN_SUITE(CheckInfoK0ProcedureProcess, KratosGeoMechanicsFastSuiteWithoutKernel) From bd5b3a8bc120c116e466ef9271cf23ff96477baa Mon Sep 17 00:00:00 2001 From: markelov Date: Mon, 13 Apr 2026 11:05:03 +0200 Subject: [PATCH 11/18] response to the review --- .../apply_k0_procedure_process.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index de336dcd256e..6307882ab230 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -99,15 +99,19 @@ void ApplyK0ProcedureProcess::CheckK0MainDirection(const Properties& rProperties << "K0_MAIN_DIRECTION is not defined for element " << ElementId << "." << std::endl; const auto dimension = rProperties.GetValue(CONSTITUTIVE_LAW).get()->WorkingSpaceDimension(); - if (dimension == 2) { - KRATOS_ERROR_IF(rProperties[K0_MAIN_DIRECTION] < 0 || rProperties[K0_MAIN_DIRECTION] > 1) - << "K0_MAIN_DIRECTION should be 0 or 1 for element " << ElementId << "." << std::endl; - } else if (dimension == 3) { - KRATOS_ERROR_IF(rProperties[K0_MAIN_DIRECTION] < 0 || rProperties[K0_MAIN_DIRECTION] > 2) - << "K0_MAIN_DIRECTION should be 0, 1 or 2 for element " << ElementId << "." << std::endl; - } else { - KRATOS_ERROR << "dimension should be 2 or 3 for element " << ElementId << "." << std::endl; + KRATOS_ERROR_IF(dimension != 2 && dimension != 3) + << "dimension should be 2 or 3 for element " << ElementId << "." << std::endl; + std::ostringstream valid_values; + for (int i = 0; i < dimension; ++i) { + if (i > 0) { + if (i == dimension - 1) valid_values << " or "; + else valid_values << ", "; + } + valid_values << i; } + KRATOS_ERROR_IF(rProperties[K0_MAIN_DIRECTION] < 0 || rProperties[K0_MAIN_DIRECTION] > 1) + << "K0_MAIN_DIRECTION should be " << valid_values.str() << " for element " << ElementId + << "." << std::endl; } void ApplyK0ProcedureProcess::CheckK0(const Properties& rProperties, IndexType ElementId) From a4dfcfc8c15858f5eb4da61ccefea6fa9ec4b5e4 Mon Sep 17 00:00:00 2001 From: markelov Date: Mon, 13 Apr 2026 11:18:03 +0200 Subject: [PATCH 12/18] response to the review comment --- .../constitutive_law_utilities.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp index c5aaaf4dffc5..edefcd187948 100644 --- a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp @@ -93,15 +93,13 @@ bool ConstitutiveLawUtilities::HasFrictionAngle(const Properties& rProperties) void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperties, IndexType ElementId) { - // If GEO_FRICTION_ANGLE is provided directly, validate its range (degrees) + double phi = 0.0; + std::string phi_name; + if (rProperties.Has(GEO_FRICTION_ANGLE)) { - const double phi = rProperties[GEO_FRICTION_ANGLE]; - KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) - << "GEO_FRICTION_ANGLE (" << phi << ") should be between 0 and 90 degrees for element " - << ElementId << "." << std::endl; - } - // If UMAT-route is used, validate index and the stored angle in UMAT parameters (degrees) - else if (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS)) { + phi = rProperties[GEO_FRICTION_ANGLE]; + phi_name = "GEO_FRICTION_ANGLE"; + } else if (rProperties.Has(INDEX_OF_UMAT_PHI_PARAMETER) && rProperties.Has(UMAT_PARAMETERS)) { const auto phi_index = rProperties[INDEX_OF_UMAT_PHI_PARAMETER]; const auto number_of_umat_parameters = static_cast(rProperties[UMAT_PARAMETERS].size()); @@ -110,14 +108,18 @@ void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperti << ") is not in range [1, size of UMAT_PARAMETERS] for element " << ElementId << "." << std::endl; - const double phi = rProperties[UMAT_PARAMETERS][phi_index - 1]; - KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) - << "Phi (" << phi << ") should be between 0 and 90 degrees for element " << ElementId - << "." << std::endl; - } else { + phi = rProperties[UMAT_PARAMETERS][phi_index - 1]; + phi_name = "Phi"; + } + + if (phi_name == "") { KRATOS_ERROR << "Properties of element ( " << ElementId << ") does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER." << std::endl; } + + KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) + << phi_name << " (" << phi << ") should be between 0 and 90 degrees for element " + << ElementId << "." << std::endl; } double ConstitutiveLawUtilities::GetFrictionAngleInDegrees(const Properties& rProperties) From df75c0ffe27d333cf5a0a12346c7b4fce26a1dca Mon Sep 17 00:00:00 2001 From: markelov Date: Mon, 13 Apr 2026 12:08:36 +0200 Subject: [PATCH 13/18] fixed a type mismatch --- .../custom_processes/apply_k0_procedure_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index 6307882ab230..c2f02800f886 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -102,7 +102,7 @@ void ApplyK0ProcedureProcess::CheckK0MainDirection(const Properties& rProperties KRATOS_ERROR_IF(dimension != 2 && dimension != 3) << "dimension should be 2 or 3 for element " << ElementId << "." << std::endl; std::ostringstream valid_values; - for (int i = 0; i < dimension; ++i) { + for (std::size_t i = 0; i < dimension; ++i) { if (i > 0) { if (i == dimension - 1) valid_values << " or "; else valid_values << ", "; From f3186e2957a02dd040e1fb0bad61ae3cc1411c5e Mon Sep 17 00:00:00 2001 From: markelov Date: Mon, 13 Apr 2026 14:35:45 +0200 Subject: [PATCH 14/18] fixed check --- .../custom_processes/apply_k0_procedure_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index c2f02800f886..bec96c0c6705 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -109,7 +109,7 @@ void ApplyK0ProcedureProcess::CheckK0MainDirection(const Properties& rProperties } valid_values << i; } - KRATOS_ERROR_IF(rProperties[K0_MAIN_DIRECTION] < 0 || rProperties[K0_MAIN_DIRECTION] > 1) + KRATOS_ERROR_IF(rProperties[K0_MAIN_DIRECTION] < 0 || rProperties[K0_MAIN_DIRECTION] > dimension) << "K0_MAIN_DIRECTION should be " << valid_values.str() << " for element " << ElementId << "." << std::endl; } From 48508d6f2c71a912c4c9bf636d8966b3f48dd05f Mon Sep 17 00:00:00 2001 From: markelov Date: Mon, 13 Apr 2026 15:11:15 +0200 Subject: [PATCH 15/18] added property Id in output --- .../custom_utilities/constitutive_law_utilities.cpp | 6 +++--- .../test_apply_k0_procedure_process.cpp | 5 +++-- .../test_constitutive_law_utilities.cpp | 11 +++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp index edefcd187948..292f7c47a50d 100644 --- a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp @@ -113,13 +113,13 @@ void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperti } if (phi_name == "") { - KRATOS_ERROR << "Properties of element ( " << ElementId + KRATOS_ERROR << "Properties ( " << rProperties.Id() << ") of element ( " << ElementId << ") does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER." << std::endl; } KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) - << phi_name << " (" << phi << ") should be between 0 and 90 degrees for element " - << ElementId << "." << std::endl; + << "Properties ( " << rProperties.Id() << "): " << phi_name << " (" << phi + << " degrees) should be between 0 and 90 degrees for element " << ElementId << "." << std::endl; } double ConstitutiveLawUtilities::GetFrictionAngleInDegrees(const Properties& rProperties) diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp index b7173f96c479..b1fa1371df54 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp @@ -585,8 +585,9 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, Krat "UMAT_PARAMETERS] for element 1") p_element->GetProperties().SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 1); - KRATOS_EXPECT_EXCEPTION_IS_THROWN(process.Check(), - "Phi (-30) should be between 0 and 90 degrees for element 1.") + KRATOS_EXPECT_EXCEPTION_IS_THROWN( + process.Check(), + "Properties ( 0): Phi (-30 degrees) should be between 0 and 90 degrees for element 1.") umat_parameters[0] = 30.0; p_element->GetProperties().SetValue(UMAT_PARAMETERS, umat_parameters); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp index b3125f12039c..0510baac27a6 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp @@ -231,22 +231,21 @@ KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_ValidateFrictionAngle, Kratos // Missing both -> error properties = Properties{}; - KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "Properties of element ( 1) does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER."); + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "Properties ( 0) of element ( 1) does not have GEO_FRICTION_ANGLE nor INDEX_OF_UMAT_PHI_PARAMETER."); // GEO_FRICTION_ANGLE out of range -> error properties = Properties{}; properties.SetValue(GEO_FRICTION_ANGLE, -1.0); - KRATOS_EXPECT_EXCEPTION_IS_THROWN( - ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), - "GEO_FRICTION_ANGLE (-1) should be between 0 and 90 degrees for element 1."); + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "Properties ( 0): GEO_FRICTION_ANGLE (-1 degrees) should be between 0 and 90 degrees for element 1."); // UMAT phi value out of range -> error properties = Properties{}; umat_parameters = UblasUtilities::CreateVector({2.0, -5.0}); properties.SetValue(UMAT_PARAMETERS, umat_parameters); properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); - KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), - "Phi (-5) should be between 0 and 90 degrees for element 1."); + KRATOS_EXPECT_EXCEPTION_IS_THROWN( + ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), + "Properties ( 0): Phi (-5 degrees) should be between 0 and 90 degrees for element 1."); // INDEX_OF_UMAT_PHI_PARAMETER out of bounds -> error properties = Properties{}; From 5ad21677e80a5dc77a6fb239ff5ce729e3dadb5f Mon Sep 17 00:00:00 2001 From: markelov Date: Mon, 13 Apr 2026 15:21:52 +0200 Subject: [PATCH 16/18] added more prints of property Id --- .../custom_utilities/constitutive_law_utilities.cpp | 10 +++++----- .../test_apply_k0_procedure_process.cpp | 8 ++++---- .../test_constitutive_law_utilities.cpp | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp index 292f7c47a50d..39e3972ee6d7 100644 --- a/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/custom_utilities/constitutive_law_utilities.cpp @@ -104,9 +104,9 @@ void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperti const auto number_of_umat_parameters = static_cast(rProperties[UMAT_PARAMETERS].size()); KRATOS_ERROR_IF(phi_index < 1 || phi_index > number_of_umat_parameters) - << "INDEX_OF_UMAT_PHI_PARAMETER (" << phi_index - << ") is not in range [1, size of UMAT_PARAMETERS] for element " << ElementId << "." - << std::endl; + << "Properties ( " << rProperties.Id() << ") of element ( " << ElementId + << "): INDEX_OF_UMAT_PHI_PARAMETER (" << phi_index + << ") is not in range [1, size of UMAT_PARAMETERS]." << std::endl; phi = rProperties[UMAT_PARAMETERS][phi_index - 1]; phi_name = "Phi"; @@ -118,8 +118,8 @@ void ConstitutiveLawUtilities::ValidateFrictionAngle(const Properties& rProperti } KRATOS_ERROR_IF(phi < 0.0 || phi > 90.0) - << "Properties ( " << rProperties.Id() << "): " << phi_name << " (" << phi - << " degrees) should be between 0 and 90 degrees for element " << ElementId << "." << std::endl; + << "Properties ( " << rProperties.Id() << ") of element ( " << ElementId << "): " << phi_name + << " (" << phi << " degrees) should be between 0 and 90 degrees." << std::endl; } double ConstitutiveLawUtilities::GetFrictionAngleInDegrees(const Properties& rProperties) diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp index b1fa1371df54..eb1478688c1d 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp @@ -580,14 +580,14 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, Krat Vector umat_parameters{1}; umat_parameters[0] = -30.0; p_element->GetProperties().SetValue(UMAT_PARAMETERS, umat_parameters); - KRATOS_EXPECT_EXCEPTION_IS_THROWN(process.Check(), - "INDEX_OF_UMAT_PHI_PARAMETER (2) is not in range [1, size of " - "UMAT_PARAMETERS] for element 1") + KRATOS_EXPECT_EXCEPTION_IS_THROWN( + process.Check(), "Properties ( 0) of element ( 1): INDEX_OF_UMAT_PHI_PARAMETER (2) is not " + "in range [1, size of UMAT_PARAMETERS].") p_element->GetProperties().SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 1); KRATOS_EXPECT_EXCEPTION_IS_THROWN( process.Check(), - "Properties ( 0): Phi (-30 degrees) should be between 0 and 90 degrees for element 1.") + "Properties ( 0) of element ( 1): Phi (-30 degrees) should be between 0 and 90 degrees.") umat_parameters[0] = 30.0; p_element->GetProperties().SetValue(UMAT_PARAMETERS, umat_parameters); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp index 0510baac27a6..a6a5aa2bfb57 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_constitutive_law_utilities.cpp @@ -236,7 +236,7 @@ KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_ValidateFrictionAngle, Kratos // GEO_FRICTION_ANGLE out of range -> error properties = Properties{}; properties.SetValue(GEO_FRICTION_ANGLE, -1.0); - KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "Properties ( 0): GEO_FRICTION_ANGLE (-1 degrees) should be between 0 and 90 degrees for element 1."); + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), " Properties ( 0) of element ( 1): GEO_FRICTION_ANGLE (-1 degrees) should be between 0 and 90 degrees."); // UMAT phi value out of range -> error properties = Properties{}; @@ -245,13 +245,13 @@ KRATOS_TEST_CASE_IN_SUITE(ConstitutiveLawUtilities_ValidateFrictionAngle, Kratos properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); KRATOS_EXPECT_EXCEPTION_IS_THROWN( ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), - "Properties ( 0): Phi (-5 degrees) should be between 0 and 90 degrees for element 1."); + " Properties ( 0) of element ( 1): Phi (-5 degrees) should be between 0 and 90 degrees."); // INDEX_OF_UMAT_PHI_PARAMETER out of bounds -> error properties = Properties{}; umat_parameters = UblasUtilities::CreateVector({2.0, 30.0}); properties.SetValue(UMAT_PARAMETERS, umat_parameters); properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 3); - KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "INDEX_OF_UMAT_PHI_PARAMETER (3) is not in range [1, size of UMAT_PARAMETERS] for element 1."); + KRATOS_EXPECT_EXCEPTION_IS_THROWN(ConstitutiveLawUtilities::ValidateFrictionAngle(properties, element_id), "Properties ( 0) of element ( 1): INDEX_OF_UMAT_PHI_PARAMETER (3) is not in range [1, size of UMAT_PARAMETERS]."); } } // namespace Kratos::Testing From 9e2a625c708b340c54b31bf8d8a56e5d36a51d90 Mon Sep 17 00:00:00 2001 From: markelov Date: Mon, 13 Apr 2026 15:33:56 +0200 Subject: [PATCH 17/18] added even more prints of property Id --- .../apply_k0_procedure_process.cpp | 19 ++++++++----- .../test_apply_k0_procedure_process.cpp | 28 ++++++++++--------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index bec96c0c6705..b0f3eaaed2e5 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -133,14 +133,16 @@ void ApplyK0ProcedureProcess::CheckOCRorPOP(const Properties& rProperties, Index if (rProperties.Has(K0_NC) || ConstitutiveLawUtilities::HasFrictionAngle(rProperties)) { if (rProperties.Has(OCR)) { const auto ocr = rProperties[OCR]; - KRATOS_ERROR_IF(ocr < 1.0) << "OCR (" << ocr << ") should be in the range [1.0,-> for element " - << ElementId << "." << std::endl; + KRATOS_ERROR_IF(ocr < 1.0) + << "OCR (" << ocr << ") should be in the range [1.0,-> for property Id of " + << rProperties.Id() << " for element " << ElementId << "." << std::endl; } if (rProperties.Has(POP)) { const auto pop = rProperties[POP]; - KRATOS_ERROR_IF(pop < 0.0) << "POP (" << pop << ") should be in the range [0.0,-> for element " - << ElementId << "." << std::endl; + KRATOS_ERROR_IF(pop < 0.0) + << "POP (" << pop << ") should be in the range [0.0,-> for property Id of " + << rProperties.Id() << " element " << ElementId << "." << std::endl; } } } @@ -151,12 +153,14 @@ void ApplyK0ProcedureProcess::CheckPoissonUnloadingReloading(const Properties& r (rProperties[POISSON_UNLOADING_RELOADING] < -1.0 || rProperties[POISSON_UNLOADING_RELOADING] >= 0.5)) << "POISSON_UNLOADING_RELOADING (" << rProperties[POISSON_UNLOADING_RELOADING] - << ") is not in range [-1.0, 0.5> for element " << ElementId << "." << std::endl; + << ") is not in range [-1.0, 0.5> for property Id of " << rProperties.Id() + << " for element " << ElementId << "." << std::endl; if (rProperties.Has(K0_VALUE_XX)) { KRATOS_ERROR_IF(rProperties.Has(POISSON_UNLOADING_RELOADING) || rProperties.Has(OCR) || rProperties.Has(POP)) - << "Insufficient material data for K0 procedure process for element " + << "Insufficient material data for K0 procedure process for property Id of " + << rProperties.Id() << " for element " << ElementId << ". Poisson unloading-reloading, OCR and POP functionality cannot be combined with K0_VALUE_XX, _YY and _ZZ." << std::endl; } @@ -167,7 +171,8 @@ void ApplyK0ProcedureProcess::CheckSufficientMaterialParameters(const Properties KRATOS_ERROR_IF_NOT( rProperties.Has(K0_NC) || ConstitutiveLawUtilities::HasFrictionAngle(rProperties) || (rProperties.Has(K0_VALUE_XX) && rProperties.Has(K0_VALUE_YY) && rProperties.Has(K0_VALUE_ZZ))) - << "Insufficient material data for K0 procedure process for element " << ElementId << ". No K0_NC, " + << "Insufficient material data for K0 procedure process for property Id of " + << rProperties.Id() << " for element " << ElementId << ". No K0_NC, " << "(INDEX_OF_UMAT_PHI_PARAMETER and UMAT_PARAMETERS) or (K0_VALUE_XX, _YY and _ZZ found)." << std::endl; } diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp index eb1478688c1d..8c4451b44c6d 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_processes/test_apply_k0_procedure_process.cpp @@ -543,9 +543,9 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, Krat p_element->GetProperties().SetValue(K0_MAIN_DIRECTION, 1); KRATOS_EXPECT_EXCEPTION_IS_THROWN( - process.Check(), - "Insufficient material data for K0 procedure process for element 1. No K0_NC, " - "(INDEX_OF_UMAT_PHI_PARAMETER and UMAT_PARAMETERS) or (K0_VALUE_XX, _YY and _ZZ found).") + process.Check(), " Insufficient material data for K0 procedure process for property Id of " + "0 for element 1. No K0_NC, (INDEX_OF_UMAT_PHI_PARAMETER and " + "UMAT_PARAMETERS) or (K0_VALUE_XX, _YY and _ZZ found).") p_element->GetProperties().SetValue(K0_VALUE_XX, -0.5); p_element->GetProperties().SetValue(K0_VALUE_YY, -0.5); p_element->GetProperties().SetValue(K0_VALUE_ZZ, -0.5); @@ -562,15 +562,15 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, Krat p_element->GetProperties().SetValue(K0_VALUE_ZZ, 0.5); p_element->GetProperties().SetValue(POISSON_UNLOADING_RELOADING, 0.75); - KRATOS_EXPECT_EXCEPTION_IS_THROWN( - process.Check(), - "POISSON_UNLOADING_RELOADING (0.75) is not in range [-1.0, 0.5> for element 1.") + KRATOS_EXPECT_EXCEPTION_IS_THROWN(process.Check(), + "POISSON_UNLOADING_RELOADING (0.75) is not in range [-1.0, " + "0.5> for property Id of 0 for element 1.") p_element->GetProperties().SetValue(POISSON_UNLOADING_RELOADING, 0.25); KRATOS_EXPECT_EXCEPTION_IS_THROWN( - process.Check(), "Insufficient material data for K0 procedure process for " - "element 1. Poisson unloading-reloading, OCR and POP functionality cannot " - "be combined with K0_VALUE_XX, _YY and _ZZ.") + process.Check(), "Insufficient material data for K0 procedure process for property Id of 0 " + "for element 1. Poisson unloading-reloading, OCR and POP functionality " + "cannot be combined with K0_VALUE_XX, _YY and _ZZ.") p_element->GetProperties().Erase(K0_VALUE_XX); p_element->GetProperties().Erase(K0_VALUE_YY); @@ -592,13 +592,15 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, Krat umat_parameters[0] = 30.0; p_element->GetProperties().SetValue(UMAT_PARAMETERS, umat_parameters); p_element->GetProperties().SetValue(OCR, 0.5); - KRATOS_EXPECT_EXCEPTION_IS_THROWN(process.Check(), - "OCR (0.5) should be in the range [1.0,-> for element 1.") + KRATOS_EXPECT_EXCEPTION_IS_THROWN( + process.Check(), + "Error: OCR (0.5) should be in the range [1.0,-> for property Id of 0 for element 1.") p_element->GetProperties().Erase(OCR); p_element->GetProperties().SetValue(POP, -100.0); - KRATOS_EXPECT_EXCEPTION_IS_THROWN(process.Check(), - "POP (-100) should be in the range [0.0,-> for element 1.") + KRATOS_EXPECT_EXCEPTION_IS_THROWN( + process.Check(), + "POP (-100) should be in the range [0.0,-> for property Id of 0 element 1.") p_element->GetProperties().Erase(POP); p_element->GetProperties().Erase(INDEX_OF_UMAT_PHI_PARAMETER); From da7cf16a2594e52c34cc3d5410bbfce04214d459 Mon Sep 17 00:00:00 2001 From: markelov Date: Mon, 13 Apr 2026 16:27:31 +0200 Subject: [PATCH 18/18] fixed a type mismatch --- .../custom_processes/apply_k0_procedure_process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index b0f3eaaed2e5..575b01cc37eb 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -109,7 +109,7 @@ void ApplyK0ProcedureProcess::CheckK0MainDirection(const Properties& rProperties } valid_values << i; } - KRATOS_ERROR_IF(rProperties[K0_MAIN_DIRECTION] < 0 || rProperties[K0_MAIN_DIRECTION] > dimension) + KRATOS_ERROR_IF(rProperties[K0_MAIN_DIRECTION] < 0 || rProperties[K0_MAIN_DIRECTION] > static_cast(dimension)) << "K0_MAIN_DIRECTION should be " << valid_values.str() << " for element " << ElementId << "." << std::endl; }