Use tuple over ndarray::s

This commit is contained in:
Magnus Ulimoen 2021-11-21 11:19:24 +01:00
parent 9679ae5ba2
commit 6ebb173847
2 changed files with 11 additions and 13 deletions

View File

@ -8,7 +8,7 @@ edition = "2018"
[dependencies] [dependencies]
sbp = { path = "../sbp", features = ["serde1"] } sbp = { path = "../sbp", features = ["serde1"] }
euler = { path = "../euler", features = ["serde1"] } euler = { path = "../euler", features = ["serde1"] }
hdf5 = "0.8.0" hdf5 = "0.8.1"
integrate = { path = "../utils/integrate" } integrate = { path = "../utils/integrate" }
rayon = "1.3.0" rayon = "1.3.0"
indicatif = "0.17.0-beta.1" indicatif = "0.17.0-beta.1"

View File

@ -592,8 +592,7 @@ impl SingleThreadedSystem {
let tds = self.output.0.dataset("t").unwrap(); let tds = self.output.0.dataset("t").unwrap();
let tpos = tds.size(); let tpos = tds.size();
tds.resize((tpos + 1,)).unwrap(); tds.resize((tpos + 1,)).unwrap();
tds.write_slice(&[ntime], ndarray::s![tpos..tpos + 1]) tds.write_slice(&[ntime], tpos..tpos + 1).unwrap();
.unwrap();
for (group, fnow) in self.output.1.iter().zip(&self.fnow) { for (group, fnow) in self.output.1.iter().zip(&self.fnow) {
let (ny, nx) = (fnow.ny(), fnow.nx()); let (ny, nx) = (fnow.ny(), fnow.nx());
let rhods = group.dataset("rho").unwrap(); let rhods = group.dataset("rho").unwrap();
@ -603,16 +602,16 @@ impl SingleThreadedSystem {
let (rho, rhou, rhov, e) = fnow.components(); let (rho, rhou, rhov, e) = fnow.components();
rhods.resize((tpos + 1, ny, nx)).unwrap(); rhods.resize((tpos + 1, ny, nx)).unwrap();
rhods.write_slice(rho, ndarray::s![tpos, .., ..]).unwrap(); rhods.write_slice(rho, (tpos, .., ..)).unwrap();
rhouds.resize((tpos + 1, ny, nx)).unwrap(); rhouds.resize((tpos + 1, ny, nx)).unwrap();
rhouds.write_slice(rhou, ndarray::s![tpos, .., ..]).unwrap(); rhouds.write_slice(rhou, (tpos, .., ..)).unwrap();
rhovds.resize((tpos + 1, ny, nx)).unwrap(); rhovds.resize((tpos + 1, ny, nx)).unwrap();
rhovds.write_slice(rhov, ndarray::s![tpos, .., ..]).unwrap(); rhovds.write_slice(rhov, (tpos, .., ..)).unwrap();
eds.resize((tpos + 1, ny, nx)).unwrap(); eds.resize((tpos + 1, ny, nx)).unwrap();
eds.write_slice(e, ndarray::s![tpos, .., ..]).unwrap(); eds.write_slice(e, (tpos, .., ..)).unwrap();
} }
} }
@ -658,8 +657,7 @@ impl DistributedSystem {
let tds = self.output.dataset("t").unwrap(); let tds = self.output.dataset("t").unwrap();
let tpos = tds.size(); let tpos = tds.size();
tds.resize((tpos + 1,)).unwrap(); tds.resize((tpos + 1,)).unwrap();
tds.write_slice(&[ntime], ndarray::s![tpos..tpos + 1]) tds.write_slice(&[ntime], tpos..tpos + 1).unwrap();
.unwrap();
} }
pub fn attach_progressbar(&mut self, ntime: u64) { pub fn attach_progressbar(&mut self, ntime: u64) {
let target = indicatif::MultiProgress::new(); let target = indicatif::MultiProgress::new();
@ -859,16 +857,16 @@ impl DistributedSystemPart {
let (rho, rhou, rhov, e) = self.current.components(); let (rho, rhou, rhov, e) = self.current.components();
let tpos = rhods.size() / (ny * nx); let tpos = rhods.size() / (ny * nx);
rhods.resize((tpos + 1, ny, nx)).unwrap(); rhods.resize((tpos + 1, ny, nx)).unwrap();
rhods.write_slice(rho, ndarray::s![tpos, .., ..]).unwrap(); rhods.write_slice(rho, (tpos, .., ..)).unwrap();
rhouds.resize((tpos + 1, ny, nx)).unwrap(); rhouds.resize((tpos + 1, ny, nx)).unwrap();
rhouds.write_slice(rhou, ndarray::s![tpos, .., ..]).unwrap(); rhouds.write_slice(rhou, (tpos, .., ..)).unwrap();
rhovds.resize((tpos + 1, ny, nx)).unwrap(); rhovds.resize((tpos + 1, ny, nx)).unwrap();
rhovds.write_slice(rhov, ndarray::s![tpos, .., ..]).unwrap(); rhovds.write_slice(rhov, (tpos, .., ..)).unwrap();
eds.resize((tpos + 1, ny, nx)).unwrap(); eds.resize((tpos + 1, ny, nx)).unwrap();
eds.write_slice(e, ndarray::s![tpos, .., ..]).unwrap(); eds.write_slice(e, (tpos, .., ..)).unwrap();
} }
fn advance(&mut self, ntime: u64) { fn advance(&mut self, ntime: u64) {