Base Classes

Algorithm Base

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

Bases: vtk.util.vtkAlgorithm.VTKPythonAlgorithmBase

This is a base class to add convienace 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 conveience 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 conveience method for handling errors on the VTK pipeline

Returns:true if an error has ovvured since last checked
Return type:bool
get_error_message()[source]

A conveience method to print the error message.

Filter Base

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

Bases: PVGeo.base.AlgorithmBase

A base class for implementing filters which holds several convienace 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: PVGeo.base.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: PVGeo.base.ReaderBase

A general base reader for all interfacing with librarues 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 us 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.

_GetObjectAtIndex(idx=None)[source]

Internal helper to get the data object at the specified index

_ReadUpFront()[source]

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

static _getVTKObject(obj)[source]

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

static _readFile(filename)[source]

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

Reader Base: Time Varying

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

Bases: PVGeo.base.ReaderBaseBase

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

RequestInformation(request, inInfo, outInfo)[source]

This is a conveience 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: PVGeo.base.AlgorithmBase

A base class for inherrited 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.
ClearFileNames()[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.

GetFileNames(idx=None)[source]

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

Modified(read_again=True)[source]

Call modified if the files needs to be read again again

NeedToRead(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
_GetFileContents(idx=None)[source]
_GetRawData(idx=0)[source]
_ReadUpFront()[source]
apply(filename)[source]

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

Two File Reader Base

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

Bases: PVGeo.base.AlgorithmBase

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

ClearMesh()[source]

Use to clear mesh file name

ClearModels()[source]

Use to clear data file names

GetMeshFileName()[source]

Get the mesh filename

GetModelFileNames(idx=None)[source]

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

static HasModels(model_files)[source]

A convienance method to see if a list contatins models filenames.

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.
NeedToReadMesh(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.
NeedToReadModels(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.
RequestInformation(request, inInfo, outInfo)[source]

Used by pipeline to handle setting up time variance

ThisHasModels()[source]

Ask self if the reader has model filenames set.

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

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

get_time_step_values()[source]

Use this in ParaView decorator to register timesteps

set_mesh_filename(filename)[source]

Set the mesh file name.

set_time_delta(dt)[source]

An advanced property for the time step in seconds.

Writer Base

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

Bases: PVGeo.base.AlgorithmBase

FillInputPortInformation(port, info)[source]

Allows us to save composite datasets as well.

Note

I only care about vtkMultiBlockDataSet

GetBlockFileName(idx)[source]

Get filename for component of a multi block dataset

GetFileName()[source]

Get the set filename.

GetFormat()[source]

Get the ASCII format used for floats

PerformWriteOut(input_data_object, filename, object_name)[source]

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

RequestData(request, inInfo, outInfo)[source]

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

SetBlockFileNames(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.

SetFileName(filename)[source]

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

UseComposite()[source]

True if input dataset is a composite dataset

Write(input_data_object=None)[source]

Perfrom the write out.

apply(input_data_object)[source]

Run this writer algorithm on the given input data object

set_format(fmt)[source]

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