Could be replaced by generated or templated functions for each stencil direction. However unsure if the switch is optimized away by the compiler anyway.