Skip to content

Commit

Permalink
[GeoMechanicsApplication] Fix performance difference between line-bas…
Browse files Browse the repository at this point in the history
…ed and interface-based piping elements (#13091)
  • Loading branch information
rfaasse authored Feb 5, 2025
1 parent 6bd1327 commit ab54c55
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoSteadyStatePwPipingElement : publ
Element::Initialize(rCurrentProcessInfo);
// all these except the PIPE_ELEMENT_LENGTH seem to be in the erosion_process_strategy only. Why do this: it is used in output for dGeoFlow
this->SetValue(PIPE_ELEMENT_LENGTH, CalculateLength(this->GetGeometry()));
this->SetValue(PIPE_EROSION, false);
constexpr double small_pipe_height = 1e-10;
this->SetValue(PIPE_HEIGHT, small_pipe_height);
this->SetValue(PREV_PIPE_HEIGHT, small_pipe_height);
this->SetValue(DIFF_PIPE_HEIGHT, 0.);
this->SetValue(PIPE_ACTIVE, false);

if (!mIsInitialized) {
this->SetValue(PIPE_EROSION, false);
constexpr double small_pipe_height = 1e-10;
this->SetValue(PIPE_HEIGHT, small_pipe_height);
this->SetValue(PREV_PIPE_HEIGHT, small_pipe_height);
this->SetValue(DIFF_PIPE_HEIGHT, 0.);
this->SetValue(PIPE_ACTIVE, false);
mIsInitialized = true;
}
}

double CalculateEquilibriumPipeHeight(const PropertiesType& rProp, const GeometryType& rGeom, double)
Expand Down Expand Up @@ -413,11 +417,15 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoSteadyStatePwPipingElement : publ
void save(Serializer& rSerializer) const override
{
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, Element)
rSerializer.save("mIsInitialized", mIsInitialized);
}

void load(Serializer& rSerializer) override
{
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, Element)
rSerializer.load("mIsInitialized", mIsInitialized);
}

bool mIsInitialized = false;
};
} // namespace Kratos
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// KRATOS___
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Richard Faasse
//

#include "custom_elements/geo_steady_state_Pw_piping_element.h"
#include "tests/cpp_tests/geo_mechanics_fast_suite.h"

namespace Kratos::Testing
{

KRATOS_TEST_CASE_IN_SUITE(GeoSteadyStatePipingElement_DoesNotLosePipingStateAfterInitializingTwice,
KratosGeoMechanicsFastSuiteWithoutKernel)
{
Model model;
auto& r_model_part = model.CreateModelPart("Dummy");
auto p_node_1 = r_model_part.CreateNewNode(1, 0.0, -0.1, 0.0);
auto p_node_2 = r_model_part.CreateNewNode(2, 1.0, -0.1, 0.0);
auto p_element = make_intrusive<GeoSteadyStatePwPipingElement<2, 2>>(
1, Kratos::make_shared<Line2D2<Node>>(p_node_1, p_node_2));

p_element->Initialize(r_model_part.GetProcessInfo());
KRATOS_EXPECT_FALSE(p_element->GetValue(PIPE_ACTIVE))

p_element->SetValue(PIPE_ACTIVE, true);
p_element->Initialize(r_model_part.GetProcessInfo());

KRATOS_EXPECT_TRUE(p_element->GetValue(PIPE_ACTIVE))
}

} // namespace Kratos::Testing

0 comments on commit ab54c55

Please sign in to comment.