Tensor Mesh

UBC Tensor Mesh Appender

class PVGeo.ubc.tensor.TensorMeshAppender(**kwargs)[source]

Bases: ModelAppenderBase

This filter reads a timeseries of models and appends it to an input vtkRectilinearGrid

_place_on_mesh(output, idx=0)[source]

Internal helepr to place a model on the mesh for a given index

_read_up_front()[source]

Internal helepr to read data at start

UBC Tensor Mesh Reader

class PVGeo.ubc.tensor.TensorMeshReader(nOutputPorts=1, outputType='vtkRectilinearGrid', **kwargs)[source]

Bases: ubcMeshReaderBase

UBC Mesh 2D/3D models are defined using a 2-file format. The β€œmesh” file describes how the data is discretized. The β€œmodel” file lists the physical property values for all cells in a mesh. A model file is meaningless without an associated mesh file. The reader will automatically detect if the mesh is 2D or 3D and read the remainder of the data with that dimensionality assumption. If the mesh file is 2D, then then model file must also be in the 2D format (same for 3D).

Note

Model File is optional. Reader will still construct vtkRectilinearGrid safely.

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

Handles data request by the pipeline.

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

Handles info request by pipeline about timesteps and grid extents.

__ubc_mesh_data_2d(filename_mesh, filename_models, output)

Helper method to read a 2D mesh

__ubc_mesh_data_3d(filename_mesh, filename_models, output)

Helper method to read a 3D mesh

__ubc_tensor_mesh(filename_mesh, filename_models, output)

Wrapper to Read UBC GIF 2D and 3D meshes. UBC Mesh 2D/3D models are defined using a 2-file format. The β€œmesh” file describes how the data is descritized. The β€œmodel” file lists the physical property values for all cells in a mesh. A model file is meaningless without an associated mesh file. If the mesh file is 2D, then then model file must also be in the 2D format (same for 3D).

Parameters:
  • filename_mesh (str) – The mesh filename as an absolute path for the input mesh file in UBC 2D/3D Mesh Format

  • filename_models (str or list(str)) – The model filename(s) as an absolute path for the input model file in UBC 2D/3D Model Format.

  • output (vtkRectilinearGrid) – The output data object

Returns:

a vtkRectilinearGrid generated from the UBC 2D/3D Mesh grid. Mesh is defined by the input mesh file. Cell data is defined by the input model file.

Return type:

vtkRectilinearGrid

clear_mesh()[source]

Use to clean/rebuild the mesh

clear_models()[source]

Use to clean the models and reread

description = 'PVGeo: UBC Mesh 2D/3D Two-File Format'
static place_model_on_mesh(mesh, model, data_name='Data')[source]

Places model data onto a mesh. This is for the UBC Grid data readers to associate model data with the mesh grid.

Parameters:
  • mesh (vtkRectilinearGrid) – The vtkRectilinearGrid that is the mesh to place the model data upon.

  • model (np.array) – A NumPy float array that holds all of the data to place inside of the mesh’s cells.

  • data_name (str) – The name of the model data array once placed on the vtkRectilinearGrid.

Returns:

Returns the input vtkRectilinearGrid with model data appended.

Return type:

vtkRectilinearGrid

static ubc_mesh_2d(FileName, output)[source]

This method reads a UBC 2D Mesh file and builds an empty vtkRectilinearGrid for data to be inserted into. Format Specs.

Parameters:
  • FileName (str) – The mesh filename as an absolute path for the input mesh file in UBC 3D Mesh Format.

  • output (vtkRectilinearGrid) – The output data object

Returns:

a vtkRectilinearGrid generated from the UBC 3D Mesh grid. Mesh is defined by the input mesh file. No data attributes here, simply an empty mesh. Use the place_model_on_mesh() method to associate with model data.

Return type:

vtkRectilinearGrid

static ubc_mesh_3d(FileName, output)[source]

This method reads a UBC 3D Mesh file and builds an empty vtkRectilinearGrid for data to be inserted into.

Parameters:
  • FileName (str) – The mesh filename as an absolute path for the input mesh file in UBC 3D Mesh Format.

  • output (vtkRectilinearGrid) – The output data object

Returns:

a vtkRectilinearGrid generated from the UBC 3D Mesh grid. Mesh is defined by the input mesh file. No data attributes here, simply an empty mesh. Use the place_model_on_mesh() method to associate with model data.

Return type:

vtkRectilinearGrid

static ubc_model_2d(FileName)[source]

Reads a 2D model file and returns a 1D NumPy float array. Use the place_model_on_mesh() method to associate with a grid.

Note

Only supports single component data

Parameters:

FileName (str) – The model filename as an absolute path for the input model file in UBCMesh Model Format. Also accepts a list of string file names.

Returns:

a NumPy float array that holds the model data read from the file. Use the place_model_on_mesh() method to associate with a grid. If a list of file names is given then it will return a dictionary of NumPy float array with keys as the basenames of the files.

Return type:

np.array

Append UBC Discrete Topography

class PVGeo.ubc.tensor.TopoMeshAppender(inputType='vtkRectilinearGrid', outputType='vtkRectilinearGrid', **kwargs)[source]

Bases: AlgorithmBase

This filter reads a single discrete topography file and appends it as a boolean data array.

Modified(read_again=True)[source]

Call modified if the files needs to be read again.

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

Used by pipeline to generate output

_place_on_mesh(output)[source]

Internal helepr to place an active cells model on the mesh

_read_up_front()[source]

Internal helepr to read data at start

clear_topo_file()[source]

Use to clear data file name.

modified(read_again=True)[source]

Call modified if the files needs to be read again.

need_to_read(flag=None)[source]

Ask self if the reader needs to read the files again

Parameters:

flag (bool) – if the flag is set then this method will set the read status

Returns:

The status of the reader aspect of the filter.

Return type:

bool

set_topo_filename(filename)[source]

Use to set the file names for the reader. Handles single strings only