KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
Classes | Functions | Variables
xdmf_utils Namespace Reference

Utilities for creating XDMF metadata from results stored in HDF5. More...

Classes

class  NonExistingModule
 

Functions

def TryOpenH5File (name, mode=None, driver=None, **kwds)
 A context manager wrapper for the opened file. More...
 
def RenumberConnectivitiesForXdmf (filename_or_list_of_filenames, h5path_to_mesh)
 Renumber mesh connectivities for XDMF. More...
 
def GetListOfSpatialGrids (spatial_grids_list, h5_model_part, current_path)
 
def CreateXdmfSpatialGrid (h5_model_part)
 Return an XDMF Grid object corresponding to a mesh in an HDF5 file. More...
 
def Has_dtype (item)
 
def XdmfNodalResults (h5_results)
 Return a list of XDMF Attribute objects for nodal results in an HDF5 file. More...
 
def XdmfNodalFlags (h5_results)
 Return a list of XDMF Attribute objects for nodal flags in an HDF5 file. More...
 
def XdmfElementResults (h5_results)
 Return a list of XDMF Attribute objects for element results in an HDF5 file. More...
 
def XdmfElementFlags (h5_results)
 Return a list of XDMF Attribute objects for element flags in an HDF5 file. More...
 
def XdmfElementGaussPointValues (h5_results)
 Return a list of XDMF Attribute objects for element integration point values in an HDF5 file. More...
 
def XdmfConditionResults (h5_results)
 Return a list of XDMF Attribute objects for element results in an HDF5 file. More...
 
def XdmfConditionFlags (h5_results)
 Return a list of XDMF Attribute objects for element flags in an HDF5 file. More...
 
def XdmfConditionGaussPointValues (h5_results)
 Return a list of XDMF Attribute objects for element integration point values in an HDF5 file. More...
 
def XdmfResults (h5_results)
 Return a list of XDMF Attribute objects for results in an HDF5 file. More...
 
def TimeLabel (file_path)
 Return the time string from the file name. More...
 
def TimeFromFileName (file_path)
 Return the time value for the file name. More...
 
def FindMatchingFiles (pattern)
 Return a list of HDF5 files matching the given file name pattern. More...
 
def GetSortedListOfFiles (pattern)
 Return sorted file list based on the time stamp. More...
 
def GetStep (value, patterns)
 
def GetMatchingGroupNames (output_dict, value, patterns, pattern_with_wildcards)
 
def CreateXdmfTemporalGridFromMultifile (list_of_h5_files, h5path_to_mesh, h5path_to_results)
 Return an XDMF Grid object for a list of temporal results in HDF5 files. More...
 
def WriteMultifileTemporalAnalysisToXdmf (ospath, h5path_to_mesh, h5path_to_results)
 Write XDMF metadata for a temporal analysis from multiple HDF5 files. More...
 
def CreateXdmfTemporalGridFromSinglefile (h5_file_name, h5path_pattern_to_mesh, h5path_pattern_to_results, bool require_results=False)
 Return an XDMF Grid object for a list of temporal results in a single HDF5 file. More...
 
def WriteSinglefileTemporalAnalysisToXdmf (h5_file_name, h5path_pattern_to_mesh, h5path_pattern_to_results, bool require_results=False)
 Write XDMF metadata for a temporal analysis from single HDF5 file. More...
 

Variables

 category
 
string warn_msg = "h5py module was not found!"
 
 h5py
 

Detailed Description

Utilities for creating XDMF metadata from results stored in HDF5.

XDMF utilities are separate from the core xdmf to reduce core dependencies.

See:

license: HDF5Application/license.txt

Function Documentation

◆ CreateXdmfSpatialGrid()

def xdmf_utils.CreateXdmfSpatialGrid (   h5_model_part)

Return an XDMF Grid object corresponding to a mesh in an HDF5 file.

Keyword arguments:
h5_model_part -- the HDF5 group containing the model part

Expects:
- element connectivities in h5_model_part["Xdmf/Elements/<element-name>"].
  Each connectivities has attributes "Dimension" and "NumberOfNodes".  For
  example, "Element2D3N" has "Dimension" 2 and "NumberOfNodes" 3.  The
  connectivities differ from the normal mdpa connectivities in that they
  directly index the array of nodal coordinates.  Currently there is
  no other way to post-process the mesh with Xdmf.

See:
- core.operations.ModelPartOutput,
- core.operations.PartitionedModelPartOutput,
- RenumberConnectivitiesForXdmf.

◆ CreateXdmfTemporalGridFromMultifile()

def xdmf_utils.CreateXdmfTemporalGridFromMultifile (   list_of_h5_files,
  h5path_to_mesh,
  h5path_to_results 
)

Return an XDMF Grid object for a list of temporal results in HDF5 files.

Keyword arguments:
list_of_h5_files -- the list of HDF5 files to be parsed
h5path_to_mesh -- the internal HDF5 file path to the mesh
h5path_to_results -- the internal HDF5 file path to the results

Expects:
- each file corresponds to a separate time step
- the first file includes a mesh.  Subsequent files may include their own
  meshes.  If a file does not contain a mesh, it is assumed to have the
  same mesh as the most recent file containing a mesh.
- meshes include XDMF mesh connectivities under the internal HDF5 file path
  "<h5path_to_mesh>/Xdmf".  If XDMF connectivities are not found, the file is
  skipped.  See RenumberConnectivitiesForXdmf.
- file names contain their time step as a substring. Optionally the first
  file may omit the time step in which case it is assumed to be zero.

If a file cannot be opened, it is skipped.

◆ CreateXdmfTemporalGridFromSinglefile()

def xdmf_utils.CreateXdmfTemporalGridFromSinglefile (   h5_file_name,
  h5path_pattern_to_mesh,
  h5path_pattern_to_results,
bool   require_results = False 
)

Return an XDMF Grid object for a list of temporal results in a single HDF5 file.

Keyword arguments:
h5_file_name -- the HDF5 file to be parsed
h5path_pattern_to_mesh -- the internal HDF5 file path pattern to the mesh [ only <step> flag is supported ]
h5path_pattern_to_results -- the internal HDF5 file path pattern to the results [ only <step> flag is supported ]

Expects:
- In prefixes, <step> flag is used maximum of one time only
- If single mesh description is found, it is considered as single mesh temporal output

◆ FindMatchingFiles()

def xdmf_utils.FindMatchingFiles (   pattern)

Return a list of HDF5 files matching the given file name pattern.

For example, "./sim/kratos" matches:
- ./sim/kratos.h5
- ./sim/kratos-0.0000.h5
- ./sim/kratos-0.2000.h5
- etc.

◆ GetListOfSpatialGrids()

def xdmf_utils.GetListOfSpatialGrids (   spatial_grids_list,
  h5_model_part,
  current_path 
)

◆ GetMatchingGroupNames()

def xdmf_utils.GetMatchingGroupNames (   output_dict,
  value,
  patterns,
  pattern_with_wildcards 
)

◆ GetSortedListOfFiles()

def xdmf_utils.GetSortedListOfFiles (   pattern)

Return sorted file list based on the time stamp.

see @FindMatchingFiles

◆ GetStep()

def xdmf_utils.GetStep (   value,
  patterns 
)

◆ Has_dtype()

def xdmf_utils.Has_dtype (   item)

◆ RenumberConnectivitiesForXdmf()

def xdmf_utils.RenumberConnectivitiesForXdmf (   filename_or_list_of_filenames,
  h5path_to_mesh 
)

Renumber mesh connectivities for XDMF.

Keyword arguments:
filename_or_list_of_filenames -- the HDF5 file(s) to renumber
h5path_to_mesh -- the internal HDF5 file path to the mesh

The mesh connectivities must be renumbered for XDMF by the node's array
index rather than its ID.  The renumbered connectivities are stored in
HDF5 and referenced by the XDMF Grid.  If a file cannot be opened, it is
skipped.

See:
- XdmfConnectivitiesWriterProcess.

◆ TimeFromFileName()

def xdmf_utils.TimeFromFileName (   file_path)

Return the time value for the file name.

If the file name contains no time value, zero time value is assumed.

◆ TimeLabel()

def xdmf_utils.TimeLabel (   file_path)

Return the time string from the file name.

E.g.:
'kratos-123.h5' -> '123'
'kratos-1.2.h5' -> '1.2'
'kratos-1.2e+00.h5' -> '1.2e+00'

Returns empty string if not found.

◆ TryOpenH5File()

def xdmf_utils.TryOpenH5File (   name,
  mode = None,
  driver = None,
**  kwds 
)

A context manager wrapper for the opened file.

In case the file cannot be opened, yield None rather than raise an
exception.  This can be the case if the file is already opened.

◆ WriteMultifileTemporalAnalysisToXdmf()

def xdmf_utils.WriteMultifileTemporalAnalysisToXdmf (   ospath,
  h5path_to_mesh,
  h5path_to_results 
)

Write XDMF metadata for a temporal analysis from multiple HDF5 files.

Keyword arguments:
ospath -- path to one of the HDF5 files or the corresponding XDMF output file.
h5path_to_mesh -- the internal HDF5 file path to the mesh
h5path_to_results -- the internal HDF5 file path to the results

◆ WriteSinglefileTemporalAnalysisToXdmf()

def xdmf_utils.WriteSinglefileTemporalAnalysisToXdmf (   h5_file_name,
  h5path_pattern_to_mesh,
  h5path_pattern_to_results,
bool   require_results = False 
)

Write XDMF metadata for a temporal analysis from single HDF5 file.

Keyword arguments:
h5_file_name -- hdf5 filename
h5path_pattern_to_mesh -- the internal HDF5 file path pattern to the mesh [ only <step> flag is supported ]
h5path_to_results -- the internal HDF5 file path pattern to the results [ only <step> flag is supported ]

◆ XdmfConditionFlags()

def xdmf_utils.XdmfConditionFlags (   h5_results)

Return a list of XDMF Attribute objects for element flags in an HDF5 file.

Keyword arguments:
h5_flags -- the HDF5 group containing the flags

Checks for flags stored by variable name in:
- h5_flags["ConditionFlagValues/<flag-name>"]

If no flags are found, returns an empty list.

See:
- core.operations.ConditionFlagValueOutput.

◆ XdmfConditionGaussPointValues()

def xdmf_utils.XdmfConditionGaussPointValues (   h5_results)

Return a list of XDMF Attribute objects for element integration point values in an HDF5 file.

Keyword arguments:
h5_results -- the HDF5 group containing the results

Checks for results stored by variable name in:
- h5_results["ConditionGaussPointValues/<variable>"]

If no results are found, returns an empty list.

See:
- core.operations.ConditionGaussPointOutput.

◆ XdmfConditionResults()

def xdmf_utils.XdmfConditionResults (   h5_results)

Return a list of XDMF Attribute objects for element results in an HDF5 file.

Keyword arguments:
h5_results -- the HDF5 group containing the results

Checks for results stored by variable name in:
- h5_results["ConditionDataValues/<variable>"]

If no results are found, returns an empty list.

See:
- core.operations.ConditionDataValueOutput.

◆ XdmfElementFlags()

def xdmf_utils.XdmfElementFlags (   h5_results)

Return a list of XDMF Attribute objects for element flags in an HDF5 file.

Keyword arguments:
h5_flags -- the HDF5 group containing the flags

Checks for flags stored by variable name in:
- h5_flags["ElementFlagValues/<flag-name>"]

If no flags are found, returns an empty list.

See:
- core.operations.ElementFlagValueOutput.

◆ XdmfElementGaussPointValues()

def xdmf_utils.XdmfElementGaussPointValues (   h5_results)

Return a list of XDMF Attribute objects for element integration point values in an HDF5 file.

Keyword arguments:
h5_results -- the HDF5 group containing the results

Checks for results stored by variable name in:
- h5_results["ElementGaussPointValues/<variable>"]

If no results are found, returns an empty list.

See:
- core.operations.ElementGaussPointOutput.

◆ XdmfElementResults()

def xdmf_utils.XdmfElementResults (   h5_results)

Return a list of XDMF Attribute objects for element results in an HDF5 file.

Keyword arguments:
h5_results -- the HDF5 group containing the results

Checks for results stored by variable name in:
- h5_results["ElementDataValues/<variable>"]

If no results are found, returns an empty list.

See:
- core.operations.ElementDataValueOutput.

◆ XdmfNodalFlags()

def xdmf_utils.XdmfNodalFlags (   h5_results)

Return a list of XDMF Attribute objects for nodal flags in an HDF5 file.

Keyword arguments:
h5_results -- the HDF5 group containing the flags

Checks for flags stored in data sets by variable name in:
- h5_flags["NodalFlagValues/<flag-name>"]

Expects:
- each flag variable occurs only once

If no flags are found, returns an empty list.

See:
- core.operations.NodalFlagsValueOutput.

◆ XdmfNodalResults()

def xdmf_utils.XdmfNodalResults (   h5_results)

Return a list of XDMF Attribute objects for nodal results in an HDF5 file.

Keyword arguments:
h5_results -- the HDF5 group containing the results

Checks for results stored in data sets by variable name in:
- h5_results["NodalSolutionStepData/<variable-name>"]
- h5_results["NodalDataValues/<variable-name>"]

Expects:
- each result variable occurs only once

If no results are found, returns an empty list.

See:
- core.operations.NodalSolutionStepDataOutput,
- core.operations.NodalDataValueOutput.

◆ XdmfResults()

def xdmf_utils.XdmfResults (   h5_results)

Return a list of XDMF Attribute objects for results in an HDF5 file.

Keyword arguments:
h5_results -- the HDF5 group containing the results

Variable Documentation

◆ category

xdmf_utils.category

◆ h5py

xdmf_utils.h5py

◆ warn_msg

string xdmf_utils.warn_msg = "h5py module was not found!"