From b468212e17367c0f4fd50c45f08a1ec7348f3580 Mon Sep 17 00:00:00 2001 From: Richard Faasse <56549273+rfaasse@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:16:56 +0200 Subject: [PATCH] [GeoMechanicsApplication] Move more unit tests to the suite without kernel (#12661) --- .../test_Pw_normal_flux_condition.cpp | 25 +- .../test_T_micro_climate_flux_condition.cpp | 91 +++- .../test_axisymmetric_stress_state.cpp | 26 +- ...ulate_incremental_displacement_process.cpp | 2 +- .../tests/cpp_tests/test_dof_utilities.cpp | 48 +- .../cpp_tests/test_equation_of_motion.cpp | 16 +- .../test_plane_strain_stress_state.cpp | 24 +- .../test_solving_strategy_factory.cpp | 2 +- .../test_steady_state_Pw_piping_element.cpp | 34 +- .../test_t_normal_flux_condition.cpp | 194 ++++---- .../test_three_dimensional_stress_state.cpp | 26 +- .../test_transient_thermal_element.cpp | 444 +++++++++--------- .../test_utilities/model_setup_utilities.cpp | 104 ++-- .../test_utilities/model_setup_utilities.h | 5 + .../cpp_tests/test_variables_utilities.cpp | 4 +- 15 files changed, 577 insertions(+), 468 deletions(-) diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_Pw_normal_flux_condition.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_Pw_normal_flux_condition.cpp index 72eabe37d1f6..7b6c52459874 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_Pw_normal_flux_condition.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_Pw_normal_flux_condition.cpp @@ -15,11 +15,12 @@ // Project includes #include "containers/model.h" #include "custom_conditions/Pw_normal_flux_condition.hpp" +#include "custom_constitutive/linear_elastic_2D_interface_law.h" #include "geo_mechanics_fast_suite.h" namespace Kratos::Testing { - KRATOS_TEST_CASE_IN_SUITE(CalculateHorizontalNormalFlux, KratosGeoMechanicsFastSuite) + KRATOS_TEST_CASE_IN_SUITE(CalculateHorizontalNormalFlux, KratosGeoMechanicsFastSuiteWithoutKernel) { // initialize modelpart @@ -33,8 +34,7 @@ namespace Kratos::Testing auto cond_prop = r_model_part.CreateNewProperties(0); // set constitutive law - const auto &r_clone_cl = KratosComponents::Get("LinearElastic2DInterfaceLaw"); - cond_prop->SetValue(CONSTITUTIVE_LAW, r_clone_cl.Clone()); + cond_prop->SetValue(CONSTITUTIVE_LAW, LinearElastic2DInterfaceLaw().Clone()); // Create the test piping element nodes auto node_1 = r_model_part.CreateNewNode(1, 0.0, 0.0, 0.0); @@ -54,8 +54,11 @@ namespace Kratos::Testing // Create the test piping element std::vector cond_nodes{1, 2}; - auto cond = r_model_part.CreateNewCondition("PwNormalFluxCondition2D2N", 1, cond_nodes, cond_prop); - // Initialize the element to initialize the constitutive law + Condition::Pointer cond = Kratos::make_intrusive>( + 1, make_shared>(node_1, node_2), cond_prop); + r_model_part.AddCondition(cond); + + // Initialize the condition to initialize the constitutive law const auto &r_process_info = r_model_part.GetProcessInfo(); cond->Initialize(r_process_info); @@ -82,7 +85,7 @@ namespace Kratos::Testing } } - KRATOS_TEST_CASE_IN_SUITE(CalculateInclinedNormalFlux, KratosGeoMechanicsFastSuite) + KRATOS_TEST_CASE_IN_SUITE(CalculateInclinedNormalFlux, KratosGeoMechanicsFastSuiteWithoutKernel) { // initialize modelpart @@ -96,8 +99,7 @@ namespace Kratos::Testing auto cond_prop = r_model_part.CreateNewProperties(0); // set constitutive law - const auto &r_clone_cl = KratosComponents::Get("LinearElastic2DInterfaceLaw"); - cond_prop->SetValue(CONSTITUTIVE_LAW, r_clone_cl.Clone()); + cond_prop->SetValue(CONSTITUTIVE_LAW, LinearElastic2DInterfaceLaw().Clone()); // Create the test piping element nodes auto node_1 = r_model_part.CreateNewNode(1, 0.0, 0.0, 0.0); @@ -117,8 +119,9 @@ namespace Kratos::Testing // Create the test piping element std::vector cond_nodes{1, 2}; - auto cond = r_model_part.CreateNewCondition("PwNormalFluxCondition2D2N", 1, cond_nodes, cond_prop); - // Initialize the element to initialize the constitutive law + Condition::Pointer cond = Kratos::make_intrusive>( + 1, make_shared>(node_1, node_2), cond_prop); + r_model_part.AddCondition(cond); // Initialize the element to initialize the constitutive law const auto &r_process_info = r_model_part.GetProcessInfo(); cond->Initialize(r_process_info); @@ -144,4 +147,4 @@ namespace Kratos::Testing 1.0e-6); } } -} \ No newline at end of file +} diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_T_micro_climate_flux_condition.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_T_micro_climate_flux_condition.cpp index 0566b084b851..9745c274042e 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_T_micro_climate_flux_condition.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_T_micro_climate_flux_condition.cpp @@ -13,6 +13,8 @@ #include "containers/model.h" #include "custom_conditions/T_microclimate_flux_condition.h" #include "geo_mechanics_fast_suite.h" +#include "geometries/line_2d_4.h" +#include "geometries/line_2d_5.h" #include @@ -129,19 +131,53 @@ ModelPart& CreateDummyModelPartWithNodes(Model& rModel, return r_result; } -intrusive_ptr CreateMicroClimateCondition(ModelPart& rModelPart, +intrusive_ptr CreateMicroClimateCondition(ModelPart& rModelPart, shared_ptr pProperties, - std::size_t DimensionSize) + std::size_t DimensionSize) { - constexpr auto condition_id = std::size_t{1}; - auto node_ids = std::vector{}; - for (const auto& node : rModelPart.Nodes()) { - node_ids.emplace_back(node.Id()); + auto r_nodes = rModelPart.Nodes(); + auto node_ids = std::vector{}; + std::transform(r_nodes.begin(), r_nodes.end(), std::back_inserter(node_ids), + [](const auto& node) { return node.Id(); }); + + PointerVector node_pointers(node_ids.size()); + std::transform(node_ids.begin(), node_ids.end(), node_pointers.ptr_begin(), + [&rModelPart](auto node_id) { return rModelPart.pGetNode(node_id); }); + + Condition::Pointer condition = nullptr; + if (DimensionSize == 2 && node_ids.size() == 2) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); + } else if (DimensionSize == 2 && node_ids.size() == 3) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); + } else if (DimensionSize == 2 && node_ids.size() == 4) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); + } else if (DimensionSize == 2 && node_ids.size() == 5) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); + } else if (DimensionSize == 3 && node_ids.size() == 3) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); + } else if (DimensionSize == 3 && node_ids.size() == 6) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); + } else if (DimensionSize == 3 && node_ids.size() == 4) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); + } else if (DimensionSize == 3 && node_ids.size() == 8) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); + } else if (DimensionSize == 3 && node_ids.size() == 9) { + condition = make_intrusive>( + 1, Kratos::make_shared>(node_pointers), pProperties); } - const auto condition_name = std::string{"GeoTMicroClimateFluxCondition"} - + std::to_string(DimensionSize) + "D" - + std::to_string(node_ids.size()) + "N"; - return rModelPart.CreateNewCondition(condition_name, condition_id, node_ids, pProperties); + + KRATOS_ERROR_IF_NOT(condition) << "Condition could not be created" << std::endl; + + rModelPart.AddCondition(condition); + return condition; } std::string ExecuteInitializeSolutionStep(intrusive_ptr pCondition, @@ -165,7 +201,7 @@ constexpr auto absolute_tolerance = 1.0e-3; namespace Kratos::Testing { -KRATOS_TEST_CASE_IN_SUITE(NoThrowWhenInitializingThermalMicroClimateCondition, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoThrowWhenInitializingThermalMicroClimateCondition, KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart) @@ -192,7 +228,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoThrowWhenInitializingThermalMicroClimateCondition, K KRATOS_EXPECT_FALSE(has_thrown) } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition2D2N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition2D2N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -209,7 +246,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition2D3N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition2D3N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -226,7 +264,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition2D4N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition2D4N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -243,7 +282,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition2D5N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition2D5N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -260,7 +300,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D3N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D3N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -277,7 +318,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D6N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D6N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -294,7 +336,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D4N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D4N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -310,7 +353,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D8N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D8N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -326,7 +370,8 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D9N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClimateCondition3D9N, + KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -342,7 +387,7 @@ KRATOS_TEST_CASE_IN_SUITE(NoErrorWhenInitializingSolutionStepOnThermalMicroClima KRATOS_EXPECT_STREQ(error_text.data(), "") } -KRATOS_TEST_CASE_IN_SUITE(CalculateLocalSystemForThermalMicroClimateCondition2D3N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateLocalSystemForThermalMicroClimateCondition2D3N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -371,7 +416,7 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateLocalSystemForThermalMicroClimateCondition2D3 KRATOS_EXPECT_VECTOR_RELATIVE_NEAR(expected_rhs_vector, rhs_vector, relative_tolerance) } -KRATOS_TEST_CASE_IN_SUITE(CalculateLocalSystemForThermalMicroClimateCondition3D6N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateLocalSystemForThermalMicroClimateCondition3D6N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ @@ -404,7 +449,7 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateLocalSystemForThermalMicroClimateCondition3D6 KRATOS_EXPECT_VECTOR_NEAR(expected_rhs_vector, rhs_vector, absolute_tolerance) } -KRATOS_TEST_CASE_IN_SUITE(CalculateLocalSystemForThermalMicroClimateCondition3D8N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateLocalSystemForThermalMicroClimateCondition3D8N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model test_model; auto create_nodes_func = [](ModelPart& rModelPart){ diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_axisymmetric_stress_state.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_axisymmetric_stress_state.cpp index 9434c8df3679..b005f9e2484a 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_axisymmetric_stress_state.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_axisymmetric_stress_state.cpp @@ -25,14 +25,11 @@ using namespace Kratos; namespace Kratos::Testing { -KRATOS_TEST_CASE_IN_SUITE(CalculateBMatrixWithValidGeometryReturnsCorrectResults, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateBMatrixWithValidGeometryReturnsCorrectResults, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); - Model model; - auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle2D3NElement(model); - Vector Np(3); Np <<= 1.0, 2.0, 3.0; @@ -43,8 +40,8 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateBMatrixWithValidGeometryReturnsCorrectResults 5.0, 6.0; // clang-format on - const Matrix calculated_matrix = - p_stress_state_policy->CalculateBMatrix(GradNpT, Np, r_model_part.GetElement(1).GetGeometry()); + const Matrix calculated_matrix = p_stress_state_policy->CalculateBMatrix( + GradNpT, Np, ModelSetupUtilities::Create2D3NTriangleGeometry()); // clang-format off Matrix expected_matrix(4, 6); @@ -57,27 +54,24 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateBMatrixWithValidGeometryReturnsCorrectResults KRATOS_CHECK_MATRIX_NEAR(calculated_matrix, expected_matrix, 1e-12) } -KRATOS_TEST_CASE_IN_SUITE(ReturnCorrectIntegrationCoefficient, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(ReturnCorrectIntegrationCoefficient, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); - Model model; - auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle2D3NElement(model); - // The shape function values for this integration point are 0.2, 0.5 and 0.3 for nodes 1, 2 and 3 respectively Geometry::IntegrationPointType integration_point(0.5, 0.3, 0.0, 0.5); const double detJ = 2.0; const double calculated_coefficient = p_stress_state_policy->CalculateIntegrationCoefficient( - integration_point, detJ, r_model_part.GetElement(1).GetGeometry()); + integration_point, detJ, ModelSetupUtilities::Create2D3NTriangleGeometry()); // The expected number is calculated as follows: // 2.0 * pi * 0.8 (radius) * 2.0 (detJ) * 0.5 (weight) = 5.02655 KRATOS_EXPECT_NEAR(calculated_coefficient, 5.02655, 1e-5); } -KRATOS_TEST_CASE_IN_SUITE(TestCloneReturnsCorrectType, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(TestCloneReturnsCorrectType, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); @@ -86,7 +80,7 @@ KRATOS_TEST_CASE_IN_SUITE(TestCloneReturnsCorrectType, KratosGeoMechanicsFastSui KRATOS_EXPECT_NE(dynamic_cast(p_cloned_stress_state_policy.get()), nullptr); } -KRATOS_TEST_CASE_IN_SUITE(TestCalculateGreenLagrangeStrainThrows, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(TestCalculateGreenLagrangeStrainThrows, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); @@ -100,7 +94,7 @@ KRATOS_TEST_CASE_IN_SUITE(TestCalculateGreenLagrangeStrainThrows, KratosGeoMecha "not implemented for axisymmetric configurations.") } -KRATOS_TEST_CASE_IN_SUITE(AxisymmetricStressState_GivesCorrectVoigtVector, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(AxisymmetricStressState_GivesCorrectVoigtVector, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); @@ -111,14 +105,14 @@ KRATOS_TEST_CASE_IN_SUITE(AxisymmetricStressState_GivesCorrectVoigtVector, Krato KRATOS_EXPECT_VECTOR_NEAR(voigt_vector, expected_voigt_vector, 1.E-10) } -KRATOS_TEST_CASE_IN_SUITE(AxisymmetricStressState_GivesCorrectVoigtSize, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(AxisymmetricStressState_GivesCorrectVoigtSize, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); KRATOS_EXPECT_EQ(p_stress_state_policy->GetVoigtSize(), VOIGT_SIZE_2D_PLANE_STRAIN); } -KRATOS_TEST_CASE_IN_SUITE(AxisymmetricStressState_GivesCorrectStressTensorSize, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(AxisymmetricStressState_GivesCorrectStressTensorSize, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_calculate_incremental_displacement_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_calculate_incremental_displacement_process.cpp index 42383f77ab27..b32c457f367c 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_calculate_incremental_displacement_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_calculate_incremental_displacement_process.cpp @@ -19,7 +19,7 @@ namespace Kratos::Testing using namespace Kratos; -KRATOS_TEST_CASE_IN_SUITE(CalculateIncrementalDisplacementProcess, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateIncrementalDisplacementProcess, KratosGeoMechanicsFastSuiteWithoutKernel) { // set up model part Model model; diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_dof_utilities.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_dof_utilities.cpp index 343b2d59642d..b40e621ed223 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_dof_utilities.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_dof_utilities.cpp @@ -15,6 +15,8 @@ #include #include "containers/model.h" +#include "custom_elements/U_Pw_small_strain_element.hpp" +#include "custom_elements/plane_strain_stress_state.h" #include "custom_utilities/dof_utilities.h" #include "geo_aliases.h" #include "geo_mechanics_application_variables.h" @@ -148,37 +150,42 @@ KRATOS_TEST_CASE_IN_SUITE(ExtractingDofsFromEmptyNodeCollectionYieldsEmptyVector KRATOS_EXPECT_TRUE(Geo::DofUtilities::ExtractDofsFromNodes(empty_geometry, WATER_PRESSURE).empty()) } -KRATOS_TEST_CASE_IN_SUITE(ExpectThrowWhenExtractingNonExistingDofsFromNodes, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(ExpectThrowWhenExtractingNonExistingDofsFromNodes, KratosGeoMechanicsFastSuiteWithoutKernel) { auto model = Model{}; auto& r_model_part = model.CreateModelPart("Dummy"); - r_model_part.CreateNewNode(1, 0.0, 0.0, 0.0); - r_model_part.CreateNewNode(2, 1.0, 0.0, 0.0); - r_model_part.CreateNewNode(3, 0.0, 1.0, 0.0); + PointerVector nodes; + nodes.push_back(r_model_part.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(r_model_part.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(r_model_part.CreateNewNode(3, 0.0, 1.0, 0.0)); - const auto node_ids = std::vector{1, 2, 3}; - const auto p_element = r_model_part.CreateNewElement("UPwSmallStrainElement2D3N", 1, node_ids, - r_model_part.CreateNewProperties(0)); + auto p_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), r_model_part.CreateNewProperties(0), + std::make_unique()); + r_model_part.AddElement(p_element); KRATOS_EXPECT_EXCEPTION_IS_THROWN( Geo::DofUtilities::ExtractDofsFromNodes(p_element->GetGeometry(), DISPLACEMENT_X), "Non-existent DOF in node #1 for variable : DISPLACEMENT_X") } -KRATOS_TEST_CASE_IN_SUITE(VariableTypeAndNodeIDsMustMatchWhenExtractingDofsFromNodes, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(VariableTypeAndNodeIDsMustMatchWhenExtractingDofsFromNodes, KratosGeoMechanicsFastSuiteWithoutKernel) { auto model = Model{}; auto& r_model_part = model.CreateModelPart("Dummy"); r_model_part.AddNodalSolutionStepVariable(DISPLACEMENT_X); - AddNodeWithDof(r_model_part, 1, 0.0, 0.0, 0.0, DISPLACEMENT_X); - AddNodeWithDof(r_model_part, 2, 1.0, 0.0, 0.0, DISPLACEMENT_X); - AddNodeWithDof(r_model_part, 3, 0.0, 1.0, 0.0, DISPLACEMENT_X); + PointerVector nodes; + nodes.push_back(AddNodeWithDof(r_model_part, 1, 0.0, 0.0, 0.0, DISPLACEMENT_X)); + nodes.push_back(AddNodeWithDof(r_model_part, 2, 1.0, 0.0, 0.0, DISPLACEMENT_X)); + nodes.push_back(AddNodeWithDof(r_model_part, 3, 0.0, 1.0, 0.0, DISPLACEMENT_X)); const auto node_ids = std::vector{1, 2, 3}; - const auto p_element = r_model_part.CreateNewElement("UPwSmallStrainElement2D3N", 1, node_ids, - r_model_part.CreateNewProperties(0)); + auto p_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), r_model_part.CreateNewProperties(0), + std::make_unique()); + r_model_part.AddElement(p_element); const auto dofs = Geo::DofUtilities::ExtractDofsFromNodes(p_element->GetGeometry(), DISPLACEMENT_X); @@ -193,7 +200,8 @@ KRATOS_TEST_CASE_IN_SUITE(VariableTypeAndNodeIDsMustMatchWhenExtractingDofsFromN KRATOS_EXPECT_EQ(dofs[2]->GetId(), 3); } -KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromNondiffOrder2DElement, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromNondiffOrder2DElement, + KratosGeoMechanicsFastSuiteWithoutKernel) { auto model = Model{}; const auto nodal_variables = Geo::ConstVariableRefs{ @@ -214,7 +222,8 @@ KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromNondiffOrde ExpectDofsHaveThisNodeId({dofs[4], dofs[5], dofs[8]}, 3); } -KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromNondiffOrder3DElement, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromNondiffOrder3DElement, + KratosGeoMechanicsFastSuiteWithoutKernel) { auto model = Model{}; const auto nodal_variables = @@ -238,7 +247,8 @@ KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromNondiffOrde ExpectDofsHaveThisNodeId({dofs[9], dofs[10], dofs[11], dofs[15]}, 4); } -KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromDiffOrder2DElement, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromDiffOrder2DElement, + KratosGeoMechanicsFastSuiteWithoutKernel) { auto model = Model{}; auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle2D6NUPwDiffOrderElement(model); @@ -262,7 +272,8 @@ KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromDiffOrder2D ExpectDofsHaveThisNodeId({dofs[10], dofs[11]}, 6); } -KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromDiffOrder3DElement, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(UDofsPrecedePwDofsWhenExtractingUPwDofsFromDiffOrder3DElement, + KratosGeoMechanicsFastSuiteWithoutKernel) { auto model = Model{}; auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle3D10NUPwDiffOrderElement(model); @@ -327,7 +338,8 @@ KRATOS_TEST_CASE_IN_SUITE(ExtractingValuesFromDofsYieldsNodalValues, KratosGeoMe expected_values, abs_tolerance) } -KRATOS_TEST_CASE_IN_SUITE(ExtractingFirstDerivativeValuesFromDofsYieldsNodalFirstDerivativeValues, KratosGeoMechanicsFastSuiteWithoutKernel) +KRATOS_TEST_CASE_IN_SUITE(ExtractingFirstDerivativeValuesFromDofsYieldsNodalFirstDerivativeValues, + KratosGeoMechanicsFastSuiteWithoutKernel) { const auto& r_variable = DISPLACEMENT_X; const auto& r_first_time_derivative = VELOCITY_X; diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_equation_of_motion.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_equation_of_motion.cpp index 816ae4c9be4a..30d8d07adb07 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_equation_of_motion.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_equation_of_motion.cpp @@ -10,6 +10,7 @@ // Main authors: Gennady Markelov // +#include "custom_constitutive/linear_elastic_2D_interface_law.h" #include "custom_utilities/equation_of_motion_utilities.h" #include "geo_mechanics_application_variables.h" #include "geo_mechanics_fast_suite.h" @@ -23,7 +24,7 @@ using namespace Kratos; namespace Kratos::Testing { -KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix2D6NDiffOrderGivesCorrectResults, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix2D6NDiffOrderGivesCorrectResults, KratosGeoMechanicsFastSuiteWithoutKernel) { Model model; auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle2D6NDiffOrderElement(model); @@ -35,8 +36,7 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix2D6NDiffOrderGivesCorrectResults, K p_elem_prop->SetValue(POROSITY, 0.0); p_elem_prop->SetValue(DENSITY_SOLID, 1700.0); // set arbitrary constitutive law - const auto& r_clone_cl = KratosComponents::Get("LinearElastic2DInterfaceLaw"); - p_elem_prop->SetValue(CONSTITUTIVE_LAW, r_clone_cl.Clone()); + p_elem_prop->SetValue(CONSTITUTIVE_LAW, LinearElastic2DInterfaceLaw().Clone()); ProcessInfo process_info; @@ -69,7 +69,7 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix2D6NDiffOrderGivesCorrectResults, K KRATOS_CHECK_MATRIX_NEAR(mass_matrix, expected_mass_matrix, 1e-4) } -KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix3D4NGivesCorrectResults, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix3D4NGivesCorrectResults, KratosGeoMechanicsFastSuiteWithoutKernel) { Model model; const auto nodal_variables = @@ -80,8 +80,8 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix3D4NGivesCorrectResults, KratosGeoM // Set the element properties auto p_elem_prop = r_model_part.pGetProperties(0); // set arbitrary constitutive law - const auto& r_clone_cl = KratosComponents::Get("LinearElastic2DInterfaceLaw"); - p_elem_prop->SetValue(CONSTITUTIVE_LAW, r_clone_cl.Clone()); + + p_elem_prop->SetValue(CONSTITUTIVE_LAW, LinearElastic2DInterfaceLaw().Clone()); // Please note these are not representative values, it just ensures the values are set p_elem_prop->SetValue(DENSITY_WATER, 1000.0); p_elem_prop->SetValue(POROSITY, 0.3); @@ -121,7 +121,7 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateMassMatrix3D4NGivesCorrectResults, KratosGeoM KRATOS_CHECK_MATRIX_NEAR(mass_matrix, expected_mass_matrix, 1e-4) } -KRATOS_TEST_CASE_IN_SUITE(CalculateDampingMatrixGivesCorrectResults, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateDampingMatrixGivesCorrectResults, KratosGeoMechanicsFastSuiteWithoutKernel) { constexpr std::size_t n = 10; @@ -160,7 +160,7 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateDampingMatrixGivesCorrectResults, KratosGeoMe KRATOS_CHECK_MATRIX_NEAR(damping_matrix, expected_damping_matrix, 1e-4) } -KRATOS_TEST_CASE_IN_SUITE(CalculateStiffnessMatrixGivesCorrectResults, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateStiffnessMatrixGivesCorrectResults, KratosGeoMechanicsFastSuiteWithoutKernel) { constexpr std::size_t voigt_size = 4; constexpr std::size_t n = 3; diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_plane_strain_stress_state.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_plane_strain_stress_state.cpp index 42b90bc3ed25..256b6b7356c9 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_plane_strain_stress_state.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_plane_strain_stress_state.cpp @@ -22,13 +22,10 @@ using namespace Kratos; namespace Kratos::Testing { -KRATOS_TEST_CASE_IN_SUITE(CalculateBMatrixGivesCorrectResults, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CalculateBMatrixGivesCorrectResults, KratosGeoMechanicsFastSuiteWithoutKernel) { auto p_stress_state_policy = std::make_unique(); - Model model; - auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle2D3NElement(model); - Vector Np(3); Np <<= 1.0, 2.0, 3.0; @@ -40,7 +37,7 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateBMatrixGivesCorrectResults, KratosGeoMechanic // clang-format on const auto calculated_matrix = - p_stress_state_policy->CalculateBMatrix(GradNpT, Np, r_model_part.GetElement(1).GetGeometry()); + p_stress_state_policy->CalculateBMatrix(GradNpT, Np, ModelSetupUtilities::Create2D3NTriangleGeometry()); // clang-format off Matrix expected_matrix(4, 6); @@ -53,26 +50,23 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateBMatrixGivesCorrectResults, KratosGeoMechanic KRATOS_CHECK_MATRIX_NEAR(calculated_matrix, expected_matrix, 1e-12) } -KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_ReturnsCorrectIntegrationCoefficient, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_ReturnsCorrectIntegrationCoefficient, KratosGeoMechanicsFastSuiteWithoutKernel) { const auto p_stress_state_policy = std::make_unique(); - Model model; - auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle2D3NElement(model); - // The shape function values for this integration point are 0.2, 0.5 and 0.3 for nodes 1, 2 and 3 respectively Geometry::IntegrationPointType integration_point(0.5, 0.3, 0.0, 0.5); const auto detJ = 2.0; const auto calculated_coefficient = p_stress_state_policy->CalculateIntegrationCoefficient( - integration_point, detJ, r_model_part.GetElement(1).GetGeometry()); + integration_point, detJ, ModelSetupUtilities::Create2D3NTriangleGeometry()); // The expected number is calculated as follows: // 2.0 (detJ) * 0.5 (weight) = 1.0 KRATOS_EXPECT_NEAR(calculated_coefficient, 1.0, 1e-5); } -KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_ReturnsCorrectGreenLagrangeStrain, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_ReturnsCorrectGreenLagrangeStrain, KratosGeoMechanicsFastSuiteWithoutKernel) { const auto p_stress_state_policy = std::make_unique(); @@ -92,7 +86,7 @@ KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_ReturnsCorrectGreenLagrangeStra KRATOS_CHECK_VECTOR_NEAR(calculated_strain, expected_vector, 1e-12) } -KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectClone, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectClone, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); @@ -101,7 +95,7 @@ KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectClone, KratosGeoMec KRATOS_EXPECT_NE(dynamic_cast(p_clone.get()), nullptr); } -KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectVoigtVector, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectVoigtVector, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); @@ -112,14 +106,14 @@ KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectVoigtVector, Kratos KRATOS_EXPECT_VECTOR_NEAR(voigt_vector, expected_voigt_vector, 1.E-10) } -KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectVoigtSize, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectVoigtSize, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); KRATOS_EXPECT_EQ(p_stress_state_policy->GetVoigtSize(), VOIGT_SIZE_2D_PLANE_STRAIN); } -KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectStressTensorSize, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(PlaneStrainStressState_GivesCorrectStressTensorSize, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_solving_strategy_factory.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_solving_strategy_factory.cpp index cc72bef9be36..f961c3bee0bb 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_solving_strategy_factory.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_solving_strategy_factory.cpp @@ -91,7 +91,7 @@ const std::string testParameters = R"( )"; -KRATOS_TEST_CASE_IN_SUITE(CreateSolvingStrategy_Throws_WhenNoStrategyTypeIsDefined, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CreateSolvingStrategy_Throws_WhenNoStrategyTypeIsDefined, KratosGeoMechanicsFastSuiteWithoutKernel) { Model model; auto& dummy_model_part = model.CreateModelPart("dummy"); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_steady_state_Pw_piping_element.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_steady_state_Pw_piping_element.cpp index 9f4b9eb3a912..f39eb3527919 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_steady_state_Pw_piping_element.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_steady_state_Pw_piping_element.cpp @@ -14,12 +14,14 @@ // Project includes #include "containers/model.h" +#include "custom_constitutive/linear_elastic_2D_interface_law.h" +#include "custom_elements/plane_strain_stress_state.h" #include "custom_elements/steady_state_Pw_piping_element.hpp" #include "geo_mechanics_fast_suite.h" namespace Kratos::Testing { - KRATOS_TEST_CASE_IN_SUITE(CalculateEquilibriumPipeHeight, KratosGeoMechanicsFastSuite) + KRATOS_TEST_CASE_IN_SUITE(CalculateEquilibriumPipeHeight, KratosGeoMechanicsFastSuiteWithoutKernel) { // initialize modelpart @@ -42,8 +44,7 @@ namespace Kratos::Testing p_elem_prop->SetValue(PIPE_MODEL_FACTOR, 1); // set constitutive law - const auto &r_clone_cl = KratosComponents::Get("LinearElastic2DInterfaceLaw"); - p_elem_prop->SetValue(CONSTITUTIVE_LAW, r_clone_cl.Clone()); + p_elem_prop->SetValue(CONSTITUTIVE_LAW, LinearElastic2DInterfaceLaw().Clone()); // Create the test piping element nodes auto p_node_1 = r_model_part.CreateNewNode(1, 0.0, -0.1, 0.0); @@ -78,8 +79,10 @@ namespace Kratos::Testing p_node_4->UnSetLock(); // Create the test piping element - std::vector element_nodes{1, 2, 3, 4}; - auto p_element = r_model_part.CreateNewElement("SteadyStatePwPipingElement2D4N", 1, element_nodes, p_elem_prop); + auto p_element = make_intrusive>( + 1, Kratos::make_shared>(p_node_1, p_node_2, p_node_3, p_node_4), + p_elem_prop, std::make_unique()); + r_model_part.AddElement(p_element); // Initialize the element to initialize the constitutive law const auto &r_process_info = r_model_part.GetProcessInfo(); @@ -88,11 +91,8 @@ namespace Kratos::Testing // get element geometry auto Geom = p_element->GetGeometry(); - // cast to piping element - auto PipeEl = dynamic_cast *>(p_element.get()); - // calculate equilibrium height - double expected_eq_height = PipeEl->CalculateEquilibriumPipeHeight(*p_elem_prop, Geom, p_elem_prop->GetValue(PIPE_ELEMENT_LENGTH)); + double expected_eq_height = p_element->CalculateEquilibriumPipeHeight(*p_elem_prop, Geom, p_elem_prop->GetValue(PIPE_ELEMENT_LENGTH)); KRATOS_EXPECT_NEAR( expected_eq_height, @@ -100,7 +100,7 @@ namespace Kratos::Testing 1.0e-6); } - KRATOS_TEST_CASE_IN_SUITE(CalculateHeadGradient, KratosGeoMechanicsFastSuite) + KRATOS_TEST_CASE_IN_SUITE(CalculateHeadGradient, KratosGeoMechanicsFastSuiteWithoutKernel) { // initialize modelpart Model current_model; @@ -115,8 +115,7 @@ namespace Kratos::Testing p_elem_prop->SetValue(DENSITY_WATER, 1000); // set constitutive law - const auto &r_clone_cl = KratosComponents::Get("LinearElastic2DInterfaceLaw"); - p_elem_prop->SetValue(CONSTITUTIVE_LAW, r_clone_cl.Clone()); + p_elem_prop->SetValue(CONSTITUTIVE_LAW, LinearElastic2DInterfaceLaw().Clone()); // Create the test piping element nodes auto p_node_1 = r_model_part.CreateNewNode(1, 0.0, -0.1, 0.0); @@ -151,8 +150,10 @@ namespace Kratos::Testing p_node_4->UnSetLock(); // Create the test piping element - std::vector element_nodes{1, 2, 3, 4}; - auto p_element = r_model_part.CreateNewElement("SteadyStatePwPipingElement2D4N", 1, element_nodes, p_elem_prop); + auto p_element = make_intrusive>( + 1, Kratos::make_shared>(p_node_1, p_node_2, p_node_3, p_node_4), + p_elem_prop, std::make_unique()); + r_model_part.AddElement(p_element); // Initialize the element to initialize the constitutive law const auto &r_process_info = r_model_part.GetProcessInfo(); @@ -161,11 +162,8 @@ namespace Kratos::Testing // get element geometry auto Geom = p_element->GetGeometry(); - // cast to piping element - auto PipeEl = dynamic_cast *>(p_element.get()); - // calculate water pressure gradient - double expected_gradient = PipeEl->CalculateHeadGradient(*p_elem_prop, Geom, p_elem_prop->GetValue(PIPE_ELEMENT_LENGTH)); + double expected_gradient = p_element->CalculateHeadGradient(*p_elem_prop, Geom, p_elem_prop->GetValue(PIPE_ELEMENT_LENGTH)); // assert gradient // expected gradient should be 2. Test is failing on purpose to check CI diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_t_normal_flux_condition.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_t_normal_flux_condition.cpp index 84f48e82bf9d..be5a9f051f84 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_t_normal_flux_condition.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_t_normal_flux_condition.cpp @@ -14,13 +14,16 @@ #include "custom_conditions/T_normal_flux_condition.h" #include "geo_mechanics_application_variables.h" #include "geo_mechanics_fast_suite.h" +#include "geometries/line_2d_4.h" +#include "geometries/line_2d_5.h" #include "includes/condition.h" using namespace Kratos; -namespace Kratos::Testing { +namespace Kratos::Testing +{ -void TestGeoTnormalFluxCondition(ModelPart& rModelPart, const std::vector & rExpectedRightHandSide) +void TestGeoTnormalFluxCondition(ModelPart& rModelPart, const std::vector& rExpectedRightHandSide) { Condition::Pointer p_condition = rModelPart.pGetCondition(1); @@ -45,11 +48,10 @@ void TestGeoTnormalFluxCondition(ModelPart& rModelPart, const std::vectorCalculateLocalSystem( - left_hand_side_matrix, right_hand_side_vector, r_current_process_info); + p_condition->CalculateLocalSystem(left_hand_side_matrix, right_hand_side_vector, r_current_process_info); for (unsigned int i = 0; i < right_hand_side_vector.size(); i++) { KRATOS_EXPECT_NEAR(right_hand_side_vector[i], rExpectedRightHandSide[i], 1.0e-4); @@ -61,8 +63,8 @@ void AssignNormalHeatFlux(ModelPart& rModelPart, double value) rModelPart.GetProcessInfo()[DELTA_TIME] = 1.0; for (unsigned int i = 0; i < rModelPart.NumberOfNodes(); i++) { - auto p_node = rModelPart.pGetNode(i + 1); - p_node->FastGetSolutionStepValue(NORMAL_HEAT_FLUX) = value; + auto p_node = rModelPart.pGetNode(i + 1); + p_node->FastGetSolutionStepValue(NORMAL_HEAT_FLUX) = value; p_node->FastGetSolutionStepValue(NORMAL_HEAT_FLUX, 1) = 0; } } @@ -70,19 +72,20 @@ void AssignNormalHeatFlux(ModelPart& rModelPart, double value) void GenerateGeoTnormalFluxCondition2D2N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); AssignNormalHeatFlux(rModelPart, 10.0); - std::vector cond_nodes{1, 2}; - rModelPart.CreateNewCondition("GeoTNormalFluxCondition2D2N", 1, cond_nodes, - rModelPart.CreateNewProperties(0)); + auto condition = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddCondition(condition); } -KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D2N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D2N, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; + Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); // Variables addition model_part.AddNodalSolutionStepVariable(TEMPERATURE); @@ -97,20 +100,21 @@ KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D2N, KratosGeoMechanicsFastSui void GenerateGeoTnormalFluxCondition2D3N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); AssignNormalHeatFlux(rModelPart, 10.0); - std::vector cond_nodes{1, 2, 3}; - rModelPart.CreateNewCondition("GeoTNormalFluxCondition2D3N", 1, cond_nodes, - rModelPart.CreateNewProperties(0)); + auto condition = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddCondition(condition); } -KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D3N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D3N, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; + Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); // Variables addition model_part.AddNodalSolutionStepVariable(TEMPERATURE); @@ -125,21 +129,22 @@ KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D3N, KratosGeoMechanicsFastSui void GenerateGeoTnormalFluxCondition2D4N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.6666, 0.3333, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.6666, 0.3333, 0.0)); AssignNormalHeatFlux(rModelPart, 10.0); - std::vector cond_nodes{1, 2, 3, 4}; - rModelPart.CreateNewCondition("GeoTNormalFluxCondition2D4N", 1, cond_nodes, - rModelPart.CreateNewProperties(0)); + auto condition = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddCondition(condition); } -KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D4N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D4N, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; + Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); // Variables addition model_part.AddNodalSolutionStepVariable(TEMPERATURE); @@ -154,22 +159,23 @@ KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D4N, KratosGeoMechanicsFastSui void GenerateGeoTnormalFluxCondition2D5N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); AssignNormalHeatFlux(rModelPart, 10.0); - std::vector cond_nodes{1, 2, 3, 4, 5}; - rModelPart.CreateNewCondition("GeoTNormalFluxCondition2D5N", 1, cond_nodes, - rModelPart.CreateNewProperties(0)); + auto condition = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddCondition(condition); } -KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D5N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D5N, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; + Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); // Variables addition model_part.AddNodalSolutionStepVariable(TEMPERATURE); @@ -184,21 +190,22 @@ KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition2D5N, KratosGeoMechanicsFastSui void GenerateGeoTnormalFluxCondition3D4N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); AssignNormalHeatFlux(rModelPart, 10.0); - std::vector cond_nodes{1, 2, 3, 4}; - rModelPart.CreateNewCondition("GeoTNormalFluxCondition3D4N", 1, cond_nodes, - rModelPart.CreateNewProperties(0)); + auto condition = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddCondition(condition); } -KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D4N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D4N, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; + Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); // Variables addition model_part.AddNodalSolutionStepVariable(TEMPERATURE); @@ -213,23 +220,24 @@ KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D4N, KratosGeoMechanicsFastSui void GenerateGeoTnormalFluxCondition3D6N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); AssignNormalHeatFlux(rModelPart, 10.0); - std::vector cond_nodes{1, 2, 3, 4, 5, 6}; - rModelPart.CreateNewCondition("GeoTNormalFluxCondition3D6N", 1, cond_nodes, - rModelPart.CreateNewProperties(0)); + auto condition = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddCondition(condition); } -KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D6N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D6N, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; + Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); // Variables addition model_part.AddNodalSolutionStepVariable(TEMPERATURE); @@ -238,32 +246,33 @@ KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D6N, KratosGeoMechanicsFastSui GenerateGeoTnormalFluxCondition3D6N(model_part); const std::vector expected_right_hand_side{3.60822e-16, -2.77556e-16, -1.66533e-16, - 1.66667, 1.66667, 1.66667}; + 1.66667, 1.66667, 1.66667}; TestGeoTnormalFluxCondition(model_part, expected_right_hand_side); } void GenerateGeoTnormalFluxCondition3D8N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); AssignNormalHeatFlux(rModelPart, 10.0); - std::vector cond_nodes{1, 2, 3, 4, 5, 6, 7, 8}; - rModelPart.CreateNewCondition("GeoTNormalFluxCondition3D8N", 1, cond_nodes, - rModelPart.CreateNewProperties(0)); + auto condition = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddCondition(condition); } -KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D8N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D8N, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; + Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); // Variables addition model_part.AddNodalSolutionStepVariable(TEMPERATURE); @@ -272,33 +281,34 @@ KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D8N, KratosGeoMechanicsFastSui GenerateGeoTnormalFluxCondition3D8N(model_part); const std::vector expected_right_hand_side{0.133919, 0.635973, -0.403995, -0.117107, - 1.86947, 1.53697, 0.721923, 1.09723}; + 1.86947, 1.53697, 0.721923, 1.09723}; TestGeoTnormalFluxCondition(model_part, expected_right_hand_side); } void GenerateGeoTnormalFluxCondition3D9N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0)); AssignNormalHeatFlux(rModelPart, 10.0); - std::vector cond_nodes{1, 2, 3, 4, 5, 6, 7, 8, 9}; - rModelPart.CreateNewCondition("GeoTNormalFluxCondition3D9N", 1, cond_nodes, - rModelPart.CreateNewProperties(0)); + auto condition = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddCondition(condition); } -KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D9N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D9N, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; + Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); // Variables addition model_part.AddNodalSolutionStepVariable(TEMPERATURE); @@ -306,8 +316,8 @@ KRATOS_TEST_CASE_IN_SUITE(GeoTNormalFluxCondition3D9N, KratosGeoMechanicsFastSui GenerateGeoTnormalFluxCondition3D9N(model_part); - const std::vector expected_right_hand_side{0.325617, 0.741605, -0.0401643, 0.160657, 0.785555, - 0.467627, 0.228477, 0.324183, 0.676021}; + const std::vector expected_right_hand_side{ + 0.325617, 0.741605, -0.0401643, 0.160657, 0.785555, 0.467627, 0.228477, 0.324183, 0.676021}; TestGeoTnormalFluxCondition(model_part, expected_right_hand_side); } diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_three_dimensional_stress_state.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_three_dimensional_stress_state.cpp index bb52756a6439..5b98b723fcfa 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_three_dimensional_stress_state.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_three_dimensional_stress_state.cpp @@ -22,13 +22,11 @@ using namespace Kratos; namespace Kratos::Testing { -KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_CalculateBMatrixReturnsCorrectResults, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_CalculateBMatrixReturnsCorrectResults, + KratosGeoMechanicsFastSuiteWithoutKernel) { auto p_stress_state_policy = std::make_unique(); - Model model; - auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle3D4NElement(model); - Vector Np(4); Np <<= 1.0, 2.0, 3.0, 4.0; @@ -40,8 +38,8 @@ KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_CalculateBMatrixReturnsCor 10.0, 11.0, 12.0; // clang-format on - const auto calculated_matrix = - p_stress_state_policy->CalculateBMatrix(GradNpT, Np, r_model_part.GetElement(1).GetGeometry()); + const auto calculated_matrix = p_stress_state_policy->CalculateBMatrix( + GradNpT, Np, ModelSetupUtilities::Create3D4NTetrahedraGeometry()); // clang-format off Matrix expected_matrix(6, 12); @@ -62,26 +60,24 @@ KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_CalculateBMatrixReturnsCor KRATOS_CHECK_MATRIX_NEAR(calculated_matrix, expected_matrix, 1e-12) } -KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_ReturnsCorrectIntegrationCoefficient, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_ReturnsCorrectIntegrationCoefficient, + KratosGeoMechanicsFastSuiteWithoutKernel) { const auto p_stress_state_policy = std::make_unique(); - Model model; - auto& r_model_part = ModelSetupUtilities::CreateModelPartWithASingle3D4NElement(model); - // The shape function values for this integration point are 0.2, 0.5 and 0.3 for nodes 1, 2 and 3 respectively Geometry::IntegrationPointType integration_point(0.5, 0.3, 0.0, 0.5); const auto detJ = 2.0; const auto calculated_coefficient = p_stress_state_policy->CalculateIntegrationCoefficient( - integration_point, detJ, r_model_part.GetElement(1).GetGeometry()); + integration_point, detJ, ModelSetupUtilities::Create3D4NTetrahedraGeometry()); // The expected number is calculated as follows: // 2.0 (detJ) * 0.5 (weight) = 1.0 KRATOS_EXPECT_NEAR(calculated_coefficient, 1.0, 1e-5); } -KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectClone, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectClone, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); @@ -112,7 +108,7 @@ KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_CalculateGreenLagrangeStra KRATOS_CHECK_VECTOR_NEAR(expected_vector, calculated_vector, 1e-12) } -KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectVoigtVector, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectVoigtVector, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); @@ -123,14 +119,14 @@ KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectVoigtVector, K KRATOS_EXPECT_VECTOR_NEAR(voigt_vector, expected_voigt_vector, 1.E-10) } -KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectVoigtSize, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectVoigtSize, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); KRATOS_EXPECT_EQ(p_stress_state_policy->GetVoigtSize(), VOIGT_SIZE_3D); } -KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectStressTensorSize, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(ThreeDimensionalStressState_GivesCorrectStressTensorSize, KratosGeoMechanicsFastSuiteWithoutKernel) { const std::unique_ptr p_stress_state_policy = std::make_unique(); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_transient_thermal_element.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_transient_thermal_element.cpp index f16839e31573..b0d745f3c67c 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_transient_thermal_element.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_transient_thermal_element.cpp @@ -14,6 +14,8 @@ #include "custom_elements/transient_thermal_element.h" #include "geo_mechanics_application_variables.h" #include "geo_mechanics_fast_suite.h" +#include "geometries/triangle_2d_10.h" +#include "geometries/triangle_2d_15.h" #include using namespace Kratos; @@ -87,44 +89,39 @@ void ValidateThermalElement(ModelPart& rModelPart) } } -void GenerateTransientThermalElementWithZeroDomainSize(ModelPart& rModelPart) +Element::Pointer GenerateTransientThermalElementWithZeroDomainSize() { - // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 0.0, 0.0, 0.0); - std::vector node_ids{1, 2, 3}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D3N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + PointerVector nodes; + nodes.push_back(make_intrusive(1, 0.0, 0.0, 0.0)); + nodes.push_back(make_intrusive(2, 0.0, 0.0, 0.0)); + nodes.push_back(make_intrusive(3, 0.0, 0.0, 0.0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes)); + + return transient_thermal_element; } -KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenDomainSizeIsInvalid, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenDomainSizeIsInvalid, KratosGeoMechanicsFastSuiteWithoutKernel) { - Model this_model; - ModelPart& model_part = this_model.CreateModelPart("Main", 3); - - GenerateTransientThermalElementWithZeroDomainSize(model_part); + Element::Pointer p_element = GenerateTransientThermalElementWithZeroDomainSize(); - Element::Pointer p_element = model_part.pGetElement(1); - const ProcessInfo& r_current_process_info = model_part.GetProcessInfo(); - - KRATOS_EXPECT_EXCEPTION_IS_THROWN( - p_element->Check(r_current_process_info), - "DomainSize smaller than 1e-15 for element 1") + KRATOS_EXPECT_EXCEPTION_IS_THROWN(p_element->Check(ProcessInfo()), + "DomainSize smaller than 1e-15 for element 1") } void GenerateTransientThermalElement2D3N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - std::vector node_ids{1, 2, 3}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D3N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenTemperatureIsMissing, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenTemperatureIsMissing, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -137,7 +134,7 @@ KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenTemperatureIsMissing, KratosGe "Missing variable TEMPERATURE on node 1") } -KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenDtTemperatureIsMissing, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenDtTemperatureIsMissing, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -152,7 +149,7 @@ KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenDtTemperatureIsMissing, Kratos "Missing variable DT_TEMPERATURE on node 1") } -KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenTemperatureDofIsMissing, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenTemperatureDofIsMissing, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -168,7 +165,7 @@ KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenTemperatureDofIsMissing, Krato "Missing degree of freedom for TEMPERATURE on node 1") } -KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenPropertyIsMissing, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenPropertyIsMissing, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -191,15 +188,16 @@ KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_WhenPropertyIsMissing, KratosGeoMe void GenerateTransientThermalElement2D3NWithNonZeroZ(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 1.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, -1.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - std::vector node_ids{1, 2, 3}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D3N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 1.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, -1.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_When2DElementHasNonZeroZValue, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_When2DElementHasNonZeroZValue, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -214,7 +212,7 @@ KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_When2DElementHasNonZeroZValue, Kra "Node with non-zero Z coordinate found. Id: 1") } -KRATOS_TEST_CASE_IN_SUITE(CheckElement_Returns0_When2DElementIsCorrectlySet, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CheckElement_Returns0_When2DElementIsCorrectlySet, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -250,7 +248,7 @@ void ExpectDoubleVectorEqual(const Vector& rExpectedVector, const Vector& rActua } KRATOS_TEST_CASE_IN_SUITE(ThermalElement_ReturnsExpectedMatrixAndVector_WhenCalculateLocalSystem, - KratosGeoMechanicsFastSuite) + KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -280,7 +278,7 @@ KRATOS_TEST_CASE_IN_SUITE(ThermalElement_ReturnsExpectedMatrixAndVector_WhenCalc ExpectDoubleVectorEqual(expected_vector, right_hand_side); } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D3N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D3N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -296,16 +294,18 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D3N, KratosGeo void GenerateTransientThermalElement2D4N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.6666, 0.3333, 0.0); - std::vector node_ids{1, 2, 3, 4}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D4N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.6666, 0.3333, 0.0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), + rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D4N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D4N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -321,19 +321,21 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D4N, KratosGeo void GenerateTransientThermalElement2D6N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); - std::vector node_ids{1, 2, 3, 4, 5, 6}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D6N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), + rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D6N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D6N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -349,21 +351,23 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D6N, KratosGeo void GenerateTransientThermalElement2D8N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); - std::vector node_ids{1, 2, 3, 4, 5, 6, 7, 8}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D8N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), + rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D8N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D8N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -379,22 +383,23 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D8N, KratosGeo void GenerateTransientThermalElement2D9N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0)); - std::vector node_ids{1, 2, 3, 4, 5, 6, 7, 8, 9}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D9N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D9N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D9N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -410,23 +415,24 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D9N, KratosGeo void GenerateTransientThermalElement2D10N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0)); - std::vector node_ids{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D10N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D10N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D10N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -442,29 +448,29 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D10N, KratosGe void GenerateTransientThermalElement2D15N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(11, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(12, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(13, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(14, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(15, 0.5, 0.5, 0.0); - - std::vector node_ids{1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15}; - rModelPart.CreateNewElement("GeoTransientThermalElement2D15N", 1, node_ids, - rModelPart.CreateNewProperties(0)); -} - -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D15N, KratosGeoMechanicsFastSuite) + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(11, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(12, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(13, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(14, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(15, 0.5, 0.5, 0.0)); + + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); +} + +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D15N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -480,18 +486,19 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement2D15N, KratosGe void GenerateTransientThermalElement3D4N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); // The z coordinate is non-zero to ensure the element has a non-zero domain size - rModelPart.CreateNewNode(4, 0.5, 0.0, 1.0); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 1.0)); - std::vector node_ids{1, 2, 3, 4}; - rModelPart.CreateNewElement("GeoTransientThermalElement3D4N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_When3DPropertyHasInvalidValue, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_When3DPropertyHasInvalidValue, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -509,7 +516,7 @@ KRATOS_TEST_CASE_IN_SUITE(CheckElement_Throws_When3DPropertyHasInvalidValue, Kra "THERMAL_CONDUCTIVITY_SOLID_ZZ has an invalid value at element 1") } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D4N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D4N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -525,21 +532,22 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D4N, KratosGeo void GenerateTransientThermalElement3D8N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); - std::vector node_ids{1, 2, 3, 4, 5, 6, 7, 8}; - rModelPart.CreateNewElement("GeoTransientThermalElement3D8N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D8N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D8N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -555,23 +563,24 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D8N, KratosGeo void GenerateTransientThermalElement3D10N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0); + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0)); - std::vector node_ids{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - rModelPart.CreateNewElement("GeoTransientThermalElement3D10N", 1, node_ids, - rModelPart.CreateNewProperties(0)); + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); } -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D10N, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D10N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -587,34 +596,34 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D10N, KratosGe void GenerateTransientThermalElement3D20N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(11, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(12, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(13, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(14, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(15, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(16, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(17, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(18, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(19, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(20, 0.5, 0.5, 0.0); - - std::vector node_ids{ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; - rModelPart.CreateNewElement("GeoTransientThermalElement3D20N", 1, node_ids, - rModelPart.CreateNewProperties(0)); -} - -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D20N, KratosGeoMechanicsFastSuite) + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(11, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(12, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(13, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(14, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(15, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(16, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(17, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(18, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(19, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(20, 0.5, 0.5, 0.0)); + + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); +} + +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D20N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); @@ -630,42 +639,41 @@ KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D20N, KratosGe void GenerateTransientThermalElement3D27N(ModelPart& rModelPart) { // Geometry creation - rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0); - rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0); - rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0); - rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(11, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(12, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(13, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(14, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(15, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(16, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(17, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(18, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(19, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(20, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(21, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(22, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(23, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(24, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(25, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(26, 0.5, 0.5, 0.0); - rModelPart.CreateNewNode(27, 0.5, 0.5, 0.0); - - std::vector node_ids{ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}; - rModelPart.CreateNewElement("GeoTransientThermalElement3D27N", 1, node_ids, - rModelPart.CreateNewProperties(0)); -} - -KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D27N, KratosGeoMechanicsFastSuite) + PointerVector nodes; + nodes.push_back(rModelPart.CreateNewNode(1, 0.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(2, 1.0, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(3, 1.0, 1.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(4, 0.5, 0.0, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(5, 1.0, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(6, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(7, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(8, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(9, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(10, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(11, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(12, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(13, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(14, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(15, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(16, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(17, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(18, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(19, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(20, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(21, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(22, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(23, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(24, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(25, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(26, 0.5, 0.5, 0.0)); + nodes.push_back(rModelPart.CreateNewNode(27, 0.5, 0.5, 0.0)); + + auto transient_thermal_element = make_intrusive>( + 1, Kratos::make_shared>(nodes), rModelPart.CreateNewProperties(0)); + rModelPart.AddElement(transient_thermal_element); +} + +KRATOS_TEST_CASE_IN_SUITE(EquationIdVectorTransientThermalElement3D27N, KratosGeoMechanicsFastSuiteWithoutKernel) { Model this_model; ModelPart& model_part = this_model.CreateModelPart("Main", 3); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_utilities/model_setup_utilities.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_utilities/model_setup_utilities.cpp index a112a96f3665..d8ac50214977 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_utilities/model_setup_utilities.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_utilities/model_setup_utilities.cpp @@ -14,6 +14,15 @@ #include "includes/model_part.h" #include "includes/properties.h" +#include +#include +#include +#include +#include +#include +#include +#include + namespace { @@ -26,13 +35,16 @@ void AddNodalVariablesToModelPart(ModelPart& rModelPart, const Geo::ConstVariabl } } -void CreateNewNodes(ModelPart& rModelPart, const std::vector& rPoints) +PointerVector CreateNewNodes(ModelPart& rModelPart, const std::vector& rPoints) { - auto NodeIndex = rModelPart.NumberOfNodes(); + PointerVector nodes; + auto NodeIndex = rModelPart.NumberOfNodes(); for (const auto& r_point : rPoints) { ++NodeIndex; - rModelPart.CreateNewNode(NodeIndex, r_point.X(), r_point.Y(), r_point.Z()); + nodes.push_back(rModelPart.CreateNewNode(NodeIndex, r_point.X(), r_point.Y(), r_point.Z())); } + + return nodes; } template @@ -61,11 +73,14 @@ ModelPart& CreateModelPartWithASingle2D3NElement(Model& rModel, const Geo::Const ModelPart& result = rModel.CreateModelPart("Main"); AddNodalVariablesToModelPart(result, rNodalVariables); - CreateNewNodes(result, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}}); + auto nodes = CreateNewNodes(result, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}}); AddDofsToNodes(result.Nodes(), rNodalVariables); - const std::vector node_ids{1, 2, 3}; - result.CreateNewElement("UPwSmallStrainElement2D3N", 1, node_ids, result.CreateNewProperties(0)); + auto element = make_intrusive>( + 1, Kratos::make_shared>(nodes), result.CreateNewProperties(0), + std::make_unique()); + + result.AddElement(element); return result; } @@ -75,11 +90,15 @@ ModelPart& CreateModelPartWithASingle3D4NElement(Model& rModel, const Geo::Const ModelPart& result = rModel.CreateModelPart("Main"); AddNodalVariablesToModelPart(result, rNodalVariables); - CreateNewNodes(result, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}); + auto nodes = + CreateNewNodes(result, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}); AddDofsToNodes(result.Nodes(), rNodalVariables); - const std::vector node_ids{1, 2, 3, 4}; - result.CreateNewElement("UPwSmallStrainElement3D4N", 1, node_ids, result.CreateNewProperties(0)); + auto element = make_intrusive>( + 1, Kratos::make_shared>(nodes), result.CreateNewProperties(0), + std::make_unique()); + + result.AddElement(element); return result; } @@ -91,15 +110,17 @@ ModelPart& CreateModelPartWithASingle2D6NDiffOrderElement(Model& rModel) const auto variables = Geo::ConstVariableRefs{std::cref(DISPLACEMENT_X), std::cref(DISPLACEMENT_Y), std::cref(DISPLACEMENT_Z), std::cref(WATER_PRESSURE)}; AddNodalVariablesToModelPart(result, variables); - CreateNewNodes( + auto nodes = CreateNewNodes( result, {{0.0, 0.0, 0.0}, {0.0, -0.05, 0.0}, {0.05, 0.0, 0.0}, {0.0, -0.025, 0.0}, {0.025, -0.025, 0.0}, {0.025, 0.0, 0.0}}); - const auto nodes = result.Nodes(); - AddDofsToNodes(nodes, variables); + AddDofsToNodes(result.Nodes(), variables); - const std::vector node_ids{1, 2, 3, 4, 5, 6}; - result.CreateNewElement("SmallStrainUPwDiffOrderElement2D6N", 1, node_ids, result.CreateNewProperties(0)); + auto element = make_intrusive( + 1, Kratos::make_shared>(nodes), result.CreateNewProperties(0), + std::make_unique()); + + result.AddElement(element); return result; } @@ -112,7 +133,7 @@ ModelPart& CreateModelPartWithASingle2D6NUPwDiffOrderElement(Model& rModel) const auto first_order_variables = Geo::ConstVariableRefs{std::cref(WATER_PRESSURE)}; AddNodalVariablesToModelPart(r_result, first_order_variables); - CreateNewNodes( + auto node_pointers = CreateNewNodes( r_result, {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.5, 0.0, 0.0}, {0.5, 0.5, 0.0}, {0.0, 0.5, 0.0}}); @@ -121,8 +142,12 @@ ModelPart& CreateModelPartWithASingle2D6NUPwDiffOrderElement(Model& rModel) AddDofsToNodes(nodes.begin(), nodes.begin() + 3, first_order_variables); const std::vector node_ids{1, 2, 3, 4, 5, 6}; - r_result.CreateNewElement("SmallStrainUPwDiffOrderElement2D6N", 1, node_ids, - r_result.CreateNewProperties(0)); + + auto element = make_intrusive( + 1, Kratos::make_shared>(node_pointers), r_result.CreateNewProperties(0), + std::make_unique()); + + r_result.AddElement(element); return r_result; } @@ -136,26 +161,45 @@ ModelPart& CreateModelPartWithASingle3D10NUPwDiffOrderElement(Model& rModel) const auto first_order_variables = Geo::ConstVariableRefs{std::cref(WATER_PRESSURE)}; AddNodalVariablesToModelPart(r_result, first_order_variables); - CreateNewNodes(r_result, {{0.0, 0.0, 0.0}, - {1.0, 0.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.0, 0.0, 1.0}, - {0.5, 0.0, 0.0}, - {0.5, 0.5, 0.0}, - {0.0, 0.5, 0.0}, - {0.0, 0.0, 0.5}, - {0.5, 0.0, 0.5}, - {0.0, 0.5, 0.5}}); + auto node_pointers = CreateNewNodes(r_result, {{0.0, 0.0, 0.0}, + {1.0, 0.0, 0.0}, + {0.0, 1.0, 0.0}, + {0.0, 0.0, 1.0}, + {0.5, 0.0, 0.0}, + {0.5, 0.5, 0.0}, + {0.0, 0.5, 0.0}, + {0.0, 0.0, 0.5}, + {0.5, 0.0, 0.5}, + {0.0, 0.5, 0.5}}); const auto nodes = r_result.Nodes(); AddDofsToNodes(nodes, second_order_variables); AddDofsToNodes(nodes.begin(), nodes.begin() + 4, first_order_variables); - const std::vector node_ids{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - r_result.CreateNewElement("SmallStrainUPwDiffOrderElement3D10N", 1, node_ids, - r_result.CreateNewProperties(0)); + auto element = make_intrusive( + 1, Kratos::make_shared>(node_pointers), r_result.CreateNewProperties(0), + std::make_unique()); + + r_result.AddElement(element); return r_result; } +Triangle2D3 Create2D3NTriangleGeometry() +{ + const auto node_1 = make_intrusive(1, 0.0, 0.0, 0.0); + const auto node_2 = make_intrusive(2, 1.0, 0.0, 0.0); + const auto node_3 = make_intrusive(3, 1.0, 1.0, 0.0); + return {node_1, node_2, node_3}; +} + +Tetrahedra3D4 Create3D4NTetrahedraGeometry() +{ + const auto node_1 = make_intrusive(1, 0.0, 0.0, 0.0); + const auto node_2 = make_intrusive(2, 1.0, 0.0, 0.0); + const auto node_3 = make_intrusive(3, 0.0, 1.0, 0.0); + const auto node_4 = make_intrusive(3, 0.0, 0.0, 1.0); + return {node_1, node_2, node_3, node_4}; +} + } // namespace Kratos::Testing::ModelSetupUtilities diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_utilities/model_setup_utilities.h b/applications/GeoMechanicsApplication/tests/cpp_tests/test_utilities/model_setup_utilities.h index 31cc9dd59344..83b944c12a79 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_utilities/model_setup_utilities.h +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_utilities/model_setup_utilities.h @@ -14,6 +14,9 @@ #include "geo_aliases.h" +#include +#include + namespace Kratos { class Model; @@ -33,5 +36,7 @@ ModelPart& CreateModelPartWithASingle3D4NElement(Model& rModel, ModelPart& CreateModelPartWithASingle2D6NUPwDiffOrderElement(Model& rModel); ModelPart& CreateModelPartWithASingle3D10NUPwDiffOrderElement(Model& rModel); +Triangle2D3 Create2D3NTriangleGeometry(); +Tetrahedra3D4 Create3D4NTetrahedraGeometry(); } // namespace Kratos::Testing::ModelSetupUtilities diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_variables_utilities.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_variables_utilities.cpp index c5844d2e72a4..9c9b3064d6df 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_variables_utilities.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_variables_utilities.cpp @@ -16,14 +16,14 @@ namespace Kratos::Testing { -KRATOS_TEST_CASE_IN_SUITE(TestVariablesUtilitiesGetsCorrectComponents, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(TestVariablesUtilitiesGetsCorrectComponents, KratosGeoMechanicsFastSuiteWithoutKernel) { const auto& component = VariablesUtilities::GetComponentFromVectorVariable(ACCELERATION.Name(), "X"); KRATOS_EXPECT_EQ(component, ACCELERATION_X); } -KRATOS_TEST_CASE_IN_SUITE(TestVariablesUtilitiesThrowsWhenComponentDoesNotExist, KratosGeoMechanicsFastSuite) +KRATOS_TEST_CASE_IN_SUITE(TestVariablesUtilitiesThrowsWhenComponentDoesNotExist, KratosGeoMechanicsFastSuiteWithoutKernel) { KRATOS_EXPECT_EXCEPTION_IS_THROWN( VariablesUtilities::GetComponentFromVectorVariable(ACCELERATION.Name(), "?"),