From c415f6bd4cb573dc6ffc564610295a1b7eb8624f Mon Sep 17 00:00:00 2001 From: Wijtze Pieter Kikstra Date: Mon, 20 Jan 2025 15:58:16 +0100 Subject: [PATCH 1/6] do not touch vector variables ( for velocity and acceleration ) in quasistatic scheme. --- .../backward_euler_quasistatic_U_Pw_scheme.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/applications/GeoMechanicsApplication/custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp b/applications/GeoMechanicsApplication/custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp index 0702d240e95d..a02fc3bd82c1 100644 --- a/applications/GeoMechanicsApplication/custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp +++ b/applications/GeoMechanicsApplication/custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp @@ -39,6 +39,23 @@ class BackwardEulerQuasistaticUPwScheme : public BackwardEulerSchemeGetFirstOrderScalarVariables()) { + if (rNode.IsFixed(r_first_order_scalar_variable.first_time_derivative)) continue; + + rNode.FastGetSolutionStepValue(r_first_order_scalar_variable.first_time_derivative) = + CalculateDerivative(r_first_order_scalar_variable.instance, rNode); + } + }); + + KRATOS_CATCH("") + } + std::string Info() const override { return "BackwardEulerQuasistaticUPwScheme"; } }; // Class BackwardEulerQuasistaticUPwScheme From 30ac1f0386d8a5ea1453fbf220eff22fa8d8d338 Mon Sep 17 00:00:00 2001 From: Wijtze Pieter Kikstra Date: Mon, 20 Jan 2025 15:59:23 +0100 Subject: [PATCH 2/6] adapt unit tests for quasistatic euler scheme --- ...backward_euler_quasistatic_U_Pw_scheme.cpp | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 applications/GeoMechanicsApplication/tests/cpp_tests/custom_strategies/test_backward_euler_quasistatic_U_Pw_scheme.cpp diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_strategies/test_backward_euler_quasistatic_U_Pw_scheme.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_strategies/test_backward_euler_quasistatic_U_Pw_scheme.cpp new file mode 100644 index 000000000000..faabf85c6998 --- /dev/null +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_strategies/test_backward_euler_quasistatic_U_Pw_scheme.cpp @@ -0,0 +1,131 @@ +// KRATOS___ +// // ) ) +// // ___ ___ +// // ____ //___) ) // ) ) +// // / / // // / / +// ((____/ / ((____ ((___/ / MECHANICS +// +// License: geo_mechanics_application/license.txt +// +// Main authors: Richard Faasse +// + +#include "containers/model.h" +#include "custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp" +#include "spaces/ublas_space.h" +#include "tests/cpp_tests/geo_mechanics_fast_suite.h" + +namespace Kratos::Testing +{ + +using namespace Kratos; +using SparseSpaceType = UblasSpace; +using LocalSpaceType = UblasSpace; + +class BackwardEulerQuasiStaticUPwSchemeTester +{ +public: + Model mModel; + + BackwardEulerQuasistaticUPwScheme mScheme; + + BackwardEulerQuasiStaticUPwSchemeTester() { CreateValidModelPart(); } + + void CreateValidModelPart() + { + auto& result = mModel.CreateModelPart("dummy", 2); + result.AddNodalSolutionStepVariable(VELOCITY); + result.AddNodalSolutionStepVariable(ACCELERATION); + result.AddNodalSolutionStepVariable(DT_WATER_PRESSURE); + result.AddNodalSolutionStepVariable(DISPLACEMENT); + result.AddNodalSolutionStepVariable(WATER_PRESSURE); + + auto p_node = result.CreateNewNode(0, 0.0, 0.0, 0.0); + p_node->AddDof(DISPLACEMENT_X); + p_node->AddDof(DISPLACEMENT_Y); + p_node->AddDof(DISPLACEMENT_Z); + p_node->AddDof(WATER_PRESSURE); + result.GetProcessInfo()[DELTA_TIME] = 4.0; + + p_node->FastGetSolutionStepValue(DISPLACEMENT, 1) = Kratos::array_1d{7.0, 8.0, 9.0}; + p_node->FastGetSolutionStepValue(VELOCITY, 1) = Kratos::array_1d{1.0, 2.0, 3.0}; + p_node->FastGetSolutionStepValue(ACCELERATION, 1) = Kratos::array_1d{4.0, 5.0, 6.0}; + + p_node->FastGetSolutionStepValue(WATER_PRESSURE, 1) = 1.0; + p_node->FastGetSolutionStepValue(WATER_PRESSURE, 0) = 2.0; + } + + ModelPart& GetModelPart() { return mModel.GetModelPart("dummy"); } +}; + +KRATOS_TEST_CASE_IN_SUITE(CheckBackwardEulerUPwScheme_ReturnsZeroForValidModelPart, KratosGeoMechanicsFastSuiteWithoutKernel) +{ + BackwardEulerQuasiStaticUPwSchemeTester tester; + KRATOS_EXPECT_EQ(tester.mScheme.Check(tester.GetModelPart()), 0); +} + +KRATOS_TEST_CASE_IN_SUITE(InitializeBackwardEulerUPwScheme_SetsTimeFactors, KratosGeoMechanicsFastSuiteWithoutKernel) +{ + BackwardEulerQuasiStaticUPwSchemeTester tester; + + tester.mScheme.Initialize(tester.GetModelPart()); + + // These are the expected numbers according to the SetTimeFactors function + constexpr double expected_dt_pressure_coefficient = 1.0 / 4.0; + constexpr double expected_velocity_coefficient = 1.0 / 4.0; + KRATOS_EXPECT_TRUE(tester.mScheme.SchemeIsInitialized()) + + CompressedMatrix A; + Vector Dx; + Vector b; + tester.mScheme.InitializeSolutionStep(tester.GetModelPart(), A, Dx, b); // This is needed to set the time factors + + KRATOS_EXPECT_DOUBLE_EQ(tester.GetModelPart().GetProcessInfo()[DT_PRESSURE_COEFFICIENT], + expected_dt_pressure_coefficient); + KRATOS_EXPECT_DOUBLE_EQ(tester.GetModelPart().GetProcessInfo()[VELOCITY_COEFFICIENT], + expected_velocity_coefficient); +} + +KRATOS_TEST_CASE_IN_SUITE(BackwardEulerUPwSchemePredict_UpdatesVariablesDerivatives, KratosGeoMechanicsFastSuiteWithoutKernel) +{ + BackwardEulerQuasiStaticUPwSchemeTester tester; + + ModelPart::DofsArrayType dof_set; + CompressedMatrix A; + Vector Dx; + Vector b; + + tester.mScheme.InitializeSolutionStep(tester.GetModelPart(), A, Dx, b); // This is needed to set the time factors + + tester.mScheme.Predict(tester.GetModelPart(), dof_set, A, Dx, b); + + constexpr auto expected_dt_water_pressure = 0.25; + KRATOS_EXPECT_DOUBLE_EQ(tester.GetModelPart().Nodes()[0].FastGetSolutionStepValue(DT_WATER_PRESSURE, 0), + expected_dt_water_pressure); +} + +KRATOS_TEST_CASE_IN_SUITE(BackwardEulerUPwSchemeUpdate_DoesNotUpdateFixedScalarVariable, + KratosGeoMechanicsFastSuiteWithoutKernel) +{ + BackwardEulerQuasiStaticUPwSchemeTester tester; + + ModelPart::DofsArrayType dof_set; + CompressedMatrix A; + Vector Dx; + Vector b; + + tester.mScheme.InitializeSolutionStep(tester.GetModelPart(), A, Dx, b); // This is needed to set the time factors + + tester.GetModelPart().Nodes()[0].Fix(DT_WATER_PRESSURE); + + tester.mScheme.Update(tester.GetModelPart(), dof_set, A, Dx, b); + + // should be the same as the original + const auto expected_dt_water_pressure = 0.0; + + const auto actual_dt_water_pressure = + tester.GetModelPart().Nodes()[0].FastGetSolutionStepValue(DT_WATER_PRESSURE, 0); + KRATOS_EXPECT_DOUBLE_EQ(actual_dt_water_pressure, expected_dt_water_pressure); +} + +} // namespace Kratos::Testing From acf0f2ed80a68839f21ff231983530a917d4bd72 Mon Sep 17 00:00:00 2001 From: Wijtze Pieter Kikstra Date: Mon, 20 Jan 2025 16:00:57 +0100 Subject: [PATCH 3/6] min_iterations 10 to scale up all steps as before --- .../ProjectParameters_stage2.json | 90 ++++--------------- 1 file changed, 15 insertions(+), 75 deletions(-) diff --git a/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/ProjectParameters_stage2.json b/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/ProjectParameters_stage2.json index f4ee8cdce6c5..6ea19bf11f53 100644 --- a/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/ProjectParameters_stage2.json +++ b/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/ProjectParameters_stage2.json @@ -35,13 +35,9 @@ "reset_displacements": true, "strategy_type": "line_search", "convergence_criterion": "displacement_criterion", - "water_pressure_relative_tolerance": 0.0001, - "water_pressure_absolute_tolerance": 1E-09, "displacement_relative_tolerance": 0.001, "displacement_absolute_tolerance": 1E-09, - "residual_relative_tolerance": 0.0001, - "residual_absolute_tolerance": 1E-09, - "min_iterations": 6, + "min_iterations": 10, "max_iterations": 50, "number_cycles": 100, "reduction_factor": 0.5, @@ -127,26 +123,10 @@ "Parameters": { "model_part_name": "PorousDomain.Displacement_Geometry", "variable_name": "DISPLACEMENT", - "active": [ - true, - false, - true - ], - "is_fixed": [ - true, - false, - true - ], - "value": [ - 0.0, - 0.0, - 0.0 - ], - "table": [ - 0, - 0, - 0 - ] + "active": [true, false, true], + "is_fixed": [true, false, true], + "value": [0.0, 0.0, 0.0], + "table": [0, 0, 0] } }, { @@ -156,26 +136,10 @@ "Parameters": { "model_part_name": "PorousDomain.Base_Displacement_Fixed", "variable_name": "DISPLACEMENT", - "active": [ - true, - true, - true - ], - "is_fixed": [ - true, - true, - true - ], - "value": [ - 0.0, - 0.0, - 0.0 - ], - "table": [ - 0, - 0, - 0 - ] + "active": [true, true, true], + "is_fixed": [true, true, true], + "value": [0.0, 0.0, 0.0], + "table": [0, 0, 0] } } ], @@ -187,21 +151,9 @@ "Parameters": { "model_part_name": "PorousDomain.Gravity_Loading-Initial_saturated", "variable_name": "VOLUME_ACCELERATION", - "active": [ - false, - true, - false - ], - "value": [ - 0.0, - -9.81, - 0.0 - ], - "table": [ - 0, - 0, - 0 - ] + "active": [false, true, false], + "value": [0.0, -9.81, 0.0], + "table": [0, 0, 0] } }, { @@ -211,21 +163,9 @@ "Parameters": { "model_part_name": "PorousDomain.Gravity_Loading-Overburden_1_unsaturated", "variable_name": "VOLUME_ACCELERATION", - "active": [ - false, - true, - false - ], - "value": [ - 0.0, - -9.81, - 0.0 - ], - "table": [ - 0, - 1, - 0 - ] + "active": [false, true, false], + "value": [0.0, -9.81, 0.0], + "table": [0, 1, 0] } }, { From a03e61f44bf70e25eed6b1e221e863c2e92f4201 Mon Sep 17 00:00:00 2001 From: Wijtze Pieter Kikstra Date: Mon, 20 Jan 2025 16:01:59 +0100 Subject: [PATCH 4/6] remove some not used parameters from project parameters and material parameters. --- .../test_backward_euler_UPw_scheme.cpp | 191 ------------------ .../MaterialParameters2.json | 14 +- .../ProjectParameters_stage1.json | 88 ++------ 3 files changed, 16 insertions(+), 277 deletions(-) delete mode 100644 applications/GeoMechanicsApplication/tests/cpp_tests/custom_strategies/test_backward_euler_UPw_scheme.cpp diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_strategies/test_backward_euler_UPw_scheme.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/custom_strategies/test_backward_euler_UPw_scheme.cpp deleted file mode 100644 index 5be0dc61e5eb..000000000000 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/custom_strategies/test_backward_euler_UPw_scheme.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// KRATOS___ -// // ) ) -// // ___ ___ -// // ____ //___) ) // ) ) -// // / / // // / / -// ((____/ / ((____ ((___/ / MECHANICS -// -// License: geo_mechanics_application/license.txt -// -// Main authors: Richard Faasse -// - -#include "containers/model.h" -#include "custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp" -#include "spaces/ublas_space.h" -#include "tests/cpp_tests/geo_mechanics_fast_suite.h" - -namespace Kratos::Testing -{ - -using namespace Kratos; -using SparseSpaceType = UblasSpace; -using LocalSpaceType = UblasSpace; - -class BackwardEulerUPwSchemeTester -{ -public: - Model mModel; - - BackwardEulerQuasistaticUPwScheme mScheme; - - BackwardEulerUPwSchemeTester() { CreateValidModelPart(); } - - void CreateValidModelPart() - { - auto& result = mModel.CreateModelPart("dummy", 2); - result.AddNodalSolutionStepVariable(VELOCITY); - result.AddNodalSolutionStepVariable(ACCELERATION); - result.AddNodalSolutionStepVariable(DT_WATER_PRESSURE); - result.AddNodalSolutionStepVariable(DISPLACEMENT); - result.AddNodalSolutionStepVariable(WATER_PRESSURE); - - auto p_node = result.CreateNewNode(0, 0.0, 0.0, 0.0); - p_node->AddDof(DISPLACEMENT_X); - p_node->AddDof(DISPLACEMENT_Y); - p_node->AddDof(DISPLACEMENT_Z); - p_node->AddDof(WATER_PRESSURE); - result.GetProcessInfo()[DELTA_TIME] = 4.0; - - p_node->FastGetSolutionStepValue(DISPLACEMENT, 1) = Kratos::array_1d{7.0, 8.0, 9.0}; - p_node->FastGetSolutionStepValue(VELOCITY, 1) = Kratos::array_1d{1.0, 2.0, 3.0}; - p_node->FastGetSolutionStepValue(ACCELERATION, 1) = Kratos::array_1d{4.0, 5.0, 6.0}; - - p_node->FastGetSolutionStepValue(WATER_PRESSURE, 1) = 1.0; - p_node->FastGetSolutionStepValue(WATER_PRESSURE, 0) = 2.0; - } - - ModelPart& GetModelPart() { return mModel.GetModelPart("dummy"); } -}; - -KRATOS_TEST_CASE_IN_SUITE(CheckBackwardEulerUPwScheme_ReturnsZeroForValidModelPart, KratosGeoMechanicsFastSuiteWithoutKernel) -{ - BackwardEulerUPwSchemeTester tester; - KRATOS_EXPECT_EQ(tester.mScheme.Check(tester.GetModelPart()), 0); -} - -KRATOS_TEST_CASE_IN_SUITE(InitializeBackwardEulerUPwScheme_SetsTimeFactors, KratosGeoMechanicsFastSuiteWithoutKernel) -{ - BackwardEulerUPwSchemeTester tester; - - tester.mScheme.Initialize(tester.GetModelPart()); - - // These are the expected numbers according to the SetTimeFactors function - constexpr double expected_dt_pressure_coefficient = 1.0 / 4.0; - constexpr double expected_velocity_coefficient = 1.0 / 4.0; - KRATOS_EXPECT_TRUE(tester.mScheme.SchemeIsInitialized()) - - CompressedMatrix A; - Vector Dx; - Vector b; - tester.mScheme.InitializeSolutionStep(tester.GetModelPart(), A, Dx, b); // This is needed to set the time factors - - KRATOS_EXPECT_DOUBLE_EQ(tester.GetModelPart().GetProcessInfo()[DT_PRESSURE_COEFFICIENT], - expected_dt_pressure_coefficient); - KRATOS_EXPECT_DOUBLE_EQ(tester.GetModelPart().GetProcessInfo()[VELOCITY_COEFFICIENT], - expected_velocity_coefficient); -} - -KRATOS_TEST_CASE_IN_SUITE(BackwardEulerUPwSchemePredict_UpdatesVariablesDerivatives, KratosGeoMechanicsFastSuiteWithoutKernel) -{ - BackwardEulerUPwSchemeTester tester; - - ModelPart::DofsArrayType dof_set; - CompressedMatrix A; - Vector Dx; - Vector b; - - tester.mScheme.InitializeSolutionStep(tester.GetModelPart(), A, Dx, b); // This is needed to set the time factors - - tester.mScheme.Predict(tester.GetModelPart(), dof_set, A, Dx, b); - - // These expected numbers result from the calculations in UpdateVariablesDerivatives - const auto expected_acceleration = Kratos::array_1d{-0.6875, -1.0, -1.3125}; - const auto expected_velocity = Kratos::array_1d{-1.75, -2.0, -2.25}; - constexpr auto expected_dt_water_pressure = 0.25; - - const auto actual_acceleration = - tester.GetModelPart().Nodes()[0].FastGetSolutionStepValue(ACCELERATION, 0); - const auto actual_velocity = tester.GetModelPart().Nodes()[0].FastGetSolutionStepValue(VELOCITY, 0); - - constexpr auto absolute_tolerance = 1.0e-6; - KRATOS_EXPECT_VECTOR_NEAR(expected_acceleration, actual_acceleration, absolute_tolerance) - KRATOS_EXPECT_VECTOR_NEAR(expected_velocity, actual_velocity, absolute_tolerance) - - KRATOS_EXPECT_DOUBLE_EQ(tester.GetModelPart().Nodes()[0].FastGetSolutionStepValue(DT_WATER_PRESSURE, 0), - expected_dt_water_pressure); -} - -KRATOS_TEST_CASE_IN_SUITE(BackwardEulerUPwSchemeUpdate_DoesNotUpdateFixedScalarVariable, - KratosGeoMechanicsFastSuiteWithoutKernel) -{ - BackwardEulerUPwSchemeTester tester; - - ModelPart::DofsArrayType dof_set; - CompressedMatrix A; - Vector Dx; - Vector b; - - tester.mScheme.InitializeSolutionStep(tester.GetModelPart(), A, Dx, b); // This is needed to set the time factors - - tester.GetModelPart().Nodes()[0].Fix(DT_WATER_PRESSURE); - - tester.mScheme.Update(tester.GetModelPart(), dof_set, A, Dx, b); - - // should be the same as the original - const auto expected_dt_water_pressure = 0.0; - - const auto actual_dt_water_pressure = - tester.GetModelPart().Nodes()[0].FastGetSolutionStepValue(DT_WATER_PRESSURE, 0); - KRATOS_EXPECT_DOUBLE_EQ(actual_dt_water_pressure, expected_dt_water_pressure); -} - -KRATOS_TEST_CASE_IN_SUITE(BackwardEulerUPwSchemeUpdate_DoesNotUpdateFixedSecondDerivativeVectorVariable, - KratosGeoMechanicsFastSuiteWithoutKernel) -{ - BackwardEulerUPwSchemeTester tester; - - ModelPart::DofsArrayType dof_set; - CompressedMatrix A; - Vector Dx; - Vector b; - - tester.mScheme.InitializeSolutionStep(tester.GetModelPart(), A, Dx, b); // This is needed to set the time factors - - tester.GetModelPart().Nodes()[0].Fix(ACCELERATION_X); - tester.GetModelPart().Nodes()[0].Fix(ACCELERATION_Z); - - tester.mScheme.Update(tester.GetModelPart(), dof_set, A, Dx, b); - - // first and last term should be the same as original, while the middle value is updated - const auto expected_acceleration = Kratos::array_1d{0.0, -1.0, 0.0}; - - const auto actual_acceleration = - tester.GetModelPart().Nodes()[0].FastGetSolutionStepValue(ACCELERATION, 0); - KRATOS_EXPECT_VECTOR_NEAR(actual_acceleration, expected_acceleration, 1e-6) -} - -KRATOS_TEST_CASE_IN_SUITE(BackwardEulerUPwSchemeUpdate_DoesNotUpdateFixedFirstDerivativeVectorVariable, - KratosGeoMechanicsFastSuiteWithoutKernel) -{ - BackwardEulerUPwSchemeTester tester; - - ModelPart::DofsArrayType dof_set; - CompressedMatrix A; - Vector Dx; - Vector b; - - tester.mScheme.InitializeSolutionStep(tester.GetModelPart(), A, Dx, b); // This is needed to set the time factors - - tester.GetModelPart().Nodes()[0].Fix(VELOCITY_Y); - - tester.mScheme.Update(tester.GetModelPart(), dof_set, A, Dx, b); - - // first and last term should be updated, while the middle value is fixed - const auto expected_velocity = Kratos::array_1d{-1.75, 0.0, -2.25}; - - const auto actual_velocity = tester.GetModelPart().Nodes()[0].FastGetSolutionStepValue(VELOCITY, 0); - KRATOS_EXPECT_VECTOR_NEAR(actual_velocity, expected_velocity, 1e-6) -} - -} // namespace Kratos::Testing diff --git a/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/MaterialParameters2.json b/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/MaterialParameters2.json index 75fee1e9fd97..7f6ac8c01820 100644 --- a/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/MaterialParameters2.json +++ b/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/MaterialParameters2.json @@ -30,12 +30,7 @@ 1.15 ], "RETENTION_LAW": "SaturatedLaw", - "RESIDUAL_SATURATION": 0.06203, - "SATURATED_SATURATION": 1.0, - "VAN_GENUCHTEN_AIR_ENTRY_PRESSURE": 2.561, - "VAN_GENUCHTEN_GN": 1.377, - "VAN_GENUCHTEN_GL": 1.25, - "MINIMUM_RELATIVE_PERMEABILITY": 0.0001 + "SATURATED_SATURATION": 1.0 } } }, @@ -62,12 +57,7 @@ "POISSON_RATIO": 0.3, "THICKNESS": 1.0, "RETENTION_LAW": "SaturatedLaw", - "RESIDUAL_SATURATION": 0.06203, - "SATURATED_SATURATION": 1.0, - "VAN_GENUCHTEN_AIR_ENTRY_PRESSURE": 2.561, - "VAN_GENUCHTEN_GN": 1.377, - "VAN_GENUCHTEN_GL": 1.25, - "MINIMUM_RELATIVE_PERMEABILITY": 0.0001 + "SATURATED_SATURATION": 1.0 } } } diff --git a/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/ProjectParameters_stage1.json b/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/ProjectParameters_stage1.json index 8ec3da776afb..1b4c64ffd672 100644 --- a/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/ProjectParameters_stage1.json +++ b/applications/GeoMechanicsApplication/tests/test_Abc_1_1_0_True_Deformations/ProjectParameters_stage1.json @@ -35,12 +35,8 @@ "reset_displacements": true, "strategy_type": "line_search", "convergence_criterion": "displacement_criterion", - "water_pressure_relative_tolerance": 0.0001, - "water_pressure_absolute_tolerance": 1E-09, "displacement_relative_tolerance": 0.001, "displacement_absolute_tolerance": 1E-09, - "residual_relative_tolerance": 0.0001, - "residual_absolute_tolerance": 1E-09, "min_iterations": 6, "max_iterations": 15, "number_cycles": 100, @@ -133,26 +129,10 @@ "Parameters": { "model_part_name": "PorousDomain.Displacement_Geometry", "variable_name": "DISPLACEMENT", - "active": [ - true, - false, - true - ], - "is_fixed": [ - true, - false, - true - ], - "value": [ - 0.0, - 0.0, - 0.0 - ], - "table": [ - 0, - 0, - 0 - ] + "active": [true, false, true], + "is_fixed": [true, false, true], + "value": [0.0, 0.0, 0.0], + "table": [0, 0, 0] } }, { @@ -162,26 +142,10 @@ "Parameters": { "model_part_name": "PorousDomain.Base_Displacement_Fixed", "variable_name": "DISPLACEMENT", - "active": [ - true, - true, - true - ], - "is_fixed": [ - true, - true, - true - ], - "value": [ - 0.0, - 0.0, - 0.0 - ], - "table": [ - 0, - 0, - 0 - ] + "active": [true, true, true], + "is_fixed": [true, true, true], + "value": [0.0, 0.0, 0.0], + "table": [0, 0, 0] } } ], @@ -193,21 +157,9 @@ "Parameters": { "model_part_name": "PorousDomain.Gravity_Loading-Initial_saturated", "variable_name": "VOLUME_ACCELERATION", - "active": [ - false, - true, - false - ], - "value": [ - 0.0, - -9.81, - 0.0 - ], - "table": [ - 0, - 0, - 0 - ] + "active": [false, true, false], + "value": [0.0, -9.81, 0.0], + "table": [0, 0, 0] } }, { @@ -217,21 +169,9 @@ "Parameters": { "model_part_name": "PorousDomain.Gravity_Loading-Overburden_1_unsaturated", "variable_name": "VOLUME_ACCELERATION", - "active": [ - false, - false, - false - ], - "value": [ - 0.0, - -9.81, - 0.0 - ], - "table": [ - 0, - 0, - 0 - ] + "active": [false, false, false], + "value": [0.0, -9.81, 0.0], + "table": [0, 0, 0] } }, { From e1b1b8d77c353a5153730a483337f605dadb431a Mon Sep 17 00:00:00 2001 From: Wijtze Pieter Kikstra Date: Mon, 20 Jan 2025 16:43:21 +0100 Subject: [PATCH 5/6] naming convention and (hopefully) Sonar Cloud codesmell indications in schemes. --- .../geomechanics_time_integration_scheme.hpp | 4 +- .../schemes/newmark_dynamic_U_Pw_scheme.hpp | 144 +++++++++--------- 2 files changed, 74 insertions(+), 74 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_strategies/schemes/geomechanics_time_integration_scheme.hpp b/applications/GeoMechanicsApplication/custom_strategies/schemes/geomechanics_time_integration_scheme.hpp index 3f309a9e083d..768a94cf3638 100644 --- a/applications/GeoMechanicsApplication/custom_strategies/schemes/geomechanics_time_integration_scheme.hpp +++ b/applications/GeoMechanicsApplication/custom_strategies/schemes/geomechanics_time_integration_scheme.hpp @@ -150,9 +150,9 @@ class GeoMechanicsTimeIntegrationScheme : public SchemeAddDynamicsToLHS(LHS_Contribution, mMassMatrix[thread], mDampingMatrix[thread], CurrentProcessInfo); + this->AddDynamicsToLHS(rLHS_Contribution, mMassMatrix[thread], mDampingMatrix[thread], rCurrentProcessInfo); - this->AddDynamicsToRHS(rCurrentCondition, RHS_Contribution, mMassMatrix[thread], - mDampingMatrix[thread], CurrentProcessInfo); + this->AddDynamicsToRHS(rCurrentCondition, rRHS_Contribution, mMassMatrix[thread], + mDampingMatrix[thread], rCurrentProcessInfo); - rCurrentCondition.EquationIdVector(EquationId, CurrentProcessInfo); + rCurrentCondition.EquationIdVector(rEquationIds, rCurrentProcessInfo); KRATOS_CATCH("") } void CalculateSystemContributions(Element& rCurrentElement, - LocalSystemMatrixType& LHS_Contribution, - LocalSystemVectorType& RHS_Contribution, - Element::EquationIdVectorType& EquationId, - const ProcessInfo& CurrentProcessInfo) override + LocalSystemMatrixType& rLHS_Contribution, + LocalSystemVectorType& rRHS_Contribution, + Element::EquationIdVectorType& rEquationIds, + const ProcessInfo& rCurrentProcessInfo) override { KRATOS_TRY int thread = OpenMPUtils::ThisThread(); - rCurrentElement.CalculateLocalSystem(LHS_Contribution, RHS_Contribution, CurrentProcessInfo); + rCurrentElement.CalculateLocalSystem(rLHS_Contribution, rRHS_Contribution, rCurrentProcessInfo); - rCurrentElement.CalculateMassMatrix(mMassMatrix[thread], CurrentProcessInfo); + rCurrentElement.CalculateMassMatrix(mMassMatrix[thread], rCurrentProcessInfo); - rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], CurrentProcessInfo); + rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], rCurrentProcessInfo); - this->AddDynamicsToLHS(LHS_Contribution, mMassMatrix[thread], mDampingMatrix[thread], CurrentProcessInfo); + this->AddDynamicsToLHS(rLHS_Contribution, mMassMatrix[thread], mDampingMatrix[thread], rCurrentProcessInfo); - this->AddDynamicsToRHS(rCurrentElement, RHS_Contribution, mMassMatrix[thread], - mDampingMatrix[thread], CurrentProcessInfo); + this->AddDynamicsToRHS(rCurrentElement, rRHS_Contribution, mMassMatrix[thread], + mDampingMatrix[thread], rCurrentProcessInfo); - rCurrentElement.EquationIdVector(EquationId, CurrentProcessInfo); + rCurrentElement.EquationIdVector(rEquationIds, rCurrentProcessInfo); KRATOS_CATCH("") } void CalculateRHSContribution(Element& rCurrentElement, - LocalSystemVectorType& RHS_Contribution, - Element::EquationIdVectorType& EquationId, - const ProcessInfo& CurrentProcessInfo) override + LocalSystemVectorType& rRHS_Contribution, + Element::EquationIdVectorType& rEquationIds, + const ProcessInfo& rCurrentProcessInfo) override { KRATOS_TRY int thread = OpenMPUtils::ThisThread(); - rCurrentElement.CalculateRightHandSide(RHS_Contribution, CurrentProcessInfo); + rCurrentElement.CalculateRightHandSide(rRHS_Contribution, rCurrentProcessInfo); - rCurrentElement.CalculateMassMatrix(mMassMatrix[thread], CurrentProcessInfo); + rCurrentElement.CalculateMassMatrix(mMassMatrix[thread], rCurrentProcessInfo); - rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], CurrentProcessInfo); + rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], rCurrentProcessInfo); - this->AddDynamicsToRHS(rCurrentElement, RHS_Contribution, mMassMatrix[thread], - mDampingMatrix[thread], CurrentProcessInfo); + this->AddDynamicsToRHS(rCurrentElement, rRHS_Contribution, mMassMatrix[thread], + mDampingMatrix[thread], rCurrentProcessInfo); - rCurrentElement.EquationIdVector(EquationId, CurrentProcessInfo); + rCurrentElement.EquationIdVector(rEquationIds, rCurrentProcessInfo); KRATOS_CATCH("") } @@ -219,114 +219,114 @@ class NewmarkDynamicUPwScheme : public GeneralizedNewmarkSchemeAddDynamicsToLHS(LHS_Contribution, mMassMatrix[thread], mDampingMatrix[thread], CurrentProcessInfo); + this->AddDynamicsToLHS(rLHS_Contribution, mMassMatrix[thread], mDampingMatrix[thread], rCurrentProcessInfo); - rCurrentCondition.EquationIdVector(EquationId, CurrentProcessInfo); + rCurrentCondition.EquationIdVector(rEquationIds, rCurrentProcessInfo); KRATOS_CATCH("") } void CalculateLHSContribution(Element& rCurrentElement, - LocalSystemMatrixType& LHS_Contribution, - Element::EquationIdVectorType& EquationId, - const ProcessInfo& CurrentProcessInfo) override + LocalSystemMatrixType& rLHS_Contribution, + Element::EquationIdVectorType& rEquationIds, + const ProcessInfo& rCurrentProcessInfo) override { KRATOS_TRY int thread = OpenMPUtils::ThisThread(); - rCurrentElement.CalculateLeftHandSide(LHS_Contribution, CurrentProcessInfo); + rCurrentElement.CalculateLeftHandSide(rLHS_Contribution, rCurrentProcessInfo); - rCurrentElement.CalculateMassMatrix(mMassMatrix[thread], CurrentProcessInfo); + rCurrentElement.CalculateMassMatrix(mMassMatrix[thread], rCurrentProcessInfo); - rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], CurrentProcessInfo); + rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], rCurrentProcessInfo); - this->AddDynamicsToLHS(LHS_Contribution, mMassMatrix[thread], mDampingMatrix[thread], CurrentProcessInfo); + this->AddDynamicsToLHS(rLHS_Contribution, mMassMatrix[thread], mDampingMatrix[thread], rCurrentProcessInfo); - rCurrentElement.EquationIdVector(EquationId, CurrentProcessInfo); + rCurrentElement.EquationIdVector(rEquationIds, rCurrentProcessInfo); KRATOS_CATCH("") } protected: - void AddDynamicsToLHS(LocalSystemMatrixType& LHS_Contribution, - LocalSystemMatrixType& M, - LocalSystemMatrixType& C, - const ProcessInfo& CurrentProcessInfo) + void AddDynamicsToLHS(LocalSystemMatrixType& rLHS_Contribution, + LocalSystemMatrixType& rM, + LocalSystemMatrixType& rC, + const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY // adding mass contribution - if (M.size1() != 0) - noalias(LHS_Contribution) += - (1.0 / (this->GetBeta() * this->GetDeltaTime() * this->GetDeltaTime())) * M; + if (rM.size1() != 0) + noalias(rLHS_Contribution) += + (1.0 / (this->GetBeta() * this->GetDeltaTime() * this->GetDeltaTime())) * rM; // adding damping contribution - if (C.size1() != 0) - noalias(LHS_Contribution) += (this->GetGamma() / (this->GetBeta() * this->GetDeltaTime())) * C; + if (rC.size1() != 0) + noalias(rLHS_Contribution) += (this->GetGamma() / (this->GetBeta() * this->GetDeltaTime())) * rC; KRATOS_CATCH("") } void AddDynamicsToRHS(Condition& rCurrentCondition, - LocalSystemVectorType& RHS_Contribution, - LocalSystemMatrixType& M, - LocalSystemMatrixType& C, - const ProcessInfo& CurrentProcessInfo) + LocalSystemVectorType& rRHS_Contribution, + LocalSystemMatrixType& rM, + LocalSystemMatrixType& rC, + const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY int thread = OpenMPUtils::ThisThread(); // adding inertia contribution - if (M.size1() != 0) { + if (rM.size1() != 0) { rCurrentCondition.GetSecondDerivativesVector(mAccelerationVector[thread], 0); - noalias(RHS_Contribution) -= prod(M, mAccelerationVector[thread]); + noalias(rRHS_Contribution) -= prod(rM, mAccelerationVector[thread]); } // adding damping contribution - if (C.size1() != 0) { + if (rC.size1() != 0) { rCurrentCondition.GetFirstDerivativesVector(mVelocityVector[thread], 0); - noalias(RHS_Contribution) -= prod(C, mVelocityVector[thread]); + noalias(rRHS_Contribution) -= prod(rC, mVelocityVector[thread]); } KRATOS_CATCH("") } void AddDynamicsToRHS(Element& rCurrentElement, - LocalSystemVectorType& RHS_Contribution, - LocalSystemMatrixType& M, - LocalSystemMatrixType& C, - const ProcessInfo& CurrentProcessInfo) + LocalSystemVectorType& rRHS_Contribution, + LocalSystemMatrixType& rM, + LocalSystemMatrixType& rC, + const ProcessInfo& rCurrentProcessInfo) { KRATOS_TRY int thread = OpenMPUtils::ThisThread(); // adding inertia contribution - if (M.size1() != 0) { + if (rM.size1() != 0) { rCurrentElement.GetSecondDerivativesVector(mAccelerationVector[thread], 0); - noalias(RHS_Contribution) -= prod(M, mAccelerationVector[thread]); + noalias(rRHS_Contribution) -= prod(rM, mAccelerationVector[thread]); } // adding damping contribution - if (C.size1() != 0) { + if (rC.size1() != 0) { rCurrentElement.GetFirstDerivativesVector(mVelocityVector[thread], 0); - noalias(RHS_Contribution) -= prod(C, mVelocityVector[thread]); + noalias(rRHS_Contribution) -= prod(rC, mVelocityVector[thread]); } KRATOS_CATCH("") From 8b17922d6e4370ab196b9302cbc16e82d4e5558c Mon Sep 17 00:00:00 2001 From: Wijtze Pieter Kikstra Date: Mon, 20 Jan 2025 17:26:56 +0100 Subject: [PATCH 6/6] tell the derivation by this-> --- .../schemes/backward_euler_quasistatic_U_Pw_scheme.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/applications/GeoMechanicsApplication/custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp b/applications/GeoMechanicsApplication/custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp index a02fc3bd82c1..394af0af1bb5 100644 --- a/applications/GeoMechanicsApplication/custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp +++ b/applications/GeoMechanicsApplication/custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp @@ -16,7 +16,6 @@ #include "backward_euler_scheme.hpp" #include "includes/define.h" #include "includes/model_part.h" -#include "solving_strategies/schemes/scheme.h" #include "utilities/parallel_utilities.h" // Application includes @@ -49,7 +48,7 @@ class BackwardEulerQuasistaticUPwScheme : public BackwardEulerSchemeCalculateDerivative(r_first_order_scalar_variable.instance, rNode); } });