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.
model_subdivision_utilities.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: Máté Kelemen
11 //
12 
13 #ifndef KRATOS_WIND_MODEL_SUBDIVISION_UTILITIES
14 #define KRATOS_WIND_MODEL_SUBDIVISION_UTILITIES
15 
16 // Project includes
17 #include "includes/model_part.h"
18 #include "includes/lock_object.h"
19 
20 
21 namespace Kratos
22 {
23 namespace Wind
24 {
25 
28 
34 class KRATOS_API(WIND_ENGINEERING_APPLICATION) ModelSubdivisionUtilities
35 {
36 public:
49  static std::vector<Kratos::shared_ptr<ModelPart>> SortNodesBySlabs(
50  ModelPart& rModelPart,
51  const array_1d<double,3>& rBottomPoint,
52  const array_1d<double,3>& rTopPoint,
53  std::size_t numberOfSlabs,
54  bool isRootSlabOpen);
55 
63  static void SortNodes(
64  ModelPart& rModelPart,
65  std::function<ModelPart*(const Node&)> sortFunction,
66  std::vector<ModelPart*>& rSubModelParts);
67 
75  static void SortElements(
76  ModelPart& rModelPart,
77  std::function<ModelPart*(const Element&)> sortFunction,
78  std::vector<ModelPart*>& rSubModelParts);
79 
87  static void SortConditions(
88  ModelPart& rModelPart,
89  std::function<ModelPart*(const Condition&)> sortFunction,
90  std::vector<ModelPart*>& rSubModelParts);
91 
92 protected:
97  {
98  public:
100 
101  ThreadSafeIndexSet(std::vector<ModelPart*>& rSubModelParts);
102 
108  void Push(ModelPart* pSubModelPart, IndexType value);
109 
111  template <class TFunction = std::function<void(ModelPart*, const std::vector<IndexType>&, IndexType)>>
112  void Apply(TFunction function);
113 
114  private:
115  using LockType = LockObject;
116 
117  std::map<ModelPart*,
118  std::pair<std::vector<IndexType>,
119  unique_ptr<LockType>>> mIndexSets;
120  };
121 
122 
124  class Slab
125  {
126  public:
127  Slab(const array_1d<double,3>& rBottomPoint,
128  const array_1d<double,3>& rTopPoint,
129  bool isOpen = false);
130 
131  bool IsBelow(const array_1d<double,3>& rPoint) const;
132 
133  bool IsAbove(const array_1d<double,3>& rPoint) const;
134 
135  bool IsInside(const array_1d<double,3>& rPoint) const;
136 
137  protected:
138  struct Plane
139  {
143  bool IsOnPositiveSide(const array_1d<double,3>& rPoint, bool open) const;
144 
147  }; // struct Plane
148 
149  const array_1d<double,3>& Normal() const;
150 
153  const bool mIsOpen;
154  }; // class Slab
155 
156  class SlabStack : public Slab
157  {
158  public:
159 
167  SlabStack(const array_1d<double,3> rBottomPoint,
168  const array_1d<double,3> rTopPoint,
169  std::size_t numberOfSlabs,
170  bool isOpen);
171 
178  std::size_t SlabIndex(const array_1d<double,3>& rPoint) const;
179 
181  std::size_t size() const;
182 
183  private:
184  std::vector<Slab::Plane> mInnerPlanes;
185  }; // class SlabStack
186 }; // class ModelSubdivisionUtilities
187 
189 
190 } // namespace Wind
191 } // namespace Kratos
192 
194 
195 #endif // KRATOS_MODEL_SUBDIVISION_UTILITIES
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
This class defines and stores a lock and gives an interface to it.
Definition: lock_object.h:42
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
std::size_t IndexType
Pointer definition of ModelPart.
Definition: model_part.h:105
This class defines the node.
Definition: node.h:65
A subset of R^3 between two parallel planes.
Definition: model_subdivision_utilities.h:125
const Plane mTopPlane
Definition: model_subdivision_utilities.h:152
const Plane mBottomPlane
Definition: model_subdivision_utilities.h:151
const bool mIsOpen
Definition: model_subdivision_utilities.h:153
Definition: model_subdivision_utilities.h:157
Definition: model_subdivision_utilities.h:97
ModelPart::IndexType IndexType
Definition: model_subdivision_utilities.h:99
Utility for populating sub model parts.
Definition: model_subdivision_utilities.h:35
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33
Definition: model_subdivision_utilities.h:139
array_1d< double, 3 > mReferencePoint
Definition: model_subdivision_utilities.h:145
array_1d< double, 3 > mNormal
Definition: model_subdivision_utilities.h:146