pvload module
Load the solution from files using ParaView.
- sapphireppplot.pvload.read_parameter_file(results_folder, file_name='log.prm')
Read contents of a
.prmparameter 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
.csvfile as tabular data.- Parameters:
results_folder (
str) – Path to the folder containingfile_patternfiles.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
.vtksolution files.- Parameters:
results_folder (
str) – Path to the folder containingsolution_*.vtkfiles.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
.vtkfiles are found in theresults_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
.vtusolution files.- Parameters:
results_folder (
str) – Path to the folder containingsolution_*.vtufiles.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
.vtufiles are found in theresults_folder.
- sapphireppplot.pvload.load_solution_pvtu(results_folder, base_file_name='solution', load_arrays=None)
Load series of
.pvtusolution files.- Parameters:
results_folder (
str) – Path to the folder containingsolution_*.pvtufiles.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
.pvtufiles are found in theresults_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
.pvtpsolution files.- Parameters:
results_folder (
str) – Path to the folder containingsolution_*.pvtpfiles.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
.pvtpfiles are found in theresults_folder.
- sapphireppplot.pvload.load_solution_hdf5_with_xdmf(results_folder, base_file_name='solution', load_arrays=None)
Load series of
.hdf5solution files from a.xdmffile.- Parameters:
results_folder (
str) – Path to the folder containing thesolution.xdmffile.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
.xdmffile found in theresults_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_endis 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:
Retrieves the folder containing simulation results.
Loads the parameter file.
Loads the solution data from the files in the results folder.
Adds time step information if necessary.
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, setparameter_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.
See also
sapphireppplot.utils.get_results_folderPrompt for results folder.
sapphireppplot.plot_properties.PlotProperties.series_namesSeries names list to load.
- 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:
Retrieves the folder containing simulation results.
Loads the parameter file.
Loads the solution data from the files in the results subfolder.
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, setparameter_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.
See also
sapphireppplot.utils.get_results_folderPrompt for results folder.
sapphireppplot.plot_properties.PlotProperties.series_namesSeries names list to load.
sapphireppplot.transform.save_extractsSave extracts.