diff --git a/sbp/examples/multigrid.rs b/sbp/examples/multigrid.rs index 0787a7c..5fe4d11 100644 --- a/sbp/examples/multigrid.rs +++ b/sbp/examples/multigrid.rs @@ -193,17 +193,10 @@ fn main() { } let integration_time: f64 = json["integration_time"].as_number().unwrap().into(); + let vortexparams = utils::json_to_vortex(json["vortex"].clone()); + let mut sys = System::new(grids, bt); - sys.vortex( - 0.0, - euler::VortexParameters { - x0: 0.0, - y0: 0.0, - mach: 0.5, - rstar: 0.5, - eps: 1.0, - }, - ); + sys.vortex(0.0, vortexparams); let max_n = { let max_nx = sys.grids.iter().map(|g| g.nx()).max().unwrap(); diff --git a/sbp/examples/quad.json b/sbp/examples/quad.json index 292f2e3..408a9a8 100644 --- a/sbp/examples/quad.json +++ b/sbp/examples/quad.json @@ -37,5 +37,12 @@ "dirW": "grid0" } ], - "integration_time": 2.0 + "integration_time": 2.0, + "vortex": { + "x0": 0.0, + "y0": 0.0, + "mach": 0.5, + "rstar": 0.5, + "eps": 1.0 + } } diff --git a/sbp/src/utils.rs b/sbp/src/utils.rs index 635ba9b..aa2d6c7 100644 --- a/sbp/src/utils.rs +++ b/sbp/src/utils.rs @@ -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, + } +}