def norm(p, arg, dd=None): """ :arg arg: is assumed to be a vector, i.e. have shape ``(n,)``. """ sym = _sym() if dd is None: dd = sym.DD_VOLUME dd = sym.as_dofdesc(dd) if p == 2: norm_squared = sym.NodalSum(dd_in=dd)( sym.FunctionSymbol("fabs")( arg * sym.MassOperator()(arg))) if isinstance(norm_squared, np.ndarray): norm_squared = norm_squared.sum() return sym.FunctionSymbol("sqrt")(norm_squared) elif p == np.Inf: result = sym.NodalMax(dd_in=dd)(sym.FunctionSymbol("fabs")(arg)) from pymbolic.primitives import Max if isinstance(result, np.ndarray): from functools import reduce result = reduce(Max, result) return result else: raise ValueError("unsupported value of p")
def max_eigenvalue_expr(self): """Return the largest eigenvalue of Maxwell's equations as a hyperbolic system. """ from math import sqrt if self.fixed_material: return 1/sqrt(self.epsilon*self.mu) # a number else: import grudge.symbolic as sym return sym.NodalMax()(1/sym.FunctionSymbol("sqrt")(self.epsilon*self.mu))
def max_eigenvalue(self, t, fields=None, discr=None): return sym.NodalMax()(sym.FunctionSymbol("fabs")(self.c))
def max_eigenvalue(self, t, fields=None, discr=None): return sym.NodalMax("vol")(sym.fabs(self.c))