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.
closest_points.h
Go to the documentation of this file.
1 
2 // | / |
3 // ' / __| _` | __| _ \ __|
4 // . \ | ( | | ( |\__ `
5 // _|\_\_| \__,_|\__|\___/ ____/
6 // Multi-Physics
7 //
8 // License: BSD License
9 // Kratos default license: kratos/license.txt
10 //
11 // Main authors: Philipp Bucher (https://github.com/philbucher)
12 //
13 
14 #pragma once
15 
16 // System includes
17 #include <set>
18 #include <limits>
19 
20 // External includes
21 
22 // Project includes
23 #include "includes/define.h"
25 #include "includes/serializer.h"
26 #include "geometries/point.h"
27 
28 namespace Kratos
29 {
32 
33 class KRATOS_API(MAPPING_APPLICATION) PointWithId : public IndexedObject, public Point
34 {
35 public:
37 
38  PointWithId(const IndexType NewId, const CoordinatesArrayType& rCoords, const double Distance);
39 
40  // Copy constructor
41  PointWithId(const PointWithId& rOther);
42 
43  PointWithId& operator=(const PointWithId& rOther) = delete;
44 
45  bool operator<(const PointWithId& rOther) const;
46 
47  double GetDistance() const { return mDistance; }
48 
49 private:
52 
53  double mDistance;
54 
56 
59 
60  // default CTor for Serializer
61  PointWithId() = default;
62 
63  friend class Serializer;
64 
65  void save(Serializer &rSerializer) const override;
66 
67  void load(Serializer &rSerializer) override;
68 
70 };
71 
72 
73 class KRATOS_API(MAPPING_APPLICATION) ClosestPointsContainer
74 {
75 public:
76  using ContainerType = std::set<PointWithId>;
77 
78  explicit ClosestPointsContainer(const std::size_t MaxSize);
79  ClosestPointsContainer(const std::size_t MaxSize, const double MaxDistance);
80 
81  // Copy constructor
82  explicit ClosestPointsContainer(const ClosestPointsContainer& rOther);
83 
85 
86  bool operator==(const ClosestPointsContainer& rOther) const;
87 
88  void Add(const PointWithId& rPoint);
89 
90  void Merge(const ClosestPointsContainer& rOther);
91 
92  ContainerType& GetPoints() { return mClosestPoints; }
93 
94  const ContainerType& GetPoints() const { return mClosestPoints; }
95 
96 private:
99 
100  ContainerType mClosestPoints;
101  std::size_t mMaxSize;
102  double mMaxDistance = std::numeric_limits<double>::max();
103 
105 
106  void LimitToMaxSize();
107 
110 
111  // default CTor for Serializer
112  ClosestPointsContainer() = default;
113 
114  friend class Serializer;
115 
116  void save(Serializer &rSerializer) const;
117 
118  void load(Serializer &rSerializer);
119 
121 };
122 
123 
125 } // namespace Kratos.
Definition: closest_points.h:74
ClosestPointsContainer & operator=(const ClosestPointsContainer &rOther)=delete
const ContainerType & GetPoints() const
Definition: closest_points.h:94
ContainerType & GetPoints()
Definition: closest_points.h:92
std::set< PointWithId > ContainerType
Definition: closest_points.h:76
This object defines an indexed object.
Definition: indexed_object.h:54
std::size_t IndexType
The definition of the index type.
Definition: indexed_object.h:63
Point class.
Definition: point.h:59
std::size_t IndexType
Definition: point.h:79
Definition: closest_points.h:34
PointWithId & operator=(const PointWithId &rOther)=delete
double GetDistance() const
Definition: closest_points.h:47
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
Short class definition.
Definition: array_1d.h:61
static double max(double a, double b)
Definition: GeometryFunctions.h:79
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
bool operator<(Dof< TDataType > const &First, Dof< TDataType > const &Second)
Less than operator.
Definition: dof.h:584
bool operator==(const Flags &Left, const Flags &Right)
Definition: flags.cpp:45
def load(f)
Definition: ode_solve.py:307
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247