diff --git a/multigrid/examples/double.json b/multigrid/examples/double.json new file mode 100644 index 0000000..93775af --- /dev/null +++ b/multigrid/examples/double.json @@ -0,0 +1,39 @@ +{ + "grids": { + "default": { + "x": { "linspace": { "start": -5, "end": 5, "steps": 100 } }, + "operators": { + "xi": "upwind9", + "eta": "upwind9h2" + }, + "boundary_conditions": { + "east": "vortex", + "west": "vortex" + } + }, + "grid0": { + "y": { "linspace": { "start": 0, "end": 5, "steps": 50, "h2": true } }, + "boundary_conditions": { + "south": { "neighbour": "grid1" }, + "north": { "neighbour": "grid1" } + } + }, + "grid1": { + "y": { "linspace": { "start": -5, "end": 0, "steps": 50, "h2": true } }, + "boundary_conditions": { + "south": { "neighbour": "grid0" }, + "north": { "neighbour": "grid0" } + } + } + }, + "integration_time": 2.0, + "vortex": { + "vortices": [{ + "x0": -1.0, + "y0": 0.0, + "rstar": 0.5, + "eps": 1.0 + }], + "mach": 0.5 + } +} diff --git a/multigrid/src/parsing.rs b/multigrid/src/parsing.rs index 347b250..ede3309 100644 --- a/multigrid/src/parsing.rs +++ b/multigrid/src/parsing.rs @@ -233,9 +233,12 @@ impl Configuration { (op::Upwind9, op::Upwind9h2) => { Right(Box::new((&Upwind9, &Upwind9h2)) as Box) } + (op::Upwind9h2, op::Upwind9) => { + Right(Box::new((&Upwind9h2, &Upwind9)) as Box) + } (op::Sbp4, op::Sbp4) => Left(Box::new(SBP4) as Box), (op::Sbp8, op::Sbp8) => Left(Box::new(SBP8) as Box), - _ => todo!(), + _ => todo!("Combination {:?}, {:?} not implemented", eta, xi), } }) .collect(); @@ -244,9 +247,12 @@ impl Configuration { .iter() .enumerate() .map(|(i, (_name, g))| { + let default_bc = default.boundary_conditions.clone().unwrap_or_default(); g.boundary_conditions .clone() - .unwrap_or_else(|| default.boundary_conditions.clone().unwrap_or_default()) + .unwrap_or_default() + .zip(default_bc) + .map(|(bc, fallback)| bc.or(fallback)) .map(|bc| match bc { None | Some(BoundaryType::Vortex) => { euler::BoundaryCharacteristic::Vortex(self.vortex.clone()) diff --git a/sbp/src/utils.rs b/sbp/src/utils.rs index 06e49e7..426ab4c 100644 --- a/sbp/src/utils.rs +++ b/sbp/src/utils.rs @@ -45,6 +45,25 @@ impl Direction { east: f(self.east), } } + pub fn zip(self, other: Direction) -> Direction<(T, U)> { + Direction { + north: (self.north, other.north), + south: (self.south, other.south), + west: (self.west, other.west), + east: (self.east, other.east), + } + } +} + +impl Direction> { + pub fn unwrap_or(self, other: Direction) -> Direction { + Direction { + north: self.north.unwrap_or(other.north), + south: self.south.unwrap_or(other.south), + west: self.west.unwrap_or(other.west), + east: self.east.unwrap_or(other.east), + } + } } impl Direction {