dorie.utilities

What is dorie.utilities?

This package bundles some useful python modules that are being used by the other DORiE python packages.

The dorie.utilities scripts

plot_vtk.py

Plots the given, ASCII encoded, VTK file(s).

This script accepts a VTK file or glob pattern, parses it, invokes dorie.utilities.vtk_plotter on each of them, and implements special handling of warnings and exceptions to keep the output as clean as possible.

The variables to be plotted may be specified using the plot_vtk.py --var command line option.

Command line options:

--vtk

Input VTK file or glob pattern

--var

The variables to plot, plots all if not given

--Wn

Hide warnings (optional, default false)

Package reference

dorie.utilities.check_path

dorie.utilities.check_path.check_path(filepath)[source]

Convenience function that checks if a path exists and creates it if needed

Parameters

filepath – Path to a file or directory that is to be created

dorie.utilities.grid

class dorie.utilities.grid.BaseGrid[source]

Base class for grids. Implements a simple data and grid cell interface.

add_data(name, data)[source]

Used for attaching data to the grid.

Parameters
  • name (str) – Name of the variable (will be used to reference it)

  • data (array_like) – Variable data. First dimensions must match the cell dimensions.

cellCenters()[source]
Returns

The cell centers of the grid.

Return type

array_like

data()[source]
Returns

The cell variables as key-value pairs

Return type

dict

dim = None

dimensionality of the grid

merge(other)[source]

Merge two grids into a new grid instance

class dorie.utilities.grid.RegularGrid(cellCenters)[source]

Class implementing a grid interface for given cell centers on a regular grid.

class dorie.utilities.grid.StructuredVTKGrid[source]
class dorie.utilities.grid.UnstructuredVTKGrid(pointCoords, connectivity, ppc)[source]

Class for storing an unstructured grid and cell variables defined on it.

Parameters
  • pointCoords (array_like of shape (npoints,dim)) – Coordinates of the grid points

  • connectivity (array_like) – For each cell, the indices of the points that make up the cell

  • ppc (3, 4, 8) – Points per grid cell

  • dim (int) – Real dimension of the grid

integrate(v)[source]

Integrates an array v defined on each cell center across the grid.

Parameters

v – Input array of shape (ncells, dim) or scalar

triangulation()[source]
Returns

Cell point coordinates x, y, z and connectivity c as (x, y, z), c

Return type

tuple

dorie.utilities.fuzzy_compare_grid

dorie.utilities.fuzzy_compare_grid.compare(grid1, grid2, abstol=None, reltol=None, strict=False)[source]

dorie.utilities.vtktools.vtkfile

class dorie.utilities.vtktools.vtkfile.VTKFile(path)[source]

This class does most of the heavy lifting when it comes to reading and operating on ASCII or base64 encoded VTK files.

plot(variables=None)[source]

Method to plot the contents of a VTK file. Makes use of matplotlib’s PolyCollection to plot each grid cell. Vector quantites are shown as quiver plots.

Note

Currently works for any 2-dimensional grid that has a usable triangulation method (i.e., all unstructured VTK grids).

Parameters

variables (list of str or None) – Specifies the variables that should be plotted

Returns

List of created figure instances

read(variables=None)[source]

Wrapper function that determines the type of the vtk files given and passes them along to the respective reader function.

Parameters
  • files (str or list of str) – Holds the file(s) to be read

  • variables (list of str or None) – CellData variables that should be returned (None reads all variables, but consumes more memory)

set_time(time)[source]

dorie.utilities.vtktools.vtk_grabber

dorie.utilities.vtktools.vtk_grabber.grab_all(location)[source]

Reads the file names of all files ending in .vtr and .vtu in a folder and returns them in a sorted list.

Parameters

location – folder to be searched

dorie.utilities.vtktools.vtk_grabber.grab_first(location)[source]

Returns the first .vtr or .vtu file found in a folder.

Parameters

location – folder to be searched

dorie.utilities.vtktools.vtk_grabber.grab_last(location)[source]

Returns the last .vtr or .vtu file found in a folder.

Parameters

location – folder to be searched

dorie.utilities.vtktools.pvd_reader

dorie.utilities.vtktools.pvd_reader.read(files)[source]

Wrapper function that loops over the pvd files given and passes them along to the reader function _read_single_pvd().

Parameters

files (str or list of str) – Holds the file(s) to be read

dorie.utilities._load_all_in_folder

dorie.utilities._load_all_in_folder.load(package, location)[source]

dorie.utilities.warnings

exception dorie.utilities.warnings.VTKWarning[source]