render_templates.py
Stuff related to rendering templates.
- render_templates.init_jinja_env(template_dir: str = '') Environment
Initialise the jinja2 environment.
- Parameters:
template_dir (str) – which directory to read templates from. If template_dir is a relative path, it will be appended to _default_template_dir. If it is an absolute path, it will be used as a full path to the directory instead.
- Returns:
env – A set-up jinja2 environment to be used to render templates
- Return type:
jinja2.Environment
- render_templates.jinja_render_hydro_part_arrays_flush_dot_h(part_structs_d: dict, metadata_d: dict, swift_header: bool = True) str
Generates the full hydro_part_arrays_flush.h header.
- Parameters:
part_structs_d (dict) – dict containing processed data ready to be inserted into the template. The dict’s keys shall be names of particle data structs to be generated. Each key shall return a dict with two keys: - “DOC”: Struct documentation, if available - “HAS_DOC”: bool saying whether struct documentation is available
metadata_d (dict) – dict containing particle (flavour) metadata
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
- Returns:
header_template – the rendered template as a string
- Return type:
str
- render_templates.jinja_render_hydro_part_arrays_struct_dot_h(part_structs_d: dict, metadata_d: dict, swift_header: bool = True) str
Generates the full hydro_part_arrays_struct.h header.
- Parameters:
part_structs_d (dict) – dict containing processed data ready to be inserted into the template. The dict’s keys shall be names of particle data structs to be generated. Each key shall return a dict with two keys: - “DOC”: Struct documentation, if available - “HAS_DOC”: bool saying whether struct documentation is available
metadata_d (dict) – dict containing particle (flavour) metadata
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
- Returns:
header_template – the rendered template as a string
- Return type:
str
- render_templates.jinja_render_hydro_part_dot_h(part_structs_d: dict, metadata_d: dict, swift_header: bool = True, manual_struct_align: bool = False, explicit_var_accessors: bool = False, global_var_accessors: bool = False, part_struct_accessors: bool = False, testing: bool = False) str
Generates the full hydro_part.h header.
- Parameters:
part_structs_d (dict) –
dict containing processed data ready to be inserted into the template. The dict’s keys shall be names of particle structs to be generated. Each key shall return a dict with two keys:
”API”: containing a list of strings containing C-code for the particle field API
”DECLARATIONS”: containing a list of strings containing C-code for the particle field declarations
metadata_d (dict) – dict containing particle (flavour) metadata
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
manual_struct_align (bool) – if True, generate a different
SWIFT_STRUCT_ALIGN_macro for each struct.explicit_var_accessors (bool) – if True, generate getters/setters which use explicitly passed pointer as an argument
global_var_accessors (bool) – if True, also generate getters/setters which use global variable pointer
part_struct_accessors (bool) – if True, generate getters/setters using a part struct
testing (bool) – if True, use minimalistic header template for unit tests to generate header file
- Returns:
header_template – the rendered template as a string
- Return type:
str
- render_templates.jinja_render_parts_dot_h(part_structs_d: dict, metadata_d: dict, swift_header: bool = True, id_checks: bool = True) str
Generates the full parts.h header.
- Parameters:
part_structs_d (dict) – dict containing processed data ready to be inserted into the template. The dict’s keys shall be names of particle data structs to be generated. Each key shall return a dict with two keys: - “DOC”: Struct documentation, if available - “HAS_DOC”: bool saying whether struct documentation is available
metadata_d (dict) – dict containing particle (flavour) metadata
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
id_checks (bool) – If True, add initialisation of particle accessor_id variables
- Returns:
header_template – the rendered template as a string
- Return type:
str
- render_templates.jinja_render_rt_struct_dot_h(rt_d: dict, metadata_d: dict, swift_header: bool = True, manual_struct_align: bool = False, explicit_var_accessors: bool = False, global_var_accessors: bool = False, part_struct_accessors: bool = False) str
Renders the full rt_struct.h header.
- Parameters:
TODO (CHECK DOCU)
rt_d (dict) –
dict containing processed data ready to be inserted into the template. The dict’s keys shall be names of struct to be generated. Each key shall return a dict with two keys:
”API”: containing a list of strings containing C-code for the particle field API
”DECLARATIONS”: containing a list of strings containing C-code for the particle field declarations
metadata_d (dict) – dict containing file metadata, as read-in from the yml file (and postprocessed)
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
explicit_var_accessors (bool) – if True, generate getters/setters which use explicitly passed pointer as an argument
global_var_accessors (bool) – if True, also generate getters/setters which use global variable pointer
part_struct_accessors (bool) – if True, generate getters/setters using a part struct
- Returns:
header_template – the rendered template as a string
- Return type:
str
- render_templates.jinja_render_timestep_limiter_struct_dot_h(limiter_structs_d: dict, metadata_d: dict, swift_header: bool = True, manual_struct_align: bool = False, explicit_var_accessors: bool = False, global_var_accessors: bool = False, part_struct_accessors: bool = False) str
Generates the full timestep_limiter_struct.h header.
- Parameters:
TODO (CHECK DOCU)
limiter_structs_d (dict) –
dict containing processed data ready to be inserted into the template. The dict’s keys shall be names of struct to be generated. Each key shall return a dict with two keys:
”API”: containing a list of strings containing C-code for the particle field API
”DECLARATIONS”: containing a list of strings containing C-code for the particle field declarations
metadata_d (dict) – dict containing file metadata, as read-in from the yml file (and postprocessed)
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
explicit_var_accessors (bool) – if True, generate getters/setters which use explicitly passed pointer as an argument
global_var_accessors (bool) – if True, also generate getters/setters which use global variable pointer
part_struct_accessors (bool) – if True, generate getters/setters using a part struct
- Returns:
header_template – the rendered template as a string
- Return type:
str
- render_templates.jinja_render_top_level_hydro_part_dot_h(hydro_part_d: dict, inputfiles: list, swift_header: bool = True, explicit_var_accessors: bool = False, global_var_accessors: bool = False, part_struct_accessors: bool = False) str
Generates the full src/hydro_part.h header.
- Parameters:
TODO (FIX DOCU)
limiter_structs_d (dict) –
dict containing processed data ready to be inserted into the template. The dict’s keys shall be names of struct to be generated. Each key shall return a dict with two keys:
”API”: containing a list of strings containing C-code for the particle field API
”DECLARATIONS”: containing a list of strings containing C-code for the particle field declarations
inputfiles (list) – list of yml files read as input
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
explicit_var_accessors (bool) – if True, generate getters/setters which use explicitly passed pointer as an argument
global_var_accessors (bool) – if True, also generate getters/setters which use global variable pointer
part_struct_accessors (bool) – if True, generate getters/setters using a part struct
- Returns:
header_template – the rendered template as a string
- Return type:
str