From 6e67ef2dc48a8aad3edc303213502dace9383adf Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 27 Jul 2023 11:55:09 -0400 Subject: [PATCH] Derivs: Correct 4th order deriv2_1d stencil --- Derivs/src/derivs.hxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Derivs/src/derivs.hxx b/Derivs/src/derivs.hxx index 2b7b1a914..cc9384902 100644 --- a/Derivs/src/derivs.hxx +++ b/Derivs/src/derivs.hxx @@ -248,10 +248,11 @@ inline CCTK_ATTRIBUTE_ALWAYS_INLINE // constexpr T c2 = -1 / T(12); // return (c2 * (var(-2) + var(2)) + c1 * (var(-1) + var(1)) + c0 * var(0)) / // pow2(dx); - const T c0 = 15 / (12 * pow2(dx)); - const T c1 = -1 / (12 * pow2(dx)); - return c1 * ((var(4) - var(1)) - (var(3) - var(0))) + - c0 * ((var(3) - var(2)) - (var(2) - var(1))); + constexpr T c0 = 4 / T(3); + constexpr T c1 = -1 / T(12); + return (c1 * ((var(+2) - var(+0)) - (var(-0) - var(-2))) + + c0 * ((var(+1) - var(+0)) - (var(-0) - var(-1)))) / + pow2(dx); } template