Microflow 3D  v1.0
AutoSettingNode.cpp
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 #include "AutoSettingNode.h"
11 
12 
14  int32_t nodeType;
15  MF::GB::NodeID nodeTMP; // Extracts nodeType fom joined values of nodeType and uid-ThreadNr +1.
16  auto accessor = m_PropagationGrid_Ptr->getAccessor();
17 
18  for (openvdb::Int64Grid::ValueOnIter iter = m_GeometryGrid_Ptr->beginValueOn(); iter.test(); ++iter) {
19  nodeTMP.node_id.NodeID = iter.getValue();
20  nodeType = nodeTMP.node_id.Node.nodeType;
21  if (nodeType == 0) {} // do nothing.
22  else if (nodeType == 3 || nodeType % 10 == 0) {
23  int32_t nodePropagation = accessor.getValue(iter.getCoord());
24  if (isOnWall_N(nodePropagation) && nodeType == 3){
25  nodeTMP.node_id.Node.nodeType = BN;
26  iter.setValue(nodeTMP.node_id.NodeID); //N wall
27  }
28  else if (isOnWall_S(nodePropagation) && nodeType == 3) {
29  nodeTMP.node_id.Node.nodeType = BN;
30  iter.setValue(nodeTMP.node_id.NodeID); //S wall
31  }
32  else if (isOnWall_W(nodePropagation) && nodeType == 3) {
33  nodeTMP.node_id.Node.nodeType = BN;
34  iter.setValue(nodeTMP.node_id.NodeID); //W wall
35  }
36  else if (isOnWall_E(nodePropagation) && nodeType == 3) {
37  nodeTMP.node_id.Node.nodeType = BN;
38  iter.setValue(nodeTMP.node_id.NodeID); //E wall
39  }
40  else if (isOnWall_T(nodePropagation) && nodeType == 3) {
41  nodeTMP.node_id.Node.nodeType = BN;
42  iter.setValue(nodeTMP.node_id.NodeID); //T wall
43  }
44  else if (isOnWall_B(nodePropagation) && nodeType == 3) {
45  nodeTMP.node_id.Node.nodeType = BN;
46  iter.setValue(nodeTMP.node_id.NodeID); //B wall
47  }
48  else if (isOnWall_N(nodePropagation) && nodeType % 10 == 0); //From thread N wall
49  else if (isOnWall_S(nodePropagation) && nodeType % 10 == 0); //From thread S wall
50  else if (isOnWall_W(nodePropagation) && nodeType % 10 == 0); //From thread W wall
51  else if (isOnWall_E(nodePropagation) && nodeType % 10 == 0); //From thread E wall
52  else if (isOnWall_T(nodePropagation) && nodeType % 10 == 0); //From thread T wall
53  else if (isOnWall_B(nodePropagation) && nodeType % 10 == 0); //From thread B wall
54  /* adds BB 61 on periodic edges
55  else if (isOnWall_N(nodePropagation) && nodeType == 4); //Periodic from thread N wall
56  else if (isOnWall_S(nodePropagation) && nodeType == 4); //Periodic from thread S wall
57  else if (isOnWall_W(nodePropagation) && nodeType == 4); //Periodic from thread W wall
58  else if (isOnWall_E(nodePropagation) && nodeType == 4); //Periodic from thread E wall
59  else if (isOnWall_T(nodePropagation) && nodeType == 4); //Periodic from thread T wall
60  else if (isOnWall_B(nodePropagation) && nodeType == 4); //Periodic from thread B wall
61  */
62  else {
63  nodeTMP.node_id.Node.nodeType = NN;
64  iter.setValue(nodeTMP.node_id.NodeID); // edge/corner/undefined node
65  }
66  }
67  }
68 }
69 
71 
72  MF::GB::NodeID nodeTMP;
73  unsigned int nodeType, nodePropagation;
74  openvdb::Coord ijh;
75  int &i = ijh[0], &j = ijh[1], &h = ijh[2];
76  auto accessorG = m_GeometryGrid_Ptr->getAccessor(); // Geometry grid accessor
77  auto accessorP = m_PropagationGrid_Ptr->getAccessor(); // Propagation grid accessor
78 
79  for (openvdb::Int64Grid::ValueOnIter iter = m_GeometryGrid_Ptr->beginValueOn(); iter.test(); ++iter) {
80  nodeTMP.node_id.NodeID = iter.getValue();
81  nodeType = nodeTMP.node_id.Node.nodeType;
82  ijh = iter.getCoord();
83  nodePropagation = accessorP.getValue(ijh);
84 
85  switch (nodeType) {
86  case 0: {
87  break;
88  } //solid
89  case 1: {
90  break;
91  } //fluid
92  case 4: {
93  break;
94  } //periodic boundary node
95  case 61: {
96  break;
97  } //BB 2
98 //---------------------------------------------------------------------------------------------------
99 //Dirichlet velocity
100 //---------------------------------------------------------------------------------------------------
101  case 21: {
102  break;
103  }
104  case 22: {
105  break;
106  }
107  case 23: {
108  break;
109  }
110  case 24: {
111  break;
112  }
113  case 25: {
114  break;
115  }
116  case 26: {
117  break;
118  }
119  case 20: {
120  if (isOnWall_N(nodePropagation)) {
121  nodeTMP.node_id.Node.nodeType = 21;
122  iter.setValue(nodeTMP.node_id.NodeID); //N wall
123  }
124  else if (isOnWall_S(nodePropagation)) {
125  nodeTMP.node_id.Node.nodeType = 22;
126  iter.setValue(nodeTMP.node_id.NodeID); //S wall
127  }
128  else if (isOnWall_E(nodePropagation)) {
129  nodeTMP.node_id.Node.nodeType = 23;
130  iter.setValue(nodeTMP.node_id.NodeID); //E wall
131  }
132  else if (isOnWall_W(nodePropagation)) {
133  nodeTMP.node_id.Node.nodeType = 24;
134  iter.setValue(nodeTMP.node_id.NodeID); //W wall
135  }
136  else if (isOnWall_B(nodePropagation)) {
137  nodeTMP.node_id.Node.nodeType = 25;
138  iter.setValue(nodeTMP.node_id.NodeID); //B wall
139  }
140  else if (isOnWall_T(nodePropagation)) {
141  nodeTMP.node_id.Node.nodeType = 26;
142  iter.setValue(nodeTMP.node_id.NodeID); //T wall
143  }
144  else {
145  nodeTMP.node_id.Node.nodeType = NN;
146  iter.setValue(nodeTMP.node_id.NodeID); // edge/corner/unrecognized node
147  }
148  break;
149  }
150 //-----------------------------------------------------------------------------------------------------------------------------------
151 //Neumann pressure
152 //-----------------------------------------------------------------------------------------------------------------------------------
153  case 31: {
154  break;
155  }
156  case 32: {
157  break;
158  }
159  case 33: {
160  break;
161  }
162  case 34: {
163  break;
164  }
165  case 35: {
166  break;
167  }
168  case 36: {
169  break;
170  }
171  case 30: {
172  if (isOnWall_N(nodePropagation)) {
173  nodeTMP.node_id.Node.nodeType = 31;
174  iter.setValue(nodeTMP.node_id.NodeID); //N wall
175  }
176  else if (isOnWall_S(nodePropagation)) {
177  nodeTMP.node_id.Node.nodeType = 32;
178  iter.setValue(nodeTMP.node_id.NodeID); //S wall
179  }
180  else if (isOnWall_E(nodePropagation)) {
181  nodeTMP.node_id.Node.nodeType = 33;
182  iter.setValue(nodeTMP.node_id.NodeID); //E wall
183  }
184  else if (isOnWall_W(nodePropagation)) {
185  nodeTMP.node_id.Node.nodeType = 34;
186  iter.setValue(nodeTMP.node_id.NodeID); //W wall
187  }
188  else if (isOnWall_B(nodePropagation)) {
189  nodeTMP.node_id.Node.nodeType = 35;
190  iter.setValue(nodeTMP.node_id.NodeID); //B wall
191  }
192  else if (isOnWall_T(nodePropagation)) {
193  nodeTMP.node_id.Node.nodeType = 36;
194  iter.setValue(nodeTMP.node_id.NodeID); //T wall
195  }
196  else {
197  nodeTMP.node_id.Node.nodeType = NN;
198  iter.setValue(nodeTMP.node_id.NodeID); // edge/corner/unrecognized node
199  }
200  break;
201  }
202 //---------------------------------------------------------------------------------------------------
203 //Dirichlet velocity = 0 na scianach
204 //---------------------------------------------------------------------------------------------------
205  case 41: {
206  break;
207  }
208  case 42: {
209  break;
210  }
211  case 43: {
212  break;
213  }
214  case 44: {
215  break;
216  }
217  case 45: {
218  break;
219  }
220  case 46: {
221  break;
222  }
223  case 40: {
224  if (isOnWall_N(nodePropagation)) {
225  nodeTMP.node_id.Node.nodeType = 41;
226  iter.setValue(nodeTMP.node_id.NodeID); //N wall
227  }
228  else if (isOnWall_S(nodePropagation)) {
229  nodeTMP.node_id.Node.nodeType = 42;
230  iter.setValue(nodeTMP.node_id.NodeID); //S wall
231  }
232  else if (isOnWall_E(nodePropagation)) {
233  nodeTMP.node_id.Node.nodeType = 43;
234  iter.setValue(nodeTMP.node_id.NodeID); //E wall
235  }
236  else if (isOnWall_W(nodePropagation)) {
237  nodeTMP.node_id.Node.nodeType = 44;
238  iter.setValue(nodeTMP.node_id.NodeID); //W wall
239  }
240  else if (isOnWall_B(nodePropagation)) {
241  nodeTMP.node_id.Node.nodeType = 45;
242  iter.setValue(nodeTMP.node_id.NodeID); //B wall
243  }
244  else if (isOnWall_T(nodePropagation)) {
245  nodeTMP.node_id.Node.nodeType = 46;
246  iter.setValue(nodeTMP.node_id.NodeID); //T wall
247  }
248  else {
249  nodeTMP.node_id.Node.nodeType = NN;
250  iter.setValue(nodeTMP.node_id.NodeID); // edge/corner/unrecognized node
251  }
252  break;
253  }
254 //--------------------------------------------------------------------------------------------------------------------------------------------
255  default : {
256  std::cout << "Undefined type of boundary node " << (int) nodeType << " (" << i << ", " << j << ", " << h << ")" << std::endl;
257  exit(EXIT_FAILURE);
258  }
259  }
260  }
261 }
262 
263 
264 unsigned char MF::GB::AutoSettingNode::ExternalNodeNormal(int32_t nodePropagation) {
265 
266  if (isInCorner_NET(nodePropagation))
267  return 21; //NET corner
268  else if (isInCorner_NWT(nodePropagation))
269  return 22; //NWT corner
270  else if (isInCorner_NEB(nodePropagation))
271  return 20; //NEB corner
272  else if (isInCorner_NWB(nodePropagation))
273  return 19; //NWB corner
274  else if (isInCorner_SET(nodePropagation))
275  return 25; //SET corner
276  else if (isInCorner_SWT(nodePropagation))
277  return 26; //SWT corner
278  else if (isInCorner_SEB(nodePropagation))
279  return 24; //SEB corner
280  else if (isInCorner_SWB(nodePropagation))
281  return 23; //SWB corner
282 
283  else if (isOnEdge_NW(nodePropagation))
284  return 8; //NW edge
285  else if (isOnEdge_NE(nodePropagation))
286  return 7; //NE edge
287  else if (isOnEdge_NT(nodePropagation))
288  return 15; //NT edge
289  else if (isOnEdge_NB(nodePropagation))
290  return 16; //NB edge
291  else if (isOnEdge_SW(nodePropagation))
292  return 9; //SW edge
293  else if (isOnEdge_SE(nodePropagation))
294  return 10; //SE edge
295  else if (isOnEdge_ST(nodePropagation))
296  return 18; //ST edge
297  else if (isOnEdge_SB(nodePropagation))
298  return 17; //SB edge
299  else if (isOnEdge_WT(nodePropagation))
300  return 14; //WT edge
301  else if (isOnEdge_WB(nodePropagation))
302  return 13; //WB edge
303  else if (isOnEdge_ET(nodePropagation))
304  return 11; //ET edge
305  else if (isOnEdge_EB(nodePropagation))
306  return 12; //EB edge
307 
308  else if (Wall_N(nodePropagation))
309  return 2; //N wall
310  else if (Wall_S(nodePropagation))
311  return 4; //S wall
312  else if (Wall_W(nodePropagation))
313  return 3; //W wall
314  else if (Wall_E(nodePropagation))
315  return 1; //E wall
316  else if (Wall_T(nodePropagation))
317  return 5; //T wall
318  else if (Wall_B(nodePropagation))
319  return 6; //B wall
320  else
321  return 255; //unknown
322 }
323 
325  openvdb::Coord xyz;
327  auto accessor = m_GeometryGrid_Ptr->getAccessor();
328  MF::GB::NodeID nodeTMP;
329 
330  // Iterate over all active values.
331  for (openvdb::Int32Grid::ValueOnIter iter = m_PropagationGrid_Ptr->beginValueOn(); iter.test(); ++iter) {
332  xyz = iter.getCoord();
333  value.node_t.FF = iter.getValue();
334  if ((value.node_t.FF & 134217727) != 134217727) {
335  nodeTMP.node_id.NodeID = accessor.getValue(xyz);
336  nodeTMP.node_id.Node.nodeType = 3;
337  accessor.setValue(xyz, nodeTMP.node_id.NodeID);
338  }
339  }
340 
341 }
struct MF::GB::NodeID::@0::@1 Node
A class that allows to determine the proper NodeID from combined nodeType, uidThreadNr, ThreadCount, ComponentNr and PhaseNr.
Definition: NodeID.h:18
void BoundaryFind()
Finds geometry boundary nodes and set its value to 3.
A structure that allows to code/decode in unsigned int number (32bit) the propagation directions of t...
void DefaultTypeSet()
Sets default node types on walls, edges and corners of geometry that are automatically detected and w...
uint64_t NodeID
Definition: NodeID.h:29
union MF::GB::NodeID::@0 node_id
void NodeTypeClass()
Classifies primary node types (e.g 20,30,40) into subtypes 21,22,23... for North/South/Est/West/Top/B...
union MF::GU::DirectionsD3Q19::@2 node_t