From c1d6846582838a53d1695809aa450a62fed3941f Mon Sep 17 00:00:00 2001 From: Markus Holzer <markus.holzer@fau.de> Date: Tue, 19 Sep 2023 09:30:59 +0200 Subject: [PATCH] [Fix] Zeroth Timestep for outflow boundary --- .../lbmpy_walberla/additional_data_handler.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/python/lbmpy_walberla/additional_data_handler.py b/python/lbmpy_walberla/additional_data_handler.py index 692d0cf57..102177487 100644 --- a/python/lbmpy_walberla/additional_data_handler.py +++ b/python/lbmpy_walberla/additional_data_handler.py @@ -1,7 +1,7 @@ from pystencils import Target from pystencils.stencil import inverse_direction -from lbmpy.advanced_streaming import AccessPdfValues, numeric_offsets, numeric_index +from lbmpy.advanced_streaming import AccessPdfValues, numeric_offsets, numeric_index, Timestep, is_inplace from lbmpy.advanced_streaming.indexing import MirroredStencilDirections from lbmpy.boundaries.boundaryconditions import LbBoundary from lbmpy.boundaries import ExtrapolationOutflow, FreeSlip, UBB @@ -26,7 +26,6 @@ def default_additional_data_handler(boundary_obj: LbBoundary, lb_method, field_n class FreeSlipAdditionalDataHandler(AdditionalDataHandler): def __init__(self, stencil, boundary_object): assert isinstance(boundary_object, FreeSlip) - self._boundary_object = boundary_object super(FreeSlipAdditionalDataHandler, self).__init__(stencil=stencil) @property @@ -110,7 +109,6 @@ class FreeSlipAdditionalDataHandler(AdditionalDataHandler): class UBBAdditionalDataHandler(AdditionalDataHandler): def __init__(self, stencil, boundary_object): assert isinstance(boundary_object, UBB) - self._boundary_object = boundary_object super(UBBAdditionalDataHandler, self).__init__(stencil=stencil) @property @@ -146,14 +144,18 @@ class UBBAdditionalDataHandler(AdditionalDataHandler): class OutflowAdditionalDataHandler(AdditionalDataHandler): - def __init__(self, stencil, boundary_object, target=Target.CPU, field_name='pdfs'): + def __init__(self, stencil, boundary_object, target=Target.CPU, field_name='pdfs', zeroth_timestep=None): assert isinstance(boundary_object, ExtrapolationOutflow) - self._boundary_object = boundary_object self._stencil = boundary_object.stencil self._lb_method = boundary_object.lb_method self._normal_direction = boundary_object.normal_direction self._field_name = field_name self._target = target + self._streaming_pattern = boundary_object.streaming_pattern + if zeroth_timestep: + self._zeroth_timestep = zeroth_timestep + else: + self._zeroth_timestep = Timestep.EVEN if is_inplace(self._streaming_pattern) else Timestep.BOTH super(OutflowAdditionalDataHandler, self).__init__(stencil=stencil) assert sum([a != 0 for a in self._normal_direction]) == 1, \ @@ -174,9 +176,9 @@ class OutflowAdditionalDataHandler(AdditionalDataHandler): f"{len(self._stencil)}> >({self._field_name}{identifier}ID); " def data_initialisation(self, direction_index): - pdf_acc = AccessPdfValues(self._boundary_object.stencil, - streaming_pattern=self._boundary_object.streaming_pattern, - timestep=self._boundary_object.zeroth_timestep, + pdf_acc = AccessPdfValues(self._stencil, + streaming_pattern=self._streaming_pattern, + timestep=self._zeroth_timestep, streaming_dir='out') init_list = [] -- GitLab