pvload module

Load the solution from files using ParaView.

sapphireppplot.pvload.read_parameter_file(results_folder, file_name='log.prm')

Read contents of a .prm parameter file.

This function utilises the ParaView CSV reader to allow reading parameter files on a remote data server. It can also be used to read any text file.

Parameters:
  • results_folder (str) – Path to the folder containing parameter file.

  • file_name (str) – File name of the parameter file including file extension. By default “log.prm”.

Return type:

list[str]

Returns:

prm_lines (list[str]) – List of lines of in the parameter file.

Raises:

FileNotFoundError – If the parameter file is found in the results_folder.

sapphireppplot.pvload.load_csv(results_folder, file_pattern='solution_*.csv', delimiter=',', have_headers=0, skip_lines=0, comments='#', array_names=None)

Load contents of a .csv file as tabular data.

Parameters:
  • results_folder (str) – Path to the folder containing file_pattern files.

  • file_pattern (str) – File pattern of the solutions files.

  • delimiter (str) – Delimiter of the CSV files.

  • have_headers (int) – Treat the first line of the file as headers?

  • skip_lines (int) – Number of lines to skip.

  • comments (str) – Character for comments.

  • array_names (Optional[list[str]]) – If a list is given, the rows of the table will be renamed accordingly.

Return type:

SourceProxy

Returns:

solution (SourceProxy) – A ParaView Source with Row data.

Raises:

FileNotFoundError – If no matching file is found in the results_folder.

Note

Tabular data in ParaView can be converted to point data using paraview.simple.TableToPoints. This point cloud can be converted into a grid using paraview.simple.PointVolumeInterpolator.

sapphireppplot.pvload.load_solution_vtk(results_folder, base_file_name='solution')

Load series of .vtk solution files.

Parameters:
  • results_folder (str) – Path to the folder containing solution_*.vtk files.

  • base_file_name (str) – Base name of the solutions files.

Return type:

SourceProxy

Returns:

solution (SourceProxy) – A ParaView reader object with selected point arrays enabled.

Raises:

FileNotFoundError – If no .vtk files are found in the results_folder.

Notes

The ‘TimeArray’ property is not set.

sapphireppplot.pvload.load_solution_vtu(results_folder, base_file_name='solution', load_arrays=None)

Load series of .vtu solution files.

Parameters:
  • results_folder (str) – Path to the folder containing solution_*.vtu files.

  • base_file_name (str) – Base name of the solutions files.

  • load_arrays (Optional[list[str]]) – The name of the arrays in the solution that should be loaded.

Return type:

SourceProxy

Returns:

solution (SourceProxy) – A ParaView reader object with selected point arrays enabled.

Raises:

FileNotFoundError – If no .vtu files are found in the results_folder.

sapphireppplot.pvload.load_solution_pvtu(results_folder, base_file_name='solution', load_arrays=None)

Load series of .pvtu solution files.

Parameters:
  • results_folder (str) – Path to the folder containing solution_*.pvtu files.

  • base_file_name (str) – Base name of the solutions files.

  • load_arrays (Optional[list[str]]) – The name of the arrays in the solution that should be loaded.

Return type:

SourceProxy

Returns:

solution (SourceProxy) – A ParaView reader object with selected point arrays enabled.

Raises:

FileNotFoundError – If no .pvtu files are found in the results_folder.

Notes

The ‘TimeArray’ property is not set.

sapphireppplot.pvload.load_solution_pvtp(results_folder, base_file_name='solution', load_arrays=None)

Load series of .pvtp solution files.

Parameters:
  • results_folder (str) – Path to the folder containing solution_*.pvtp files.

  • base_file_name (str) – Base name of the solutions files.

  • load_arrays (Optional[list[str]]) – The name of the arrays in the solution that should be loaded.

Return type:

SourceProxy

Returns:

solution (SourceProxy) – A ParaView reader object with selected point arrays enabled.

Raises:

FileNotFoundError – If no .pvtp files are found in the results_folder.

sapphireppplot.pvload.load_solution_hdf5_with_xdmf(results_folder, base_file_name='solution', load_arrays=None)

Load series of .hdf5 solution files from a .xdmf file.

Parameters:
  • results_folder (str) – Path to the folder containing the solution.xdmf file.

  • base_file_name (str) – Base name of the solutions files.

  • load_arrays (Optional[list[str]]) – The name of the arrays in the solution that should be loaded.

Return type:

SourceProxy

Returns:

solution (SourceProxy) – A ParaView reader object with selected point arrays enabled.

Raises:

FileNotFoundError – If no matching .xdmf file found in the results_folder.

Notes

  • The ‘TimeArray’ property is set to “None”.

sapphireppplot.pvload.scale_time_steps(solution, animation_scene, t_start=0.0, t_end=1.0, scale=None)

Scale time steps to match start and end time.

Parameters:
  • solution (SourceProxy) – Solution without time steps.

  • animation_scene (Optional[Proxy]) – The ParaView AnimationScene. Can be left empty to to manually update timestep values.

  • t_start (float) – Simulation start time.

  • t_end (float) – Simulation end time.

  • scale (Optional[float]) – Time scaling factor. If set, t_end is ignored and this scaling is used instead.

Return type:

SourceProxy

Returns:

solution_temporal_scaled (SourceProxy) – Solution with scaled time steps.

sapphireppplot.pvload.load_solution(plot_properties, file_format='vtu', path_prefix='', base_file_name='solution', t_start=0.0, t_end=1.0, animation_time=None, parameter_file_name='log.prm')

Simplified loading of the solution independent of file format.

This function performs the following steps:

  1. Retrieves the folder containing simulation results.

  2. Loads the parameter file.

  3. Loads the solution data from the files in the results folder.

  4. Adds time step information if necessary.

  5. Updates the animation scene to the specified animation time.

Parameters:
  • plot_properties (PlotProperties) – Properties of the solution to load.

  • file_format (Literal['vtk', 'vtu', 'pvtu', 'hdf5']) – Format of the solution files.

  • path_prefix (str) – Prefix for relative path.

  • base_file_name (str) – Base name of the solutions files.

  • t_start (float) – Simulation start time.

  • t_end (float) – Simulation end time.

  • animation_time (Optional[float]) – Set the time at which the animation scene is displayed. Defaults to the last time step.

  • parameter_file_name (Optional[str]) – File name of the parameter file including file extension. To skip, set parameter_file_name = None.

Return type:

tuple[str, Dict[str, Any], SourceProxy, Proxy]

Returns:

  • results_folder (str) – The path to the results folder.

  • prm (ParamDict) – Dictionary of the parameters.

  • solution (SourceProxy) – A ParaView reader object with selected point arrays enabled.

  • animation_scene (Proxy) – The ParaView AnimationScene.

Raises:

ValueError – If no matching files are found.

sapphireppplot.pvload.load_extract(base_file_name, plot_properties, file_format='pvtp', path_prefix='', results_folder='', subfolder='extracts', animation_time=None, parameter_file_name='log.prm')

Load extract of a solution.

This function performs the following steps:

  1. Retrieves the folder containing simulation results.

  2. Loads the parameter file.

  3. Loads the solution data from the files in the results subfolder.

  4. Updates the animation scene to the specified animation time.

Parameters:
  • base_file_name (str) – Filename of the extract.

  • plot_properties (PlotProperties) – Properties of the solution to load.

  • file_format (Literal['pvtp', 'pvtu']) – Format of the extracted files.

  • path_prefix (str) – Prefix for relative path.

  • results_folder (str) – The path to the results folder.

  • subfolder (str) – Subfolder with the extracts.

  • animation_time (Optional[float]) – Set the time at which the animation scene is displayed. Defaults to the last time step.

  • parameter_file_name (Optional[str]) – File name of the parameter file including file extension. To skip, set parameter_file_name = None.

Return type:

tuple[str, Dict[str, Any], SourceProxy, Proxy]

Returns:

  • results_folder (str) – The path to the results folder.

  • prm (ParamDict) – Dictionary of the parameters.

  • solution (SourceProxy) – A ParaView reader object with selected point arrays enabled.

  • animation_scene (Proxy) – The ParaView AnimationScene.

Raises:

ValueError – If no matching files are found.