diff --git a/nutils/expression_v2.py b/nutils/expression_v2.py index 2a2ea78fd..6d15c4a14 100644 --- a/nutils/expression_v2.py +++ b/nutils/expression_v2.py @@ -701,7 +701,7 @@ def define_for(self, __name: str, *, gradient: Optional[str] = None, curl: Optio raise ValueError('The curl can only be defined for a geometry with shape (3,) but got {}.'.format(numpy.shape(geom))) # Definition: `curl_ki(u_...)` := `ε_kji ∇_j(u_...)`. Should be used as # `curl_ki(u_i)`, which is equivalent to `ε_kji ∇_j(u_i)`. - setattr(self, curl, lambda arg: (function.levicivita(3) * function.grad(arg, geom)[..., numpy.newaxis, :, numpy.newaxis]).sum(-2)) + setattr(self, curl, lambda arg: numpy.sum(function.levicivita(3) * function.grad(arg, geom)[..., numpy.newaxis, :, numpy.newaxis], axis=-2)) if normal: setattr(self, normal, function.normal(geom)) for i, jacobian in enumerate(jacobians): diff --git a/nutils/function.py b/nutils/function.py index 45dd42c5e..02c82a2cb 100644 --- a/nutils/function.py +++ b/nutils/function.py @@ -1976,10 +1976,10 @@ def opposite(__arg: IntoArray) -> Array: :func:`jump` : the jump at an interface ''' - arg = Array.cast(__arg) + arg, scale = Array.cast_withscale(__arg) for space in sorted(arg.spaces): arg = _Opposite(arg, space) - return arg + return arg * scale def mean(__arg: IntoArray) -> Array: @@ -2009,8 +2009,7 @@ def mean(__arg: IntoArray) -> Array: array([ 1.5]) ''' - arg = Array.cast(__arg) - return .5 * (arg + opposite(arg)) + return .5 * (__arg + opposite(__arg)) def jump(__arg: IntoArray) -> Array: @@ -2046,8 +2045,7 @@ def jump(__arg: IntoArray) -> Array: array([ 1.]) ''' - arg = Array.cast(__arg) - return opposite(arg) - arg + return opposite(__arg) - __arg # REDUCTION diff --git a/nutils/sample.py b/nutils/sample.py index f3f3dfeb7..74d83e03a 100644 --- a/nutils/sample.py +++ b/nutils/sample.py @@ -446,7 +446,8 @@ def get_evaluable_indices(self, ielem: evaluable.Array) -> evaluable.Array: return evaluable.Range(npoints) + offset def __call__(self, __func: function.IntoArray) -> function.Array: - return _ConcatenatePoints(function.Array.cast(__func), self) + func, funcscale = function.Array.cast_withscale(__func) + return _ConcatenatePoints(func, self) * funcscale class _CustomIndex(_TransformChainsSample): @@ -538,8 +539,8 @@ def integral(self, __func: function.IntoArray) -> function.Array: return function.zeros(func.shape, func.dtype) def __call__(self, __func: function.IntoArray) -> function.Array: - func = function.Array.cast(__func) - return function.zeros((0, *func.shape), func.dtype) + func, funcscale = function.Array.cast_withscale(__func) + return function.zeros((0, *func.shape), func.dtype) * funcscale def basis(self) -> function.Array: return function.zeros((0,), float)