From 342e41479782484e323f3a92acb44e3117bcdf54 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Wed, 8 Apr 2020 20:49:03 -0500 Subject: [PATCH 1/2] add a test to create all basic layer potentials --- test/test_symbolic.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test_symbolic.py b/test/test_symbolic.py index 508ff296..12145d69 100644 --- a/test/test_symbolic.py +++ b/test/test_symbolic.py @@ -201,6 +201,23 @@ def test_expr_pickling(): # }}} +# {{{ test basic layer potentials + +@pytest.mark.parametrize("lpot_class", [ + sym.S, sym.Sp, sym.Spp, sym.D, sym.Dp + ]) +def test_layer_potential_construction(lpot_class, ambient_dim=2): + from sumpy.kernel import LaplaceKernel + + kernel_sym = LaplaceKernel(ambient_dim) + density_sym = sym.var("sigma") + lpot_sym = lpot_class(kernel_sym, density_sym, qbx_forced_limit=None) + + assert lpot_sym is not None + +# }}} + + @pytest.mark.parametrize(("name", "source_discr_stage", "target_granularity"), [ ("default", None, None), ("default-explicit", sym.QBX_SOURCE_STAGE1, sym.GRANULARITY_NODE), -- GitLab From ae82e6f3446cae5428bccf03e71c192fdc3b8378 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Fri, 10 Apr 2020 16:21:55 -0500 Subject: [PATCH 2/2] fix Spp implementation --- pytential/symbolic/primitives.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pytential/symbolic/primitives.py b/pytential/symbolic/primitives.py index ea59b676..7667fc01 100644 --- a/pytential/symbolic/primitives.py +++ b/pytential/symbolic/primitives.py @@ -1669,6 +1669,16 @@ def normal_derivative(ambient_dim, operand, dim=None, dofdesc=None): * d(operand)) +def normal_second_derivative(ambient_dim, operand, dim=None, dofdesc=None): + d = Derivative() + n = normal(ambient_dim, dim, dofdesc) + nabla = d.dnabla(ambient_dim) + + return d.resolve(n.scalar_product( + n.scalar_product(nabla) * d(d.resolve(nabla * d(operand))) + )) + + def Sp(kernel, *args, **kwargs): dofdesc = kwargs.get("target") if "qbx_forced_limit" not in kwargs: @@ -1702,9 +1712,9 @@ def Spp(kernel, *args, **kwargs): dim = kwargs.pop("dim", None) dofdesc = kwargs.get("target") - return normal_derivative( + return normal_second_derivative( ambient_dim, - Sp(kernel, *args, **kwargs), + S(kernel, *args, **kwargs), dim=dim, dofdesc=dofdesc) -- GitLab