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_impl.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_IMPL
14 #define KRATOS_WIND_MODEL_SUBDIVISION_UTILITIES_IMPL
15 
16 // post-included in "model_subdivision_utilities.h"
17 
18 // Core includes
19 #include "utilities/math_utils.h"
20 
21 // STL includes
22 #include <mutex> // for std::lock_guard
23 
24 
25 namespace Kratos
26 {
27 namespace Wind
28 {
29 
30 
33 {
35 
36  // Push index to the corresponding container of the model part pointer
37  // Note: the case where pSubModelPart==NULL is valid, and means the value will not be pushed anywhere
38  if (pSubModelPart) {
39  auto& rPair = mIndexSets[pSubModelPart];
40  std::lock_guard<LockType> lock(*rPair.second); // replace with std::scoped_lock (c++17)
41  rPair.first.push_back(value);
42  }
43 
44  KRATOS_CATCH("");
45 }
46 
47 
48 template <class TFunction>
50 {
52 
53  for (auto& rPair : mIndexSets) {
54  (rPair.first->*function)(rPair.second.first, 0);
55  }
56 
57  KRATOS_CATCH("")
58 }
59 
60 
62 {
63  return mBottomPlane.IsOnPositiveSide(rPoint, mIsOpen);
64 }
65 
67 {
68  return mTopPlane.IsOnPositiveSide(rPoint, mIsOpen);
69 }
70 
72 {
73  return (!IsBelow(rPoint)) && (!IsAbove(rPoint));
74 }
75 
76 
78 {
79  const double product = MathUtils<double>::Dot(rPoint - mReferencePoint, mNormal);
80  if (product < 0) {
81  return false;
82  }
83  else if (0 < product) {
84  return true;
85  }
86  else if (open) {
87  return true;
88  }
89  else {
90  return false;
91  }
92 }
93 
94 
96 {
97  return mTopPlane.mNormal;
98 }
99 
100 
101 } // namespace Wind
102 } // namespace Kratos
103 
104 #endif
static double Dot(const Vector &rFirstVector, const Vector &rSecondVector)
Performs the dot product of two vectors of arbitrary size.
Definition: math_utils.h:669
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
bool IsBelow(const array_1d< double, 3 > &rPoint) const
Definition: model_subdivision_utilities_impl.h:61
bool IsInside(const array_1d< double, 3 > &rPoint) const
Definition: model_subdivision_utilities_impl.h:71
bool IsAbove(const array_1d< double, 3 > &rPoint) const
Definition: model_subdivision_utilities_impl.h:66
const array_1d< double, 3 > & Normal() const
Definition: model_subdivision_utilities_impl.h:95
void Apply(TFunction function)
Only to be used with ModelPart::AddNodes, ModelPart::AddElements, and ModelPart::AddConditions.
Definition: model_subdivision_utilities_impl.h:49
ModelPart::IndexType IndexType
Definition: model_subdivision_utilities.h:99
void Push(ModelPart *pSubModelPart, IndexType value)
Definition: model_subdivision_utilities_impl.h:31
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
bool IsOnPositiveSide(const array_1d< double, 3 > &rPoint, bool open) const
Definition: model_subdivision_utilities_impl.h:77