Skip to content

Commit

Permalink
Added test with matching number of tables and coordinates.
Browse files Browse the repository at this point in the history
  • Loading branch information
WPK4FEM committed Dec 13, 2024
1 parent faeb405 commit 2d7186b
Showing 1 changed file with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@

using namespace Kratos;

namespace
{

bool CanCreateInstanceOfApplyPhreaticMultiLinePressureTableProcessWithoutFailure(ModelPart& rModelPart,
const Parameters& rProcessParameters)
{
try {
ApplyPhreaticMultiLinePressureTableProcess{rModelPart, rProcessParameters};
} catch (const Exception&) {
return false;
}

return true;
}

} // namespace

namespace Kratos::Testing
{

Expand All @@ -36,9 +53,28 @@ KRATOS_TEST_CASE_IN_SUITE(ApplyPhreaticMultiLinePressureTableProcessThrowsWhenTa
"table": [1, 2, 3, 4]
} )"};

KRATOS_EXPECT_EXCEPTION_IS_THROWN(
(ApplyPhreaticMultiLinePressureTableProcess{r_model_part, test_parameters}),
"Got 2 coordinates and 4 table references. The number of coordinates and table references should be equal.")
KRATOS_EXPECT_EXCEPTION_IS_THROWN((ApplyPhreaticMultiLinePressureTableProcess{r_model_part, test_parameters}), "Got 2 coordinates and 4 table references. The number of coordinates and table references should be equal.")
}

KRATOS_TEST_CASE_IN_SUITE(ApplyPhreaticMultiLinePressureTableProcessDoesNotThrowWhenTableLengthMatchesCoordinates,
KratosGeoMechanicsFastSuiteWithoutKernel)
{
auto model = Model{};
auto& r_model_part = model.CreateModelPart("foo");
auto test_parameters = Parameters{R"(
{
"model_part_name": "foo",
"variable_name": "WATER_PRESSURE",
"x_coordinates": [0.0, 1.0, 2.0],
"y_coordinates": [0.0, 1.0, 2.0],
"z_coordinates": [0.0, 0.0, 0.0],
"gravity_direction": 1,
"out_of_plane_direction": 2,
"table": [0, 0, 3]
} )"};

KRATOS_EXPECT_TRUE(CanCreateInstanceOfApplyPhreaticMultiLinePressureTableProcessWithoutFailure(
r_model_part, test_parameters))
}

} // namespace Kratos::Testing

0 comments on commit 2d7186b

Please sign in to comment.