KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
dgeoflow.h
Go to the documentation of this file.
1 // KRATOS___
2 // // ) )
3 // // ___ ___
4 // // ____ //___) ) // ) )
5 // // / / // // / /
6 // ((____/ / ((____ ((___/ / MECHANICS
7 //
8 // License: geo_mechanics_application/license.txt
9 //
10 // Main authors: Jonathan Nuttall
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 /* External includes */
18 
19 #include "includes/kernel.h"
21 
22 /* Utility includes */
23 #include "includes/model_part.h"
24 #include "spaces/ublas_space.h"
25 
26 // Linear solvers
28 
29 // The most basic scheme (static)
31 
32 // The most builder and solver (the block builder and solver)
34 
35 // The strategies to test
36 #include <custom_processes/apply_component_table_process.hpp>
37 #include <custom_processes/apply_constant_hydrostatic_pressure_process.hpp>
39 
43 
45 
46 namespace Kratos
47 {
48 
49 class KRATOS_API(GEO_MECHANICS_APPLICATION) KratosExecute
50 {
51 public:
52  KratosExecute();
53 
54  using NodeType = Node;
57 
58  // The direct solver
61 
62  // The convergence criteria type
66 
69 
70  // Dof arrays
72 
73  static ConvergenceCriteriaType::Pointer setup_criteria_dgeoflow();
74  static LinearSolverType::Pointer setup_solver_dgeoflow();
75  static GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer setup_strategy_dgeoflow(ModelPart& rModelPart);
76  void ParseProcesses(ModelPart& rModelPart, Parameters projFile);
77 
79  double minCriticalHead = 0.0;
80  double maxCriticalHead = 0.0;
81  double stepCriticalHead = 0.0;
82 
83  CriticalHeadInfo(double minCriticalHead, double maxCriticalHead, double stepCriticalHead)
84  : minCriticalHead(minCriticalHead), maxCriticalHead(maxCriticalHead), stepCriticalHead(stepCriticalHead)
85  {
86  }
87  };
88 
90  std::function<void(const char*)> LogCallback;
91  std::function<void(double)> ReportProgress;
92  std::function<void(const char*)> ReportTextualProgress;
93  std::function<bool()> ShouldCancel;
94 
95  CallBackFunctions(std::function<void(const char*)> LogCallback,
96  std::function<void(double)> ReportProgress,
97  std::function<void(const char*)> ReportTextualProgress,
98  std::function<bool()> ShouldCancel)
99  : LogCallback(std::move(LogCallback)),
100  ReportProgress(std::move(ReportProgress)),
101  ReportTextualProgress(std::move(ReportTextualProgress)),
102  ShouldCancel(std::move(ShouldCancel))
103  {
104  }
105  };
106 
107  int ExecuteFlowAnalysis(std::string_view WorkingDirectory,
108  const std::string& rProjectParamsFileName,
109  const CriticalHeadInfo& rCriticalHeadInfo,
110  std::string_view CriticalHeadBoundaryModelPartName,
111  const CallBackFunctions& rCallBackFunctions);
112 
113  void ExecuteWithoutPiping(ModelPart& rModelPart,
114  const Kratos::Parameters& rGidOutputSettings,
115  const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy) const;
116 
117  int ExecuteWithPiping(ModelPart& rModelPart,
118  const Kratos::Parameters& rGidOutputSettings,
119  const CriticalHeadInfo& rCriticalHeadInfo,
120  LoggerOutput::Pointer pOutput,
121  const CallBackFunctions& rCallBackFunctions,
122  const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy);
123 
124  void WriteCriticalHeadResultToFile() const;
125 
126  void AddNodalSolutionStepVariables(ModelPart& rModelPart) const;
127 
128  int FindCriticalHead(ModelPart& rModelPart,
129  const Kratos::Parameters& rGidOutputSettings,
130  const CriticalHeadInfo& rCriticalHeadInfo,
131  LoggerOutput::Pointer pOutput,
132  const shared_ptr<Process>& pRiverBoundary,
133  const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy,
134  const CallBackFunctions& rCallBackFunctions);
135 
136  void HandleCriticalHeadFound(const CriticalHeadInfo& rCriticalHeadInfo);
137 
138  void HandleCleanUp(const CallBackFunctions& rCallBackFunctions, LoggerOutput::Pointer pOutput);
139 
140 private:
141  // Initial Setup
142  Model mCurrentModel;
143  Kernel mKernel;
144  KratosGeoMechanicsApplication::Pointer mpGeoApp;
145  std::string mWorkingDirectory;
146  std::string mCriticalHeadBoundaryModelPartName;
147  bool mPipingSuccess = false;
148  double mCriticalHead = 0.0;
149  double mCurrentHead = 0.0;
150  std::vector<std::shared_ptr<Process>> mProcesses;
151  int mEchoLevel = 1;
152 
153  void ResetModelParts();
154 
155  [[nodiscard]] int GetEchoLevel() const;
156 
157  void SetEchoLevel(int level);
158 
159  shared_ptr<Process> FindRiverBoundaryByName(const std::string& CriticalHeadBoundaryModelPartName) const;
160 
161  shared_ptr<Process> FindRiverBoundaryAutomatically(
162  const KratosExecute::GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer rpSolvingStrategy) const;
163 
164  int MainExecution(ModelPart& rModelPart,
165  const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer rpSolvingStrategy,
166  double Time,
167  double DeltaTime,
168  unsigned int NumberOfIterations) const;
169 
170  bool AreExceedingMaxCriticalHead(double CurrentHead, double MaxCriticalHead) const;
171 };
172 } // namespace Kratos
This is the base class to define the different convergence criterion considered.
Definition: convergence_criteria.h:58
Definition: geo_mechanics_newton_raphson_erosion_process_strategy.hpp:38
Kernel is in charge of synchronization the whole system of Kratos itself and its application.
Definition: kernel.h:53
Definition: dgeoflow.h:50
typename MixedGenericCriteriaType::ConvergenceVariableListType ConvergenceVariableListType
Definition: dgeoflow.h:65
Base class for all the linear solvers in Kratos.
Definition: linear_solver.h:65
Convergence criteria for mixed vector-scalar problems.
Definition: mixed_generic_criteria.h:42
std::vector< std::tuple< const VariableData *, TDataType, TDataType > > ConvergenceVariableListType
Definition: mixed_generic_criteria.h:61
This class aims to manage different model parts across multi-physics simulations.
Definition: model.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
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
A functor that serves as the identity function.
Definition: set_identity_function.h:43
Definition: skyline_lu_factorization_solver.h:562
A class template for handling data types, matrices, and vectors in a Ublas space.
Definition: ublas_space.h:121
void SetEchoLevel(const int EchoLevel)
Definition: add_custom_io_to_python.cpp:344
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
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
namespace
Definition: array_1d.h:793
std::function< void(const char *)> ReportTextualProgress
Definition: dgeoflow.h:92
std::function< bool()> ShouldCancel
Definition: dgeoflow.h:93
std::function< void(double)> ReportProgress
Definition: dgeoflow.h:91
std::function< void(const char *)> LogCallback
Definition: dgeoflow.h:90
CallBackFunctions(std::function< void(const char *)> LogCallback, std::function< void(double)> ReportProgress, std::function< void(const char *)> ReportTextualProgress, std::function< bool()> ShouldCancel)
Definition: dgeoflow.h:95
CriticalHeadInfo(double minCriticalHead, double maxCriticalHead, double stepCriticalHead)
Definition: dgeoflow.h:83