From 8a725b524e484451035a2b5b27ede83de739ed6e Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Wed, 11 Jan 2017 19:48:26 -0600 Subject: [PATCH 01/14] update curve-pot example --- examples/curve-pot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/curve-pot.py b/examples/curve-pot.py index 777c53ee..52453699 100644 --- a/examples/curve-pot.py +++ b/examples/curve-pot.py @@ -225,6 +225,7 @@ def draw_pot_figure(aspect_ratio, else: # {{{ 3D plots + plotval_vol = vol_pot.real plotval_c = curve_pot.real @@ -260,7 +261,8 @@ def draw_pot_figure(aspect_ratio, if __name__ == "__main__": draw_pot_figure(aspect_ratio=1, nsrc=100, novsmp=100, helmholtz_k=(15+4j)*0.3, what_operator="D", what_operator_lpot="D", force_center_side=1) - pt.savefig("eigvals-ext-nsrc100-novsmp100.pdf") + +# pt.savefig("eigvals-ext-nsrc100-novsmp100.pdf") #pt.clf() #draw_pot_figure(aspect_ratio=1, nsrc=100, novsmp=100, helmholtz_k=0, # what_operator="D", what_operator_lpot="D", force_center_side=-1) -- GitLab From d7ec5033f2ee871ac3c6107543648f662d626eee Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Wed, 11 Jan 2017 19:52:09 -0600 Subject: [PATCH 02/14] Revert "Fix stresslet kernel to be FMMable." This reverts commit e250e5bba96e2ba251449980ee4e59f678dd1bf6. --- sumpy/kernel.py | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 4a3987b5..39f490a3 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -506,22 +506,26 @@ class StressletKernel(ExpressionKernel): if dim == 2: d = make_sym_vector("d", dim) + n = make_sym_vector(stresslet_vector_name, dim) r = pymbolic_real_norm_2(d) expr = ( - -var("log")(r)*(1 if icomp == jcomp else 0) - + - d[icomp]*d[jcomp]/r**2 + sum(n[axis]*d[axis] for axis in range(dim)) + * + d[icomp]*d[jcomp]/r**4 ) - scaling = 1/(4*var("pi")) + scaling = 1/(var("pi")) + elif dim == 3: d = make_sym_vector("d", dim) + n = make_sym_vector(stresslet_vector_name, dim) r = pymbolic_real_norm_2(d) expr = ( - (1/r)*(1 if icomp == jcomp else 0) - + - d[icomp]*d[jcomp]/r**3 + sum(n[axis]*d[axis] for axis in range(dim)) + * + d[icomp]*d[jcomp]/r**5 ) - scaling = -1/(8*var("pi")) + scaling = -3/(4*var("pi")) + elif dim is None: expr = None scaling = None @@ -558,28 +562,15 @@ class StressletKernel(ExpressionKernel): return [ KernelArgument( loopy_arg=lp.ValueArg(self.viscosity_mu_name, np.float64), - )] - - def get_source_args(self): - return [ + ), KernelArgument( loopy_arg=lp.GlobalArg(self.stresslet_vector_name, None, shape=(self.dim, "nsources"), - dim_tags="sep,C"))] - - def postprocess_at_source(self, expr, avec): - dimensions = len(avec) - assert dimensions == self.dim + dim_tags="sep,C")) + ] - from sumpy.symbolic import make_sympy_vector - n = make_sympy_vector(self.stresslet_vector_name, dimensions) - - # avec = center-src -> minus sign from chain rule - return sum(-n[axis]*expr.diff(avec[axis]) - for axis in range(dimensions)) - - def get_code_transformer(self): + def get_code_tranformer(self): from sumpy.codegen import VectorComponentRewriter vcr = VectorComponentRewriter([self.stresslet_vector_name]) from pymbolic.primitives import Variable -- GitLab From bb22c0e487898295a10bf02d800fc09dce19d0f6 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Thu, 12 Jan 2017 01:09:33 -0600 Subject: [PATCH 03/14] remove normal vector from stresslet kernel --- sumpy/kernel.py | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 39f490a3..bfefc39f 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -492,11 +492,10 @@ class StokesletKernel(ExpressionKernel): class StressletKernel(ExpressionKernel): - init_arg_names = ("dim", "icomp", "jcomp", "viscosity_mu_name", - "stresslet_vector_name") + init_arg_names = ("dim", "icomp", "jcomp", "kcomp", "viscosity_mu_name") - def __init__(self, dim=None, icomp=None, jcomp=None, viscosity_mu_name="mu", - stresslet_vector_name="stresslet_vec"): + def __init__(self, dim=None, icomp=None, jcomp=None, kcomp=None, + viscosity_mu_name="mu"): """ :arg viscosity_mu_name: The argument name to use for dynamic viscosity :math:`\mu` the then generating functions to @@ -509,9 +508,7 @@ class StressletKernel(ExpressionKernel): n = make_sym_vector(stresslet_vector_name, dim) r = pymbolic_real_norm_2(d) expr = ( - sum(n[axis]*d[axis] for axis in range(dim)) - * - d[icomp]*d[jcomp]/r**4 + d[icomp]*d[jcomp]*d[kcomp]/r**4 ) scaling = 1/(var("pi")) @@ -520,9 +517,7 @@ class StressletKernel(ExpressionKernel): n = make_sym_vector(stresslet_vector_name, dim) r = pymbolic_real_norm_2(d) expr = ( - sum(n[axis]*d[axis] for axis in range(dim)) - * - d[icomp]*d[jcomp]/r**5 + d[icomp]*d[jcomp]*d[kcomp]/r**5 ) scaling = -3/(4*var("pi")) @@ -533,9 +528,9 @@ class StressletKernel(ExpressionKernel): raise RuntimeError("unsupported dimensionality") self.viscosity_mu_name = viscosity_mu_name - self.stresslet_vector_name = stresslet_vector_name self.icomp = icomp self.jcomp = jcomp + self.kcomp = kcomp ExpressionKernel.__init__( self, @@ -545,32 +540,27 @@ class StressletKernel(ExpressionKernel): is_complex_valued=False) def __getinitargs__(self): - return (self._dim, self.icomp, self.jcomp, self.viscosity_mu_name, - self.stresslet_vector_name) + return (self._dim, self.icomp, self.jcomp, self.kcomp, + self.viscosity_mu_name) def update_persistent_hash(self, key_hash, key_builder): key_hash.update(type(self).__name__.encode()) key_builder.rec(key_hash, ( - self.dim, self.icomp, self.jcomp, self.viscosity_mu_name, - self.stresslet_vector_name)) + self.dim, self.icomp, self.jcomp, self.kcomp, + self.viscosity_mu_name)) def __repr__(self): - return "StressletKnl%dD_%d%d[%s]" % (self.dim, self.icomp, self.jcomp, - self.stresslet_vector_name) + return "StressletKnl%dD_%d%d%d" % (self.dim, self.icomp, self.jcomp, + self.kcomp) def get_args(self): return [ KernelArgument( loopy_arg=lp.ValueArg(self.viscosity_mu_name, np.float64), - ), - KernelArgument( - loopy_arg=lp.GlobalArg(self.stresslet_vector_name, - None, - shape=(self.dim, "nsources"), - dim_tags="sep,C")) + ) ] - def get_code_tranformer(self): + def get_code_transformer(self): from sumpy.codegen import VectorComponentRewriter vcr = VectorComponentRewriter([self.stresslet_vector_name]) from pymbolic.primitives import Variable @@ -907,8 +897,8 @@ class KernelDimensionSetter(KernelIdentityMapper): return StressletKernel(self.dim, kernel.icomp, kernel.jcomp, - viscosity_mu_name=kernel.viscosity_mu_name, - stresslet_vector_name=kernel.stresslet_vector_name) + kernel.kcomp, + viscosity_mu_name=kernel.viscosity_mu_name) # }}} -- GitLab From 30f9c6344e42eeb3cb4d447e2104eb6e3a01e5cb Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Thu, 12 Jan 2017 01:16:30 -0600 Subject: [PATCH 04/14] Revert "remove normal vector from stresslet kernel" This reverts commit bb22c0e487898295a10bf02d800fc09dce19d0f6. --- sumpy/kernel.py | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index bfefc39f..39f490a3 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -492,10 +492,11 @@ class StokesletKernel(ExpressionKernel): class StressletKernel(ExpressionKernel): - init_arg_names = ("dim", "icomp", "jcomp", "kcomp", "viscosity_mu_name") + init_arg_names = ("dim", "icomp", "jcomp", "viscosity_mu_name", + "stresslet_vector_name") - def __init__(self, dim=None, icomp=None, jcomp=None, kcomp=None, - viscosity_mu_name="mu"): + def __init__(self, dim=None, icomp=None, jcomp=None, viscosity_mu_name="mu", + stresslet_vector_name="stresslet_vec"): """ :arg viscosity_mu_name: The argument name to use for dynamic viscosity :math:`\mu` the then generating functions to @@ -508,7 +509,9 @@ class StressletKernel(ExpressionKernel): n = make_sym_vector(stresslet_vector_name, dim) r = pymbolic_real_norm_2(d) expr = ( - d[icomp]*d[jcomp]*d[kcomp]/r**4 + sum(n[axis]*d[axis] for axis in range(dim)) + * + d[icomp]*d[jcomp]/r**4 ) scaling = 1/(var("pi")) @@ -517,7 +520,9 @@ class StressletKernel(ExpressionKernel): n = make_sym_vector(stresslet_vector_name, dim) r = pymbolic_real_norm_2(d) expr = ( - d[icomp]*d[jcomp]*d[kcomp]/r**5 + sum(n[axis]*d[axis] for axis in range(dim)) + * + d[icomp]*d[jcomp]/r**5 ) scaling = -3/(4*var("pi")) @@ -528,9 +533,9 @@ class StressletKernel(ExpressionKernel): raise RuntimeError("unsupported dimensionality") self.viscosity_mu_name = viscosity_mu_name + self.stresslet_vector_name = stresslet_vector_name self.icomp = icomp self.jcomp = jcomp - self.kcomp = kcomp ExpressionKernel.__init__( self, @@ -540,27 +545,32 @@ class StressletKernel(ExpressionKernel): is_complex_valued=False) def __getinitargs__(self): - return (self._dim, self.icomp, self.jcomp, self.kcomp, - self.viscosity_mu_name) + return (self._dim, self.icomp, self.jcomp, self.viscosity_mu_name, + self.stresslet_vector_name) def update_persistent_hash(self, key_hash, key_builder): key_hash.update(type(self).__name__.encode()) key_builder.rec(key_hash, ( - self.dim, self.icomp, self.jcomp, self.kcomp, - self.viscosity_mu_name)) + self.dim, self.icomp, self.jcomp, self.viscosity_mu_name, + self.stresslet_vector_name)) def __repr__(self): - return "StressletKnl%dD_%d%d%d" % (self.dim, self.icomp, self.jcomp, - self.kcomp) + return "StressletKnl%dD_%d%d[%s]" % (self.dim, self.icomp, self.jcomp, + self.stresslet_vector_name) def get_args(self): return [ KernelArgument( loopy_arg=lp.ValueArg(self.viscosity_mu_name, np.float64), - ) + ), + KernelArgument( + loopy_arg=lp.GlobalArg(self.stresslet_vector_name, + None, + shape=(self.dim, "nsources"), + dim_tags="sep,C")) ] - def get_code_transformer(self): + def get_code_tranformer(self): from sumpy.codegen import VectorComponentRewriter vcr = VectorComponentRewriter([self.stresslet_vector_name]) from pymbolic.primitives import Variable @@ -897,8 +907,8 @@ class KernelDimensionSetter(KernelIdentityMapper): return StressletKernel(self.dim, kernel.icomp, kernel.jcomp, - kernel.kcomp, - viscosity_mu_name=kernel.viscosity_mu_name) + viscosity_mu_name=kernel.viscosity_mu_name, + stresslet_vector_name=kernel.stresslet_vector_name) # }}} -- GitLab From f5d2ede16b9b86fb3aef404af70da6cad047b031 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Thu, 12 Jan 2017 01:42:42 -0600 Subject: [PATCH 05/14] Fix modified Stresslet --- sumpy/kernel.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index bfefc39f..5a4cb6c1 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -505,7 +505,6 @@ class StressletKernel(ExpressionKernel): if dim == 2: d = make_sym_vector("d", dim) - n = make_sym_vector(stresslet_vector_name, dim) r = pymbolic_real_norm_2(d) expr = ( d[icomp]*d[jcomp]*d[kcomp]/r**4 -- GitLab From 2e134f77e0deb4ed3bb47f914410fe21118f043a Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Thu, 12 Jan 2017 02:42:13 -0600 Subject: [PATCH 06/14] Remove code transform for stresslet-vec-less Stresslet --- sumpy/kernel.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 5a4cb6c1..00418abc 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -559,16 +559,6 @@ class StressletKernel(ExpressionKernel): ) ] - def get_code_transformer(self): - from sumpy.codegen import VectorComponentRewriter - vcr = VectorComponentRewriter([self.stresslet_vector_name]) - from pymbolic.primitives import Variable - via = _VectorIndexAdder(self.stresslet_vector_name, (Variable("isrc"),)) - - def transform(expr): - return via(vcr(expr)) - - return transform mapper_method = "map_stresslet_kernel" -- GitLab From d30030b90c36daa0f72421863a180be012e5d3f1 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Thu, 12 Jan 2017 03:26:28 -0600 Subject: [PATCH 07/14] fix typo --- sumpy/kernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 39f490a3..a6865926 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -570,7 +570,7 @@ class StressletKernel(ExpressionKernel): dim_tags="sep,C")) ] - def get_code_tranformer(self): + def get_code_transformer(self): from sumpy.codegen import VectorComponentRewriter vcr = VectorComponentRewriter([self.stresslet_vector_name]) from pymbolic.primitives import Variable -- GitLab From ad76279cea15936b2c57fc49d1c58ec3d1d45e9b Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Mon, 30 Jan 2017 16:39:17 -0600 Subject: [PATCH 08/14] fix 3d stresslet --- sumpy/kernel.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 00418abc..d7249acb 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -513,7 +513,6 @@ class StressletKernel(ExpressionKernel): elif dim == 3: d = make_sym_vector("d", dim) - n = make_sym_vector(stresslet_vector_name, dim) r = pymbolic_real_norm_2(d) expr = ( d[icomp]*d[jcomp]*d[kcomp]/r**5 -- GitLab From 4c6b5fe749e92d49074111d8463e22cdd6e86ed0 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Mon, 30 Jan 2017 16:53:11 -0600 Subject: [PATCH 09/14] trim whitespace --- sumpy/kernel.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index d7249acb..8f8f0edf 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -558,7 +558,6 @@ class StressletKernel(ExpressionKernel): ) ] - mapper_method = "map_stresslet_kernel" # }}} -- GitLab From 76ed55aea81424d6d70149ab9424ff964fee4027 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Mon, 30 Jan 2017 16:58:09 -0600 Subject: [PATCH 10/14] trim more whitespace --- sumpy/kernel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 8f8f0edf..2e19c625 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -494,7 +494,7 @@ class StokesletKernel(ExpressionKernel): class StressletKernel(ExpressionKernel): init_arg_names = ("dim", "icomp", "jcomp", "kcomp", "viscosity_mu_name") - def __init__(self, dim=None, icomp=None, jcomp=None, kcomp=None, + def __init__(self, dim=None, icomp=None, jcomp=None, kcomp=None, viscosity_mu_name="mu"): """ :arg viscosity_mu_name: The argument name to use for @@ -538,7 +538,7 @@ class StressletKernel(ExpressionKernel): is_complex_valued=False) def __getinitargs__(self): - return (self._dim, self.icomp, self.jcomp, self.kcomp, + return (self._dim, self.icomp, self.jcomp, self.kcomp, self.viscosity_mu_name) def update_persistent_hash(self, key_hash, key_builder): -- GitLab From 44119db662934d6fc37dec9b663a03babdd95565 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Fri, 3 Feb 2017 16:09:58 -0600 Subject: [PATCH 11/14] remove unneeded variable name from stresslet --- sumpy/kernel.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 75500808..1a20ffa8 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -526,7 +526,6 @@ class StressletKernel(ExpressionKernel): raise RuntimeError("unsupported dimensionality") self.viscosity_mu_name = viscosity_mu_name - self.stresslet_vector_name = stresslet_vector_name self.icomp = icomp self.jcomp = jcomp self.kcomp = kcomp -- GitLab From f4a3561e45a230533b9fda0da4dbf0c16fdcb6ba Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Fri, 3 Feb 2017 16:26:27 -0600 Subject: [PATCH 12/14] remove stresslet_vector_name from hash key builder --- sumpy/kernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 1a20ffa8..e7864ebe 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -545,7 +545,7 @@ class StressletKernel(ExpressionKernel): key_hash.update(type(self).__name__.encode()) key_builder.rec(key_hash, ( self.dim, self.icomp, self.jcomp, self.kcomp, self.viscosity_mu_name, - self.stresslet_vector_name)) + self.viscosity_mu_name)) def __repr__(self): return "StressletKnl%dD_%d%d%d" % (self.dim, self.icomp, self.jcomp, -- GitLab From e801b1a67703abe0b25fddc385c21b20078eac76 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Fri, 3 Feb 2017 16:31:07 -0600 Subject: [PATCH 13/14] fix silly typo --- sumpy/kernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index e7864ebe..50115360 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -544,7 +544,7 @@ class StressletKernel(ExpressionKernel): def update_persistent_hash(self, key_hash, key_builder): key_hash.update(type(self).__name__.encode()) key_builder.rec(key_hash, ( - self.dim, self.icomp, self.jcomp, self.kcomp, self.viscosity_mu_name, + self.dim, self.icomp, self.jcomp, self.kcomp, self.viscosity_mu_name)) def __repr__(self): -- GitLab From 5d1b3b0859cd6217e566991506f3e0af389daa51 Mon Sep 17 00:00:00 2001 From: Natalie Beams Date: Fri, 3 Feb 2017 16:34:15 -0600 Subject: [PATCH 14/14] fix map_stresslet_kernel --- sumpy/kernel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sumpy/kernel.py b/sumpy/kernel.py index 50115360..2e19c625 100644 --- a/sumpy/kernel.py +++ b/sumpy/kernel.py @@ -884,8 +884,8 @@ class KernelDimensionSetter(KernelIdentityMapper): return StressletKernel(self.dim, kernel.icomp, kernel.jcomp, - viscosity_mu_name=kernel.viscosity_mu_name, - stresslet_vector_name=kernel.stresslet_vector_name) + kernel.kcomp, + viscosity_mu_name=kernel.viscosity_mu_name) # }}} -- GitLab