Skip to content
Snippets Groups Projects
Commit dc00b2d8 authored by Michael Kuron's avatar Michael Kuron :mortar_board:
Browse files

staggered boundary generation: direction index should point to fluid cell when...

staggered boundary generation: direction index should point to fluid cell when inner_or_boundary=False

In that case, the index vector contains the boundary cells, so the direction should point to the fluid cell.
When inner_or_boundary=True, the index vector contains the fluid cells and the direction points to the boundary cell.
parent 5110ba9b
No related merge requests found
...@@ -41,6 +41,10 @@ def generate_boundary(generation_context, class_name, boundary_object, lb_method ...@@ -41,6 +41,10 @@ def generate_boundary(generation_context, class_name, boundary_object, lb_method
stencil = lb_method.stencil stencil = lb_method.stencil
stencil_info = [(i, d, ", ".join([str(e) for e in d])) for i, d in enumerate(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 = { context = {
'class_name': boundary_object.name, 'class_name': boundary_object.name,
...@@ -48,6 +52,7 @@ def generate_boundary(generation_context, class_name, boundary_object, lb_method ...@@ -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), 'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype),
'kernel': KernelInfo(kernel), 'kernel': KernelInfo(kernel),
'stencil_info': stencil_info, 'stencil_info': stencil_info,
'inverse_directions' : inv_dirs,
'dim': lb_method.dim, 'dim': lb_method.dim,
'target': target, 'target': target,
'namespace': 'lbm', 'namespace': 'lbm',
......
...@@ -41,6 +41,10 @@ def generate_staggered_boundary(generation_context, class_name, boundary_object, ...@@ -41,6 +41,10 @@ def generate_staggered_boundary(generation_context, class_name, boundary_object,
stencil = neighbor_stencil stencil = neighbor_stencil
stencil_info = [(i, d, ", ".join([str(e) for e in d])) for i, d in enumerate(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 = { context = {
'class_name': boundary_object.name, 'class_name': boundary_object.name,
...@@ -48,6 +52,7 @@ def generate_staggered_boundary(generation_context, class_name, boundary_object, ...@@ -48,6 +52,7 @@ def generate_staggered_boundary(generation_context, class_name, boundary_object,
'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype), 'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype),
'kernel': KernelInfo(kernel), 'kernel': KernelInfo(kernel),
'stencil_info': stencil_info, 'stencil_info': stencil_info,
'inverse_directions' : inv_dirs,
'dim': dim, 'dim': dim,
'target': target, 'target': target,
'namespace': 'pystencils', 'namespace': 'pystencils',
...@@ -95,6 +100,10 @@ def generate_staggered_flux_boundary(generation_context, class_name, boundary_ob ...@@ -95,6 +100,10 @@ def generate_staggered_flux_boundary(generation_context, class_name, boundary_ob
stencil = neighbor_stencil stencil = neighbor_stencil
stencil_info = [(i, d, ", ".join([str(e) for e in d])) for i, d in enumerate(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 = { context = {
'class_name': boundary_object.name, 'class_name': boundary_object.name,
...@@ -102,6 +111,7 @@ def generate_staggered_flux_boundary(generation_context, class_name, boundary_ob ...@@ -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), 'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype),
'kernel': KernelInfo(kernel), 'kernel': KernelInfo(kernel),
'stencil_info': stencil_info, 'stencil_info': stencil_info,
'inverse_directions' : inv_dirs,
'dim': dim, 'dim': dim,
'target': target, 'target': target,
'namespace': 'pystencils', 'namespace': 'pystencils',
......
...@@ -164,7 +164,7 @@ public: ...@@ -164,7 +164,7 @@ public:
{% if inner_or_boundary -%} {% if inner_or_boundary -%}
auto element = {{StructName}}(it.x(), it.y(), {%if dim == 3%} it.z(), {%endif %} {{dirIdx}} ); auto element = {{StructName}}(it.x(), it.y(), {%if dim == 3%} it.z(), {%endif %} {{dirIdx}} );
{% else -%} {% 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 -%} {% endif -%}
indexVectorAll.push_back( element ); indexVectorAll.push_back( element );
if( inner.contains( it.x(), it.y(), it.z() ) ) if( inner.contains( it.x(), it.y(), it.z() ) )
......
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