Microflow 3D  v1.0
AutoSettingNode.h
Go to the documentation of this file.
1 // ==============================================================================================
2 // Microflow 3D, http://www.microflow.pwr.edu.pl/
3 // Created by Roman Szafran on 01.05.19.
4 // Copyright (c) 2019 Wroclaw University of Science and Technology.
5 // Distributed under the Apache License, Version 2.0. You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0 or see accompanying file license.txt.
7 // Redistributions of source code must retain the above copyright and license notice.
8 // ==============================================================================================
9 
10 #pragma once
11 
12 // OpenVDB
13 #include <openvdb/openvdb.h>
14 
15 #include <memory>
16 #include <cstdint>
17 
18 #include "ConfigData.h"
19 #include "LatticeParametersD3Q19.h"
20 #include "PropagationD3Q19.h"
21 #include "GeometryBuilder/NodeID.h"
22 
23 namespace MF {
24  namespace GB {
25 
28 
29  public:
30  AutoSettingNode(const std::shared_ptr<MF::Database::ConfigData> & ConfigData_Ptr, const openvdb::Int64Grid::Ptr & GeometryGrid_Ptr,
31  const std::shared_ptr<MF::GU::LatticeParametersD3Q19> & LatticeParameters_Ptr, const openvdb::Int32Grid::Ptr & PropagationGrid_Ptr) :
32  m_ConfigData_Ptr(ConfigData_Ptr),
33  m_GeometryGrid_Ptr(GeometryGrid_Ptr),
34  m_LatticeParameters_Ptr(LatticeParameters_Ptr),
35  m_PropagationGrid_Ptr(PropagationGrid_Ptr)
36  {};
37 
38  ~AutoSettingNode() = default;
39 
40  static std::shared_ptr<MF::GB::AutoSettingNode> New(const std::shared_ptr<MF::Database::ConfigData> & ConfigData_Ptr,
41  const openvdb::Int64Grid::Ptr & GeometryGrid_Ptr,
42  const std::shared_ptr<MF::GU::LatticeParametersD3Q19> & LatticeParameters_Ptr,
43  const openvdb::Int32Grid::Ptr & PropagationGrid_Ptr) {
44  auto AutoSettingNode_Ptr = std::make_shared<MF::GB::AutoSettingNode>(ConfigData_Ptr, GeometryGrid_Ptr, LatticeParameters_Ptr, PropagationGrid_Ptr);
45  return AutoSettingNode_Ptr;
46  };
47  // Functions work only with grids of type openvdb::Int32Grid
48  void DefaultTypeSet();
49  void NodeTypeClass();
50  void BoundaryFind();
51 
52  private:
53 
54  std::shared_ptr<MF::Database::ConfigData> m_ConfigData_Ptr;
55  openvdb::Int64Grid::Ptr m_GeometryGrid_Ptr;
56  std::shared_ptr<MF::GU::LatticeParametersD3Q19> m_LatticeParameters_Ptr;
57  openvdb::Int32Grid::Ptr m_PropagationGrid_Ptr;
58 
59  int32_t BN = m_ConfigData_Ptr->getCaseIntParam("DefaultBoundaryCondition.DefaultWallNode_BN");
60  int32_t NN = m_ConfigData_Ptr->getCaseIntParam("DefaultBoundaryCondition.DefaultNode_NN");
61 
62  static unsigned char ExternalNodeNormal(int32_t nodePropagation);
63 
64  // Returns true only for exact boundary type nodes.
65 
66  static inline bool isOnWall_N(int32_t nodePropagationValue) { return nodePropagationValue == 126254715;};
67 
68  static inline bool isOnWall_S(int32_t nodePropagationValue) { return nodePropagationValue == 7993839; };
69 
70  static inline bool isOnWall_W(int32_t nodePropagationValue) { return nodePropagationValue == 53976311; };
71 
72  static inline bool isOnWall_E(int32_t nodePropagationValue) { return nodePropagationValue == 80733053; };
73 
74  static inline bool isOnWall_T(int32_t nodePropagationValue) { return nodePropagationValue == 26949599; };
75 
76  static inline bool isOnWall_B(int32_t nodePropagationValue) { return nodePropagationValue == 107270079; };
77 
78  // Returns true for nodes that lie on external walls/edges/corners.
79 
80  static bool Wall_N(int32_t nodePropagationValue) { return ((~nodePropagationValue & 127) & ~123) > 0;};
81 
82  static bool Wall_S(int32_t nodePropagationValue) { return ((~nodePropagationValue & 127) & ~111) > 0;};
83 
84  static bool Wall_W(int32_t nodePropagationValue) { return ((~nodePropagationValue & 127) & ~119) > 0;};
85 
86  static bool Wall_E(int32_t nodePropagationValue) { return ((~nodePropagationValue & 127) & ~125) > 0;};
87 
88  static bool Wall_T(int32_t nodePropagationValue) { return ((~nodePropagationValue & 127) & ~95) > 0;};
89 
90  static bool Wall_B(int32_t nodePropagationValue) { return ((~nodePropagationValue & 127) & ~63) > 0;};
91 
92  static bool isInCorner_NET(int32_t nodePropagationValue) { return (Wall_N(nodePropagationValue) && Wall_E(nodePropagationValue) && Wall_T(nodePropagationValue));};
93 
94  static bool isInCorner_NWT(int32_t nodePropagationValue) { return (Wall_N(nodePropagationValue) && Wall_W(nodePropagationValue) && Wall_T(nodePropagationValue));};
95 
96  static bool isInCorner_NEB(int32_t nodePropagationValue) { return (Wall_N(nodePropagationValue) && Wall_E(nodePropagationValue) && Wall_B(nodePropagationValue));};
97 
98  static bool isInCorner_NWB(int32_t nodePropagationValue) { return (Wall_N(nodePropagationValue) && Wall_W(nodePropagationValue) && Wall_B(nodePropagationValue));};
99 
100  static bool isInCorner_SET(int32_t nodePropagationValue) { return (Wall_S(nodePropagationValue) && Wall_E(nodePropagationValue) && Wall_T(nodePropagationValue));};
101 
102  static bool isInCorner_SWT(int32_t nodePropagationValue) { return (Wall_S(nodePropagationValue) && Wall_W(nodePropagationValue) && Wall_T(nodePropagationValue));};
103 
104  static bool isInCorner_SEB(int32_t nodePropagationValue) { return (Wall_S(nodePropagationValue) && Wall_E(nodePropagationValue) && Wall_B(nodePropagationValue));};
105 
106  static bool isInCorner_SWB(int32_t nodePropagationValue) { return (Wall_S(nodePropagationValue) && Wall_W(nodePropagationValue) && Wall_B(nodePropagationValue));};
107 
108  static bool isOnEdge_NW(int32_t nodePropagationValue) { return (Wall_N(nodePropagationValue) && Wall_W(nodePropagationValue));};
109 
110  static bool isOnEdge_NE(int32_t nodePropagationValue) { return (Wall_N(nodePropagationValue) && Wall_E(nodePropagationValue));};
111 
112  static bool isOnEdge_NT(int32_t nodePropagationValue) { return (Wall_N(nodePropagationValue) && Wall_T(nodePropagationValue));};
113 
114  static bool isOnEdge_NB(int32_t nodePropagationValue) { return (Wall_N(nodePropagationValue) && Wall_B(nodePropagationValue));};
115 
116  static bool isOnEdge_SW(int32_t nodePropagationValue) { return (Wall_S(nodePropagationValue) && Wall_W(nodePropagationValue));};
117 
118  static bool isOnEdge_SE(int32_t nodePropagationValue) { return (Wall_S(nodePropagationValue) && Wall_E(nodePropagationValue));};
119 
120  static bool isOnEdge_ST(int32_t nodePropagationValue) { return (Wall_S(nodePropagationValue) && Wall_T(nodePropagationValue));};
121 
122  static bool isOnEdge_SB(int32_t nodePropagationValue) { return (Wall_S(nodePropagationValue) && Wall_B(nodePropagationValue));};
123 
124  static bool isOnEdge_WT(int32_t nodePropagationValue) { return (Wall_W(nodePropagationValue) && Wall_T(nodePropagationValue));};
125 
126  static bool isOnEdge_WB(int32_t nodePropagationValue) { return (Wall_W(nodePropagationValue) && Wall_B(nodePropagationValue));};
127 
128  static bool isOnEdge_ET(int32_t nodePropagationValue) { return (Wall_E(nodePropagationValue) && Wall_T(nodePropagationValue));};
129 
130  static bool isOnEdge_EB(int32_t nodePropagationValue) { return (Wall_E(nodePropagationValue) && Wall_B(nodePropagationValue));};
131 
132  };
133 
134  } /* namespace GB */
135 } /* namespase MF */
136 
void BoundaryFind()
Finds geometry boundary nodes and set its value to 3.
A class of methods that automatically classify nodes of any geometry.
void DefaultTypeSet()
Sets default node types on walls, edges and corners of geometry that are automatically detected and w...
static std::shared_ptr< MF::GB::AutoSettingNode > New(const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr, const openvdb::Int64Grid::Ptr &GeometryGrid_Ptr, const std::shared_ptr< MF::GU::LatticeParametersD3Q19 > &LatticeParameters_Ptr, const openvdb::Int32Grid::Ptr &PropagationGrid_Ptr)
void NodeTypeClass()
Classifies primary node types (e.g 20,30,40) into subtypes 21,22,23... for North/South/Est/West/Top/B...
AutoSettingNode(const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr, const openvdb::Int64Grid::Ptr &GeometryGrid_Ptr, const std::shared_ptr< MF::GU::LatticeParametersD3Q19 > &LatticeParameters_Ptr, const openvdb::Int32Grid::Ptr &PropagationGrid_Ptr)