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.
calculate_distance_to_boundary_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: Miguel Maso Sotomayor
11 //
12 
13 #ifndef KRATOS_CALCULATE_DISTANCE_TO_BOUNDARY_PROCESS_H_INCLUDED
14 #define KRATOS_CALCULATE_DISTANCE_TO_BOUNDARY_PROCESS_H_INCLUDED
15 
16 
17 // System includes
18 
19 
20 // External includes
21 
22 
23 // Project includes
24 #include "containers/model.h"
25 #include "processes/process.h"
26 #include "geometries/geometry.h"
28 
29 
30 namespace Kratos
31 {
34 
37 
41 
45 
49 
53 
55 class ModelPart;
56 
64 class KRATOS_API(SHALLOW_WATER_APPLICATION) CalculateDistanceToBoundaryProcess : public Process
65 {
66 public:
69 
72 
74 
75  typedef Node NodeType;
76 
80 
83  Model& rModel,
84  Parameters ThisParameters) :
85  Process(),
86  mrModelPart(rModel.GetModelPart(ThisParameters["computing_model_part_name"].GetString())),
87  mrBoundaryPart(rModel.GetModelPart(ThisParameters["absorbing_boundary_name"].GetString()))
88  {
89  msInstancesCount++;
90  mInitializeDistance = (msInstancesCount == 1);
91  ThisParameters.ValidateAndAssignDefaults(GetDefaultParameters());
92  mRSquaredThreshold = ThisParameters["r_squared_threshold"].GetDouble();
93  FindApproximatingGeometry(mpBoundary, mrBoundaryPart);
94  }
95 
98  ModelPart& rComputingModelPart,
99  ModelPart& rBoundaryModelPart,
100  double RSquaredThreshold = 0.99) :
101  Process(),
102  mrModelPart(rComputingModelPart),
103  mrBoundaryPart(rBoundaryModelPart)
104  {
105  msInstancesCount++;
106  mInitializeDistance = (msInstancesCount == 1);
107  mRSquaredThreshold = RSquaredThreshold;
108  FindApproximatingGeometry(mpBoundary, mrBoundaryPart);
109  }
110 
113  msInstancesCount--;
114  }
115 
119 
120 
124 
125  int Check() override;
126 
127  void ExecuteBeforeSolutionLoop() override;
128 
129  const Parameters GetDefaultParameters() const override;
130 
134 
135 
139 
140 
144 
146  virtual std::string Info() const override
147  {
148  std::stringstream buffer;
149  buffer << "CalculateDistanceToBoundaryProcess";
150  return buffer.str();
151  }
152 
154  virtual void PrintInfo(std::ostream& rOStream) const override
155  {
156  rOStream << Info();
157  }
158 
160  virtual void PrintData(std::ostream& rOStream) const override
161  {
162  }
163 
164 
168 
169 
171 
172 private:
175 
176  static std::size_t msInstancesCount;
177 
181 
182  ModelPart& mrModelPart;
183  ModelPart& mrBoundaryPart;
184  GeometryType::Pointer mpBoundary;
185  double mRSquaredThreshold;
186  bool mBruteForceSearch;
187  bool mInitializeDistance;
188 
192 
193 
197 
198  void FindApproximatingGeometry(GeometryType::Pointer& pEntity, const ModelPart& rBoundaryPart);
199 
200  double RSquared(const GeometryType& rLine, const ModelPart& rBoundaryPart);
201 
202  double SquaredDistance(const Point& rPointA, const Point& rPointB);
203 
204  double Distance(const Point& rPointA, const Point& rPointB);
205 
209 
210 
214 
215 
219 
222 
225 
226 
228 
229 }; // Class CalculateDistanceToBoundaryProcess
230 
232 
235 
236 
240 
241 
243 inline std::istream& operator >> (std::istream& rIStream,
245 
247 inline std::ostream& operator << (std::ostream& rOStream,
249 {
250  rThis.PrintInfo(rOStream);
251  rOStream << std::endl;
252  rThis.PrintData(rOStream);
253 
254  return rOStream;
255 }
257 
259 
260 } // namespace Kratos.
261 
262 #endif // KRATOS_CALCULATE_DISTANCE_TO_BOUNDARY_PROCESS_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Calculate the minimum distance from all the nodes to a boundary condition in 2D.
Definition: calculate_distance_to_boundary_process.h:65
CalculateDistanceToBoundaryProcess(Model &rModel, Parameters ThisParameters)
Constructor with Model and Parameters.
Definition: calculate_distance_to_boundary_process.h:82
virtual ~CalculateDistanceToBoundaryProcess()
Destructor.
Definition: calculate_distance_to_boundary_process.h:112
Node NodeType
Definition: calculate_distance_to_boundary_process.h:75
KRATOS_CLASS_POINTER_DEFINITION(CalculateDistanceToBoundaryProcess)
Pointer definition of CalculateDistanceToBoundaryProcess.
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: calculate_distance_to_boundary_process.h:154
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: calculate_distance_to_boundary_process.h:160
Geometry< Point > GeometryType
Definition: calculate_distance_to_boundary_process.h:73
virtual std::string Info() const override
Turn back information as a string.
Definition: calculate_distance_to_boundary_process.h:146
CalculateDistanceToBoundaryProcess(ModelPart &rComputingModelPart, ModelPart &rBoundaryModelPart, double RSquaredThreshold=0.99)
Constructor with ModelPart.
Definition: calculate_distance_to_boundary_process.h:97
Geometry base class.
Definition: geometry.h:71
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
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
Point class.
Definition: point.h:59
The base class for all processes in Kratos.
Definition: process.h:49
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432