Skip to content

Commit

Permalink
Merge branch 'holzer-master-patch-a261' into 'master'
Browse files Browse the repository at this point in the history
[Fix] Usage of field data in generated BC

See merge request walberla/walberla!664
  • Loading branch information
schottenhamml committed Apr 5, 2024
2 parents 702f529 + 47e6bd9 commit ead8a37
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/lbmpy_walberla/templates/BoundaryCollection.tmpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class {{class_name}}
{
{% for object_name, boundary_class, kernel, additional_data_handler in zip(object_names, boundary_classes, kernel_list, additional_data_handlers) -%}

{{object_name}} = std::make_shared< {{boundary_class}} >({{- ["blocks", "pdfsID", [kernel|generate_function_collection_call(['indexVector', 'indexVectorSize', 'pdfs', 'timestep', 'gpuStream'])], additional_data_handler.constructor_argument_name] | type_identifier_list -}});
{{object_name}} = std::make_shared< {{boundary_class}} >({{- ["blocks", "pdfsID", [kernel|generate_function_collection_call(['indexVector', 'indexVectorSize', 'pdfs', 'timestep', 'gpuStream'], use_field_ids=True)], additional_data_handler.constructor_argument_name] | type_identifier_list -}});
{% endfor %}

{% for object_name, flag_uid in zip(object_names, flag_uids) -%}
Expand Down
29 changes: 24 additions & 5 deletions python/pystencils_walberla/jinja_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,21 +378,40 @@ def get_end_coordinates(field_object):


@jinja2_context_decorator
def generate_function_collection_call(ctx, kernel_info, parameters_to_ignore=(), cell_interval=None, ghost_layers=None):
def generate_function_collection_call(ctx, kernel, parameters_to_ignore=(),
cell_interval=None, ghost_layers=None, use_field_ids=False):

"""Generates the function call to a pystencils kernel. It can be understood as a lightweight version of
`generate_call`. Thus, it will only generate the parameters needed to call the kernel as a list of strings.
Args:
ctx: code generation context
kernel: pystencils kernel
parameters_to_ignore: In some cases not all parameters need to be printed. This is especially the case when
fixed parameters exist that are hardcoded in the jinja template.
cell_interval: Defines the name (string) of a walberla CellInterval object in scope.
ghost_layers: Defines the name (string) of a variable to define the number of used ghost_layers.
use_field_ids: If set to true field names will be printed with the suffix `ID_`, to indicated that
a BlockDataID is passed.
"""

target = translate_target(ctx['target'])
is_gpu = target == Target.GPU

parameters = []
for param in kernel_info.parameters:
for param in kernel.parameters:
if param.is_field_pointer and param.field_name not in parameters_to_ignore:
parameters.append(param.field_name)
if use_field_ids:
parameters.append(f"{param.field_name}ID_")
else:
parameters.append(param.field_name)

for param in kernel_info.parameters:
for param in kernel.parameters:
if not param.is_field_parameter and param.symbol.name not in parameters_to_ignore:
parameters.append(param.symbol.name)

# TODO due to backward compatibility with high level interface spec
for parameter in kernel_info.kernel_selection_tree.get_selection_parameter_list():
for parameter in kernel.kernel_selection_tree.get_selection_parameter_list():
if parameter.name not in parameters_to_ignore:
parameters.append(parameter.name)

Expand Down

0 comments on commit ead8a37

Please sign in to comment.