Specify file paths#

Functions to download sample datasets from the Ansys example data repository.

Functions:

delete_downloads()

Delete all downloaded examples from the default examples folder to free space or update the files.

download_file(filename[, directory, ...])

Download specified example file from the Ansys example data repository.

path(filename)

ansys.fluent.core.examples.downloads.delete_downloads()#

Delete all downloaded examples from the default examples folder to free space or update the files.

Notes

The default examples path is given by pyfluent.EXAMPLES_PATH.

ansys.fluent.core.examples.downloads.download_file(filename, directory=None, save_path=None, return_only_filename=None)#

Download specified example file from the Ansys example data repository.

Parameters:
filenamestr

File to download.

directorystr, optional

Ansys example data repository directory where specified file is located. If not specified, looks for the file in the root directory of the repository.

save_pathstr, optional

Path to download the specified file to.

return_only_filenamebool, optional

When unspecified, defaults to False, unless the PYFLUENT_LAUNCH_CONTAINER=1 environment variable is specified, in which case defaults to True. Relevant when using Fluent Docker container images, as the full path for the imported file from the host side is not necessarily going to be the same as the one for Fluent inside the container. Assuming the Fluent inside the container has its working directory set to the path that was mounted from the host, and that the example files are being made available by the host through this same path, only the filename is required for Fluent to find and open the file.

Returns:
str

Filepath of the downloaded or already existing file, or only the file name if return_only_filename=True.

Examples

>>> from ansys.fluent.core import examples
>>> filepath = examples.download_file("bracket.iges", "geometry")
>>> filepath
'/home/user/.local/share/ansys_fluent_core/examples/bracket.iges'
>>> filename = examples.download_file("bracket.iges", "geometry", return_only_filename=True)
>>> filename
'bracket.iges'
>>> filepath = examples.download_file("bracket.iges", "geometry", save_path='.')
'/home/<current_folder_path>/bracket.iges'
>>> filename = examples.download_file("bracket.iges", "geometry", save_path='.', return_only_filename=True)
>>> filename
'bracket.iges'
>>> filepath = examples.download_file("bracket.iges", "geometry", save_path='<user_specified_path>')
'/home/<user_specified_path>/bracket.iges'
>>> filename = examples.download_file("bracket.iges", "geometry", save_path='<user_specified_path>',
...                                   return_only_filename=True)
>>> filename
'bracket.iges'
ansys.fluent.core.examples.downloads.path(filename)#