From c4ba49d21c007dbb3a887c0c228846fe5e41db68 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 19 May 2018 07:23:39 -0500 Subject: [PATCH 1/3] Make dd_axis work with vector inputs --- pytential/symbolic/primitives.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pytential/symbolic/primitives.py b/pytential/symbolic/primitives.py index 17a17013..fbb277df 100644 --- a/pytential/symbolic/primitives.py +++ b/pytential/symbolic/primitives.py @@ -909,6 +909,13 @@ def dd_axis(axis, ambient_dim, operand): """Return the derivative along (XYZ) axis *axis* (in *ambient_dim*-dimensional space) of *operand*. """ + from pytools.obj_array import is_obj_array, with_object_array_or_scalar + if is_obj_array(operand): + def dd_axis_comp(operand_i): + return dd_axis(axis, ambient_dim, operand_i) + + return with_object_array_or_scalar(dd_axis_comp, operand) + d = Derivative() unit_vector = np.zeros(ambient_dim) -- GitLab From 30255f9f9bad83abf228a9677a0e43c1796cfa2a Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 19 May 2018 07:23:56 -0500 Subject: [PATCH 2/3] Fix sym.div() --- pytential/symbolic/primitives.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pytential/symbolic/primitives.py b/pytential/symbolic/primitives.py index fbb277df..3a297fd1 100644 --- a/pytential/symbolic/primitives.py +++ b/pytential/symbolic/primitives.py @@ -1416,7 +1416,9 @@ def n_cross(vec, where=None): def div(vec): ambient_dim = len(vec) - return sum(dd_axis(iaxis, ambient_dim, vec) for iaxis in range(ambient_dim)) + return sum( + dd_axis(iaxis, ambient_dim, vec[iaxis]) + for iaxis in range(ambient_dim)) def curl(vec): -- GitLab From 12b3079421a957137ae090504045af4dc2983adc Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 19 May 2018 07:24:38 -0500 Subject: [PATCH 3/3] Test div S(n rho)==-D(rho) --- test/test_layer_pot.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/test/test_layer_pot.py b/test/test_layer_pot.py index f81a5e55..3e50aa94 100644 --- a/test/test_layer_pot.py +++ b/test/test_layer_pot.py @@ -389,16 +389,20 @@ def test_perf_data_gathering(ctx_getter, n_arms=5): # {{{ test 3D jump relations -@pytest.mark.parametrize("relation", ["sp", "nxcurls"]) +@pytest.mark.parametrize("relation", ["sp", "nxcurls", "div_s"]) def test_3d_jump_relations(ctx_factory, relation, visualize=False): - #logging.basicConfig(level=logging.INFO) + # logging.basicConfig(level=logging.INFO) pytest.importorskip("pyfmmlib") cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) - target_order = 4 + if relation == "div_s": + target_order = 3 + else: + target_order = 4 + qbx_order = target_order from pytools.convergence import EOCRecorder @@ -469,6 +473,16 @@ def test_3d_jump_relations(ctx_factory, relation, visualize=False): - (sym.Sp(knl, density_sym, qbx_forced_limit="avg") - 0.5*density_sym)) + elif relation == "div_s": + + density = m.cos(2*x) * m.cos(2*y) * m.cos(z) + density_sym = sym.var("density") + + jump_identity_sym = ( + sym.div(sym.S(knl, sym.normal(3).as_vector()*density_sym, + qbx_forced_limit="avg")) + + sym.D(knl, density_sym, qbx_forced_limit="avg")) + else: raise ValueError("unexpected value of 'relation': %s" % relation) -- GitLab