Skip to content

Commit 0040ede

Browse files
authored
Clean up piping strategy and piping interface element (#12785)
Cleaned up the piping strategy as well as the piping interface element. This is to prepare for the transition from piping interface elements to piping line elements. For some time (while the piping line element is developed further and validated), these two element types will co-exist.
1 parent ebfd53a commit 0040ede

5 files changed

Lines changed: 58 additions & 52 deletions

File tree

applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_piping_element.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
// Application includes
1414
#include "custom_elements/steady_state_Pw_piping_element.hpp"
1515
#include "custom_utilities/element_utilities.hpp"
16+
#include "custom_utilities/transport_equation_utilities.hpp"
1617
#include "utilities/math_utils.h"
18+
1719
#include <cmath>
1820

1921
namespace Kratos
@@ -272,23 +274,6 @@ double SteadyStatePwPipingElement<3, 8>::CalculateHeadGradient(const PropertiesT
272274
<< std::endl;
273275
}
274276

275-
/// <summary>
276-
/// Calculate the particle diameter for the particles in the pipe. The particle diameter equals d70,
277-
/// when the unmodified sellmeijer piping rule is used.
278-
/// </summary>
279-
/// <param name="Prop"></param>
280-
/// <param name="Geom"></param>
281-
/// <returns></returns>
282-
template <unsigned int TDim, unsigned int TNumNodes>
283-
double SteadyStatePwPipingElement<TDim, TNumNodes>::CalculateParticleDiameter(const PropertiesType& Prop)
284-
{
285-
double diameter;
286-
287-
if (Prop[PIPE_MODIFIED_D]) diameter = 2.08e-4 * pow((Prop[PIPE_D_70] / 2.08e-4), 0.4);
288-
else diameter = Prop[PIPE_D_70];
289-
return diameter;
290-
}
291-
292277
/// <summary>
293278
/// Calculates the equilibrium pipe height of a piping element according to Sellmeijers rule
294279
/// </summary>
@@ -310,7 +295,7 @@ double SteadyStatePwPipingElement<TDim, TNumNodes>::CalculateEquilibriumPipeHeig
310295
double dhdx = CalculateHeadGradient(Prop, Geom, pipe_length);
311296

312297
// calculate particle diameter
313-
double particle_d = CalculateParticleDiameter(Prop);
298+
double particle_d = GeoTransportEquationUtilities::CalculateParticleDiameter(Prop);
314299

315300
// todo calculate slope of pipe, currently pipe is assumed to be horizontal
316301
const double pipeSlope = 0;

applications/GeoMechanicsApplication/custom_elements/steady_state_Pw_piping_element.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) SteadyStatePwPipingElement
119119
std::vector<double>& rValues,
120120
const ProcessInfo& rCurrentProcessInfo) override;
121121

122-
double CalculateParticleDiameter(const PropertiesType& Prop);
123-
124122
double pipe_initialised = false;
125123

126124
private:

applications/GeoMechanicsApplication/custom_strategies/strategies/geo_mechanics_newton_raphson_erosion_process_strategy.hpp

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "boost/range/adaptor/filtered.hpp"
2323
#include "custom_elements/steady_state_Pw_piping_element.hpp"
2424
#include "custom_strategies/strategies/geo_mechanics_newton_raphson_strategy.hpp"
25+
#include "custom_utilities/transport_equation_utilities.hpp"
2526
#include "geo_mechanics_application_variables.h"
2627

2728
#include <chrono>
@@ -45,11 +46,9 @@ class GeoMechanicsNewtonRaphsonErosionProcessStrategy
4546
using DofsArrayType = typename BaseType::DofsArrayType;
4647
using TSystemMatrixType = typename BaseType::TSystemMatrixType;
4748
using TSystemVectorType = typename BaseType::TSystemVectorType;
48-
using filtered_elements =
49-
typename boost::range_detail::filtered_range<std::function<bool(Element*)>, std::vector<Element*>>;
50-
using PropertiesType = Properties;
51-
using NodeType = Node;
52-
using GeometryType = Geometry<NodeType>;
49+
using PropertiesType = Properties;
50+
using NodeType = Node;
51+
using GeometryType = Geometry<NodeType>;
5352

5453
GeoMechanicsNewtonRaphsonErosionProcessStrategy(ModelPart& model_part,
5554
typename TSchemeType::Pointer pScheme,
@@ -76,7 +75,17 @@ class GeoMechanicsNewtonRaphsonErosionProcessStrategy
7675

7776
// get piping elements
7877
std::vector<Element*> PipeElements = GetPipingElements();
79-
unsigned int n_el = PipeElements.size(); // number of piping elements
78+
79+
auto piping_interface_elements = std::vector<SteadyStatePwPipingElement<2, 4>*>{};
80+
std::transform(
81+
PipeElements.begin(), PipeElements.end(), std::back_inserter(piping_interface_elements),
82+
[](auto p_element) { return dynamic_cast<SteadyStatePwPipingElement<2, 4>*>(p_element); });
83+
KRATOS_DEBUG_ERROR_IF(std::any_of(piping_interface_elements.begin(),
84+
piping_interface_elements.end(), [](auto p_element) {
85+
return p_element == nullptr;
86+
})) << "Not all open piping elements could be downcast to SteadyStatePwPipingElement<2, 4>*\n";
87+
88+
unsigned int n_el = PipeElements.size(); // number of piping elements
8089

8190
// get initially open pipe elements
8291
unsigned int openPipeElements = this->InitialiseNumActivePipeElements(PipeElements);
@@ -104,7 +113,7 @@ class GeoMechanicsNewtonRaphsonErosionProcessStrategy
104113
std::function<bool(Element*)> filter = [](Element* i) {
105114
return i->Has(PIPE_ACTIVE) && i->GetValue(PIPE_ACTIVE);
106115
};
107-
filtered_elements OpenPipeElements = PipeElements | boost::adaptors::filtered(filter);
116+
auto OpenPipeElements = piping_interface_elements | boost::adaptors::filtered(filter);
108117
KRATOS_INFO_IF("PipingLoop", this->GetEchoLevel() > 0 && rank == 0)
109118
<< "Number of Open Pipe Elements: " << boost::size(OpenPipeElements) << std::endl;
110119

@@ -242,21 +251,6 @@ class GeoMechanicsNewtonRaphsonErosionProcessStrategy
242251
return nOpenElements;
243252
}
244253

245-
/// <summary>
246-
/// Calculates the pipe particle diameter according to the modified Sellmeijer rule if selected.
247-
/// Else the pipe particle diameter is equal to the d70.
248-
/// </summary>
249-
/// <param name="Prop"></param>
250-
/// <returns></returns>
251-
double CalculateParticleDiameter(const PropertiesType& Prop)
252-
{
253-
double diameter;
254-
255-
if (Prop[PIPE_MODIFIED_D]) diameter = 2.08e-4 * pow((Prop[PIPE_D_70] / 2.08e-4), 0.4);
256-
else diameter = Prop[PIPE_D_70];
257-
return diameter;
258-
}
259-
260254
/// <summary>
261255
/// Calculates the maximum pipe height which the algorithm will allow
262256
/// </summary>
@@ -270,8 +264,8 @@ class GeoMechanicsNewtonRaphsonErosionProcessStrategy
270264
// loop over all elements
271265
for (Element* pipe_element : pipe_elements) {
272266
// calculate pipe particle diameter of pipe element
273-
PropertiesType prop = pipe_element->GetProperties();
274-
double particle_diameter = this->CalculateParticleDiameter(prop);
267+
PropertiesType prop = pipe_element->GetProperties();
268+
double particle_diameter = GeoTransportEquationUtilities::CalculateParticleDiameter(prop);
275269

276270
// get maximum pipe particle diameter of all pipe elements
277271
if (particle_diameter > max_diameter) {
@@ -310,7 +304,8 @@ class GeoMechanicsNewtonRaphsonErosionProcessStrategy
310304
GeoMechanicsNewtonRaphsonStrategy<TSparseSpace, TDenseSpace, TLinearSolver>::FinalizeSolutionStep();
311305
}
312306

313-
bool check_pipe_equilibrium(filtered_elements open_pipe_elements, double amax, unsigned int mPipingIterations)
307+
template <typename FilteredElementType>
308+
bool check_pipe_equilibrium(const FilteredElementType& open_pipe_elements, double amax, unsigned int mPipingIterations)
314309
{
315310
bool equilibrium = false;
316311
bool converged = true;
@@ -338,13 +333,12 @@ class GeoMechanicsNewtonRaphsonErosionProcessStrategy
338333
// Update depth of open piping Elements
339334
equilibrium = true;
340335
for (auto OpenPipeElement : open_pipe_elements) {
341-
auto pElement = static_cast<SteadyStatePwPipingElement<2, 4>*>(OpenPipeElement);
342336
// get open pipe element geometry and properties
343337
auto& Geom = OpenPipeElement->GetGeometry();
344338
auto& prop = OpenPipeElement->GetProperties();
345339

346340
// calculate equilibrium pipe height and get current pipe height
347-
double eq_height = pElement->CalculateEquilibriumPipeHeight(
341+
double eq_height = OpenPipeElement->CalculateEquilibriumPipeHeight(
348342
prop, Geom, OpenPipeElement->GetValue(PIPE_ELEMENT_LENGTH));
349343
double current_height = OpenPipeElement->GetValue(PIPE_HEIGHT);
350344

@@ -420,13 +414,14 @@ class GeoMechanicsNewtonRaphsonErosionProcessStrategy
420414
/// <param name="open_pipe_elements"> open pipe elements</param>
421415
/// <param name="grow"> boolean to check if pipe grows</param>
422416
/// <returns></returns>
423-
void save_or_reset_pipe_heights(filtered_elements open_pipe_elements, bool grow)
417+
template <typename FilteredElementType>
418+
void save_or_reset_pipe_heights(const FilteredElementType& open_pipe_elements, bool grow)
424419
{
425-
for (Element* OpenPipeElement : open_pipe_elements) {
420+
for (auto p_element : open_pipe_elements) {
426421
if (grow) {
427-
OpenPipeElement->SetValue(PREV_PIPE_HEIGHT, OpenPipeElement->GetValue(PIPE_HEIGHT));
422+
p_element->SetValue(PREV_PIPE_HEIGHT, p_element->GetValue(PIPE_HEIGHT));
428423
} else {
429-
OpenPipeElement->SetValue(PIPE_HEIGHT, OpenPipeElement->GetValue(PREV_PIPE_HEIGHT));
424+
p_element->SetValue(PIPE_HEIGHT, p_element->GetValue(PREV_PIPE_HEIGHT));
430425
}
431426
}
432427
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// KRATOS___
2+
// // ) )
3+
// // ___ ___
4+
// // ____ //___) ) // ) )
5+
// // / / // // / /
6+
// ((____/ / ((____ ((___/ / MECHANICS
7+
//
8+
// License: geo_mechanics_application/license.txt
9+
//
10+
// Main authors: Anne van de Graaf
11+
//
12+
13+
#include "transport_equation_utilities.hpp"
14+
15+
namespace Kratos
16+
{
17+
18+
double GeoTransportEquationUtilities::CalculateParticleDiameter(const Properties& rProperties)
19+
{
20+
return rProperties.Has(PIPE_MODIFIED_D) && rProperties[PIPE_MODIFIED_D]
21+
? 2.08e-4 * std::pow((rProperties[PIPE_D_70] / 2.08e-4), 0.4)
22+
: rProperties[PIPE_D_70];
23+
}
24+
25+
} // namespace Kratos

applications/GeoMechanicsApplication/custom_utilities/transport_equation_utilities.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
#include "custom_retention/retention_law.h"
1919
#include "custom_utilities/stress_strain_utilities.h"
2020
#include "geo_mechanics_application_variables.h"
21+
#include "includes/kratos_export_api.h"
2122
#include "includes/variables.h"
2223

2324
namespace Kratos
2425
{
2526

26-
class GeoTransportEquationUtilities
27+
class KRATOS_API(GEO_MECHANICS_APPLICATION) GeoTransportEquationUtilities
2728
{
2829
public:
2930
template <unsigned int TDim, unsigned int TNumNodes>
@@ -156,6 +157,8 @@ class GeoTransportEquationUtilities
156157
return result;
157158
}
158159

160+
[[nodiscard]] static double CalculateParticleDiameter(const Properties& rProperties);
161+
159162
private:
160163
[[nodiscard]] static double CalculateBiotCoefficient(const Matrix& rConstitutiveMatrix,
161164
const Properties& rProperties)

0 commit comments

Comments
 (0)