From 1d77a54f50bbd30d0a91e4a5757720d77827939f Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
Date: Tue, 2 Apr 2019 22:55:06 -0500
Subject: [PATCH] simplify laplacian

---
 sumpy/expansion/__init__.py | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/sumpy/expansion/__init__.py b/sumpy/expansion/__init__.py
index e2513e3c..673b595b 100644
--- a/sumpy/expansion/__init__.py
+++ b/sumpy/expansion/__init__.py
@@ -541,17 +541,10 @@ class PDE(object):
         return self + (-1)*other_pde
 
     def laplacian(self):
-        eqs = []
-        for eq in self.eqs:
-            new_eq = defaultdict(lambda: 0)
-            for ident, v in eq.items():
-                for d in range(self.dim):
-                    mi = list(ident.mi)
-                    mi[d] += 2
-                    new_ident = CoeffIdentifier(tuple(mi), ident.iexpr)
-                    new_eq[new_ident] += v
-            eqs.append(dict(new_eq))
-        return PDE(self.dim, eqs=eqs)
+        p = PDE(self.dim, eqs=[])
+        for j in range(len(self.eqs)):
+            p = p | self[j].grad().div()
+        return p
 
     def __or__(self, other_pde):
         assert self.dim == other_pde.dim
-- 
GitLab