add hdf5 output option

This commit is contained in:
Magnus Ulimoen
2020-04-04 22:14:15 +02:00
parent 358f831513
commit c17ef20c76
4 changed files with 138 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import h5py
import os
@@ -195,6 +196,29 @@ def plot_pressure(grids, save: bool, filename="figure.png"):
def read_from_file(filename):
grids = []
file = h5py.File(filename, "r")
for groupname in file:
group = file[groupname]
if not isinstance(group, h5py.Group):
continue
grids.append(
{
"x": group["x"][:],
"y": group["y"][:],
"rho": group["rho"][-1, :, :],
"rhou": group["rhou"][-1, :, :],
"rhov": group["rhov"][-1, :, :],
"e": group["e"][-1, :, :],
}
)
return grids
def read_from_legacy_file(filename):
grids = []
with open(filename, "rb") as f:
ngrids = int(np.fromfile(f, dtype=np.uint32, count=1))
for i in range(ngrids):