diff --git a/examples/curve-pot.py b/examples/curve-pot.py index 023bd7e19bb69b619db9003c2f30111ec23e80ba..db2c667c7f9cd54cf93574439097f3582cc85b3d 100644 --- a/examples/curve-pot.py +++ b/examples/curve-pot.py @@ -91,7 +91,8 @@ def draw_pot_figure(aspect_ratio, knl_kwargs = {} vol_source_knl, vol_target_knl = process_kernel(knl, what_operator) - p2p = P2P(actx.context, source_kernels=(vol_source_knl,), + p2p = P2P(actx.context, + source_kernels=(vol_source_knl,), target_kernels=(vol_target_knl,), exclude_self=False, value_dtypes=np.complex128) @@ -157,35 +158,40 @@ def draw_pot_figure(aspect_ratio, lpot_kwargs = knl_kwargs.copy() if what_operator == "D": - volpot_kwargs["src_derivative_dir"] = native_curve.normal + volpot_kwargs["src_derivative_dir"] = actx.from_numpy(native_curve.normal) if what_operator_lpot == "D": - lpot_kwargs["src_derivative_dir"] = ovsmp_curve.normal + lpot_kwargs["src_derivative_dir"] = actx.from_numpy(ovsmp_curve.normal) if what_operator_lpot == "S'": - lpot_kwargs["tgt_derivative_dir"] = native_curve.normal + lpot_kwargs["tgt_derivative_dir"] = actx.from_numpy(native_curve.normal) # }}} + targets = actx.from_numpy(fp.points) + sources = actx.from_numpy(native_curve.pos) + ovsmp_sources = actx.from_numpy(ovsmp_curve.pos) + if 0: # {{{ build matrix from fourier import make_fourier_interp_matrix fim = make_fourier_interp_matrix(novsmp, nsrc) + from sumpy.tools import build_matrix from scipy.sparse.linalg import LinearOperator def apply_lpot(x): xovsmp = np.dot(fim, x) evt, (y,) = lpot(actx.queue, - native_curve.pos, - ovsmp_curve.pos, - centers, - [xovsmp * ovsmp_curve.speed * ovsmp_weights], - expansion_radii=np.ones(centers.shape[1]), + sources, + ovsmp_sources, + actx.from_numpy(centers), + [actx.from_numpy(xovsmp * ovsmp_curve.speed * ovsmp_weights)], + expansion_radii=actx.from_numpy(np.ones(centers.shape[1])), **lpot_kwargs) - return y + return actx.to_numpy(y) op = LinearOperator((nsrc, nsrc), apply_lpot) mat = build_matrix(op, dtype=np.complex128) @@ -200,19 +206,26 @@ def draw_pot_figure(aspect_ratio, mode_nr = 0 density = np.cos(mode_nr*2*np.pi*native_t).astype(np.complex128) - ovsmp_density = np.cos(mode_nr*2*np.pi*ovsmp_t).astype(np.complex128) + strength = actx.from_numpy(native_curve.speed * native_weights * density) + evt, (vol_pot,) = p2p(actx.queue, - fp.points, - native_curve.pos, - [native_curve.speed*native_weights*density], **volpot_kwargs) + targets, + sources, + [strength], **volpot_kwargs) + vol_pot = actx.to_numpy(vol_pot) + + ovsmp_density = np.cos(mode_nr*2*np.pi*ovsmp_t).astype(np.complex128) + ovsmp_strength = actx.from_numpy( + ovsmp_curve.speed * ovsmp_weights * ovsmp_density) evt, (curve_pot,) = lpot(actx.queue, - native_curve.pos, - ovsmp_curve.pos, - centers, - [ovsmp_density * ovsmp_curve.speed * ovsmp_weights], - expansion_radii=np.ones(centers.shape[1]), + sources, + ovsmp_sources, + actx.from_numpy(centers), + [ovsmp_strength], + expansion_radii=actx.from_numpy(np.ones(centers.shape[1])), **lpot_kwargs) + curve_pot = actx.to_numpy(curve_pot) # }}}