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 int32 m = this->head_(i,j,k);
23 CellType currentCell(i,j,k);
24 int32 n = -1;
25 
26 while( m > -1 )
27 {
28 
29  auto p_m = this->pointPosition_[m];
30  auto d_m = sizeRatio_* diameter_[m];
31 
32  // the same cell
33  n = this->next_(m);
34 
35  while(n >-1)
36  {
37 
38  auto p_n = this->pointPosition_[n];
39  auto d_n = sizeRatio_*diameter_[n];
40 
41  if( sphereSphereCheck(p_m, p_n, d_m, d_n) )
42  {
43  auto ln = n;
44  auto lm = m;
45 
46  if(lm>ln) Swap(lm,ln);
47  if( auto res = pairs.insert(lm,ln); res <0)
48  {
49  getFullUpdate++;
50  }
51  }
52 
53  n = this->next_(n);
54  }
55 
56  // neighbor cells
57  CellType neighborCell;
58  for(int32 ni=0; ni<13; ni++)
59  {
60  if(ni==0) neighborCell = currentCell + CellType( 0, 0,-1);
61  else if(ni==1) neighborCell = currentCell + CellType(-1, 0,-1);
62  else if(ni==2) neighborCell = currentCell + CellType(-1, 0, 0);
63  else if(ni==3) neighborCell = currentCell + CellType(-1, 0, 1);
64  else if(ni==4) neighborCell = currentCell + CellType( 0,-1,-1);
65  else if(ni==5) neighborCell = currentCell + CellType( 0,-1, 0);
66  else if(ni==6) neighborCell = currentCell + CellType( 0,-1, 1);
67  else if(ni==7) neighborCell = currentCell + CellType(-1,-1,-1);
68  else if(ni==8) neighborCell = currentCell + CellType(-1,-1, 0);
69  else if(ni==9) neighborCell = currentCell + CellType(-1,-1, 1);
70  else if(ni==10) neighborCell = currentCell + CellType( 1,-1,-1);
71  else if(ni==11) neighborCell = currentCell + CellType( 1,-1, 0);
72  else if(ni==12) neighborCell = currentCell + CellType( 1,-1, 1);
73 
74  if( this->isInRange(neighborCell) )
75  {
76 
77  n = this->head_(neighborCell.x(), neighborCell.y(), neighborCell.z());
78  while( n>-1)
79  {
80 
81  auto p_n = this->pointPosition_[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( auto res = pairs.insert(lm,ln); res <0)
90  {
91  getFullUpdate++;
92  }
93  }
94  n = this->next_[n];
95  }
96  }
97 
98  }
99  m = this->next_[m];
100 }
101 
n
int32 n
Definition: NBSLoop.hpp:24
m
int32 m
Definition: NBSLoop.hpp:22
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
currentCell
CellType currentCell(i, j, k)
pFlow::sphereSphereCheck
INLINE_FUNCTION_HD bool sphereSphereCheck(const realx3 &p1, const realx3 p2, real d1, real d2)
Definition: contactSearchFunctions.hpp:105