diff --git a/grudge/eager.py b/grudge/eager.py index a67f2b46a9c4f1ecfa9341343666a2b3070f7a08..a1385685eabce917c75cfe2f49d379000ef33333 100644 --- a/grudge/eager.py +++ b/grudge/eager.py @@ -166,6 +166,18 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries): return bind(self, sym.norm(p, sym.var("arg")), local_only=True) def norm(self, vec, p=2): + if (isinstance(vec, np.ndarray) + and vec.dtype.char == "O" + and not isinstance(vec, DOFArray)): + if p == 2: + return sum( + self.norm(vec[idx])**2 + for idx in np.ndindex(vec.shape))**0.5 + elif p == np.inf: + return max(self.norm(vec[idx]) for idx in np.ndindex(vec.shape)) + else: + raise ValueError("unsupported norm order") + return self._norm(p)(arg=vec) @memoize_method