forked from jan/opencl_fdfd
Conductor partial fixup
This commit is contained in:
parent
985fca76f4
commit
fdcf090249
@ -35,7 +35,7 @@ if ( z == sz - 1 ) {
|
|||||||
//Update H components; set them to 0 if PMC is enabled there.
|
//Update H components; set them to 0 if PMC is enabled there.
|
||||||
// Also divide by mu only if requested.
|
// Also divide by mu only if requested.
|
||||||
{% if pmc -%}
|
{% if pmc -%}
|
||||||
if (pmc[XX + i]) {
|
if (pmc[XX + i] != 0) {
|
||||||
Hx[i] = cdouble_new(0.0, 0.0);
|
Hx[i] = cdouble_new(0.0, 0.0);
|
||||||
} else
|
} else
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
@ -51,7 +51,7 @@ if (pmc[XX + i]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{% if pmc -%}
|
{% if pmc -%}
|
||||||
if (pmc[YY + i]) {
|
if (pmc[YY + i] != 0) {
|
||||||
Hy[i] = cdouble_new(0.0, 0.0);
|
Hy[i] = cdouble_new(0.0, 0.0);
|
||||||
} else
|
} else
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
@ -67,8 +67,8 @@ if (pmc[YY + i]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{% if pmc -%}
|
{% if pmc -%}
|
||||||
if (pmc[XX + i]) {
|
if (pmc[ZZ + i] != 0) {
|
||||||
Hx[i] = cdouble_new(0.0, 0.0);
|
Hz[i] = cdouble_new(0.0, 0.0);
|
||||||
} else
|
} else
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{
|
{
|
||||||
|
@ -34,9 +34,7 @@ if ( z == 0 ) {
|
|||||||
|
|
||||||
//Update E components; set them to 0 if PEC is enabled there.
|
//Update E components; set them to 0 if PEC is enabled there.
|
||||||
{% if pec -%}
|
{% if pec -%}
|
||||||
if (pec[XX + i]) {
|
if (pec[XX + i] == 0)
|
||||||
Ex[i] = cdouble_new(0.0, 0.0);
|
|
||||||
} else
|
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{
|
{
|
||||||
cdouble_t tEx = cdouble_mul(Ex[i], oeps[XX + i]);
|
cdouble_t tEx = cdouble_mul(Ex[i], oeps[XX + i]);
|
||||||
@ -47,9 +45,7 @@ if (pec[XX + i]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{% if pec -%}
|
{% if pec -%}
|
||||||
if (pec[YY + i]) {
|
if (pec[YY + i] == 0)
|
||||||
Ey[i] = cdouble_new(0.0, 0.0);
|
|
||||||
} else
|
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{
|
{
|
||||||
cdouble_t tEy = cdouble_mul(Ey[i], oeps[YY + i]);
|
cdouble_t tEy = cdouble_mul(Ey[i], oeps[YY + i]);
|
||||||
@ -60,9 +56,7 @@ if (pec[YY + i]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{% if pec -%}
|
{% if pec -%}
|
||||||
if (pec[ZZ + i]) {
|
if (pec[ZZ + i] == 0)
|
||||||
Ez[i] = cdouble_new(0.0, 0.0);
|
|
||||||
} else
|
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{
|
{
|
||||||
cdouble_t tEz = cdouble_mul(Ez[i], oeps[ZZ + i]);
|
cdouble_t tEz = cdouble_mul(Ez[i], oeps[ZZ + i]);
|
||||||
|
9
opencl_fdfd/kernels/p2e.cl
Normal file
9
opencl_fdfd/kernels/p2e.cl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
{%- if pec -%}
|
||||||
|
if (pec[i] != 0) {
|
||||||
|
E[i] = cdouble_new(0.0, 0.0);
|
||||||
|
} else
|
||||||
|
{%- endif -%}
|
||||||
|
{
|
||||||
|
E[i] = cdouble_mul(Pr[i], p[i]);
|
||||||
|
}
|
@ -91,12 +91,12 @@ def cg_solver(omega, dxes, J, epsilon, mu=None, pec=None, pmc=None, adjoint=Fals
|
|||||||
if pec is None:
|
if pec is None:
|
||||||
gpec = load_field(numpy.array([]), dtype=numpy.int8)
|
gpec = load_field(numpy.array([]), dtype=numpy.int8)
|
||||||
else:
|
else:
|
||||||
gpec = load_field(pec, dtype=numpy.int8)
|
gpec = load_field(pec.astype(bool), dtype=numpy.int8)
|
||||||
|
|
||||||
if pmc is None:
|
if pmc is None:
|
||||||
gpmc = load_field(numpy.array([]), dtype=numpy.int8)
|
gpmc = load_field(numpy.array([]), dtype=numpy.int8)
|
||||||
else:
|
else:
|
||||||
gpmc = load_field(pmc, dtype=numpy.int8)
|
gpmc = load_field(pmc.astype(bool), dtype=numpy.int8)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Generate OpenCL kernels
|
Generate OpenCL kernels
|
||||||
|
@ -101,15 +101,18 @@ def create_a(context, shape, mu=False, pec=False, pmc=False):
|
|||||||
header = shape_source(shape) + dixyz_source + xyz_source
|
header = shape_source(shape) + dixyz_source + xyz_source
|
||||||
vec_h = vec_source + E_ptrs + H_ptrs
|
vec_h = vec_source + E_ptrs + H_ptrs
|
||||||
|
|
||||||
p2e_source = 'E[i] = cdouble_mul(Pr[i], p[i]);'
|
pec_arg = ['char *pec']
|
||||||
|
pmc_arg = ['char *pmc']
|
||||||
|
des = [ctype + ' *inv_de' + a for a in 'xyz']
|
||||||
|
dhs = [ctype + ' *inv_dh' + a for a in 'xyz']
|
||||||
|
|
||||||
|
p2e_source = jinja_env.get_template('p2e.cl').render(pec=pec)
|
||||||
P2E_kernel = ElementwiseKernel(context,
|
P2E_kernel = ElementwiseKernel(context,
|
||||||
name='P2E',
|
name='P2E',
|
||||||
preamble=preamble,
|
preamble=preamble,
|
||||||
operation=p2e_source,
|
operation=p2e_source,
|
||||||
arguments=', '.join(ptrs('E', 'p', 'Pr')))
|
arguments=', '.join(ptrs('E', 'p', 'Pr') + pec_arg))
|
||||||
|
|
||||||
pmc_arg = ['char *pmc']
|
|
||||||
des = [ctype + ' *inv_de' + a for a in 'xyz']
|
|
||||||
e2h_source = jinja_env.get_template('e2h.cl').render(mu=mu,
|
e2h_source = jinja_env.get_template('e2h.cl').render(mu=mu,
|
||||||
pmc=pmc,
|
pmc=pmc,
|
||||||
dixyz_source=header,
|
dixyz_source=header,
|
||||||
@ -120,8 +123,6 @@ def create_a(context, shape, mu=False, pec=False, pmc=False):
|
|||||||
operation=e2h_source,
|
operation=e2h_source,
|
||||||
arguments=', '.join(ptrs('E', 'H', 'inv_mu') + pmc_arg + des))
|
arguments=', '.join(ptrs('E', 'H', 'inv_mu') + pmc_arg + des))
|
||||||
|
|
||||||
pec_arg = ['char *pec']
|
|
||||||
dhs = [ctype + ' *inv_dh' + a for a in 'xyz']
|
|
||||||
h2e_source = jinja_env.get_template('h2e.cl').render(pmc=pec,
|
h2e_source = jinja_env.get_template('h2e.cl').render(pmc=pec,
|
||||||
dixyz_source=header,
|
dixyz_source=header,
|
||||||
vec_source=vec_h)
|
vec_source=vec_h)
|
||||||
@ -132,7 +133,7 @@ def create_a(context, shape, mu=False, pec=False, pmc=False):
|
|||||||
arguments=', '.join(ptrs('E', 'H', 'oeps', 'Pl') + pec_arg + dhs))
|
arguments=', '.join(ptrs('E', 'H', 'oeps', 'Pl') + pec_arg + dhs))
|
||||||
|
|
||||||
def spmv(E, H, p, idxes, oeps, inv_mu, pec, pmc, Pl, Pr, e):
|
def spmv(E, H, p, idxes, oeps, inv_mu, pec, pmc, Pl, Pr, e):
|
||||||
e2 = P2E_kernel(E, p, Pr, wait_for=e)
|
e2 = P2E_kernel(E, p, Pr, pec, wait_for=e)
|
||||||
e2 = E2H_kernel(E, H, inv_mu, pmc, *idxes[0], wait_for=[e2])
|
e2 = E2H_kernel(E, H, inv_mu, pmc, *idxes[0], wait_for=[e2])
|
||||||
e2 = H2E_kernel(E, H, oeps, Pl, pec, *idxes[1], wait_for=[e2])
|
e2 = H2E_kernel(E, H, oeps, Pl, pec, *idxes[1], wait_for=[e2])
|
||||||
return [e2]
|
return [e2]
|
||||||
|
Loading…
Reference in New Issue
Block a user