# fluidsim.util.util¶

## Utilities for the numerical simulations (fluidsim.util)¶

### Public API¶

fluidsim.util.util.load_sim_for_plot(name_dir=None, merge_missing_params=False, hide_stdout=False)[source]

Create a object Simul from a dir result.

Creating simulation objects with this function should be fast because the state is not initialized with the output file and only a coarse operator is created.

Parameters
name_dirstr (optional)

Name of the directory of the simulation. If nothing is given, we load the data in the current directory. Can be an absolute path, a relative path, or even simply just the name of the directory under $FLUIDSIM_PATH. merge_missing_paramsbool (optional, default == False) Can be used to load old simulations carried out with an old fluidsim version. hide_stdoutbool (optional, default == False) If True, without stdout. fluidsim.util.util.load_state_phys_file(name_dir=None, t_approx=None, modif_save_params=True, merge_missing_params=False, init_with_initialized_state=True, hide_stdout=False)[source] Create a simulation from a file. For large resolution, creating a simulation object with this function can be slow because the state is initialized with the output file. Parameters name_dirstr (optional) Name of the directory of the simulation. If nothing is given, we load the data in the current directory. Can be an absolute path, a relative path, or even simply just the name of the directory under$FLUIDSIM_PATH.

t_approxnumber (optional)

Approximate time of the file to be loaded.

modif_save_paramsbool (optional, default == True)

params.output.HAS_TO_SAVE = False
params.output.ONLINE_PLOT_OK = False

merge_missing_paramsbool (optional, default == False)

Can be used to load old simulations carried out with an old fluidsim version.

init_with_initialized_statebool (optional, default == True)

If True, call sim.output.init_with_initialized_state.

hide_stdoutbool (optional, default == False)

If True, without stdout.

fluidsim.util.util.load_for_restart(name_dir=None, t_approx=None, merge_missing_params=False)[source]

Load params and Simul for a restart.

>>> params, Simul = load_for_restart(name_dir)

Parameters
name_dirstr (optional)

Name of the directory of the simulation. If nothing is given, we load the data in the current directory. Can be an absolute path, a relative path, or even simply just the name of the directory under \$FLUIDSIM_PATH.

t_approxnumber (optional)

Approximate time of the file to be loaded.

merge_missing_paramsbool (optional, default == False)

Can be used to load old simulations carried out with an old fluidsim version.

### Internal API¶

fluidsim.util.util.open_patient(path, *args, time_wait_total=200, time_wait_once=2, class_file=<class 'h5py._hl.files.File'>, **kwargs)[source]

Open a hdf5 type file in a “patient” way.

If the file is already opened by another process (errno==11 for hdf5), the error is caught and we retry later.

Parameters
time_wait_totalnumber (optional)

Time to wait before raising the error.

time_wait_oncenumber (optional)

Time between attempts.

class_filetype (optional)

Class of the file (default h5py.File, but could be h5netcdf.File).

Functions

 available_solver_keys([package]) Inspects a package or a subpackage for all available solvers. get_dim_from_solver_key(key[, package]) Try to guess the dimension from the solver key (via the operator name). import_module_solver_from_key([key, package]) Import and reload the solver. import_simul_class_from_key(key[, package]) Import and reload a simul class. load_for_restart([name_dir, t_approx, …]) Load params and Simul for a restart. load_sim_for_plot([name_dir, …]) Create a object Simul from a dir result. load_state_phys_file([name_dir, t_approx, …]) Create a simulation from a file. modif_resolution_all_dir([t_approx, …]) Save files with a modified resolution. modif_resolution_from_dir([name_dir, …]) Save a file with a modified resolution. module_solver_from_key([key, package]) Return the string corresponding to a module solver. name_file_from_time_approx(path_dir[, t_approx]) Return the file name whose time is the closest to the given time. open_patient(path, *args[, time_wait_total, …]) Open a hdf5 type file in a “patient” way. pathdir_from_namedir(name_dir, pathlib.Path, …) Return the path of a result directory. times_start_end_from_path(path) Return the start and end times from a result directory path.

Classes

 ModulesSolvers(names_solvers[, package]) Dictionary to gather imported solvers.