From c3f2b6910110f72bf47596e6ccfcdec641efa6b9 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Wed, 13 Sep 2023 10:24:58 +0200 Subject: [PATCH] Add sanity check to timestep arg of get_accessor --- lbmpy/advanced_streaming/utility.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lbmpy/advanced_streaming/utility.py b/lbmpy/advanced_streaming/utility.py index 72ed100a..d2f4da5a 100644 --- a/lbmpy/advanced_streaming/utility.py +++ b/lbmpy/advanced_streaming/utility.py @@ -58,24 +58,27 @@ odd_accessors = { } +def is_inplace(streaming_pattern): + if streaming_pattern not in streaming_patterns: + raise ValueError('Invalid streaming pattern', streaming_pattern) + + return streaming_pattern in ['aa', 'esotwist', 'esopull', 'esopush'] + + def get_accessor(streaming_pattern: str, timestep: Timestep) -> PdfFieldAccessor: if streaming_pattern not in streaming_patterns: raise ValueError( "Invalid value of parameter 'streaming_pattern'.", streaming_pattern) + if is_inplace(streaming_pattern) and (timestep == Timestep.BOTH): + raise ValueError(f"Invalid timestep for streaming pattern {streaming_pattern}: {str(timestep)}") + if timestep == Timestep.EVEN: return even_accessors[streaming_pattern] else: return odd_accessors[streaming_pattern] -def is_inplace(streaming_pattern): - if streaming_pattern not in streaming_patterns: - raise ValueError('Invalid streaming pattern', streaming_pattern) - - return streaming_pattern in ['aa', 'esotwist', 'esopull', 'esopush'] - - def get_timesteps(streaming_pattern): return (Timestep.EVEN, Timestep.ODD) if is_inplace(streaming_pattern) else (Timestep.BOTH, ) -- GitLab