fluidsim.util.util

Utilities for the numerical simulations (fluidsim.util.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)

If True, the parameters of the simulation are modified before loading:

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.

fluidsim.util.util.modif_resolution_from_dir(name_dir=None, t_approx=None, coef_modif_resol=2, PLOT=True)[source]

Save a file with a modified resolution.

fluidsim.util.util.modif_resolution_from_dir_memory_efficient(name_dir=None, t_approx=None, coef_modif_resol=2)[source]

Save a file with a modified resolution.

Faster and more memory efficient than modif_resolution_from_dir (but not plot).

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()

List all available solvers.

get_dim_from_solver_key(key)

Try to guess the dimension from the solver key (via the operator name).

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.

modif_resolution_from_dir_memory_efficient([…])

Save a file with a modified resolution.

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])

Return the path of a result directory.

print_memory_usage_seq(message[, flush])

times_start_end_from_path(path)

Return the start and end times from a result directory path.

Classes

ModulesSolvers(names_solvers)

Dictionary to gather imported solvers.

StatePhysLike(path_file, oper, oper2)