Пример #1
0
def 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
    """
    pat = ospath
    # Strip any time label from the file name.
    time_label = TimeLabel(pat)
    pat = pat.rstrip('.h5').rstrip('.xdmf')
    if time_label:
        pat = pat.rstrip(time_label).rstrip("-")
    # Generate the temporal grid.
    list_of_files = GetSortedListOfFiles(pat)
    RenumberConnectivitiesForXdmf(list_of_files, h5path_to_mesh)
    temporal_grid = CreateXdmfTemporalGridFromMultifile(
        list_of_files, h5path_to_mesh, h5path_to_results)
    domain = Domain(temporal_grid)
    xdmf = Xdmf(domain)
    # Write the XML tree containing the XDMF metadata to the file.
    ET.ElementTree(xdmf.create_xml_element()).write(pat + ".xdmf")
Пример #2
0
def WriteSinglefileTemporalAnalysisToXdmf(h5_file_name, h5path_pattern_to_mesh,
                                          h5path_pattern_to_results):
    """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 ]
    """

    if (h5path_pattern_to_mesh.startswith("/")):
        h5path_pattern_to_mesh = h5path_pattern_to_mesh[1:]

    if (h5path_pattern_to_results.startswith("/")):
        h5path_pattern_to_results = h5path_pattern_to_results[1:]

    temporal_grid = CreateXdmfTemporalGridFromSinglefile(
        h5_file_name, h5path_pattern_to_mesh, h5path_pattern_to_results)
    domain = Domain(temporal_grid)
    xdmf = Xdmf(domain)
    # Write the XML tree containing the XDMF metadata to the file.
    ET.ElementTree(xdmf.create_xml_element()).write(
        h5_file_name[:h5_file_name.rfind(".")] + ".xdmf")