forked from jan/opencl_fdfd
split up into multiple files
This commit is contained in:
parent
20949f56ff
commit
a379d8b794
5 changed files with 400 additions and 361 deletions
87
opencl_fdfd/kernels/e2h.cl
Normal file
87
opencl_fdfd/kernels/e2h.cl
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
*
|
||||
* H update equations
|
||||
*
|
||||
*/
|
||||
|
||||
//Define sx, x, dix (and y, z versions of those)
|
||||
{{dixyz_source}}
|
||||
|
||||
//Define vectorized fields and pointers (eg. Hx = H + XX)
|
||||
{{vec_source}}
|
||||
|
||||
|
||||
// Wrap indices if necessary
|
||||
int ipx, ipy, ipz;
|
||||
if ( x == sx - 1 ) {
|
||||
ipx = i - (sx - 1) * dix;
|
||||
} else {
|
||||
ipx = i + dix;
|
||||
}
|
||||
|
||||
if ( y == sy - 1 ) {
|
||||
ipy = i - (sy - 1) * diy;
|
||||
} else {
|
||||
ipy = i + diy;
|
||||
}
|
||||
|
||||
if ( z == sz - 1 ) {
|
||||
ipz = i - (sz - 1) * diz;
|
||||
} else {
|
||||
ipz = i + diz;
|
||||
}
|
||||
|
||||
|
||||
//Update H components; set them to 0 if PMC is enabled there.
|
||||
// Also divide by mu only if requested.
|
||||
{% if pmc -%}
|
||||
if (pmc[XX + i]) {
|
||||
Hx[i] = cdouble_new(0.0, 0.0);
|
||||
} else
|
||||
{%- endif -%}
|
||||
{
|
||||
cdouble_t Dzy = cdouble_mul(cdouble_sub(Ez[ipy], Ez[i]), inv_dey[y]);
|
||||
cdouble_t Dyz = cdouble_mul(cdouble_sub(Ey[ipz], Ey[i]), inv_dez[z]);
|
||||
|
||||
{%- if mu -%}
|
||||
Hx[i] = cdouble_mul(inv_mu[XX + i], cdouble_sub(Dzy, Dyz));
|
||||
{%- else -%}
|
||||
Hx[i] = cdouble_sub(Dzy, Dyz);
|
||||
{%- endif %}
|
||||
}
|
||||
|
||||
{% if pmc -%}
|
||||
if (pmc[YY + i]) {
|
||||
Hy[i] = cdouble_new(0.0, 0.0);
|
||||
} else
|
||||
{%- endif -%}
|
||||
{
|
||||
cdouble_t Dxz = cdouble_mul(cdouble_sub(Ex[ipz], Ex[i]), inv_dez[z]);
|
||||
cdouble_t Dzx = cdouble_mul(cdouble_sub(Ez[ipx], Ez[i]), inv_dex[x]);
|
||||
|
||||
{%- if mu -%}
|
||||
Hy[i] = cdouble_mul(inv_mu[YY + i], cdouble_sub(Dxz, Dzx));
|
||||
{%- else -%}
|
||||
Hy[i] = cdouble_sub(Dxz, Dzx);
|
||||
{%- endif %}
|
||||
}
|
||||
|
||||
{% if pmc -%}
|
||||
if (pmc[XX + i]) {
|
||||
Hx[i] = cdouble_new(0.0, 0.0);
|
||||
} else
|
||||
{%- endif -%}
|
||||
{
|
||||
cdouble_t Dyx = cdouble_mul(cdouble_sub(Ey[ipx], Ey[i]), inv_dex[x]);
|
||||
cdouble_t Dxy = cdouble_mul(cdouble_sub(Ex[ipy], Ex[i]), inv_dey[y]);
|
||||
|
||||
{%- if mu -%}
|
||||
Hz[i] = cdouble_mul(inv_mu[ZZ + i], cdouble_sub(Dyx, Dxy));
|
||||
{%- else -%}
|
||||
Hz[i] = cdouble_sub(Dyx, Dxy);
|
||||
{%- endif %}
|
||||
}
|
||||
|
||||
/*
|
||||
* End H update equations
|
||||
*/
|
||||
77
opencl_fdfd/kernels/h2e.cl
Normal file
77
opencl_fdfd/kernels/h2e.cl
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
*
|
||||
* E update equations
|
||||
*
|
||||
*/
|
||||
|
||||
//Define sx, x, dix (and y, z versions of those)
|
||||
{{dixyz_source}}
|
||||
|
||||
//Define vectorized fields and pointers (eg. Hx = H + XX)
|
||||
{{vec_source}}
|
||||
|
||||
|
||||
// Wrap indices if necessary
|
||||
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[XX + i]) {
|
||||
Ex[i] = cdouble_new(0.0, 0.0);
|
||||
} else
|
||||
{%- endif -%}
|
||||
{
|
||||
cdouble_t tEx = cdouble_mul(Ex[i], oeps[XX + i]);
|
||||
cdouble_t Dzy = cdouble_mul(cdouble_sub(Hz[i], Hz[imy]), inv_dhy[y]);
|
||||
cdouble_t Dyz = cdouble_mul(cdouble_sub(Hy[i], Hy[imz]), inv_dhz[z]);
|
||||
tEx = cdouble_add(tEx, cdouble_sub(Dzy, Dyz));
|
||||
Ex[i] = cdouble_mul(tEx, Pl[XX + i]);
|
||||
}
|
||||
|
||||
{% if pec -%}
|
||||
if (pec[YY + i]) {
|
||||
Ey[i] = cdouble_new(0.0, 0.0);
|
||||
} else
|
||||
{%- endif -%}
|
||||
{
|
||||
cdouble_t tEy = cdouble_mul(Ey[i], oeps[YY + i]);
|
||||
cdouble_t Dxz = cdouble_mul(cdouble_sub(Hx[i], Hx[imz]), inv_dhz[z]);
|
||||
cdouble_t Dzx = cdouble_mul(cdouble_sub(Hz[i], Hz[imx]), inv_dhx[x]);
|
||||
tEy = cdouble_add(tEy, cdouble_sub(Dxz, Dzx));
|
||||
Ey[i] = cdouble_mul(tEy, Pl[YY + i]);
|
||||
}
|
||||
|
||||
{% if pec -%}
|
||||
if (pec[ZZ + i]) {
|
||||
Ez[i] = cdouble_new(0.0, 0.0);
|
||||
} else
|
||||
{%- endif -%}
|
||||
{
|
||||
cdouble_t tEz = cdouble_mul(Ez[i], oeps[ZZ + i]);
|
||||
cdouble_t Dyx = cdouble_mul(cdouble_sub(Hy[i], Hy[imx]), inv_dhx[x]);
|
||||
cdouble_t Dxy = cdouble_mul(cdouble_sub(Hx[i], Hx[imy]), inv_dhy[y]);
|
||||
tEz = cdouble_add(tEz, cdouble_sub(Dyx, Dxy));
|
||||
Ez[i] = cdouble_mul(tEz, Pl[ZZ + i]);
|
||||
}
|
||||
|
||||
/*
|
||||
* End H update equations
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue