From dc120e4609aa1c590a5b2ac8b5f536a9edfccf61 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 17 Aug 2020 11:43:56 -0500 Subject: [PATCH] Complain if trying to compute norms of non-vector arrays --- grudge/symbolic/operators.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grudge/symbolic/operators.py b/grudge/symbolic/operators.py index b47611d7..b95575f6 100644 --- a/grudge/symbolic/operators.py +++ b/grudge/symbolic/operators.py @@ -724,6 +724,9 @@ def norm(p, arg, dd=None): prim.fabs(arg * MassOperator()(arg))) if isinstance(norm_squared, np.ndarray): + if len(norm_squared.shape) != 1: + raise NotImplementedError("can only take the norm of vectors") + norm_squared = norm_squared.sum() return prim.sqrt(norm_squared) @@ -732,6 +735,9 @@ def norm(p, arg, dd=None): result = NodalMax(dd_in=dd)(prim.fabs(arg)) if isinstance(result, np.ndarray): + if len(result.shape) != 1: + raise NotImplementedError("can only take the norm of vectors") + from pymbolic.primitives import Max result = Max(result) -- GitLab