ogstools.meshlib.xdmf_reader module#

This file provides an override to meshios XDMF Reader since it misses a feature to handle hyperslabs (there are two ways to handle hyperslab: the common documented here and the way paraview supports it (documentation missing).

Example:

2D_single_fracture_HT.h5:/meshes/2D_single_fracture/temperature|0 0:1 1:1 190:97 190

to be read like:

| start : stride : count : end
class ogstools.meshlib.xdmf_reader.DataItem[source]#

Bases: ABC

Abstract base class for all classes that end with DataItem.

rawdata_path: Path#
abstract __getitem__(args)[source]#
Return type:

ndarray

class ogstools.meshlib.xdmf_reader.H5DataItem[source]#

Bases: DataItem

A class to handle the data item in the xdmf file that references to a h5 file. With init only the xdmf meta data is read. (light computation) With selected_values the requested values are read from h5 file (heavy computation)

Parameters:
  • file_info – The file_info string from the XDMF file example: 2D_single_fracture_HT.h5:/meshes/2D_single_fracture/geometry|0 0 0:1 1 1:1 190 3:97 190 3

  • xdmf_path – Path to the xdmf file that references to the h5 file

__init__(file_info, xdmf_path)[source]#
Parameters:
  • file_info (str) – The file_info string from the XDMF file example: 2D_single_fracture_HT.h5:/meshes/2D_single_fracture/geometry|0 0 0:1 1 1:1 190 3:97 190 3

  • xdmf_path (Path) – Path to the xdmf file that references to the h5 file

__getitem__(args)[source]#

Reads value from HDF5 file based on given selection.

param args: See numpy array indexing https://numpy.org/doc/stable/user/basics.indexing.html# :returns: A numpy array (sliced) of the requested data for all timesteps

Return type:

ndarray

selected_values()[source]#

Returns all values of the DataItem that are selected in the xdmf file. An empty selection means all values are read.

In the xdmf file with <DataItem> tag you optionally find a string containing the 1.h5filename, 2. name of h5 group, 3. selection e.g. 2D_single_fracture_HT.h5:/meshes/2D_single_fracture/geometry|0 0 0:1 1 1:1 190 3:97 190 3 The selection here is: 0 0 0:1 1 1:1 190 3:97 190 3 The meaning is: [(offset(0,0,0): step(1,1,1) : end(1,190,3) : of_data_with_size(97,190,30))]

Returns:

A numpy array (sliced) of the requested data for all timesteps

Return type:

ndarray

class ogstools.meshlib.xdmf_reader.XMLDataItem[source]#

Bases: DataItem

__init__(name, dims, data_type, precision)[source]#
__getitem__(args)[source]#
Return type:

ndarray

class ogstools.meshlib.xdmf_reader.BinaryDataItem[source]#

Bases: DataItem

__init__(name, dims, data_type, precision)[source]#
__getitem__(args)[source]#
Return type:

ndarray

class ogstools.meshlib.xdmf_reader.DataItems[source]#

Bases: object

__init__(items, center)[source]#
__getitem__(args)[source]#
Return type:

ndarray

class ogstools.meshlib.xdmf_reader.XDMFReader[source]#

Bases: TimeSeriesReader

__init__(filename)[source]#
has_fast_access(key=None)[source]#
Return type:

bool

rawdata_path(key=None)[source]#
Return type:

Path

read_data(k)[source]#
Return type:

tuple[float, dict, dict, dict]

select_item(data_item)[source]#
Return type:

ndarray