www.cemf.ir
NBSLoop.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 uint32 m = cellIter.start(i,j,k);
23 int32x3 currentCell(i,j,k);
24 uint32 n = mapperNBS::NoPos;
25 
26 while( m != mapperNBS::NoPos)
27 {
28 
29  auto p_m = pointPos[m];
30  auto d_m = sizeRatio* diameter[m];
31 
32  // the same cell
33  n = cellIter.getNext(m);
34 
35  while(n != mapperNBS::NoPos)
36  {
37  auto p_n = pointPos[n];
38  auto d_n = sizeRatio*diameter[n];
39 
40  if( sphereSphereCheck(p_m, p_n, d_m, d_n) )
41  {
42  auto ln = n;
43  auto lm = m;
44 
45  if(lm>ln) Swap(lm,ln);
46  if( pairs.insert(lm,ln) == static_cast<uint32>(-1))
47  {
48  getFullUpdate++;
49  }
50  }
51 
52  n = cellIter.getNext(n);;
53  }
54 
55  // neighbor cells
56  int32x3 neighborCell;
57  for(uint32 ni=0u; ni<13; ni++)
58  {
59  if(ni==0) neighborCell = currentCell + int32x3( 0, 0,-1);
60  else if(ni==1) neighborCell = currentCell + int32x3(-1, 0,-1);
61  else if(ni==2) neighborCell = currentCell + int32x3(-1, 0, 0);
62  else if(ni==3) neighborCell = currentCell + int32x3(-1, 0, 1);
63  else if(ni==4) neighborCell = currentCell + int32x3( 0,-1,-1);
64  else if(ni==5) neighborCell = currentCell + int32x3( 0,-1, 0);
65  else if(ni==6) neighborCell = currentCell + int32x3( 0,-1, 1);
66  else if(ni==7) neighborCell = currentCell + int32x3(-1,-1,-1);
67  else if(ni==8) neighborCell = currentCell + int32x3(-1,-1, 0);
68  else if(ni==9) neighborCell = currentCell + int32x3(-1,-1, 1);
69  else if(ni==10) neighborCell = currentCell + int32x3( 1,-1,-1);
70  else if(ni==11) neighborCell = currentCell + int32x3( 1,-1, 0);
71  else if(ni==12) neighborCell = currentCell + int32x3( 1,-1, 1);
72 
73  if( neighborCell.x()>=0 && neighborCell.y()>=0 && neighborCell.z()>=0 &&
74  neighborCell.x()<nCells.x() && neighborCell.y()<nCells.y() && neighborCell.z()<nCells.z() )
75  {
76 
77  n = cellIter.start(neighborCell.x(), neighborCell.y(), neighborCell.z());
78  while(n != mapperNBS::NoPos)
79  {
80 
81  auto p_n = pointPos[n];
82  auto d_n = sizeRatio*diameter[n];
83 
84  if(sphereSphereCheck(p_m, p_n, d_m, d_n))
85  {
86  auto ln = n;
87  auto lm = m;
88  if(lm>ln) Swap(lm,ln);
89  if( pairs.insert(lm,ln) == static_cast<uint32>(-1))
90  {
91  getFullUpdate++;
92  }
93  }
94  n = cellIter.next(n);
95  }
96  }
97  }
98  m = cellIter.next(m);
99 }
100 
currentCell
int32x3 currentCell(i, j, k)
pFlow::NBSLevel0Kernels::Swap
INLINE_FUNCTION_HD void Swap(T &x, T &y)
Definition: NBSLevel0Kernels.hpp:38
pFlow::NBSLevel0Kernels::sphereSphereCheck
INLINE_FUNCTION_HD bool sphereSphereCheck(const realx3 &p1, const realx3 p2, real d1, real d2)
Definition: NBSLevel0Kernels.hpp:46
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::int32x3
triple< int32 > int32x3
Definition: types.hpp:38
n
uint32 n
Definition: NBSLoop.hpp:24
m
uint32 m
Definition: NBSLoop.hpp:22