Skip to content

Commit

Permalink
[GeoMechanicsApplication] Shorter domain of the phreatic line causes …
Browse files Browse the repository at this point in the history
…a crash (#12634)

* fixed return index
* added unit test comparing to computed values.
Co-authored-by: gennady.markelov <[email protected]>
  • Loading branch information
markelov208 authored Aug 21, 2024
1 parent 98f2ae9 commit b9c905a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ int ApplyConstantPhreaticMultiLinePressureProcess::findIndex(const Node& rNode)
}
}

return number_of_coordinates - 1;
return number_of_coordinates - 2;
}

double ApplyConstantPhreaticMultiLinePressureProcess::CalculatePressure(const Node& rNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "custom_processes/apply_constant_phreatic_multi_line_pressure_process.h"
#include "geo_mechanics_fast_suite.h"
#include "includes/checks.h"
#include "geometries/quadrilateral_2d_4.h"
#include "processes/structured_mesh_generator_process.h"

using namespace Kratos;

Expand Down Expand Up @@ -140,4 +142,48 @@ KRATOS_TEST_CASE_IN_SUITE(ApplyConstantPhreaticMultiLinePressureProcessDoesNotTh
r_model_part, test_parameters))
}

KRATOS_TEST_CASE_IN_SUITE(ApplyConstantPhreaticMultilinePressureProcess_AppliesCorrectPressure_WhenPhreaticLineDoesNotSpanEntireDomain,
KratosGeoMechanicsFastSuite)
{
auto model = Model{};
auto& r_model_part = model.CreateModelPart("foo");
r_model_part.AddNodalSolutionStepVariable(WATER_PRESSURE);

// Set up the test model part mesh
auto p_point_1 = Kratos::make_intrusive<Node>(1, 0.0, 0.0, 0.0);
auto p_point_2 = Kratos::make_intrusive<Node>(2, 0.0, 1.0, 0.0);
auto p_point_3 = Kratos::make_intrusive<Node>(3, 5.0, 1.0, 0.0);
auto p_point_4 = Kratos::make_intrusive<Node>(4, 5.0, 0.0, 0.0);
Quadrilateral2D4<Node> domain_geometry(p_point_1, p_point_2, p_point_3, p_point_4);
Parameters mesher_parameters(R"({
"number_of_divisions": 2,
"element_name": "Element2D3N",
"condition_name": "LineCondition",
"create_skin_sub_model_part": true
})");
StructuredMeshGeneratorProcess(domain_geometry, r_model_part, mesher_parameters).Execute();

auto test_parameters = Parameters{R"(
{
"model_part_name": "foo",
"variable_name": "WATER_PRESSURE",
"specific_weight": 10000.0,
"x_coordinates": [0.0, 1.0, 2.0],
"y_coordinates": [1.0, 1.0, 1.0],
"z_coordinates": [0.0, 0.0, 0.0],
"gravity_direction": 1
} )"};

ApplyConstantPhreaticMultiLinePressureProcess process{r_model_part, test_parameters};
process.ExecuteInitialize();

const auto phreatic_line_position = 1.0;
const auto specific_weight = 10000.0;
block_for_each(r_model_part.Nodes(),
[&phreatic_line_position, &specific_weight](auto& node) {
const auto water_pressure = (node.Y() - phreatic_line_position) * specific_weight;
KRATOS_EXPECT_DOUBLE_EQ(node.FastGetSolutionStepValue(WATER_PRESSURE, 0), water_pressure);
});
}

} // namespace Kratos::Testing

0 comments on commit b9c905a

Please sign in to comment.