VTUinterface API reference documentation!
VTUinterface is a python package for easy accessing VTU/PVD files as outputed by Finite Element software like OpenGeoSys. It uses the VTK python wrapper and linear interpolation between time steps and grid points access any points in and and time within the simulation domain.
- Copyright (c) 2012-2022, OpenGeoSys Community (http://www.opengeosys.org)
- Distributed under a Modified BSD License.
See accompanying file LICENSE or http://www.opengeosys.org/project/license
- class VTUinterface.vtuIO.PVDIO(filename, nneighbors=20, dim=3, one_d_axis=0, two_d_planenormal=2, interpolation_backend=None)
Bases:
object
Class for handling I/O of PVD files
- Parameters:
filename (str) –
nneighbors (int, optional) –
dim (int) –
one_d_axis (int) – between 0 and 2, default: 0
two_d_planenormal (int) – between 0 and 2, default: 2
interpolation_backend (str) – scipy or vtk
- append(filename, vtu_rename=False)
appends entries from another PVD file
- Parameters:
filename (str) –
vtu_rename (bool) –
- clear_pvd_path(write=True)
Delete relative and absolute directory paths in the vtu filenames of the PVD file.
- Parameters:
write (bool) –
- static create_pvd_from_pattern(filename, pattern='')
- delete_cell_field(fieldnames=None)
delete cell field(s) and write data to disk
- Parameters:
fieldnames (str or list) – if None all fields will be deleted
- delete_integration_point_field(fieldnames=None, skip_last=False)
delete integration point field(s) and write data to disk
- Parameters:
fieldnames (str or list) – if None all fields will be deleted
skip_last (boolean) –
- delete_point_field(fieldnames=None)
delete point field(s) and write data to disk
- Parameters:
fieldnames (str or list) – if None all fields will be deleted
- get_cell_field_names()
Get names of all cell fields in the vtu file.
- get_integration_point_field_names()
Get names of integration point fields in the vtu file.
- get_point_field_names()
Get names of all point fields in the vtu file.
- read_aggregate(fieldname, agg_fct, data_type='point', pointsetarray=None)
Return time series data of an aggregate function for field “fieldname”.
- Parameters:
fieldname (str or list) –
agg_fct (str,) – can be: “min”, “max” or “mean”
data_type (str optional) – “point” or “cell”
pointsetarray (str, list or numpy.ndarray) – defines a submesh if str pointsetarray is construed as filename containing the mesh
- read_pvd(filename)
Read in PVD file
- Parameters:
filename (str) –
- read_set_data(time, fieldname, pointsetarray=None, data_type='point', interpolation_method=None)
Get data of field “fieldname” at time “time” alon a given “pointsetarray”.
- Parameters:
time (float) –
fieldname (str) –
pointsetarray (list, numpy.ndarray or str) – if str, pointsetarray is construed as a filename of a submesh
interpolation_method (str) – default: ‘linear’
- read_time_series(fieldname, pts=None, data_type='point', interpolation_method=None)
Return time series data of field “fieldname” at points pts. Also a list of fieldnames can be provided as “fieldname”
- Parameters:
fieldname (str) –
pts (dict, optional) –
data_type (str optional) – “point” or “cell”
interpolation_method (str, optional) – default: ‘linear
- read_time_slice(time, fieldname)
Print field “fieldname” at time “time”.
- Parameters:
time (float) –
fieldname (str) –
- rename(newname)
Rename PVD file
- Parameters:
newname (str) –
- write_prj(filename)
exports input data (if available) as OGS project files
- Parameters:
filename (str) –
- write_xdmf(filename)
exports data as XDMF/HDF
- Parameters:
filename (str) –
- class VTUinterface.vtuIO.VTUIO(filename, nneighbors=20, dim=3, one_d_axis=0, two_d_planenormal=2, interpolation_backend=None)
Bases:
object
Class for handling I/O of VTU files
- Parameters:
filename (str) –
nneighbors (int, optional) – default: 20
dim (int, optional) – default: 3
one_d_axis (int) – between 0 and 2, default: 0
two_d_planenormal (int) – between 0 and 2, default: 2
interpolation_backend (str) – scipy or vtk
- add_cell_field(field, fieldname, ofilename, writefile=True, array_type=None, datamode=None)
Write a field (numpy array of correct size) to field “fieldname” as file “ofilename”.
- Parameters:
field (array) –
fieldname (str) –
ofilename (str) –
writefile (bool) –
array_type (vtk array type) –
datamode (str) –
- add_integration_point_field(field, fieldname, ofilename, writefile=True, array_type=None, datamode=None)
Write a field (numpy array of correct size) to field “fieldname” as file “ofilename”.
- Parameters:
field (array) –
fieldname (str) –
ofilename (str) –
writefile (bool) –
array_type (vtk array type) –
datamode (str) –
- add_point_field(field, fieldname, ofilename, writefile=True, array_type=None, datamode=None)
Write a field (numpy array of correct size) to field “fieldname” as file “ofilename”.
- Parameters:
field (array) –
fieldname (str) –
ofilename (str) –
writefile (bool) –
array_type (vtk array type) –
datamode (str) –
- property cell_center_points
Method for obtaining cell center points
- property data_arrays
- delete_cell_field(fieldnames=None, ofilename=None, writefile=True)
delete cell field(s) and write data to disk
- Parameters:
fieldnames (str or list) – if None all fields will be deleted
ofilename (str) –
writefile (bool) –
- delete_integration_point_field(fieldnames=None, ofilename=None, writefile=True)
delete integration point field(s) and write data to disk
- Parameters:
fieldnames (str or list) – if None all fields will be deleted
ofilename (str) –
writefile (bool) –
- delete_point_field(fieldnames=None, ofilename=None, writefile=True)
delete point field(s) and write data to disk
- Parameters:
fieldnames (str or list) – if None all fields will be deleted
ofilename (str) –
writefile (bool) –
- func_to_field(function, fieldname, ofilename=None, cell=False, array_type=None, writefile=True, datamode=None)
Add a field to the vtu file (which will be saved directly as “ofilename” by providing a three argument function(x,y,z)
- Parameters:
function (function) –
fieldname (str) –
ofilename (str) –
cell (bool) –
datamode (str) –
- func_to_m_dim_field(functionarray, fieldname, ofilename=None, cell=False, array_type=None, writefile=True, datamode=None)
Add a multidimensional field to the vtu file (which will be saved directly as “ofilename” by providing am array of three argument functions.
- Parameters:
functionarray (array of objects) –
fieldname (str) –
ofilename (str) –
- get_cell_field(fieldname)
Return vtu point field as numpy array.
- Parameters:
fieldname (str) –
- get_cell_field_as_point_data(fieldname)
Return vtu cell field as point field.
- Parameters:
fieldname (str) –
- get_cell_field_names()
Get names of all cell fields in the vtu file.
- get_data(fieldname, pts=None, data_type='point', interpolation_method=None)
Get data of field “fieldname” at all points specified in “pts”.
- Parameters:
fieldname (str) –
pts (dict, optional) – default: {‘pt0’: (0.0,0.0,0.0)}
interpolation_method (str, optional) – default: ‘linear’
- get_data_scipy(neighbors, points_interpol, fieldname, data_type='point', interpolation_method='linear')
Get interpolated data for points_interpol using neighbor points.
- get_data_vtk(points_interpol, data_type='point', interpolation_method='probefilter')
Get interpolated data for points_interpol using vtks built-in interpolation methods
- get_integration_point_field(fieldname)
Return integration point field.
- Parameters:
fieldname (str) –
- get_integration_point_field_names()
Get names of all integration point data fields in the vtu file.
- get_nearest_indices(points_interpol)
Return a dictionary with closest mesh point indices
- Parameters:
points_interpol (dict) –
- get_nearest_points(points_interpol)
Return a dictionary with closest mesh points
- Parameters:
points_interpol (dict) –
- get_neighbors(points_interpol, data_type='point')
Method for obtaining neighbor points for interpolation.
- get_point_field(fieldname)
Return vtu cell field as numpy array.
- Parameters:
fieldname (str) –
- get_point_field_names()
Get names of all point fields in the vtu file.
- get_set_data(fieldname, pointsetarray=None, data_type='point', interpolation_method=None)
Get data specified in fieldname at all points specified in “pointsetarray”.
- Parameters:
fieldname (str) –
pointsetarray (list, numpy.ndarray or str) – if str, pointsetarray is construed as a filename of a submesh
interpolation_method (str, optional) – default: ‘linear’
- property header
- point_data_to_cell_data(fieldname, ofilename=None, writefile=True, datamode=None)
convert pointdata to cell data of field “fieldname”
- Parameters:
fieldname (str) –
ofilename (str) –
datamode (str) –
- write(filename, datamode=None)
Write data as file “filename”.
- Parameters:
filename (str) –
datamode (str) –