diff --git a/python/lbmpy_walberla/templates/BoundaryCollection.tmpl.h b/python/lbmpy_walberla/templates/BoundaryCollection.tmpl.h index 47f313860dacc6cf69c783047c3ed53e82bcb91b..ea4e7dd48c6786a4f804e346a71b377fb9a2da47 100644 --- a/python/lbmpy_walberla/templates/BoundaryCollection.tmpl.h +++ b/python/lbmpy_walberla/templates/BoundaryCollection.tmpl.h @@ -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) -%} diff --git a/python/pystencils_walberla/jinja_filters.py b/python/pystencils_walberla/jinja_filters.py index b2413bcefe8c4a4468e4971c1b8901116519c57d..6d05bf8ffd51808821311bf09f0db263570983b9 100644 --- a/python/pystencils_walberla/jinja_filters.py +++ b/python/pystencils_walberla/jinja_filters.py @@ -378,21 +378,40 @@ def generate_call(ctx, kernel, ghost_layers_to_include=0, cell_interval=None, st @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)