consolidate boundary conditions in common.cl; add some comments and minor cleanup
This commit is contained in:
parent
f364fbc8b6
commit
3ad0dd3c50
1 changed files with 54 additions and 69 deletions
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
{{common_cl}}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__global ctype *oeps_x = oeps + XX;
|
||||
__global ctype *oeps_y = oeps + YY;
|
||||
|
|
@ -33,41 +34,14 @@ __global ctype *Pl_y = Pl + YY;
|
|||
__global ctype *Pl_z = Pl + ZZ;
|
||||
|
||||
|
||||
/*
|
||||
* Implement periodic boundary conditions
|
||||
*
|
||||
* imx gives the index of the adjacent cell in the minus-x direction ([i]ndex [m]inus [x]).
|
||||
* In the event that we start at x == 0, we actually want to wrap around and grab the cell
|
||||
* where x == (sx - 1) instead, ie. imx = i + (sx - 1) * dix .
|
||||
*/
|
||||
int imx, imy, imz;
|
||||
if ( x == 0 ) {
|
||||
imx = i + (sx - 1) * dix;
|
||||
} else {
|
||||
imx = i - dix;
|
||||
}
|
||||
|
||||
if ( y == 0 ) {
|
||||
imy = i + (sy - 1) * diy;
|
||||
} else {
|
||||
imy = i - diy;
|
||||
}
|
||||
|
||||
if ( z == 0 ) {
|
||||
imz = i + (sz - 1) * diz;
|
||||
} else {
|
||||
imz = i - diz;
|
||||
}
|
||||
|
||||
|
||||
//Update E components; set them to 0 if PEC is enabled there.
|
||||
{% if pec -%}
|
||||
if (pec_x[i] == 0)
|
||||
{%- endif -%}
|
||||
{
|
||||
ctype tEx = mul(Ex[i], oeps_x[i]);
|
||||
ctype Dzy = mul(sub(Hz[i], Hz[imy]), inv_dhy[y]);
|
||||
ctype Dyz = mul(sub(Hy[i], Hy[imz]), inv_dhz[z]);
|
||||
ctype Dzy = mul(sub(Hz[i], Hz[i + my]), inv_dhy[y]);
|
||||
ctype Dyz = mul(sub(Hy[i], Hy[i + mz]), inv_dhz[z]);
|
||||
tEx = add(tEx, sub(Dzy, Dyz));
|
||||
Ex[i] = mul(tEx, Pl_x[i]);
|
||||
}
|
||||
|
|
@ -77,8 +51,8 @@ if (pec_y[i] == 0)
|
|||
{%- endif -%}
|
||||
{
|
||||
ctype tEy = mul(Ey[i], oeps_y[i]);
|
||||
ctype Dxz = mul(sub(Hx[i], Hx[imz]), inv_dhz[z]);
|
||||
ctype Dzx = mul(sub(Hz[i], Hz[imx]), inv_dhx[x]);
|
||||
ctype Dxz = mul(sub(Hx[i], Hx[i + mz]), inv_dhz[z]);
|
||||
ctype Dzx = mul(sub(Hz[i], Hz[i + mx]), inv_dhx[x]);
|
||||
tEy = add(tEy, sub(Dxz, Dzx));
|
||||
Ey[i] = mul(tEy, Pl_y[i]);
|
||||
}
|
||||
|
|
@ -88,8 +62,8 @@ if (pec_z[i] == 0)
|
|||
{%- endif -%}
|
||||
{
|
||||
ctype tEz = mul(Ez[i], oeps_z[i]);
|
||||
ctype Dyx = mul(sub(Hy[i], Hy[imx]), inv_dhx[x]);
|
||||
ctype Dxy = mul(sub(Hx[i], Hx[imy]), inv_dhy[y]);
|
||||
ctype Dyx = mul(sub(Hy[i], Hy[i + mx]), inv_dhx[x]);
|
||||
ctype Dxy = mul(sub(Hx[i], Hx[i + my]), inv_dhy[y]);
|
||||
tEz = add(tEz, sub(Dyx, Dxy));
|
||||
Ez[i] = mul(tEz, Pl_z[i]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue