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.
distance_modification_process.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Ruben Zorrilla
11 //
12 //
13 
14 #ifndef KRATOS_DISTANCE_MODIFICATION_PROCESS_H
15 #define KRATOS_DISTANCE_MODIFICATION_PROCESS_H
16 
17 // System includes
18 #include <string>
19 #include <iostream>
20 
21 // External includes
22 
23 // Project includes
24 #include "includes/define.h"
25 #include "processes/process.h"
27 
28 // Application includes
29 
30 
31 namespace Kratos
32 {
35 
38 
42 
46 
50 
54 
57 class KRATOS_API(FLUID_DYNAMICS_APPLICATION) DistanceModificationProcess : public Process
58 {
59 public:
62 
64 
65  static constexpr std::array<std::array<std::size_t,2>, 3> NodeIDs2D {{ {{1,2}}, {{2,0}}, {{0,1}} }};
66  static constexpr std::array<std::array<std::size_t,2>, 6> NodeIDs3D {{ {{0,1}}, {{1,2}}, {{2,0}}, {{0,3}}, {{1,3}}, {{2,3}} }};
67 
70 
74 
77  ModelPart& rModelPart,
78  const double FactorCoeff, //TODO: Remove it (here for legacy reasons)
79  const double DistanceThreshold,
80  const bool CheckAtEachStep,
81  const bool NegElemDeactivation,
82  const bool RecoverOriginalDistance);
83 
86  ModelPart& rModelPart,
87  Parameters& rParameters);
88 
91  Model& rModel,
92  Parameters& rParameters);
93 
96 
100 
101  void Execute() override;
102 
103  void ExecuteInitialize() override;
104 
105  void ExecuteBeforeSolutionLoop() override;
106 
107  void ExecuteInitializeSolutionStep() override;
108 
109  void ExecuteFinalizeSolutionStep() override;
110 
114 
118 
122 
126 
128  std::string Info() const override
129  {
130  std::stringstream buffer;
131  buffer << "DistanceModificationProcess" ;
132  return buffer.str();
133  }
134 
136  void PrintInfo(std::ostream& rOStream) const override {rOStream << "DistanceModificationProcess";}
137 
139  void PrintData(std::ostream& rOStream) const override {}
140 
141 
145 
147 
148 private:
151 
155 
156  ModelPart& mrModelPart;
157  double mDistanceThreshold;
158  bool mIsModified;
159  bool mContinuousDistance;
160  bool mCheckAtEachStep;
161  bool mNegElemDeactivation;
162  bool mAvoidAlmostEmptyElements;
163  bool mRecoverOriginalDistance;
164  std::vector<std::size_t> mModifiedDistancesIDs;
165  std::vector<double> mModifiedDistancesValues;
166  std::vector<Vector> mModifiedElementalDistancesValues;
167  std::vector<const Variable<double>*> mDoubleVariablesList;
168  std::vector<const ComponentType*> mComponentVariablesList;
169 
173 
177 
178  void CheckDefaultsAndProcessSettings(Parameters &rParameters);
179 
186  void InitializeEmbeddedIsActive();
187 
188  void ModifyDistance();
189 
190  void ModifyDiscontinuousDistance();
191 
192  void RecoverDeactivationPreviousState();
193 
194  void RecoverOriginalDistance();
195 
196  void RecoverOriginalDiscontinuousDistance();
197 
198  void DeactivateFullNegativeElements();
199 
200  template<class TDistancesVectorType>
201  void SetElementToSplitFlag(
202  Element &rElem,
203  const TDistancesVectorType& rDistancesVector)
204  {
205  std::size_t n_pos = 0;
206  std::size_t n_neg = 0;
207  for (double i_dist : rDistancesVector) {
208  if (i_dist < 0.0) {
209  n_neg++;
210  } else {
211  n_pos++;
212  }
213  }
214  if (n_neg != 0 && n_pos != 0) {
215  rElem.Set(TO_SPLIT, true);
216  } else {
217  rElem.Set(TO_SPLIT, false);
218  }
219  }
220 
221  void SetContinuousDistanceToSplitFlag();
222 
223  void SetDiscontinuousDistanceToSplitFlag();
224 
231  void CheckAndStoreVariablesList(const std::vector<std::string>& rVariableStringArray);
232 
241  const std::array<std::size_t,2> GetNodeIDs(
242  const std::size_t NumEdges,
243  const std::size_t EdgeID);
244 
248 
249 
253 
254 
258 
260  DistanceModificationProcess() = delete;
261 
263  DistanceModificationProcess& operator=(DistanceModificationProcess const& rOther) = delete;
264 
266  DistanceModificationProcess(DistanceModificationProcess const& rOther) = delete;
267 
269 
270 }; // Class DistanceModificationProcess
271 
275 
279 
281 
283 
284 }; // namespace Kratos.
285 
286 #endif // KRATOS_DISTANCE_MODIFICATION_PROCESS_H
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: periodic_interface_process.hpp:55
void ExecuteInitialize() override
Definition: periodic_interface_process.hpp:37
Definition: distance_modification_process.h:58
Variable< double > ComponentType
Definition: distance_modification_process.h:63
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: distance_modification_process.h:139
std::string Info() const override
Turn back information as a string.
Definition: distance_modification_process.h:128
KRATOS_CLASS_POINTER_DEFINITION(DistanceModificationProcess)
Pointer definition of DistanceModificationProcess.
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: distance_modification_process.h:136
~DistanceModificationProcess() override
Destructor.
Definition: distance_modification_process.h:95
Base class for all Elements.
Definition: element.h:60
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
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 provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
The base class for all processes in Kratos.
Definition: process.h:49
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21