jaxfluids.io_utils package

Submodules

jaxfluids.io_utils.logger module

class jaxfluids.io_utils.logger.Logger(logger_name: str = '', logging_level: str = 'INFO')[source]

Bases: object

Logger for the JAX-FLUIDS solver. Logs information during the simulation to file and/or screen.

configure_logger(log_path: str) None[source]

Configures the logger. Sets up formatter, file and stream handler.

Parameters:

log_path (str) – Path to which logs are saved.

hline() None[source]

Inserts a dashed horizontal line in log.

log_end_time_step(info_list: List) None[source]

Logs information at the end of an integration step.

Parameters:

info_list (List) – List of strings to be printed at the end of an integration step.

log_initialization() None[source]

Logs the initialization of the SimManager.

log_jax_fluids() None[source]
log_numerical_setup_and_case_setup(numerica_setup_dict: Dict, case_setup_dict: Dict) None[source]

Logs numerical setup and input file.

Parameters:
  • numerica_setup_dict (Dict) – Dictionary which contains information on the numerical setup.

  • case_setup_dict (Dict) – Dictionary which contains information on the case setup.

log_sim_finish(end_time: float) None[source]

Logs the simulation end.

Parameters:

end_time (float) – Final simulation time.

log_sim_start() None[source]

Logs the simulation start.

log_start_time_step(info_list: List) None[source]

Logs information at the beginning of an integration step.

Parameters:

info_list (List) – List of strings to be printed at the start of an integration step.

log_turbulent_stats_at_start(turb_stats_dict: Dict) None[source]

Logs the turbulent statistics of the initial turbulent flow field.

Parameters:

turb_stats_dict (Dict) – Dictionary which information on turbulent statistics.

log_turbulent_stats_running(turb_stats_running_dict: Dict) None[source]

Logs the running turbulent statistics during a turbulent simulation.

Parameters:

turb_stats_running_dict (Dict) – Dictionary which information on turbulent statistics.

nline() None[source]

Inserts a line break in log.

jaxfluids.io_utils.output_writer module

class jaxfluids.io_utils.output_writer.OutputWriter(input_reader: InputReader, unit_handler: UnitHandler, domain_information: DomainInformation, material_manager: MaterialManager, levelset_handler: LevelsetHandler, derivative_stencil_conservatives: SpatialDerivative, derivative_stencil_geometry: SpatialDerivative | None)[source]

Bases: object

Output writer for JAX-FLUIDS. The OutputWriter class can write h5 and xdmf files. h5 and xdmf files can be visualized in paraview. Xdmf output is activated via the is_xdmf_file flag under the output keyword in the numerical setup.

If the xdmf option is activated, a single xdmf file is written for each h5 file. Additionally, at the end of the simulation, an time series xdmf file is written which summarizes the whole simulation. This enables loading the entire timeseries into Paraview.

compute_absolute_velocity(velocity: Array) Array[source]

Computes the absolute velocity field for h5 output.

Parameters:

velocity (jnp.ndarray) – Buffer of velocities.

Returns:

Buffer of absolute velocity.

Return type:

jnp.ndarray

compute_absolute_vorticity(velocity: Array) Array[source]

Computes absolute vorticity field for h5 output.

Parameters:

velocity (jnp.ndarray) – Buffer of velocities.

Returns:

Buffer of absolute vorticity.

Return type:

jnp.ndarray

compute_mach_number(primes: Array, volume_fraction: Array | None) Array[source]

Computes the Mach number field for h5 output.

Parameters:
  • primes (jnp.ndarray) – Buffer of primitive variables.

  • volume_fraction (Union[jnp.ndarray, None]) – Buffer of volume fraction.

Returns:

Buffer of Mach number.

Return type:

jnp.ndarray

compute_miscellaneous(primes: Array, quantity: str, volume_fraction: Array | None) Array[source]

Compute miscellaneous output fields for h5 output.

Parameters:
  • primes (jnp.ndarray) – Buffer of primitive variables.

  • quantity (str) – String identifier of the quantity to be computed.

  • volume_fraction (Union[jnp.ndarray, None]) – Buffer of the volume fraction field, only for two-phase simulations. Otherwise None.

Returns:

Computed phyiscal output quantity.

Return type:

jnp.ndarray

compute_real_buffer(buffer: Array, volume_fraction: Array) Array[source]

For two-phase simulations, merges the two separate phase buffers into a single real buffer. Calculation is done as a arithmetic average based on the volume fraction.

Parameters:
  • buffer (jnp.ndarray) – Data buffer.

  • volume_fraction (jnp.ndarray) – Buffer of the volume fraction.

Returns:

Combined data buffer of the ‘real’ fluid.

Return type:

jnp.ndarray

compute_schlieren(density: Array) Array[source]

Computes numerical schlieren field for h5 output.

Parameters:

density (jnp.ndarray) – Buffer of density.

Returns:

Buffer of schlieren.

Return type:

jnp.ndarray

compute_vorticity(velocity: Array) Array[source]

Computes vorticity field for h5 output.

Parameters:

velocity (jnp.ndarray) – Buffer of velocities.

Returns:

Buffer of vorticity.

Return type:

jnp.ndarray

create_folder() None[source]

Sets up a folder for the simulation. Dumps the numerical setup and cas setup into the simulation folder and creates an output folder within in simulation folder into which simulation output is saved.

simulation_folder —- Numerical setup —- Case setup —- domain

get_folder_name() Tuple[str, str][source]

Returns a name for the simulation folder based on the case name.

Returns:

Path to the simulation folder and path to domain folder within simulation folder.

Return type:

Tuple[str, str]

get_xdmf(group: str, quant: str, h5file_name: str, Nx: int, Ny: int, Nz: int) str[source]

Returns the string for the xdmf file for the given output quantity.

Parameters:
  • group (str) – Group name in h5 file under which the quantity is stored.

  • quant (str) – Name of the output quantity.

  • h5file_name (str) – Name of the corresponding h5 file.

  • Nx (int) – Resolution in x direction.

  • Ny (int) – Resolution in y direction.

  • Nz (int) – Resolution in z direction.

Returns:

Xdmf string for the specified quantity.

Return type:

str

write_h5file(buffer_dictionary: Dict[str, Dict[str, Array]]) None[source]
write_output(buffer_dictionary: Dict[str, Dict[str, Array | float]], force_output: bool, simulation_finish: bool = False) None[source]

Writes h5 and (optional) xdmf output.

Parameters:
  • buffer_dictionary (Dict[str, Dict[str, Union[jnp.ndarray, float]]]) – Dictionary with flow field buffers

  • force_output (bool) – Flag which forces an output.

  • simulation_finish (bool, optional) – Flag that indicates the simulation finish -> then timeseries xdmf is written, defaults to False

write_timeseries_xdmffile() None[source]

Write xdmffile for the complete time series so that visualization tools like Paraview can load the complete time series at once. This is done once at the end of a simulation when every output time stamp is known.

write_xdmffile(current_time: float) None[source]

Writes an xdmf file for the current time step. The xdmf file corresponds to an h5 file which holds the data buffers.

Parameters:

current_time (float) – Current simulation time.

Module contents