Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geo/check number of tables phreatic multi line #12689

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ void ApplyConstantPhreaticMultiLinePressureProcess::InitializeParameters(Paramet
"is_seepage": false,
"gravity_direction": 1,
"out_of_plane_direction": 2,
"x_coordinates": [0.0,1.0],
"y_coordinates": [1.0,0.5],
"z_coordinates": [0.0,0.0],
"x_coordinates": [0.0, 1.0],
"y_coordinates": [1.0, 0.5],
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
"z_coordinates": [0.0, 0.0],
"specific_weight" : 10000.0,
"pressure_tension_cut_off" : 0.0,
"table" : [0,1]
"table" : [0, 0]
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
} )");

// Some values are mandatory, since no meaningful default value exist. For this reason try
Expand Down Expand Up @@ -172,7 +172,7 @@ std::string ApplyConstantPhreaticMultiLinePressureProcess::Info() const

void ApplyConstantPhreaticMultiLinePressureProcess::PrintInfo(std::ostream& rOStream) const
{
rOStream << "ApplyConstantPhreaticMultiLinePressureProcess";
rOStream << Info();
}

const std::string& ApplyConstantPhreaticMultiLinePressureProcess::VariableName() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ ApplyPhreaticMultiLinePressureTableProcess::ApplyPhreaticMultiLinePressureTableP
{
KRATOS_TRY

KRATOS_ERROR_IF(HorizontalDirectionCoordinates().size() != rParameters["table"].GetVector().size())
<< "Got " << HorizontalDirectionCoordinates().size() << " coordinates and "
<< rParameters["table"].GetVector().size() << " table references. The number of coordinates "
<< "and table references should be equal." << std::endl;

for (auto value : rParameters["table"].GetVector()) {
const auto TableId = static_cast<unsigned int>(value);
if (TableId > 0) {
Expand Down Expand Up @@ -80,7 +85,7 @@ std::string ApplyPhreaticMultiLinePressureTableProcess::Info() const

void ApplyPhreaticMultiLinePressureTableProcess::PrintInfo(std::ostream& rOStream) const
{
rOStream << "ApplyPhreaticMultiLinePressureTableProcess";
rOStream << Info();
}

} // namespace Kratos
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ KRATOS_TEST_CASE_IN_SUITE(ApplyConstantPhreaticMultiLinePressureProcessDoesNotTh
r_model_part, test_parameters))

test_parameters.RemoveValue("x_coordinates");
test_parameters.AddVector("x_coordinates", ScalarVector{5, 1.0});
test_parameters.AddVector("x_coordinates", ScalarVector{2, 1.0});
rfaasse marked this conversation as resolved.
Show resolved Hide resolved

KRATOS_EXPECT_TRUE(CanCreateInstanceOfApplyConstantPhreaticMultiLinePressureProcessWithoutFailure(
r_model_part, test_parameters))
Expand Down Expand Up @@ -171,6 +171,7 @@ KRATOS_TEST_CASE_IN_SUITE(ApplyConstantPhreaticMultilinePressureProcess_AppliesC
"x_coordinates": [0.0, 1.0, 2.0],
"y_coordinates": [1.0, 1.0, 1.0],
"z_coordinates": [0.0, 0.0, 0.0],
"table": [0, 0, 0],
"gravity_direction": 1
} )"};

Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,13 @@
"model_part_name": "PorousDomain.Fluid_Pressure-auto-1",
"variable_name": "WATER_PRESSURE",
"is_fixed": true,
"value": 0.0,
"table": [0, 0, 0],
"fluid_pressure_type": "Phreatic_Multi_Line",
"gravity_direction": 1,
"out_of_plane_direction": 2,
"x_coordinates" : [0.0,0.5,1.0],
"y_coordinates": [1.0,0.9,0.5],
"z_coordinates": [0.0,0.0,0.0],
"z_coordinates": [0.0,0.0,0.0],
"table": [0, 0, 0],
"specific_weight": 10000.0
}
}],
Expand Down
Loading