From 01c13ce56546acccbaffcbd0e6ad4df58d40b0ed Mon Sep 17 00:00:00 2001 From: Wijtze Pieter Kikstra Date: Fri, 29 Nov 2024 17:15:40 +0100 Subject: [PATCH] Review request on testing. Capital I to start sentence. --- .../custom_processes/apply_c_phi_reduction_process.cpp | 8 +++++--- .../custom_processes/apply_k0_procedure_process.cpp | 4 ++-- .../cpp_tests/test_apply_c_phi_reduction_process.cpp | 4 ++-- .../tests/cpp_tests/test_apply_k0_procedure_process.cpp | 7 ++++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_c_phi_reduction_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_c_phi_reduction_process.cpp index ae56415fde07..33c368f978ae 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_c_phi_reduction_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_c_phi_reduction_process.cpp @@ -77,8 +77,9 @@ double ApplyCPhiReductionProcess::GetAndCheckPhi(const Element::PropertiesType& << "Missing required item INDEX_OF_UMAT_PHI_PARAMETER" << std::endl; KRATOS_ERROR_IF(part_properties[INDEX_OF_UMAT_PHI_PARAMETER] < 1 || - part_properties[INDEX_OF_UMAT_PHI_PARAMETER] > static_cast(part_properties[UMAT_PARAMETERS].size())) - << "invalid INDEX_OF_UMAT_PHI_PARAMETER: " << part_properties[INDEX_OF_UMAT_PHI_PARAMETER] + part_properties[INDEX_OF_UMAT_PHI_PARAMETER] > + static_cast(part_properties[UMAT_PARAMETERS].size())) + << "Invalid INDEX_OF_UMAT_PHI_PARAMETER: " << part_properties[INDEX_OF_UMAT_PHI_PARAMETER] << " (out-of-bounds index)" << std::endl; const double phi = part_properties[UMAT_PARAMETERS][part_properties[INDEX_OF_UMAT_PHI_PARAMETER] - 1]; KRATOS_ERROR_IF(phi < 0. || phi > 90.) << "Friction angle Phi out of range: " << phi << std::endl; @@ -106,7 +107,8 @@ double ApplyCPhiReductionProcess::GetAndCheckC(const Element::PropertiesType& rP << "Missing required item INDEX_OF_UMAT_C_PARAMETER" << std::endl; KRATOS_ERROR_IF(part_properties[INDEX_OF_UMAT_C_PARAMETER] < 1 || - part_properties[INDEX_OF_UMAT_C_PARAMETER] > static_cast(part_properties[UMAT_PARAMETERS].size())) + part_properties[INDEX_OF_UMAT_C_PARAMETER] > + static_cast(part_properties[UMAT_PARAMETERS].size())) << "invalid INDEX_OF_UMAT_C_PARAMETER: " << part_properties[INDEX_OF_UMAT_C_PARAMETER] << " (out-of-bounds index)" << std::endl; const auto c = part_properties[UMAT_PARAMETERS][part_properties[INDEX_OF_UMAT_C_PARAMETER] - 1]; diff --git a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp index caba91f842b7..f78bbc7b20c5 100644 --- a/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/custom_processes/apply_k0_procedure_process.cpp @@ -108,7 +108,7 @@ 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 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) @@ -209,7 +209,7 @@ void ApplyK0ProcedureProcess::CalculateK0Stresses(Element& rElement) const { // 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 auto k0_main_direction = rProp[K0_MAIN_DIRECTION]; auto k0_vector = CreateK0Vector(rProp); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_c_phi_reduction_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_c_phi_reduction_process.cpp index c7f2c2a1175f..f78c850d872a 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_c_phi_reduction_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_c_phi_reduction_process.cpp @@ -131,12 +131,12 @@ KRATOS_TEST_CASE_IN_SUITE(CheckFailureUmatInputsApplyCPhiReductionProcess, Krato r_model_part_properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 0); KRATOS_EXPECT_EXCEPTION_IS_THROWN( (ApplyCPhiReductionProcess{r_model_part, {}}.ExecuteInitializeSolutionStep()), - "invalid INDEX_OF_UMAT_PHI_PARAMETER: 0 (out-of-bounds index)") + "Invalid INDEX_OF_UMAT_PHI_PARAMETER: 0 (out-of-bounds index)") r_model_part_properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 7); KRATOS_EXPECT_EXCEPTION_IS_THROWN( (ApplyCPhiReductionProcess{r_model_part, {}}.ExecuteInitializeSolutionStep()), - "invalid INDEX_OF_UMAT_PHI_PARAMETER: 7 (out-of-bounds index)") + "Invalid INDEX_OF_UMAT_PHI_PARAMETER: 7 (out-of-bounds index)") r_model_part_properties.SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 4); umat_parameters(3) = -0.0001; diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_k0_procedure_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_k0_procedure_process.cpp index 83227f5b1645..a4f0437a1bf5 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_k0_procedure_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_k0_procedure_process.cpp @@ -479,10 +479,15 @@ KRATOS_TEST_CASE_IN_SUITE(K0ProcedureChecksIfProcessHasCorrectMaterialData, Krat p_element->GetProperties().Erase(K0_VALUE_YY); p_element->GetProperties().Erase(K0_VALUE_ZZ); - p_element->GetProperties().SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 1); + p_element->GetProperties().SetValue(INDEX_OF_UMAT_PHI_PARAMETER, 2); 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") + 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.")