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.
apply_ray_casting_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: Pooyan Dadvand, Ruben Zorrilla
11 //
12 
13 #if !defined(KRATOS_APPLY_RAY_CASTING_PROCESS_H_INCLUDED )
14 #define KRATOS_APPLY_RAY_CASTING_PROCESS_H_INCLUDED
15 
16 // System includes
17 #include <string>
18 #include <iostream>
19 
20 // External includes
21 
22 // Project includes
24 
25 namespace Kratos
26 {
29 
32 
34 
36 template<std::size_t TDim = 3>
37 class KRATOS_API(KRATOS_CORE) ApplyRayCastingProcess : public Process
38 {
39 
40 public:
43 
44  //TODO: delete after deprecated constructor are removed.
46  enum class DistanceDatabase {
47  NodeHistorical,
48  NodeNonHistorical
49  };
50 
53 
54  KRATOS_REGISTRY_ADD_TEMPLATE_PROTOTYPE("Processes.KratosMultiphysics", Process, ApplyRayCastingProcess, TDim)
56 
57  //TODO: These using statements have been included to make the old functions able to compile. It is still pending to update them.
61  using CellNodeDataType = ConfigurationType::cell_node_data_type;
62 
64  typedef std::vector<std::pair<double, IntersectionGeometryType*> > IntersectionsContainerType;
65 
67  using NodeScalarGetFunctionType = std::function<double&(NodeType& rNode, const Variable<double>& rDistanceVariable)>;
68  using ApplyNodalFunctorType = std::function<void(NodeType&, const double)>;
69 
73 
83  ModelPart& rVolumePart,
84  ModelPart& rSkinPart,
85  Parameters ThisParameters = Parameters());
86 
95  KRATOS_DEPRECATED_MESSAGE("Deprecated constructor, please use the one with Parameters.")
97  ModelPart& rVolumePart,
98  ModelPart& rSkinPart,
99  const double RelativeTolerance);
100 
108  FindIntersectedGeometricalObjectsProcess& TheFindIntersectedObjectsProcess,
109  Parameters ThisParameters = Parameters());
110 
119  KRATOS_DEPRECATED_MESSAGE("Deprecated constructor, please use the one with Parameters.")
121  FindIntersectedGeometricalObjectsProcess& TheFindIntersectedObjectsProcess,
122  const double RelativeTolerance,
123  const Variable<double>* pDistanceVariable,
124  const DistanceDatabase& rDistanceDatabase);
125 
127  ~ApplyRayCastingProcess() override;
128 
132 
135  {
136  mIsSearchStructureAllocated = false; //used in dtor
137  }
138 
141 
144 
148 
149  const Parameters GetDefaultParameters() const override;
150 
159  virtual double DistancePositionInSpace(const Node &rNode);
160 
172  virtual void GetRayIntersections(
173  const double* ray,
174  const unsigned int direction,
175  std::vector<std::pair<double,Element::GeometryType*> > &rIntersections);
176 
189  virtual int GetCellIntersections(
190  OctreeType::cell_type* cell,
191  const double* ray,
192  OctreeType::key_type* ray_key,
193  const unsigned int direction,
194  std::vector<std::pair<double, Element::GeometryType*> > &rIntersections);
195 
200  void Execute() override;
201 
205 
207  std::string Info() const override;
208 
210  void PrintInfo(std::ostream& rOStream) const override;
211 
213  void PrintData(std::ostream& rOStream) const override;
214 
216 protected:
219 
220 
224 
226  double mEpsilon;
232  const Variable<double>* mpDistanceVariable = nullptr;
234 
235 
239 
240 
244 
255  Element::GeometryType& rGeometry,
256  const double* pRayPoint1,
257  const double* pRayPoint2,
258  double* pIntersectionPoint);
259 
269  const array_1d<double,3> &rCoords,
270  array_1d<array_1d<double,3>, (TDim == 3) ? 9 : 5> &rExtraRayOrigs);
271 
272 
276  void CorrectExtraRayOrigin(double* ExtraRayCoords);
277 
286  void ComputeExtraRayColors(
287  const array_1d<double,3> &rCoords,
288  array_1d<double,TDim> &rDistances);
289 
290 
296  void CalculateCharacteristicLength();
297 
302  void SetRayCastingTolerances();
303 
307  NodeScalarGetFunctionType CreateDistanceGetterFunctor() const;
308 
313  virtual ApplyNodalFunctorType CreateApplyNodalFunction() const;
314 
318 
319 
323 
324 
328 
329 
330 
332 }; // Class ApplyRayCastingProcess
333 
337 
338 
342 
344 inline std::istream& operator >> (
345  std::istream& rIStream,
346  ApplyRayCastingProcess<>& rThis);
347 
349 inline std::ostream& operator << (
350  std::ostream& rOStream,
351  const ApplyRayCastingProcess<>& rThis)
352 {
353  rThis.PrintInfo(rOStream);
354  rOStream << std::endl;
355  rThis.PrintData(rOStream);
356 
357  return rOStream;
358 }
361 
362 } // namespace Kratos.
363 
364 #endif // KRATOS_APPLY_RAY_CASTING_PROCESS_H_INCLUDED defined
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Applies ray casting to distinguish the color (like in/out) of each node in modelpart.
Definition: apply_ray_casting_process.h:38
int ComputeRayIntersection(Element::GeometryType &rGeometry, const double *pRayPoint1, const double *pRayPoint2, double *pIntersectionPoint)
Checks if a ray intersects an intersecting geometry candidate For a given intersecting geometry,...
FindIntersectedGeometricalObjectsProcess * mpFindIntersectedObjectsProcess
Definition: apply_ray_casting_process.h:229
NodeScalarGetFunctionType mDistanceGetterFunctor
Definition: apply_ray_casting_process.h:233
double mCharacteristicLength
Definition: apply_ray_casting_process.h:231
double mExtraRayOffset
Definition: apply_ray_casting_process.h:227
double mEpsilon
Definition: apply_ray_casting_process.h:226
std::function< void(NodeType &, const double)> ApplyNodalFunctorType
Definition: apply_ray_casting_process.h:68
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: apply_ray_casting_process.cpp:526
double mRelativeTolerance
Definition: apply_ray_casting_process.h:228
Parameters mSettings
Definition: apply_ray_casting_process.h:225
ApplyRayCastingProcess(ApplyRayCastingProcess const &rOther)=delete
Copy constructor.
ApplyRayCastingProcess & operator=(ApplyRayCastingProcess const &rOther)=delete
Assignment operator.
KRATOS_CLASS_POINTER_DEFINITION(ApplyRayCastingProcess)
Pointer definition of ApplyRayCastingProcess.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: apply_ray_casting_process.cpp:533
bool mIsSearchStructureAllocated
Definition: apply_ray_casting_process.h:230
std::vector< std::pair< double, IntersectionGeometryType * > > IntersectionsContainerType
Definition: apply_ray_casting_process.h:64
DistanceDatabase
Nodal databases auxiliary enum.
Definition: apply_ray_casting_process.h:46
void GetExtraRayOrigins(const array_1d< double, 3 > &rCoords, array_1d< array_1d< double, 3 >,(TDim==3) ? 9 :5 > &rExtraRayOrigs)
Creates the start point in space for new extra rays around current ray This method is used to create ...
std::function< double &(NodeType &rNode, const Variable< double > &rDistanceVariable)> NodeScalarGetFunctionType
Definition: apply_ray_casting_process.h:67
Definition: calculate_signed_distance_to_3d_skin_process.h:58
Base class for all Elements.
Definition: element.h:60
This class takes two modelparts and marks the intersected ones with SELECTED flag.
Definition: find_intersected_geometrical_objects_process.h:321
Geometry base class.
Definition: geometry.h:71
This class contains the cell node data.
Definition: find_intersected_geometrical_objects_process.h:51
This class contains the tools related with the distance spatial container cell data.
Definition: find_intersected_geometrical_objects_process.h:42
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 represents a cell in an octree to be used with Octree class.
Definition: octree_binary_cell.h:70
CellType cell_type
Definition: octree_binary.h:68
cell_type::key_type key_type
Definition: octree_binary.h:70
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
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_REGISTRY_ADD_TEMPLATE_PROTOTYPE(NAME, X, Y,...)
Definition: define_registry.h:56
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
namespace KRATOS_DEPRECATED_MESSAGE("Please use std::filesystem directly") filesystem
Definition: kratos_filesystem.h:33
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
tuple const
Definition: ode_solve.py:403
namespace
Definition: array_1d.h:793