-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Geo/check number of tables phreatic multi line (#12689)
* Make sure the number of attached tables matches the number of points for phreatic multiline. * Added test with matching number of tables and coordinates.
- Loading branch information
Showing
5 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...nicsApplication/tests/cpp_tests/test_apply_phreatic_multi_line_pressure_table_process.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// KRATOS___ | ||
// // ) ) | ||
// // ___ ___ | ||
// // ____ //___) ) // ) ) | ||
// // / / // // / / | ||
// ((____/ / ((____ ((___/ / MECHANICS | ||
// | ||
// License: geo_mechanics_application/license.txt | ||
// | ||
// Main authors: Wijtze Pieter Kikstra | ||
// | ||
#include "containers/model.h" | ||
#include "custom_processes/apply_phreatic_multi_line_pressure_table_process.h" | ||
#include "geo_mechanics_fast_suite.h" | ||
#include "includes/checks.h" | ||
|
||
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 | ||
{ | ||
|
||
KRATOS_TEST_CASE_IN_SUITE(ApplyPhreaticMultiLinePressureTableProcessThrowsWhenTableLengthDoesNotMatchCoordinates, | ||
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], | ||
"y_coordinates": [0.0, 1.0], | ||
"z_coordinates": [0.0, 0.0], | ||
"gravity_direction": 1, | ||
"out_of_plane_direction": 2, | ||
"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_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters