cuIBM
A GPU-based Immersed Boundary Method code
generateBC1.inl
Go to the documentation of this file.
1 
9 
10 
15 template <>
17 {
18  logger.startTimer("generateBC1");
19 
20  real alpha = intgSchm.alphaImplicit[subStep];
21 
22  // raw pointers from cusp arrays
23  real *bc1_r = thrust::raw_pointer_cast(&bc1[0]),
24  *q_r = thrust::raw_pointer_cast(&q[0]),
25  *dx = thrust::raw_pointer_cast(&(domInfo->dx[0])),
26  *dy = thrust::raw_pointer_cast(&(domInfo->dy[0])),
27  *dxD = thrust::raw_pointer_cast(&(domInfo->dxD[0])),
28  *dyD = thrust::raw_pointer_cast(&(domInfo->dyD[0]));
29 
30  real *xminus = thrust::raw_pointer_cast(&(bc[XMINUS][0])),
31  *xplus = thrust::raw_pointer_cast(&(bc[XPLUS][0])),
32  *yminus = thrust::raw_pointer_cast(&(bc[YMINUS][0])),
33  *yplus = thrust::raw_pointer_cast(&(bc[YPLUS][0]));
34 
35  real dx0, dx1, dy0, dy1,
36  nu = (*paramDB)["flow"]["nu"].get<real>(),
37  dt = (*paramDB)["simulation"]["dt"].get<real>();
38 
39  boundaryCondition **bcInfo = (*paramDB)["flow"]["boundaryConditions"].get<boundaryCondition **>();
40 
41  const int blocksize = 256;
42 
43  real C, beta;
44 
45  int nx = domInfo->nx,
46  ny = domInfo->ny;
47 
48  int numU = (nx-1)*ny;
49 
50  // initialize vector bc1 with zeros
51  cusp::blas::fill(bc1, 0.0);
52 
53  dim3 dimGridx( int((nx - 0.5)/blocksize) + 1, 1),
54  dimGridy( int((ny - 0.5)/blocksize) + 1, 1);
55 
56  dim3 dimBlock(blocksize, 1);
57 
59  if(bcInfo[YMINUS][0].type == DIRICHLET)
60  {
62  dy0 = 0.5*dy[0];
63  dy1 = 0.5*(dy[0] + dy[1]);
65  C = alpha * 2.0 * nu / (dy0 * (dy0+dy1));
66  kernels::bc1DirichletU <<<dimGridx, dimBlock>>> (bc1_r, nx-1, nx, 0, 1, dxD, C, yminus);
67 
69  C = alpha * 2.0 * nu / (dy[0] * (dy[0]+dy[1]));
70  kernels::bc1DirichletV <<<dimGridx, dimBlock>>> (bc1_r, nx, nx, numU, 0, 1, dyD, C, yminus, nx-1);
71  }
72  //else if(F.nbc.bottom_type==BC_CONVECTIVE)
73 
75  if(bcInfo[YPLUS][0].type == DIRICHLET)
76  {
78  dy0 = 0.5*(dy[ny-2] + dy[ny-1]);
79  dy1 = 0.5*(dy[ny-1]);
80  C = alpha * 2.0 * nu / (dy1 * (dy0+dy1));
81  kernels::bc1DirichletU <<<dimGridx, dimBlock>>> (bc1_r, nx-1, nx, (nx-1)*(ny-1), 1, dxD, C, yplus);
82 
84  C = alpha * 2.0 * nu / (dy[ny-1] * (dy[ny-1]+dy[ny-2]));
85  kernels::bc1DirichletV <<<dimGridx, dimBlock>>> (bc1_r, nx, nx, numU, nx*(ny-2), 1, dyD, C, yplus, nx-1);
86  }
87  else if(bcInfo[YPLUS][0].type == CONVECTIVE)
88  {
90  beta = bcInfo[YPLUS][1].value * dt / (0.5 * dy[ny-1]);
91  dy0 = 0.5*(dy[ny-2] + dy[ny-1]);
92  dy1 = 0.5*(dy[ny-1]);
93  C = alpha * 2.0 * nu / (dy1 * (dy0+dy1));
94  kernels::bc1ConvectiveU <<<dimGridx, dimBlock>>> (bc1_r, nx-1, nx, (nx-1)*(ny-1), 1, dxD, dyD, C, yplus, q_r, beta);
95 
97  beta = bcInfo[YPLUS][1].value * dt / dy[ny-1];
98  C = alpha * 2.0 * nu / (dy[ny-1] * (dy[ny-1]+dy[ny-2]));
99  kernels::bc1ConvectiveV <<<dimGridx, dimBlock>>> (bc1_r, nx, nx, numU, nx*(ny-2), 1, dxD, dyD, C, yplus, nx-1, q_r, beta);
100  }
101  else if(bcInfo[YPLUS][0].type == SPECIAL)
102  {
104  dy0 = 0.5*(dy[ny-2] + dy[ny-1]);
105  dy1 = 0.5*(dy[ny-1]);
106  C = alpha * 2.0 * nu / (dy1 * (dy0+dy1));
107  kernels::bc1SpecialU <<<dimGridx, dimBlock>>> (bc1_r, nx-1, nx, (nx-1)*(ny-1), 1, dxD, C, yplus, (timeStep+1)*dt);
108 
110  C = alpha * 2.0 * nu / (dy[ny-1] * (dy[ny-1]+dy[ny-2]));
111  kernels::bc1DirichletV <<<dimGridx, dimBlock>>> (bc1_r, nx, nx, numU, nx*(ny-2), 1, dyD, C, yplus, nx-1);
112  }
113 
115  if(bcInfo[XMINUS][0].type == DIRICHLET)
116  {
118  C = alpha * 2.0 * nu / ( dx[0] * (dx[0]+dx[1]) );
119  kernels::bc1DirichletU <<<dimGridy, dimBlock>>> (bc1_r, ny, nx, 0, (nx-1), dxD, C, xminus);
120 
122  dx0 = 0.5*dx[0];
123  dx1 = 0.5*(dx[0] + dx[1]);
124  C = alpha * 2.0 * nu / (dx0 * (dx0+dx1));
125  kernels::bc1DirichletV <<<dimGridy, dimBlock>>> (bc1_r, ny-1, nx, numU, 0, nx, dyD, C, xminus, ny);
126  }
127  //else if(F.nbc.left_type==BC_CONVECTIVE)
128 
130  if(bcInfo[XPLUS][0].type == DIRICHLET)
131  {
133  C = alpha * 2.0 * nu / ( dx[nx-1] * (dx[nx-1]+dx[nx-2]) );
134  kernels::bc1DirichletU <<<dimGridy, dimBlock>>> (bc1_r, ny, nx, nx-2, (nx-1), dxD, C, xplus);
135 
137  dx0 = 0.5*(dx[nx-1] + dx[nx-2]);
138  dx1 = 0.5*(dx[nx-1]);
139  C = alpha * 2.0 * nu / (dx1 * (dx0+dx1));
140  kernels::bc1DirichletV <<<dimGridy, dimBlock>>> (bc1_r, ny-1, nx, numU, nx-1, nx, dyD, C, xplus, ny);
141  }
142  else if(bcInfo[XPLUS][0].type == CONVECTIVE)
143  {
145  beta = bcInfo[XPLUS][0].value * dt / dx[nx-1];
146  C = alpha * 2.0 * nu / ( dx[nx-1] * (dx[nx-1]+dx[nx-2]) );
147  kernels::bc1ConvectiveU <<<dimGridy, dimBlock>>> (bc1_r, ny, nx, nx-2, nx-1, dxD, dyD, C, xplus, q_r, beta);
148 
150  beta = bcInfo[XPLUS][0].value * dt / (0.5*dx[nx-1]);
151  dx0 = 0.5*(dx[nx-1] + dx[nx-2]);
152  dx1 = 0.5*(dx[nx-1]);
153  C = alpha * 2.0 * nu / (dx1 * (dx0+dx1));
154  kernels::bc1ConvectiveV <<<dimGridy, dimBlock>>> (bc1_r, ny-1, nx, numU, nx-1, nx, dxD, dyD, C, xplus, ny, q_r, beta);
155  }
156 
157  logger.stopTimer("generateBC1");
158 } // generateBC1
Declaration of the kernels to generate right hand-side terms of the intermediate velocity flux solver...
virtual void generateBC1()
double real
Is a float or a double depending on the machine precision.
Definition: types.h:116
Dirichlet boundary condition.
Definition: types.h:35
right boundary
Definition: types.h:50
bottom boundary
Definition: types.h:51
left boundary
Definition: types.h:49
convective boundary condition
Definition: types.h:37
top boundary
Definition: types.h:52
Definition: types.h:39
Stores the type of boundary condition and its value.