Base Classes

Algorithm Base

class PVGeo.base.AlgorithmBase(nInputPorts=1, inputType='vtkDataSet', nOutputPorts=1, outputType='vtkTable', **kwargs)[source]

Bases: VTKPythonAlgorithmBase

This is a base class to add coconvenience methods to the VTKPythonAlgorithmBase for all algorithms implemented in PVGeo. We implement our algorithms in this manner to harness all of the backend support that the VTKPythonAlgorithmBase class provides for integrating custom algorithms on a VTK pipeline. All of the pipeline methods for setting inputs, getting outputs, making requests are handled by the super classes. For more information on what functionality is available, check out the VTK Docs for the vtkAlgorithm and then check out the following blog posts:

GetOutput(port=0)[source]

A convenience method to get the output data object of this PVGeo algorithm.

apply()[source]

Update the algorithm and get the output data object

error_occurred()[source]

A convenience method for handling errors on the VTK pipeline

Returns:

true if an error has occurred since last checked

Return type:

bool

get_error_message()[source]

A convenience method to print the error message.

get_output(port=0)[source]

Alias for self.GetOutput()

update()[source]

Alias for self.Update()

Filter Base

class PVGeo.base.FilterBase(nInputPorts=1, inputType='vtkDataSet', nOutputPorts=1, outputType='vtkPolyData', **kwargs)[source]

Bases: AlgorithmBase

A base class for implementing filters which holds several conveience methods

apply(input_data_object)[source]

Run this algorithm on the given input dataset

Filter Preserve Type Base

class PVGeo.base.FilterPreserveTypeBase(nInputPorts=1, **kwargs)[source]

Bases: FilterBase

A Base class for implementing filters that preserve the data type of their arbitrary input.

RequestDataObject(request, inInfo, outInfo)[source]

There is no need to overwrite this. This method lets the pipeline know that the algorithm will dynamically decide the output data type based in the input data type.

Interfaced Base Reader

class PVGeo.base.InterfacedBaseReader(**kwargs)[source]

Bases: ReaderBase

A general base reader for all interfacing with libraries that already have file I/O methods and VTK data object interfaces. This provides a routine for using an external library to handle all I/O and produce the VTK data objects.

RequestData(request, inInfo, outInfo)[source]

Do not override. Used by pipeline to get data for current timestep and populate the output data object.

RequestDataObject(request, inInfo, outInfo)[source]

Do not override. This method lets the user dynamically decide the output data type based in the read meshes. Note: they all have to be the same VTK type.

RequestInformation(request, inInfo, outInfo)[source]

Do not override. Used by pipeline to set extents and time info.

_get_object_at_index(idx=None)[source]

Internal helper to get the data object at the specified index

static _get_vtk_object(obj)[source]

OVERRIDE: Given an object in the interfaced library’s type, return a converted VTK data object.

static _read_file(filename)[source]

OVERRIDE: Reads from the the libraries format and returns an object in the given library’s format.

_read_up_front()[source]

Do not override. A predifiened routine for reading the files up front.

Reader Base: Time Varying

class PVGeo.base.ReaderBase(nOutputPorts=1, outputType='vtkTable', **kwargs)[source]

Bases: ReaderBaseBase

A base class for inherited functionality common to all reader algorithms that need to handle a time series.

RequestInformation(request, inInfo, outInfo)[source]

This is a convenience method that should be overwritten when needed. This will handle setting the timesteps appropriately based on the number of file names when the pipeline needs to know the time information.

_update_time_steps()[source]

For internal use only: appropriately sets the timesteps.

get_time_step_values()[source]

Use this in ParaView decorator to register timesteps on the pipeline.

set_time_delta(dt)[source]

An advanced property to set the time step in seconds.

Reader Base Base

class PVGeo.base.ReaderBaseBase(nOutputPorts=1, outputType='vtkTable', **kwargs)[source]

Bases: AlgorithmBase

A base class for inherited functionality common to all reader algorithms

AddFileName(filename)[source]

Use to set the file names for the reader. Handles singlt string or list of strings.

Parameters:

filename (str) – The absolute file name with path to read.

Modified(read_again=True)[source]

Call modified if the files needs to be read again again

_get_file_contents(idx=None)[source]
_get_raw_data(idx=0)[source]
_read_up_front()[source]
add_file_name(filename)[source]

Use to set the file names for the reader. Handles singlt string or list of strings.

Parameters:

filename (str) – The absolute file name with path to read.

apply(filename)[source]

Given a file name (or list of file names), perform the read

clear_file_names()[source]

Use to clear file names of the reader.

Note

This does not set the reader to need to read again as there are no files to read.

get_file_names(idx=None)[source]

Returns the list of file names or given and index returns a specified timestep’s filename.

modified(read_again=True)[source]
need_to_read(flag=None)[source]

Ask self if the reader needs to read the files again.

Parameters:

flag (bool) – Set the read status

Returns:

the status of the reader.

Return type:

bool

Two File Reader Base

class PVGeo.base.TwoFileReaderBase(nOutputPorts=1, outputType='vtkUnstructuredGrid', **kwargs)[source]

Bases: AlgorithmBase

A base clase for readers that need to handle two input files. One meta-data file and a series of data files.

Modified(read_again_mesh=True, read_again_models=True)[source]

Call modified if the files needs to be read again again

Parameters:
  • read_again_mesh (bool) – set the status of the reader for mesh files.

  • read_again_models (bool) – set the status of the reader for model files.

RequestInformation(request, inInfo, outInfo)[source]

Used by pipeline to handle setting up time variance

__update_time_steps()

For internal use only

add_model_file_name(filename)[source]

Use to set the file names for the reader. Handles single string or list of strings.

Parameters:

filename (str or list(str)) – the file name(s) to use for the model data.

apply()[source]

Perform the read with parameters/file names set during init or by setters

clear_mesh()[source]

Use to clear mesh file name

clear_models()[source]

Use to clear data file names

get_mesh_filename()[source]

Get the mesh filename

get_model_filenames(idx=None)[source]

Returns the list of file names or given and index returns a specified timestep’s filename.

get_time_step_values()[source]

Use this in ParaView decorator to register timesteps

static has_models(model_files)[source]

A convenience ethod to see if a list contatins models filenames.

modified(read_again_mesh=True, read_again_models=True)[source]
need_to_readMesh(flag=None)[source]

Ask self if the reader needs to read the mesh file again.

Parameters:

flag (bool) – set the status of the reader for mesh files.

need_to_readModels(flag=None)[source]

Ask self if the reader needs to read the model files again.

Parameters:

flag (bool) – set the status of the reader for model files.

set_mesh_filename(filename)[source]

Set the mesh file name.

set_time_delta(dt)[source]

An advanced property for the time step in seconds.

this_has_models()[source]

Ask self if the reader has model filenames set.

Writer Base

class PVGeo.base.WriterBase(nInputPorts=1, inputType='vtkPolyData', **kwargs)[source]

Bases: AlgorithmBase

FillInputPortInformation(port, info)[source]

Allows us to save composite datasets as well.

Note

I only care about vtkMultiBlockDataSet

RequestData(request, inInfo, outInfo)[source]

Subclasses must implement a perform_write_out method that takes an input data object and a filename. This method will automatically handle composite data sets.

SetFileName(filename)[source]

Specify the filename for the output. Writer can only handle a single output data object/time step.

Write(input_data_object=None)[source]

Perform the write out.

apply(input_data_object)[source]

Run this writer algorithm on the given input data object

get_block_filename(idx)[source]

Get filename for component of a multi block dataset

get_file_name()[source]

Get the set filename.

get_format()[source]

Get the ASCII format used for floats

perform_write_out(input_data_object, filename, object_name)[source]

This method must be implemented. This is automatically called by RequestData for single inputs or composite inputs.

set_block_filenames(n)[source]

Gets a list of filenames based on user input filename and creates a numbered list of filenames for the reader to save out. Assumes the filename has an extension set already.

set_file_name(filename)[source]

Specify the filename for the output. Writer can only handle a single output data object/time step.

set_format(fmt)[source]

Use to set the ASCII format for the writer default is '%.9e'

use_composite()[source]

True if input dataset is a composite dataset

write(input_data_object=None)[source]