remove legacy output format
This commit is contained in:
parent
d3465d5e1e
commit
d23341c0f5
|
@ -216,39 +216,6 @@ def read_from_file(filename):
|
||||||
return grids
|
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):
|
|
||||||
(neta, nxi) = np.fromfile(f, dtype=np.uint32, count=2)
|
|
||||||
|
|
||||||
x = np.fromfile(f, dtype=np.double, count=neta * nxi)
|
|
||||||
x = x.reshape((neta, nxi))
|
|
||||||
|
|
||||||
y = np.fromfile(f, dtype=np.double, count=neta * nxi)
|
|
||||||
y = y.reshape((neta, nxi))
|
|
||||||
|
|
||||||
rho = np.fromfile(f, dtype=np.double, count=neta * nxi)
|
|
||||||
rho = rho.reshape((neta, nxi))
|
|
||||||
|
|
||||||
rhou = np.fromfile(f, dtype=np.double, count=neta * nxi)
|
|
||||||
rhou = rhou.reshape((neta, nxi))
|
|
||||||
|
|
||||||
rhov = np.fromfile(f, dtype=np.double, count=neta * nxi)
|
|
||||||
rhov = rhov.reshape((neta, nxi))
|
|
||||||
|
|
||||||
e = np.fromfile(f, dtype=np.double, count=neta * nxi)
|
|
||||||
e = e.reshape((neta, nxi))
|
|
||||||
|
|
||||||
grids.append(
|
|
||||||
{"x": x, "y": y, "rho": rho, "rhou": rhou, "rhov": rhov, "e": e}
|
|
||||||
)
|
|
||||||
|
|
||||||
return grids
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = ArgumentParser(description="Plot a solution from the eulersolver")
|
parser = ArgumentParser(description="Plot a solution from the eulersolver")
|
||||||
parser.add_argument("filename", metavar="filename", type=str)
|
parser.add_argument("filename", metavar="filename", type=str)
|
||||||
|
|
|
@ -352,11 +352,8 @@ struct Options {
|
||||||
#[structopt(short, long)]
|
#[structopt(short, long)]
|
||||||
jobs: Option<Option<usize>>,
|
jobs: Option<Option<usize>>,
|
||||||
/// Name of output file
|
/// Name of output file
|
||||||
#[structopt(default_value = "output")]
|
#[structopt(default_value = "output.hdf")]
|
||||||
output: std::path::PathBuf,
|
output: std::path::PathBuf,
|
||||||
/// Output on the legacy format
|
|
||||||
#[structopt(long)]
|
|
||||||
legacy: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -419,14 +416,8 @@ fn main() {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let output = if opt.legacy {
|
let output = File::create(&opt.output, sys.grids.as_slice()).unwrap();
|
||||||
None
|
output.add_timestep(0, sys.fnow.as_slice()).unwrap();
|
||||||
} else {
|
|
||||||
Some(File::create(&opt.output, sys.grids.as_slice()).unwrap())
|
|
||||||
};
|
|
||||||
if let Some(file) = output.as_ref() {
|
|
||||||
file.add_timestep(0, sys.fnow.as_slice()).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
let bar = progressbar(opt.no_progressbar, ntime);
|
let bar = progressbar(opt.no_progressbar, ntime);
|
||||||
for _ in 0..ntime {
|
for _ in 0..ntime {
|
||||||
|
@ -439,11 +430,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
bar.finish();
|
bar.finish();
|
||||||
|
|
||||||
if let Some(file) = output.as_ref() {
|
output.add_timestep(ntime, sys.fnow.as_slice()).unwrap();
|
||||||
file.add_timestep(ntime, sys.fnow.as_slice()).unwrap();
|
|
||||||
} else {
|
|
||||||
legacy_output(&opt.output, &sys);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn progressbar(dummy: bool, ntime: u64) -> indicatif::ProgressBar {
|
fn progressbar(dummy: bool, ntime: u64) -> indicatif::ProgressBar {
|
||||||
|
@ -458,39 +445,6 @@ fn progressbar(dummy: bool, ntime: u64) -> indicatif::ProgressBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn legacy_output<T: sbp::operators::UpwindOperator, P: AsRef<std::path::Path>>(
|
|
||||||
path: &P,
|
|
||||||
sys: &System<T>,
|
|
||||||
) {
|
|
||||||
use std::io::prelude::*;
|
|
||||||
let file = std::fs::File::create(path).unwrap();
|
|
||||||
let mut file = std::io::BufWriter::new(file);
|
|
||||||
let ngrids = sys.grids.len();
|
|
||||||
file.write_all(&(ngrids as u32).to_le_bytes()).unwrap();
|
|
||||||
for (grid, s) in sys.grids.iter().zip(&sys.fnow) {
|
|
||||||
file.write_all(&(grid.ny() as u32).to_le_bytes()).unwrap();
|
|
||||||
file.write_all(&(grid.nx() as u32).to_le_bytes()).unwrap();
|
|
||||||
for x in grid.x().as_slice().unwrap() {
|
|
||||||
file.write_all(&(x.to_le_bytes())).unwrap();
|
|
||||||
}
|
|
||||||
for y in grid.y().as_slice().unwrap() {
|
|
||||||
file.write_all(&(y.to_le_bytes())).unwrap();
|
|
||||||
}
|
|
||||||
for rho in s.rho().as_slice().unwrap() {
|
|
||||||
file.write_all(&(rho.to_le_bytes())).unwrap();
|
|
||||||
}
|
|
||||||
for rhou in s.rhou().as_slice().unwrap() {
|
|
||||||
file.write_all(&(rhou.to_le_bytes())).unwrap();
|
|
||||||
}
|
|
||||||
for rhov in s.rhov().as_slice().unwrap() {
|
|
||||||
file.write_all(&(rhov.to_le_bytes())).unwrap();
|
|
||||||
}
|
|
||||||
for e in s.e().as_slice().unwrap() {
|
|
||||||
file.write_all(&(e.to_le_bytes())).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct File(hdf5::File);
|
struct File(hdf5::File);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue