modulus.plot_utils

plot_utils.vtk

Helper functions for generating vtk files

class modulus.plot_utils.vtk.VTKFromFile(file_path: str, export_map: Dict[str, List[str]] = {}, file_name: str = 'vtk_output', file_dir: str = '.', force_legacy: bool = False)

Bases: object

Reads VTK file into memory and constructs corresponding VTK object

file_pathstr

File directory/name of input vtk file

export_mapDict[str, List[str]], optional

Export map dictionary with keys that are VTK variables names and values that are lists of output variables. Will use 1 to 1 mapping if none is provided, by default {}

file_namestr, optional

File name of output vtk file, by default “vtk_output”

file_dirstr, optional

File directory of output vtk file, by default “.”

force_legacybool, optional

Force a legacy only read, by default False

class modulus.plot_utils.vtk.VTKPolyData(points: numpy.array, line_index: Optional[numpy.array] = None, poly_index: Optional[Tuple[numpy.array, numpy.array]] = None, export_map: Dict[str, List[str]] = {}, file_name: str = 'vtk_output', file_dir: str = '.', init_vtk: bool = True)

Bases: modulus.plot_utils.vtk.VTKBase

vtkPolyData wrapper class

pointsnp.array

Array of point locations [npoints, (1,2 or 3)]

line_indexnp.array, optional

Array of line connections [nedges, 2], by default None

poly_indexTuple[poly_offsets, poly_connectivity]

Tuple of polygon offsets and polygon connectivity arrays. Polygon offsets is a 1D array denoting how many points make up a face for each polygon. Polygon connectivity is a 1D array that contains verticies of each polygon face in order, by default None

export_mapDict[str, List[str]], optional

Export map dictionary with keys that are VTK variables names and values that are lists of output variables. Will use 1 to 1 mapping if none is provided, by default {}

file_namestr, optional

File name of output vtk file, by default “vtk_output”

file_dirstr, optional

File directory of output vtk file, by default “.”

init_vtkbool, optional

Initialize new VTK object from parameters (used by VTKFromFile), by default True

class modulus.plot_utils.vtk.VTKRectilinearGrid(axis_coords: List[numpy.array], export_map: Dict[str, List[str]] = {}, file_name: str = 'vtk_output', file_dir: str = '.', init_vtk: bool = True)

Bases: modulus.plot_utils.vtk.VTKBase

vtkRectilinearGrid wrapper class

axis_coordsList[np.array]

List of arrays that define points on each axis

export_mapDict[str, List[str]], optional

Export map dictionary with keys that are VTK variables names and values that are lists of output variables. Will use 1 to 1 mapping if none is provided, by default {}

file_namestr, optional

File name of output vtk file, by default “vtk_output”

file_dirstr, optional

File directory of output vtk file, by default “.”

init_vtkbool, optional

Initialize new VTK object from parameters (used by VTKFromFile), by default True

class modulus.plot_utils.vtk.VTKStructuredGrid(points: numpy.array, dims: List[int], export_map: Dict[str, List[str]] = {}, file_name: str = 'vtk_output', file_dir: str = '.', init_vtk: bool = True)

Bases: modulus.plot_utils.vtk.VTKBase

vtkStructuredGrid wrapper class

pointsnp.array

Mesh grid of points in ‘ij’ format

dimsList[int]

Number of points in each dimension

export_mapDict[str, List[str]], optional

Export map dictionary with keys that are VTK variables names and values that are lists of output variables. Will use 1 to 1 mapping if none is provided, by default {}

file_namestr, optional

File name of output vtk file, by default “vtk_output”

file_dirstr, optional

File directory of output vtk file, by default “.”

init_vtkbool, optional

Initialize new VTK object from parameters (used by VTKFromFile), by default True

class modulus.plot_utils.vtk.VTKUniformGrid(bounds: List[List[int]], npoints: List[int], export_map: Dict[str, List[str]] = {}, file_name: str = 'vtk_output', file_dir: str = '.', init_vtk: bool = True)

Bases: modulus.plot_utils.vtk.VTKBase

vtkUniformGrid wrapper class

boundsList[List[int]]

Domain bounds of each dimension

npointsList[int]

List of number of points in each dimension

export_mapDict[str, List[str]], optional

Export map dictionary with keys that are VTK variables names and values that are lists of output variables. Will use 1 to 1 mapping if none is provided, by default {}

file_namestr, optional

File name of output vtk file, by default “vtk_output”

file_dirstr, optional

File directory of output vtk file, by default “.”

init_vtkbool, optional

Initialize new VTK object from parameters (used by VTKFromFile), by default True

class modulus.plot_utils.vtk.VTKUnstructuredGrid(points: numpy.array, cell_index: Tuple[numpy.array, numpy.array], cell_types: numpy.array, export_map: Dict[str, List[str]] = {}, file_name: str = 'vtk_output', file_dir: str = '.', init_vtk: bool = True)

Bases: modulus.plot_utils.vtk.VTKBase

vtkUnstructuredGrid wrapper class

pointsnp.array

Array of point locations [npoints, (1,2 or 3)]

cell_indexTuple[ np.array, np.array ]

Tuple of (cell_offsets, cell_connectivity) arrays. Cell offsets is a 1D array denoting how many points make up a face for each cell. Cell connectivity is a 1D array that contains verticies of each cell face in order

cell_typesnp.array

Array of cell vtk types: https://vtk.org/doc/nightly/html/vtkCellType_8h_source.html

export_mapDict[str, List[str]], optional

Export map dictionary with keys that are VTK variables names and values that are lists of output variables. Will use 1 to 1 mapping if none is provided, by default {}

file_namestr, optional

File name of output vtk file, by default “vtk_output”

file_dirstr, optional

File directory of output vtk file, by default “.”

init_vtkbool, optional

Initialize new VTK object from parameters (used by VTKFromFile), by default True

modulus.plot_utils.vtk.grid_to_vtk(var_dict: Dict[str, numpy.array], file_path: str, batch_index: int = 0)

Helper method for nodes to export image/grid data to vtkUniformData file. Arrays should be in the numpy ‘ij’ layout (element [0,0] is origin)

var_dictDict[str, np.array]

Dictionary of variables in the array format [batch, dim, xdim, ydim, zdim]

file_pathstr

File directory/name of output vtk file

batch_indexint, optional

Batch index to write to file, by default 0

modulus.plot_utils.vtk.var_to_polyvtk(var_dict: Dict[str, numpy.array], file_path: str, coordinates=['x', 'y', 'z'])

Helper method for nodes to export thier variables to a vtkPolyData file Should be avoided when possible as other VTK formats can save on memory.

var_dictDict[str, np.array]

Dictionary of variables in the array format [nstates, dim]

file_pathstr

File directory/name of output vtk file

coordinateslist, optional

Variable names that corresponds to point positions, by default [“x”, “y”, “z”]