diff --git a/lbmpy/advanced_streaming/utility.py b/lbmpy/advanced_streaming/utility.py index 72ed100a97db4b5b09c033ab420e9e6a2b544f40..d2f4da5a8aa4c36c6ec49a8d1a46d4879ad2643c 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, )