diff --git a/python/lbmpy_walberla/boundary.py b/python/lbmpy_walberla/boundary.py index 89c0a7d97d8aea3c1693c2ad59b2c91143d7cf58..b3fbb8c318e94387031467bbe6c0cf380affd5e0 100644 --- a/python/lbmpy_walberla/boundary.py +++ b/python/lbmpy_walberla/boundary.py @@ -41,6 +41,10 @@ def generate_boundary(generation_context, class_name, boundary_object, lb_method stencil = lb_method.stencil stencil_info = [(i, d, ", ".join([str(e) for e in d])) for i, d in enumerate(stencil)] + inv_dirs = [] + for direction in stencil: + inverse_dir = tuple([-i for i in direction]) + inv_dirs.append(stencil.index(inverse_dir)) context = { 'class_name': boundary_object.name, @@ -48,6 +52,7 @@ def generate_boundary(generation_context, class_name, boundary_object, lb_method 'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype), 'kernel': KernelInfo(kernel), 'stencil_info': stencil_info, + 'inverse_directions' : inv_dirs, 'dim': lb_method.dim, 'target': target, 'namespace': 'lbm', diff --git a/python/pystencils_walberla/boundary.py b/python/pystencils_walberla/boundary.py index 2df49896e38ae1c34f8266e9007369d1e28f3791..6a93733e2fe2f57d919120c881de0bfa83d953ed 100644 --- a/python/pystencils_walberla/boundary.py +++ b/python/pystencils_walberla/boundary.py @@ -41,6 +41,10 @@ def generate_staggered_boundary(generation_context, class_name, boundary_object, stencil = neighbor_stencil stencil_info = [(i, d, ", ".join([str(e) for e in d])) for i, d in enumerate(stencil)] + inv_dirs = [] + for direction in stencil: + inverse_dir = tuple([-i for i in direction]) + inv_dirs.append(stencil.index(inverse_dir)) context = { 'class_name': boundary_object.name, @@ -48,6 +52,7 @@ def generate_staggered_boundary(generation_context, class_name, boundary_object, 'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype), 'kernel': KernelInfo(kernel), 'stencil_info': stencil_info, + 'inverse_directions' : inv_dirs, 'dim': dim, 'target': target, 'namespace': 'pystencils', @@ -95,6 +100,10 @@ def generate_staggered_flux_boundary(generation_context, class_name, boundary_ob stencil = neighbor_stencil stencil_info = [(i, d, ", ".join([str(e) for e in d])) for i, d in enumerate(stencil)] + inv_dirs = [] + for direction in stencil: + inverse_dir = tuple([-i for i in direction]) + inv_dirs.append(stencil.index(inverse_dir)) context = { 'class_name': boundary_object.name, @@ -102,6 +111,7 @@ def generate_staggered_flux_boundary(generation_context, class_name, boundary_ob 'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype), 'kernel': KernelInfo(kernel), 'stencil_info': stencil_info, + 'inverse_directions' : inv_dirs, 'dim': dim, 'target': target, 'namespace': 'pystencils', diff --git a/python/pystencils_walberla/templates/Boundary.tmpl.h b/python/pystencils_walberla/templates/Boundary.tmpl.h index 1c3d9c0e26837043000ad938482226d22946a901..46c8b69d21222daed9870cd7ba179ed2d376b4d2 100644 --- a/python/pystencils_walberla/templates/Boundary.tmpl.h +++ b/python/pystencils_walberla/templates/Boundary.tmpl.h @@ -164,7 +164,7 @@ public: {% if inner_or_boundary -%} auto element = {{StructName}}(it.x(), it.y(), {%if dim == 3%} it.z(), {%endif %} {{dirIdx}} ); {% else -%} - auto element = {{StructName}}(it.x() + cell_idx_c({{dirVec[0]}}), it.y() + cell_idx_c({{dirVec[1]}}), {%if dim == 3%} it.z() + cell_idx_c({{dirVec[2]}}), {%endif %} {{dirIdx}} ); + auto element = {{StructName}}(it.x() + cell_idx_c({{dirVec[0]}}), it.y() + cell_idx_c({{dirVec[1]}}), {%if dim == 3%} it.z() + cell_idx_c({{dirVec[2]}}), {%endif %} {{inverse_directions[dirIdx]}} ); {% endif -%} indexVectorAll.push_back( element ); if( inner.contains( it.x(), it.y(), it.z() ) )