示例#1
0
def AddNodalData(results_group, results):
    for variable_name in results_group.keys():
        if isinstance(results_group[variable_name], h5py.Dataset):
            if variable_name in results:
                raise ValueError('Nodal result "' + variable_name + '" is already defined.')
            data = xdmf.HDF5UniformDataItem(results_group.get(variable_name))
            results[variable_name] = xdmf.NodalData(variable_name, data)
示例#2
0
def GetSpatialGrid(h5py_file):
    elements_path = "/ModelData/Xdmf/Elements/"
    coordinates_path = "/ModelData/Nodes/Local/Coordinates"
    spatial_grid = xdmf.SpatialGrid()
    coords_data = xdmf.HDF5UniformDataItem(h5py_file.get(coordinates_path))
    geom = xdmf.Geometry(coords_data)
    elems_group = h5py_file.get(elements_path)
    for name in elems_group.keys():
        if isinstance(elems_group[name], h5py.Group):
            single_elem_group = elems_group.get(name)
            dim = single_elem_group.attrs["Dimension"]
            num_points = single_elem_group.attrs["NumberOfNodes"]
            cell_type = xdmf.TopologyCellType(dim, num_points)
            connectivity_data = xdmf.HDF5UniformDataItem(h5py_file.get(elements_path + '/' + name + '/Connectivities'))
            topology = xdmf.UniformMeshTopology(cell_type, connectivity_data)
            spatial_grid.add_grid(xdmf.UniformGrid(name, geom, topology))
    return spatial_grid
示例#3
0
def GetNodalResults(h5py_file):
    nodal_results_path = "/ResultsData/NodalResults"
    results = []
    results_group = h5py_file.get(nodal_results_path)
    for variable_name in results_group.keys():
        if isinstance(results_group[variable_name], h5py.Dataset):
            data = xdmf.HDF5UniformDataItem(results_group.get(variable_name))
            results.append(xdmf.NodalSolutionStepData(variable_name, data))
    return results
示例#4
0
def GetElementResults(h5py_file):
    element_results_path = "/ResultsData/ElementResults"
    results = []
    if not element_results_path in h5py_file:
        return results
    results_group = h5py_file.get(element_results_path)
    for variable_name in results_group.keys():
        if isinstance(results_group[variable_name], h5py.Dataset):
            data = xdmf.HDF5UniformDataItem(results_group.get(variable_name))
            results.append(xdmf.ElementSolutionStepData(variable_name, data))
    return results