allow several vortices

This commit is contained in:
Magnus Ulimoen
2020-04-22 23:59:06 +02:00
parent d60770dcbf
commit db6f7ef41f
4 changed files with 79 additions and 45 deletions

View File

@@ -70,9 +70,9 @@ impl System {
}
}
fn vortex(&mut self, t: Float, vortex_params: euler::VortexParameters) {
fn vortex(&mut self, t: Float, vortex_params: &euler::VortexParameters) {
for (f, g) in self.fnow.iter_mut().zip(&self.grids) {
f.vortex(g.x(), g.y(), t, vortex_params);
f.vortex(g.x(), g.y(), t, &vortex_params);
}
}
@@ -161,12 +161,12 @@ fn main() {
let json = json::parse(&filecontents).unwrap();
let vortexparams = json_to_vortex(json["vortex"].clone());
let (names, grids, bt, operators) = json_to_grids(json["grids"].clone(), vortexparams);
let (names, grids, bt, operators) = json_to_grids(json["grids"].clone(), vortexparams.clone());
let integration_time: Float = json["integration_time"].as_number().unwrap().into();
let mut sys = System::new(grids, bt, operators);
sys.vortex(0.0, vortexparams);
sys.vortex(0.0, &vortexparams);
let max_n = {
let max_nx = sys.grids.iter().map(|g| g.nx()).max().unwrap();
@@ -233,7 +233,7 @@ fn main() {
let mut e = 0.0;
for ((fmod, grid), op) in sys.fnow.iter().zip(&sys.grids).zip(&sys.operators) {
let mut fvort = fmod.clone();
fvort.vortex(grid.x(), grid.y(), time, vortexparams);
fvort.vortex(grid.x(), grid.y(), time, &vortexparams);
let sbpop: &dyn SbpOperator2d = op.as_ref().either(|op| &**op, |uo| uo.as_sbp());
e += fmod.h2_err(&fvort, sbpop);
}

View File

@@ -110,7 +110,7 @@ pub fn json_to_grids(
let determine_bc = |dir: Option<&str>| match dir {
Some(dir) => {
if dir == "vortex" {
sbp::euler::BoundaryCharacteristic::Vortex(vortexparams)
sbp::euler::BoundaryCharacteristic::Vortex(vortexparams.clone())
} else if let Some(grid) = dir.strip_prefix("interpolate:") {
use sbp::operators::*;
let (grid, int_op) = if let Some(rest) = grid.strip_prefix("4:") {
@@ -363,11 +363,13 @@ pub fn json_to_vortex(mut json: JsonValue) -> super::euler::VortexParameters {
}
}
super::euler::VortexParameters {
x0,
y0,
mach,
rstar,
eps,
}
let vortice = super::euler::Vortice { x0, y0, eps, rstar };
let vortices = {
let mut a = super::euler::ArrayVec::new();
a.push(vortice);
a
};
super::euler::VortexParameters { vortices, mach }
}