add progressbar
This commit is contained in:
parent
d80a9bfa6d
commit
18ebbfde75
|
@ -20,6 +20,7 @@ f32 = []
|
|||
[dev-dependencies]
|
||||
criterion = "0.3.0"
|
||||
structopt = "0.3.12"
|
||||
indicatif = "0.14.0"
|
||||
|
||||
[[bench]]
|
||||
name = "maxwell"
|
||||
|
|
|
@ -158,6 +158,8 @@ impl<T: operators::UpwindOperator> System<T> {
|
|||
#[derive(Debug, StructOpt)]
|
||||
struct Options {
|
||||
json: std::path::PathBuf,
|
||||
#[structopt(long, help = "Disable the progressbar")]
|
||||
no_progressbar: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -189,6 +191,7 @@ fn main() {
|
|||
for grid in jgrids {
|
||||
grids.push(grid::Grid::new(grid.x, grid.y).unwrap());
|
||||
}
|
||||
let integration_time: f64 = json["integration_time"].as_number().unwrap().into();
|
||||
|
||||
let mut sys = System::new(grids, bt);
|
||||
sys.vortex(
|
||||
|
@ -207,11 +210,24 @@ fn main() {
|
|||
let max_ny = sys.grids.iter().map(|g| g.ny()).max().unwrap();
|
||||
std::cmp::max(max_nx, max_ny)
|
||||
};
|
||||
let t: f64 = json["integration_time"].as_number().unwrap().into();
|
||||
let dt = 0.2 / (max_n as Float);
|
||||
for _ in 0..(t / dt) as _ {
|
||||
|
||||
let ntime = (integration_time / dt).round() as usize;
|
||||
|
||||
let bar = if opt.no_progressbar {
|
||||
indicatif::ProgressBar::hidden()
|
||||
} else {
|
||||
let bar = indicatif::ProgressBar::new(ntime as _);
|
||||
bar.with_style(
|
||||
indicatif::ProgressStyle::default_bar()
|
||||
.template("{wide_bar:.cyan/blue} {pos}/{len} ({eta})"),
|
||||
)
|
||||
};
|
||||
for _ in 0..ntime {
|
||||
bar.inc(1);
|
||||
sys.advance(dt);
|
||||
}
|
||||
bar.finish();
|
||||
|
||||
dump_to_file(&sys);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::Float;
|
||||
use json::JsonValue;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SimpleGrid {
|
||||
|
@ -27,8 +28,7 @@ pub struct SimpleGrid {
|
|||
/// Optional parameters:
|
||||
/// * name (for relating boundaries)
|
||||
/// * dir{e,w,n,s} (for boundary terms)
|
||||
pub fn json_to_grids(json: json::JsonValue) -> Result<Vec<SimpleGrid>, String> {
|
||||
use json::JsonValue;
|
||||
pub fn json_to_grids(json: JsonValue) -> Result<Vec<SimpleGrid>, String> {
|
||||
fn json_to_grid(mut grid: JsonValue) -> Result<SimpleGrid, String> {
|
||||
#[derive(Debug)]
|
||||
enum ArrayForm {
|
||||
|
|
Loading…
Reference in New Issue