Add improved default bc

This commit is contained in:
Magnus Ulimoen 2020-09-04 16:14:03 +02:00
parent cb2423ecb3
commit f1cb01d47c
3 changed files with 66 additions and 2 deletions

View File

@ -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
}
}

View File

@ -233,9 +233,12 @@ impl Configuration {
(op::Upwind9, op::Upwind9h2) => { (op::Upwind9, op::Upwind9h2) => {
Right(Box::new((&Upwind9, &Upwind9h2)) as Box<dyn UpwindOperator2d>) Right(Box::new((&Upwind9, &Upwind9h2)) as Box<dyn UpwindOperator2d>)
} }
(op::Upwind9h2, op::Upwind9) => {
Right(Box::new((&Upwind9h2, &Upwind9)) as Box<dyn UpwindOperator2d>)
}
(op::Sbp4, op::Sbp4) => Left(Box::new(SBP4) as Box<dyn SbpOperator2d>), (op::Sbp4, op::Sbp4) => Left(Box::new(SBP4) as Box<dyn SbpOperator2d>),
(op::Sbp8, op::Sbp8) => Left(Box::new(SBP8) as Box<dyn SbpOperator2d>), (op::Sbp8, op::Sbp8) => Left(Box::new(SBP8) as Box<dyn SbpOperator2d>),
_ => todo!(), _ => todo!("Combination {:?}, {:?} not implemented", eta, xi),
} }
}) })
.collect(); .collect();
@ -244,9 +247,12 @@ impl Configuration {
.iter() .iter()
.enumerate() .enumerate()
.map(|(i, (_name, g))| { .map(|(i, (_name, g))| {
let default_bc = default.boundary_conditions.clone().unwrap_or_default();
g.boundary_conditions g.boundary_conditions
.clone() .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 { .map(|bc| match bc {
None | Some(BoundaryType::Vortex) => { None | Some(BoundaryType::Vortex) => {
euler::BoundaryCharacteristic::Vortex(self.vortex.clone()) euler::BoundaryCharacteristic::Vortex(self.vortex.clone())

View File

@ -45,6 +45,25 @@ impl<T> Direction<T> {
east: f(self.east), east: f(self.east),
} }
} }
pub fn zip<U>(self, other: Direction<U>) -> 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<T> Direction<Option<T>> {
pub fn unwrap_or(self, other: Direction<T>) -> Direction<T> {
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<T> Direction<T> { impl<T> Direction<T> {