headers.py
- headers.generate_hydro_part_arrays_flush_dot_h(part_d: dict, metadata_d: dict, swift_header: bool = True) str
Generate a hydro_part_arrays_flush.h, which contains the functions needed for particle data flushing.
- Parameters:
part_d (dict) – dict containing the read-in particle struct fields
metadata_d (dict) – dict containing particle (flavour) metadata
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
- Returns:
header_file – The contents of the hydro_part.h file.
- Return type:
str
- headers.generate_hydro_part_arrays_struct_dot_h(part_d: dict, metadata_d: dict, swift_header: bool = True) str
Generate a hydro_part_arrays_struct.h, which contains a struct part_arrays, containing pointers to all particle fields in a cell.
- Parameters:
part_d (dict) – dict containing the read-in particle struct fields
metadata_d (dict) – dict containing particle (flavour) metadata
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
- Returns:
header_file – The contents of the hydro_part.h file.
- Return type:
str
- headers.generate_hydro_part_dot_h(part_d: dict, metadata_d: dict, swift_header: bool = True, id_checks: bool = True, manual_align: bool = False, explicit_var_accessors: bool = False, global_var_accessors: bool = False, part_struct_accessors: bool = False, testing: bool = False) str
Generate a src/<flavour>/hydro_part.h.
- Parameters:
part_d (dict) – dict containing the read-in particle struct fields
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 a struct_id field to every struct for debugging checks and a debugging check in each getter/setter
manual_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, 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_file – The contents of the hydro_part.h file.
- Return type:
str
- headers.generate_hydro_space_dot_c(part_d: dict, metadata_d: dict, swift_header: bool = True) str
Generate a hydro_space.c which contains the functions needed for Required by space.[ch]
- Parameters:
part_d (dict) – dict containing the read-in particle struct fields
metadata_d (dict) – dict containing particle (flavour) metadata
swift_header (bool) – if True, generate headers compatible with swift, not swiftgpupacksim
- Returns:
header_file – The contents of the hydro_part.h file.
- Return type:
str
- headers.generate_parts_dot_h(part_d: dict, metadata_d: dict, swift_header: bool = True, id_checks: bool = True) str
Generate a parts.h, which contains:
init_part_arrays(), function to allocate memory for all arrays in struct part_arraysclear_parts(), function to free all data allocated ininit_part_arrays()
- Parameters:
part_d (dict) – dict containing the read-in particle struct fields
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_file – The contents of the hydro_part.h file.
- Return type:
str
- headers.generate_rt_struct_dot_h(rt_d: dict, metadata_d: dict, swift_header: bool = True, explicit_var_accessors: bool = False, global_var_accessors: bool = False, part_struct_accessors: bool = False) str
Generate a timestep_limiter_struct.h
- Parameters:
rt_d (dict) – dict containing the read-in rt struct fields
metadata_d (dict) – dict containing limiter metadata
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, generate getters/setters which use global variable pointer
part_struct_accessors (bool) – if True, generate getters/setters using a part struct
- Returns:
header_file – The contents of the timeste_limiter_struct.h file.
- Return type:
str
- headers.generate_timestep_limiter_struct_dot_h(limiter_d: dict, metadata_d: dict, swift_header: bool = True, explicit_var_accessors: bool = False, global_var_accessors: bool = False, part_struct_accessors: bool = False) str
Generate a timestep_limiter_struct.h
- Parameters:
limiter_d (dict) – dict containing the read-in limiter struct fields
metadata_d (dict) – dict containing limiter metadata
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, generate getters/setters which use global variable pointer
part_struct_accessors (bool) – if True, generate getters/setters using a part struct
- Returns:
header_file – The contents of the timeste_limiter_struct.h file.
- Return type:
str
- headers.generate_top_level_hydro_part_dot_h(inputs: dict, swift_header: bool = True, explicit_var_accessors: bool = False, global_var_accessors: bool = False, part_struct_accessors: bool = False) str
Generate a top level hydro_part.h file, i.e. src/hydro_part.h.
This file is special: It contains the getters/setters API for quantities that each particle needs to have, as they are used outside of the hydro kernels, such as time step related variables. As such, the getters/setters access the relevant structs first, not directly particles. Eacch of these structs should have its own getters and setters defined already, using only the struct to access the relevant members.
- Parameters:
inputs (dict containing pairs of yml input files (keys) and struct data) –
(values) to be used in the API, where the data should be another dict containing the name of the struct itself (“struct” key) and the name used in the API (“name” key)
Example: inputs = {“timestep_limiter_struct.yml”: data} data = {“struct”: “timestep_limiter_data”, “name”: “timestep_limiter”}
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, generate getters/setters which use global variable pointer
part_struct_accessors (bool) – if True, generate getters/setters using a part struct
- Returns:
header_file – The contents of the timeste_limiter_struct.h file.
- Return type:
str