Skip to content
Snippets Groups Projects
Commit 2139e193 authored by Helen Schottenhamml's avatar Helen Schottenhamml
Browse files

Merge branch 'FixZerothTimeStep' into 'master'

[Fix] Zeroth Timestep for outflow boundary

See merge request walberla/walberla!625
parents 64f117da c1d68465
No related merge requests found
from pystencils import Target from pystencils import Target
from pystencils.stencil import inverse_direction 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.advanced_streaming.indexing import MirroredStencilDirections
from lbmpy.boundaries.boundaryconditions import LbBoundary from lbmpy.boundaries.boundaryconditions import LbBoundary
from lbmpy.boundaries import ExtrapolationOutflow, FreeSlip, UBB from lbmpy.boundaries import ExtrapolationOutflow, FreeSlip, UBB
...@@ -26,7 +26,6 @@ def default_additional_data_handler(boundary_obj: LbBoundary, lb_method, field_n ...@@ -26,7 +26,6 @@ def default_additional_data_handler(boundary_obj: LbBoundary, lb_method, field_n
class FreeSlipAdditionalDataHandler(AdditionalDataHandler): class FreeSlipAdditionalDataHandler(AdditionalDataHandler):
def __init__(self, stencil, boundary_object): def __init__(self, stencil, boundary_object):
assert isinstance(boundary_object, FreeSlip) assert isinstance(boundary_object, FreeSlip)
self._boundary_object = boundary_object
super(FreeSlipAdditionalDataHandler, self).__init__(stencil=stencil) super(FreeSlipAdditionalDataHandler, self).__init__(stencil=stencil)
@property @property
...@@ -110,7 +109,6 @@ class FreeSlipAdditionalDataHandler(AdditionalDataHandler): ...@@ -110,7 +109,6 @@ class FreeSlipAdditionalDataHandler(AdditionalDataHandler):
class UBBAdditionalDataHandler(AdditionalDataHandler): class UBBAdditionalDataHandler(AdditionalDataHandler):
def __init__(self, stencil, boundary_object): def __init__(self, stencil, boundary_object):
assert isinstance(boundary_object, UBB) assert isinstance(boundary_object, UBB)
self._boundary_object = boundary_object
super(UBBAdditionalDataHandler, self).__init__(stencil=stencil) super(UBBAdditionalDataHandler, self).__init__(stencil=stencil)
@property @property
...@@ -146,14 +144,18 @@ class UBBAdditionalDataHandler(AdditionalDataHandler): ...@@ -146,14 +144,18 @@ class UBBAdditionalDataHandler(AdditionalDataHandler):
class OutflowAdditionalDataHandler(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) assert isinstance(boundary_object, ExtrapolationOutflow)
self._boundary_object = boundary_object
self._stencil = boundary_object.stencil self._stencil = boundary_object.stencil
self._lb_method = boundary_object.lb_method self._lb_method = boundary_object.lb_method
self._normal_direction = boundary_object.normal_direction self._normal_direction = boundary_object.normal_direction
self._field_name = field_name self._field_name = field_name
self._target = target 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) super(OutflowAdditionalDataHandler, self).__init__(stencil=stencil)
assert sum([a != 0 for a in self._normal_direction]) == 1, \ assert sum([a != 0 for a in self._normal_direction]) == 1, \
...@@ -174,9 +176,9 @@ class OutflowAdditionalDataHandler(AdditionalDataHandler): ...@@ -174,9 +176,9 @@ class OutflowAdditionalDataHandler(AdditionalDataHandler):
f"{len(self._stencil)}> >({self._field_name}{identifier}ID); " f"{len(self._stencil)}> >({self._field_name}{identifier}ID); "
def data_initialisation(self, direction_index): def data_initialisation(self, direction_index):
pdf_acc = AccessPdfValues(self._boundary_object.stencil, pdf_acc = AccessPdfValues(self._stencil,
streaming_pattern=self._boundary_object.streaming_pattern, streaming_pattern=self._streaming_pattern,
timestep=self._boundary_object.zeroth_timestep, timestep=self._zeroth_timestep,
streaming_dir='out') streaming_dir='out')
init_list = [] init_list = []
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment