json parse vortex parameters

This commit is contained in:
Magnus Ulimoen
2020-04-02 22:49:27 +02:00
parent 18ebbfde75
commit a31ca3ff3e
3 changed files with 34 additions and 11 deletions

View File

@@ -246,3 +246,26 @@ fn parse_err() {
json_to_grids(r#"{"x": "linspace:1.2:3.1:412.2", "y": [0.1, 0.2]}"#).unwrap_err();
json_to_grids(r#"{"x": [-2, -3, "dfd"], "y": [0.1, 0.2]}"#).unwrap_err();
}
pub fn json_to_vortex(mut json: JsonValue) -> super::euler::VortexParameters {
let x0 = json.remove("x0").as_number().unwrap().into();
let y0 = json.remove("y0").as_number().unwrap().into();
let mach = json.remove("mach").as_number().unwrap().into();
let rstar = json.remove("rstar").as_number().unwrap().into();
let eps = json.remove("eps").as_number().unwrap().into();
if !json.is_empty() {
eprintln!("Found unused items when parsing vortex");
for (name, val) in json.entries() {
eprintln!("\t{} {}", name, val.dump());
}
}
super::euler::VortexParameters {
x0,
y0,
mach,
rstar,
eps,
}
}