@@ -91,7 +91,8 @@ def draw_pot_figure(aspect_ratio,
9191 knl_kwargs = {}
9292
9393 vol_source_knl , vol_target_knl = process_kernel (knl , what_operator )
94- p2p = P2P (actx .context , source_kernels = (vol_source_knl ,),
94+ p2p = P2P (actx .context ,
95+ source_kernels = (vol_source_knl ,),
9596 target_kernels = (vol_target_knl ,),
9697 exclude_self = False ,
9798 value_dtypes = np .complex128 )
@@ -157,35 +158,40 @@ def map_to_curve(t):
157158 lpot_kwargs = knl_kwargs .copy ()
158159
159160 if what_operator == "D" :
160- volpot_kwargs ["src_derivative_dir" ] = native_curve .normal
161+ volpot_kwargs ["src_derivative_dir" ] = actx . from_numpy ( native_curve .normal )
161162
162163 if what_operator_lpot == "D" :
163- lpot_kwargs ["src_derivative_dir" ] = ovsmp_curve .normal
164+ lpot_kwargs ["src_derivative_dir" ] = actx . from_numpy ( ovsmp_curve .normal )
164165
165166 if what_operator_lpot == "S'" :
166- lpot_kwargs ["tgt_derivative_dir" ] = native_curve .normal
167+ lpot_kwargs ["tgt_derivative_dir" ] = actx . from_numpy ( native_curve .normal )
167168
168169 # }}}
169170
171+ targets = actx .from_numpy (fp .points )
172+ sources = actx .from_numpy (native_curve .pos )
173+ ovsmp_sources = actx .from_numpy (ovsmp_curve .pos )
174+
170175 if 0 :
171176 # {{{ build matrix
172177
173178 from fourier import make_fourier_interp_matrix
174179 fim = make_fourier_interp_matrix (novsmp , nsrc )
180+
175181 from sumpy .tools import build_matrix
176182 from scipy .sparse .linalg import LinearOperator
177183
178184 def apply_lpot (x ):
179185 xovsmp = np .dot (fim , x )
180186 evt , (y ,) = lpot (actx .queue ,
181- native_curve . pos ,
182- ovsmp_curve . pos ,
183- centers ,
184- [xovsmp * ovsmp_curve .speed * ovsmp_weights ],
185- expansion_radii = np .ones (centers .shape [1 ]),
187+ sources ,
188+ ovsmp_sources ,
189+ actx . from_numpy ( centers ) ,
190+ [actx . from_numpy ( xovsmp * ovsmp_curve .speed * ovsmp_weights ) ],
191+ expansion_radii = actx . from_numpy ( np .ones (centers .shape [1 ]) ),
186192 ** lpot_kwargs )
187193
188- return y
194+ return actx . to_numpy ( y )
189195
190196 op = LinearOperator ((nsrc , nsrc ), apply_lpot )
191197 mat = build_matrix (op , dtype = np .complex128 )
@@ -200,19 +206,26 @@ def apply_lpot(x):
200206
201207 mode_nr = 0
202208 density = np .cos (mode_nr * 2 * np .pi * native_t ).astype (np .complex128 )
203- ovsmp_density = np .cos (mode_nr * 2 * np .pi * ovsmp_t ).astype (np .complex128 )
209+ strength = actx .from_numpy (native_curve .speed * native_weights * density )
210+
204211 evt , (vol_pot ,) = p2p (actx .queue ,
205- fp .points ,
206- native_curve .pos ,
207- [native_curve .speed * native_weights * density ], ** volpot_kwargs )
212+ targets ,
213+ sources ,
214+ [strength ], ** volpot_kwargs )
215+ vol_pot = actx .to_numpy (vol_pot )
216+
217+ ovsmp_density = np .cos (mode_nr * 2 * np .pi * ovsmp_t ).astype (np .complex128 )
218+ ovsmp_strength = actx .from_numpy (
219+ ovsmp_curve .speed * ovsmp_weights * ovsmp_density )
208220
209221 evt , (curve_pot ,) = lpot (actx .queue ,
210- native_curve . pos ,
211- ovsmp_curve . pos ,
212- centers ,
213- [ovsmp_density * ovsmp_curve . speed * ovsmp_weights ],
214- expansion_radii = np .ones (centers .shape [1 ]),
222+ sources ,
223+ ovsmp_sources ,
224+ actx . from_numpy ( centers ) ,
225+ [ovsmp_strength ],
226+ expansion_radii = actx . from_numpy ( np .ones (centers .shape [1 ]) ),
215227 ** lpot_kwargs )
228+ curve_pot = actx .to_numpy (curve_pot )
216229
217230 # }}}
218231
0 commit comments