22 #include "boost/range/adaptor/filtered.hpp"
35 template <
class TSparseSpace,
class TDenseSpace,
class TLinearSolver>
50 typename boost::range_detail::filtered_range<std::function<
bool(
Element*)>, std::vector<Element*>>;
56 typename TSchemeType::Pointer pScheme,
57 typename TLinearSolver::Pointer pNewLinearSolver,
58 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
59 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
61 int MaxIterations = 30,
62 bool CalculateReactions =
false,
63 bool ReformDofSetAtEachStep =
false,
69 pNewConvergenceCriteria,
74 ReformDofSetAtEachStep,
78 mPipingIterations = rParameters[
"max_piping_iterations"].
GetInt();
84 <<
"Max Piping Iterations: " << mPipingIterations << std::endl;
90 unsigned int n_el = PipeElements.size();
93 unsigned int openPipeElements = this->InitialiseNumActivePipeElements(PipeElements);
95 if (PipeElements.empty()) {
97 <<
"No Pipe Elements -> Finalizing Solution " << std::endl;
102 double amax = CalculateMaxPipeHeight(PipeElements);
105 while (grow && (openPipeElements < n_el)) {
110 Element* tip_element = PipeElements.at(openPipeElements);
111 openPipeElements += 1;
112 tip_element->
SetValue(PIPE_ACTIVE,
true);
116 return i->Has(PIPE_ACTIVE) &&
i->GetValue(PIPE_ACTIVE);
118 filtered_elements OpenPipeElements = PipeElements | boost::adaptors::filtered(filter);
120 <<
"Number of Open Pipe Elements: " << boost::size(OpenPipeElements) << std::endl;
125 check_pipe_equilibrium(OpenPipeElements, amax, mPipingIterations);
128 std::tie(grow, openPipeElements) =
129 check_status_tip_element(openPipeElements, n_el, amax, PipeElements);
133 if (openPipeElements < n_el) {
134 save_or_reset_pipe_heights(OpenPipeElements, grow);
137 bool converged = Recalculate();
140 KRATOS_ERROR_IF_NOT(converged) <<
"Groundwater flow calculation failed to converge." << std::endl;
167 std::vector<Element*> PipeElements;
168 double PipeElementStartX;
171 if (
element.GetProperties().Has(PIPE_START_ELEMENT)) {
172 PipeElements.push_back(&
element);
174 long unsigned int startElement =
element.GetProperties()[PIPE_START_ELEMENT];
177 <<
element.Id() <<
" " << startElement << std::endl;
179 if (
element.Id() == startElement) {
180 PipeElementStartX =
element.GetGeometry().GetPoint(0)[0];
185 if (PipeElements.empty()) {
190 auto rightPipe = std::max_element(PipeElements.begin(), PipeElements.end(),
192 return a->GetGeometry().GetPoint(0)[0] < b->GetGeometry().GetPoint(0)[0];
196 auto leftPipe = std::min_element(PipeElements.begin(), PipeElements.end(),
198 return a->GetGeometry().GetPoint(0)[0] < b->GetGeometry().GetPoint(0)[0];
201 double minX = leftPipe[0]->GetGeometry().GetPoint(0)[0];
202 double maxX = rightPipe[0]->GetGeometry().GetPoint(0)[0];
205 << minX <<
" " << maxX <<
" " << PipeElementStartX << std::endl;
207 if ((minX != PipeElementStartX) && (maxX != PipeElementStartX)) {
208 KRATOS_ERROR <<
"Unable to determine pipe direction (multiple directions possible) - "
209 "Check PIPE_START_ELEMENT"
213 if (minX == PipeElementStartX) {
216 return lhs->GetGeometry().GetPoint(0)[0] < rhs->GetGeometry().GetPoint(0)[0];
221 return lhs->GetGeometry().GetPoint(0)[0] > rhs->GetGeometry().GetPoint(0)[0];
226 <<
"Number of Pipe Elements: " << PipeElements.size() << std::endl;
227 for (
const Element* pipeElement : PipeElements) {
229 <<
"PipeElementIDs (in order): " << pipeElement->Id() << std::endl;
236 unsigned int mPipingIterations;
238 double small_pipe_height = 1
e-10;
239 double pipe_height_accuracy = small_pipe_height * 10;
247 int InitialiseNumActivePipeElements(std::vector<Element*> PipeElements)
249 int nOpenElements = 0;
251 for (
Element* pipe_element : PipeElements) {
252 if (pipe_element->GetValue(PIPE_ACTIVE)) {
256 return nOpenElements;
269 if (Prop[PIPE_MODIFIED_D]) diameter = 2.08e-4 * pow((Prop[PIPE_D_70] / 2.08e-4), 0.4);
270 else diameter = Prop[PIPE_D_70];
279 double CalculateMaxPipeHeight(std::vector<Element*> pipe_elements)
281 double max_diameter = 0;
285 for (Element* pipe_element : pipe_elements) {
288 double particle_diameter = this->CalculateParticleDiameter(
prop);
291 if (particle_diameter > max_diameter) {
292 max_diameter = particle_diameter;
306 double CalculatePipeHeightIncrement(
double max_pipe_height,
const unsigned int n_steps)
308 return max_pipe_height / (
n_steps - 1);
314 <<
"Recalculating" << std::endl;
330 bool check_pipe_equilibrium(
filtered_elements open_pipe_elements,
double amax,
unsigned int mPipingIterations)
332 bool equilibrium =
false;
333 bool converged =
true;
334 unsigned int PipeIter = 0;
339 double da = CalculatePipeHeightIncrement(amax, mPipingIterations);
341 while (PipeIter < mPipingIterations && !equilibrium && converged) {
346 converged = Recalculate();
357 for (
auto OpenPipeElement : open_pipe_elements) {
358 auto pElement =
static_cast<SteadyStatePwPipingElement<2, 4>*
>(OpenPipeElement);
361 auto& Geom = OpenPipeElement->GetGeometry();
362 auto&
prop = OpenPipeElement->GetProperties();
365 double eq_height = pElement->CalculateEquilibriumPipeHeight(
366 prop, Geom, OpenPipeElement->GetValue(PIPE_ELEMENT_LENGTH));
367 double current_height = OpenPipeElement->GetValue(PIPE_HEIGHT);
370 if (current_height > eq_height) {
371 OpenPipeElement->SetValue(PIPE_EROSION,
true);
375 if (((!OpenPipeElement->GetValue(PIPE_EROSION) || (current_height > eq_height)) &&
376 current_height < amax)) {
377 OpenPipeElement->SetValue(PIPE_HEIGHT, OpenPipeElement->GetValue(PIPE_HEIGHT) + da);
383 if (!OpenPipeElement->GetValue(PIPE_EROSION) && (PipeIter > 1) &&
384 ((eq_height - current_height) > OpenPipeElement->GetValue(DIFF_PIPE_HEIGHT))) {
386 OpenPipeElement->SetValue(PIPE_HEIGHT, small_pipe_height);
390 OpenPipeElement->SetValue(DIFF_PIPE_HEIGHT, eq_height - current_height);
407 std::tuple<bool, int> check_status_tip_element(
unsigned int n_open_elements,
408 unsigned int n_elements,
409 double max_pipe_height,
410 std::vector<Element*> PipeElements)
415 if (n_open_elements < n_elements) {
416 Element* tip_element = PipeElements.at(n_open_elements - 1);
417 double pipe_height = tip_element->GetValue(PIPE_HEIGHT);
419 if ((pipe_height > max_pipe_height + std::numeric_limits<double>::epsilon()) ||
420 (pipe_height < pipe_height_accuracy)) {
423 tip_element->SetValue(PIPE_EROSION,
false);
424 tip_element->SetValue(PIPE_ACTIVE,
false);
425 n_open_elements -= 1;
428 <<
"Number of Open Pipe Elements: " << n_open_elements << std::endl;
433 return std::make_tuple(grow, n_open_elements);
444 for (Element* OpenPipeElement : open_pipe_elements) {
446 OpenPipeElement->SetValue(PREV_PIPE_HEIGHT, OpenPipeElement->GetValue(PIPE_HEIGHT));
448 OpenPipeElement->SetValue(PIPE_HEIGHT, OpenPipeElement->GetValue(PREV_PIPE_HEIGHT));
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
This is the base class to define the different convergence criterion considered.
Definition: convergence_criteria.h:58
Base class for all Elements.
Definition: element.h:60
Definition: geo_mechanics_newton_raphson_erosion_process_strategy.hpp:38
typename boost::range_detail::filtered_range< std::function< bool(Element *)>, std::vector< Element * > > filtered_elements
Definition: geo_mechanics_newton_raphson_erosion_process_strategy.hpp:50
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: geo_mechanics_newton_raphson_erosion_process_strategy.hpp:81
std::vector< Element * > GetPipingElements()
Definition: geo_mechanics_newton_raphson_erosion_process_strategy.hpp:164
KRATOS_CLASS_POINTER_DEFINITION(GeoMechanicsNewtonRaphsonErosionProcessStrategy)
Properties PropertiesType
Definition: geo_mechanics_newton_raphson_erosion_process_strategy.hpp:51
int Check() override
Function to perform expensive checks.
Definition: geo_mechanics_newton_raphson_erosion_process_strategy.hpp:150
GeoMechanicsNewtonRaphsonErosionProcessStrategy(ModelPart &model_part, typename TSchemeType::Pointer pScheme, typename TLinearSolver::Pointer pNewLinearSolver, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, Parameters &rParameters, int MaxIterations=30, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false)
Definition: geo_mechanics_newton_raphson_erosion_process_strategy.hpp:55
Definition: geo_mechanics_newton_raphson_strategy.hpp:31
void SetValue(const TVariableType &rThisVariable, typename TVariableType::Type const &rValue)
Definition: geometrical_object.h:238
Geometry base class.
Definition: geometry.h:71
Implicit solving strategy base class This is the base class from which we will derive all the implici...
Definition: implicit_solving_strategy.h:61
BaseType::TSystemVectorType TSystemVectorType
Definition: implicit_solving_strategy.h:72
Scheme< TSparseSpace, TDenseSpace > TSchemeType
Definition: implicit_solving_strategy.h:82
BaseType::DofsArrayType DofsArrayType
Definition: implicit_solving_strategy.h:90
BuilderAndSolver< TSparseSpace, TDenseSpace, TLinearSolver > TBuilderAndSolverType
Definition: implicit_solving_strategy.h:84
BaseType::TSystemMatrixType TSystemMatrixType
Definition: implicit_solving_strategy.h:70
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
TBuilderAndSolverType::Pointer GetBuilderAndSolver()
Get method for the builder and solver.
Definition: residualbased_newton_raphson_strategy.h:493
TSchemeType::Pointer GetScheme()
Get method for the time scheme.
Definition: residualbased_newton_raphson_strategy.h:475
bool SolveSolutionStep() override
Solves the current step. This function returns true if a solution has been found, false otherwise.
Definition: residualbased_newton_raphson_strategy.h:884
void Predict() override
Operation to predict the solution ... if it is not called a trivial predictor is used in which the va...
Definition: residualbased_newton_raphson_strategy.h:625
void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: residualbased_newton_raphson_strategy.h:781
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: residualbased_newton_raphson_strategy.h:848
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
Solving strategy base class This is the base class from which we will derive all the strategies (impl...
Definition: solving_strategy.h:64
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
int GetEchoLevel()
This returns the level of echo for the solving strategy.
Definition: solving_strategy.h:271
virtual int Check()
Function to perform expensive checks.
Definition: solving_strategy.h:377
bool MoveMeshFlag()
This function returns the flag that says if the mesh is moved.
Definition: solving_strategy.h:290
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
REACTION_CHECK_STIFFNESS_FACTOR INNER_LOOP_ITERATION DISTANCE_THRESHOLD ACTIVE_CHECK_FACTOR AUXILIAR_COORDINATES NORMAL_GAP WEIGHTED_GAP WEIGHTED_SCALAR_RESIDUAL bool
Definition: contact_structural_mechanics_application_variables.h:93
int n_steps
Definition: bombardelli_test.py:27
model_part
Definition: face_heat.py:14
rhs
Definition: generate_frictional_mortar_condition.py:297
lhs
Definition: generate_frictional_mortar_condition.py:297
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
prop
Definition: read_stl.py:10
height_factor
Definition: sp_statistics.py:22
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31
Definition: mesh_converter.cpp:33