Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array context #16

Closed
wants to merge 87 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
5915199
Initial, incomplete adaptation to meshmode's ArrayContext
inducer Jun 15, 2020
66fc944
Improve ArrayContext processing in BoundOperator.{__call__,eval}
inducer Jun 17, 2020
3dbc2c8
Track introduction of ArrayContext.np
inducer Jun 17, 2020
f0e5c54
symbolic.primitives: Fix the dimension check for a few 3D-surface-only
mattwala Jun 30, 2020
5cc8cf5
Merge branch 'master' of https://github.com/inducer/pytential into fi…
mattwala Jun 30, 2020
86934b7
Merge branch 'fix-surface-check' into 'master'
inducer Jul 1, 2020
273ba51
CI: Disable tests, only keep examples for now
mattwala Jul 2, 2020
cf635e0
Update requirements.txt
mattwala Jul 2, 2020
459ec80
Port over examples
mattwala Jul 2, 2020
1306729
Relax sumpy version
mattwala Jul 2, 2020
c738c07
Add utils.py
mattwala Jul 2, 2020
c1678d1
pylint fixes
mattwala Jul 2, 2020
657c35f
flake8 fixes
mattwala Jul 2, 2020
51fa634
requirements.txt: Point to revert-cffi-go-to-pybind branch of islpy
mattwala Jul 2, 2020
8a70c0d
Port over some tests
mattwala Jul 2, 2020
54a125a
flake8 fix
mattwala Jul 2, 2020
36919c9
Improve test specificity
mattwala Jul 2, 2020
c1df687
Merge branch 'master' into array-context
mattwala Jul 2, 2020
16864ec
Port test_symbolic.py
mattwala Jul 2, 2020
fddc8c4
Mark test_muller.py as OK
mattwala Jul 2, 2020
473de87
formatting
mattwala Jul 2, 2020
bb6d56e
Port test_global_qbx.py
mattwala Jul 2, 2020
a7d8282
Misc fixes for test_global_qbx
mattwala Jul 2, 2020
55a2b36
Port test_layer_pot_eigenvalues.py
mattwala Jul 2, 2020
ce86dc6
Point requirements.txt to sumpy master
mattwala Jul 2, 2020
b32792e
Fixes for test_layer_pot_eigenvalues
mattwala Jul 2, 2020
72a09b0
Port test_layer_pot_identity
mattwala Jul 2, 2020
7ce0165
Actually run the tests in test_layer_pot_identity.py
mattwala Jul 2, 2020
25582e5
Port test_layer_pot.py
mattwala Jul 2, 2020
01872e9
port test_matrix to array-context
alexfikl Jul 3, 2020
c3077e9
Port test_scalar_int_eq.py
mattwala Jul 3, 2020
80ab289
port test_linalg_proxy to array-context
alexfikl Jul 3, 2020
87df581
flake8 fixes
mattwala Jul 3, 2020
9b4ce76
Thaw failed_target_flags after QBXTargetAssociationFailedException
mattwala Jul 3, 2020
fee617b
Port test_maxwell.py
mattwala Jul 3, 2020
21d641d
Add test_maxwell.py to setup.cfg tests
mattwala Jul 3, 2020
d4a8585
port test_stokes to array-context
alexfikl Jul 3, 2020
16b103d
enable tests in setup.cfg
alexfikl Jul 3, 2020
d790dfe
Merge branch 'array-context' into array-context-tests
alexfikl Jul 3, 2020
213ee64
Allow tests marked as slowtest to run
mattwala Jul 3, 2020
b57224c
Fix yaml syntax
mattwala Jul 3, 2020
58d21fc
Merge branch 'array-context' into array-context-tests
alexfikl Jul 3, 2020
030c7c0
Document default_vdot()
mattwala Jul 3, 2020
af7ff8c
Improve the documentation in MatVecOp
mattwala Jul 3, 2020
0760994
Remove unneeded FIXME
mattwala Jul 3, 2020
37e9404
remove stray debugging remnants
alexfikl Jul 3, 2020
b5f1e9d
Remove another FIXME
mattwala Jul 3, 2020
740cd15
Apply 1 suggestion(s) to 1 file(s)
Jul 3, 2020
67b1228
Apply 1 suggestion(s) to 1 file(s)
Jul 3, 2020
c09cfb9
Apply 1 suggestion(s) to 1 file(s)
Jul 3, 2020
94a220d
switch argument order in unflatten_to_numpy
alexfikl Jul 3, 2020
6b50ccf
Address more FIXMEs
mattwala Jul 4, 2020
9303cc2
Remove FIXME
mattwala Jul 4, 2020
b51f070
Address another FIXME
mattwala Jul 4, 2020
087411c
Merge branch 'array-context' into 'array-context-tests'
mattwala Jul 4, 2020
d476b09
flake8 fix
mattwala Jul 4, 2020
c28247b
Merge branch 'array-context' into HEAD
mattwala Jul 4, 2020
56373b8
Apply 1 suggestion(s) to 1 file(s)
Jul 4, 2020
27c7922
Apply 1 suggestion(s) to 1 file(s)
Jul 4, 2020
fb062bb
remove partition_by_coarse
alexfikl Jul 4, 2020
58d0dfa
[ci skip] Rename default_vdot to structured_vdot
mattwala Jul 4, 2020
61b6220
Merge branch 'array-context-tests' into 'array-context'
mattwala Jul 4, 2020
ef9c1c4
Undo setup.cfg changes
mattwala Jul 4, 2020
c296c6d
Tweak setup.cfg
mattwala Jul 4, 2020
459f2f1
Undo changes to .gitlab-ci.yml
mattwala Jul 4, 2020
e08ec0e
Re-dangle Conda requirements files
mattwala Jul 4, 2020
15b7c8d
Fix CI failures on master due to recent Sumpy P2P API changes
mattwala Jul 5, 2020
10d1ed7
Merge branch 'track-sumpy-changes' into 'master'
mattwala Jul 5, 2020
3440900
Merge branch 'master' into array-context
mattwala Jul 5, 2020
a2a7273
Tweak comments in examples
mattwala Jul 6, 2020
0a298d9
Fix getting host array
mattwala Jul 6, 2020
db0a8c2
Fix naming to QBXFMMGeometryDataCodeContainer
mattwala Jul 6, 2020
f1d7193
Rename _FMMGeometryCodeContainer to _FMMGeometryDataCodeContainer
mattwala Jul 6, 2020
f1281a0
Update pytential/symbolic/execution.py
mattwala Jul 6, 2020
bdb3cf2
Remove too_slow_test_helmholtz.py
mattwala Jul 6, 2020
10c3787
Make an interleave_dof_arrays underscored method
mattwala Jul 6, 2020
ec9bdb1
Merge branch 'array-context' of https://github.com/inducer/pytential …
mattwala Jul 6, 2020
499ffc3
Delete DielectricSRep2DBoundaryOperator and DielectricSDRep2DBoundary…
mattwala Jul 8, 2020
90056c1
Move flatten() import to top of file, and don't use a separate
mattwala Jul 10, 2020
0c63898
pytential.source: Introduce _SumpyP2PMixin
mattwala Jul 10, 2020
a86f7a9
Fix incorrect parentheses placement
mattwala Jul 10, 2020
0f6471b
Re-dangle islpy back to master
inducer Jul 11, 2020
2fc4fb1
Move Apple CI to Github
inducer Jul 11, 2020
5fe6d92
Merge remote-tracking branch 'gitlab/array-context' into array-context
inducer Jul 11, 2020
ba588a6
Try mac CI with normal conda env without mac workarounds
inducer Jul 11, 2020
753a54a
mac CI: Try and install compiler from conda
inducer Jul 11, 2020
4e7f2db
Apply suggestions from @isuruf to fix Github Mac CI
inducer Jul 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
port test_stokes to array-context
alexfikl committed Jul 3, 2020
commit d4a85856f412ee52a4e817aedfeb4e559856dbbe
2 changes: 1 addition & 1 deletion test/test_matrix.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
import numpy.linalg as la

import pyopencl as cl
import pyopencl.array # noqa
import pyopencl.array

from pytools.obj_array import make_obj_array, is_obj_array

59 changes: 34 additions & 25 deletions test/test_stokes.py
Original file line number Diff line number Diff line change
@@ -25,9 +25,10 @@

import numpy as np
import pyopencl as cl
import pyopencl.clmath # noqa
import pyopencl.clmath
import pytest

from meshmode.array_context import PyOpenCLArrayContext
from meshmode.discretization import Discretization
from meshmode.discretization.poly_element import \
InterpolatoryQuadratureSimplexGroupFactory
@@ -46,7 +47,7 @@

def run_exterior_stokes_2d(ctx_factory, nelements,
mesh_order=4, target_order=4, qbx_order=4,
fmm_order=10, mu=1, circle_rad=1.5, visualize=False):
fmm_order=False, mu=1, circle_rad=1.5, visualize=False):

# This program tests an exterior Stokes flow in 2D using the
# compound representation given in Hsiao & Kress,
@@ -57,6 +58,7 @@ def run_exterior_stokes_2d(ctx_factory, nelements,

cl_ctx = cl.create_some_context()
queue = cl.CommandQueue(cl_ctx)
actx = PyOpenCLArrayContext(queue)

ovsmp_target_order = 4*target_order

@@ -68,8 +70,7 @@ def run_exterior_stokes_2d(ctx_factory, nelements,
lambda t: circle_rad * ellipse(1, t),
np.linspace(0, 1, nelements+1),
target_order)
coarse_density_discr = Discretization(
cl_ctx, mesh,
coarse_density_discr = Discretization(actx, mesh,
InterpolatoryQuadratureSimplexGroupFactory(target_order))

from pytential.qbx import QBXLayerPotentialSource
@@ -111,8 +112,8 @@ def outside_circle(test_points, radius):

density_discr = places.get_discretization(sym.DEFAULT_SOURCE)

normal = bind(places, sym.normal(2).as_vector())(queue)
path_length = bind(places, sym.integral(2, 1, 1))(queue)
normal = bind(places, sym.normal(2).as_vector())(actx)
path_length = bind(places, sym.integral(2, 1, 1))(actx)

# }}}

@@ -150,47 +151,52 @@ def outside_circle(test_points, radius):

def fund_soln(x, y, loc, strength):
#with direction (1,0) for point source
r = cl.clmath.sqrt((x - loc[0])**2 + (y - loc[1])**2)
r = actx.np.sqrt((x - loc[0])**2 + (y - loc[1])**2)
scaling = strength/(4*np.pi*mu)
xcomp = (-cl.clmath.log(r) + (x - loc[0])**2/r**2) * scaling
xcomp = (-actx.np.log(r) + (x - loc[0])**2/r**2) * scaling
ycomp = ((x - loc[0])*(y - loc[1])/r**2) * scaling
return [xcomp, ycomp]

def rotlet_soln(x, y, loc):
r = cl.clmath.sqrt((x - loc[0])**2 + (y - loc[1])**2)
r = actx.np.sqrt((x - loc[0])**2 + (y - loc[1])**2)
xcomp = -(y - loc[1])/r**2
ycomp = (x - loc[0])/r**2
return [xcomp, ycomp]

def fund_and_rot_soln(x, y, loc, strength):
#with direction (1,0) for point source
r = cl.clmath.sqrt((x - loc[0])**2 + (y - loc[1])**2)
r = actx.np.sqrt((x - loc[0])**2 + (y - loc[1])**2)
scaling = strength/(4*np.pi*mu)
xcomp = (
(-cl.clmath.log(r) + (x - loc[0])**2/r**2) * scaling
(-actx.np.log(r) + (x - loc[0])**2/r**2) * scaling
- (y - loc[1])*strength*0.125/r**2 + 3.3)
ycomp = (
((x - loc[0])*(y - loc[1])/r**2) * scaling
+ (x - loc[0])*strength*0.125/r**2 + 1.5)
return [xcomp, ycomp]
return make_obj_array([xcomp, ycomp])

nodes = density_discr.nodes().with_queue(queue)
from meshmode.dof_array import unflatten, flatten, thaw
nodes = flatten(thaw(actx, density_discr.nodes()))
fund_soln_loc = np.array([0.5, -0.2])
strength = 100.
bc = fund_and_rot_soln(nodes[0], nodes[1], fund_soln_loc, strength)
bc = unflatten(actx, density_discr,
fund_and_rot_soln(nodes[0], nodes[1], fund_soln_loc, strength))

omega_sym = sym.make_sym_vector("omega", dim)
u_A_sym_bdry = stokeslet_obj.apply( # noqa: N806
omega_sym, mu_sym, qbx_forced_limit=1)

omega = [
cl.array.to_device(queue, (strength/path_length)*np.ones(len(nodes[0]))),
cl.array.to_device(queue, np.zeros(len(nodes[0])))]
from pytential.utils import unflatten_from_numpy
omega = unflatten_from_numpy(actx, make_obj_array([
(strength/path_length)*np.ones(len(nodes[0])),
np.zeros(len(nodes[0]))
]), density_discr)

bvp_rhs = bind(places,
sym.make_sym_vector("bc", dim) + u_A_sym_bdry)(queue,
sym.make_sym_vector("bc", dim) + u_A_sym_bdry)(actx,
bc=bc, mu=mu, omega=omega)
gmres_result = gmres(
bound_op.scipy_op(queue, "sigma", np.float64, mu=mu, normal=normal),
bound_op.scipy_op(actx, "sigma", np.float64, mu=mu, normal=normal),
bvp_rhs,
x0=bvp_rhs,
tol=1e-9, progress=True,
@@ -203,7 +209,7 @@ def fund_and_rot_soln(x, y, loc, strength):

sigma = gmres_result.solution
sigma_int_val_sym = sym.make_sym_vector("sigma_int_val", 2)
int_val = bind(places, sym.integral(2, 1, sigma_sym))(queue, sigma=sigma)
int_val = bind(places, sym.integral(2, 1, sigma_sym))(actx, sigma=sigma)
int_val = -int_val/(2 * np.pi)
print("int_val = ", int_val)

@@ -217,7 +223,7 @@ def fund_and_rot_soln(x, y, loc, strength):
- u_A_sym_vol + sigma_int_val_sym)

where = (sym.DEFAULT_SOURCE, "point_target")
vel = bind(places, representation_sym, auto_where=where)(queue,
vel = bind(places, representation_sym, auto_where=where)(actx,
sigma=sigma,
mu=mu,
normal=normal,
@@ -226,7 +232,7 @@ def fund_and_rot_soln(x, y, loc, strength):
print("@@@@@@@@")

plot_vel = bind(places, representation_sym,
auto_where=(sym.DEFAULT_SOURCE, "plot_target"))(queue,
auto_where=(sym.DEFAULT_SOURCE, "plot_target"))(actx,
sigma=sigma,
mu=mu,
normal=normal,
@@ -240,8 +246,10 @@ def get_obj_array(obj_array):
])

exact_soln = fund_and_rot_soln(
cl.array.to_device(queue, eval_points[0]), cl.array.to_device(
queue, eval_points[1]), fund_soln_loc, strength)
actx.from_numpy(eval_points[0]),
actx.from_numpy(eval_points[1]),
fund_soln_loc,
strength)

vel = get_obj_array(vel)
err = vel-get_obj_array(exact_soln)
@@ -289,7 +297,7 @@ def get_obj_array(obj_array):

# }}}

h_max = bind(places, sym.h_max(qbx.ambient_dim))(queue)
h_max = bind(places, sym.h_max(qbx.ambient_dim))(actx)
return h_max, l2_err


@@ -301,6 +309,7 @@ def test_exterior_stokes_2d(ctx_factory, qbx_order=3):
for nelements in [20, 50]:
h_max, l2_err = run_exterior_stokes_2d(ctx_factory, nelements)
eoc_rec.add_data_point(h_max, l2_err)
break

print(eoc_rec)
assert eoc_rec.order_estimate() >= qbx_order - 1