use Direction struct
This commit is contained in:
parent
655d76f47d
commit
9023adf01f
|
@ -596,14 +596,6 @@ fn fluxes(k: (&mut Field, &mut Field), y: &Field, metrics: &Metrics) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct BoundaryTerms<'a> {
|
|
||||||
pub north: ArrayView2<'a, Float>,
|
|
||||||
pub south: ArrayView2<'a, Float>,
|
|
||||||
pub east: ArrayView2<'a, Float>,
|
|
||||||
pub west: ArrayView2<'a, Float>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum BoundaryCharacteristic {
|
pub enum BoundaryCharacteristic {
|
||||||
This,
|
This,
|
||||||
|
@ -620,6 +612,7 @@ pub struct Direction<T> {
|
||||||
pub east: T,
|
pub east: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type BoundaryTerms<'a> = Direction<ArrayView2<'a, Float>>;
|
||||||
pub type BoundaryCharacteristics = Direction<BoundaryCharacteristic>;
|
pub type BoundaryCharacteristics = Direction<BoundaryCharacteristic>;
|
||||||
|
|
||||||
fn boundary_extractor<'a>(
|
fn boundary_extractor<'a>(
|
||||||
|
@ -679,12 +672,12 @@ pub fn extract_boundaries<'a>(
|
||||||
BoundaryCharacteristic::This => field.south(),
|
BoundaryCharacteristic::This => field.south(),
|
||||||
BoundaryCharacteristic::Grid(g) => fields[g].south(),
|
BoundaryCharacteristic::Grid(g) => fields[g].south(),
|
||||||
BoundaryCharacteristic::Vortex(v) => {
|
BoundaryCharacteristic::Vortex(v) => {
|
||||||
let field = eb.n.as_mut().unwrap();
|
let field = eb.north.as_mut().unwrap();
|
||||||
vortexify(field.view_mut(), grid.north(), v, time);
|
vortexify(field.view_mut(), grid.north(), v, time);
|
||||||
field.view()
|
field.view()
|
||||||
}
|
}
|
||||||
BoundaryCharacteristic::Interpolate(g) => {
|
BoundaryCharacteristic::Interpolate(g) => {
|
||||||
let to = eb.n.as_mut().unwrap();
|
let to = eb.north.as_mut().unwrap();
|
||||||
let fine2coarse = field.nx() < fields[g].nx();
|
let fine2coarse = field.nx() < fields[g].nx();
|
||||||
|
|
||||||
let operator = interpolation_operators.as_ref().unwrap()[ig]
|
let operator = interpolation_operators.as_ref().unwrap()[ig]
|
||||||
|
@ -706,12 +699,12 @@ pub fn extract_boundaries<'a>(
|
||||||
BoundaryCharacteristic::This => field.north(),
|
BoundaryCharacteristic::This => field.north(),
|
||||||
BoundaryCharacteristic::Grid(g) => fields[g].north(),
|
BoundaryCharacteristic::Grid(g) => fields[g].north(),
|
||||||
BoundaryCharacteristic::Vortex(v) => {
|
BoundaryCharacteristic::Vortex(v) => {
|
||||||
let field = eb.s.as_mut().unwrap();
|
let field = eb.south.as_mut().unwrap();
|
||||||
vortexify(field.view_mut(), grid.south(), v, time);
|
vortexify(field.view_mut(), grid.south(), v, time);
|
||||||
field.view()
|
field.view()
|
||||||
}
|
}
|
||||||
BoundaryCharacteristic::Interpolate(g) => {
|
BoundaryCharacteristic::Interpolate(g) => {
|
||||||
let to = eb.s.as_mut().unwrap();
|
let to = eb.south.as_mut().unwrap();
|
||||||
let fine2coarse = field.nx() < fields[g].nx();
|
let fine2coarse = field.nx() < fields[g].nx();
|
||||||
let operator = interpolation_operators.as_ref().unwrap()[ig]
|
let operator = interpolation_operators.as_ref().unwrap()[ig]
|
||||||
.south
|
.south
|
||||||
|
@ -732,12 +725,12 @@ pub fn extract_boundaries<'a>(
|
||||||
BoundaryCharacteristic::This => field.east(),
|
BoundaryCharacteristic::This => field.east(),
|
||||||
BoundaryCharacteristic::Grid(g) => fields[g].east(),
|
BoundaryCharacteristic::Grid(g) => fields[g].east(),
|
||||||
BoundaryCharacteristic::Vortex(v) => {
|
BoundaryCharacteristic::Vortex(v) => {
|
||||||
let field = eb.w.as_mut().unwrap();
|
let field = eb.west.as_mut().unwrap();
|
||||||
vortexify(field.view_mut(), grid.west(), v, time);
|
vortexify(field.view_mut(), grid.west(), v, time);
|
||||||
field.view()
|
field.view()
|
||||||
}
|
}
|
||||||
BoundaryCharacteristic::Interpolate(g) => {
|
BoundaryCharacteristic::Interpolate(g) => {
|
||||||
let to = eb.w.as_mut().unwrap();
|
let to = eb.west.as_mut().unwrap();
|
||||||
let fine2coarse = field.ny() < fields[g].ny();
|
let fine2coarse = field.ny() < fields[g].ny();
|
||||||
let operator = interpolation_operators.as_ref().unwrap()[ig]
|
let operator = interpolation_operators.as_ref().unwrap()[ig]
|
||||||
.west
|
.west
|
||||||
|
@ -758,12 +751,12 @@ pub fn extract_boundaries<'a>(
|
||||||
BoundaryCharacteristic::This => field.west(),
|
BoundaryCharacteristic::This => field.west(),
|
||||||
BoundaryCharacteristic::Grid(g) => fields[g].west(),
|
BoundaryCharacteristic::Grid(g) => fields[g].west(),
|
||||||
BoundaryCharacteristic::Vortex(v) => {
|
BoundaryCharacteristic::Vortex(v) => {
|
||||||
let field = eb.e.as_mut().unwrap();
|
let field = eb.east.as_mut().unwrap();
|
||||||
vortexify(field.view_mut(), grid.east(), v, time);
|
vortexify(field.view_mut(), grid.east(), v, time);
|
||||||
field.view()
|
field.view()
|
||||||
}
|
}
|
||||||
BoundaryCharacteristic::Interpolate(g) => {
|
BoundaryCharacteristic::Interpolate(g) => {
|
||||||
let to = eb.e.as_mut().unwrap();
|
let to = eb.east.as_mut().unwrap();
|
||||||
let fine2coarse = field.ny() < fields[g].ny();
|
let fine2coarse = field.ny() < fields[g].ny();
|
||||||
let operator = interpolation_operators.as_ref().unwrap()[ig]
|
let operator = interpolation_operators.as_ref().unwrap()[ig]
|
||||||
.east
|
.east
|
||||||
|
@ -784,37 +777,31 @@ pub fn extract_boundaries<'a>(
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
/// Used for storing boundary elements
|
/// Used for storing boundary elements
|
||||||
pub struct BoundaryStorage {
|
pub type BoundaryStorage = Direction<Option<ndarray::Array2<Float>>>;
|
||||||
pub n: Option<ndarray::Array2<Float>>,
|
|
||||||
pub s: Option<ndarray::Array2<Float>>,
|
|
||||||
pub e: Option<ndarray::Array2<Float>>,
|
|
||||||
pub w: Option<ndarray::Array2<Float>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BoundaryStorage {
|
impl BoundaryStorage {
|
||||||
pub fn new(bt: &BoundaryCharacteristics, grid: &Grid) -> Self {
|
pub fn new(bt: &BoundaryCharacteristics, grid: &Grid) -> Self {
|
||||||
Self {
|
Self {
|
||||||
n: match bt.north {
|
north: match bt.north {
|
||||||
BoundaryCharacteristic::Vortex(_) | BoundaryCharacteristic::Interpolate(_) => {
|
BoundaryCharacteristic::Vortex(_) | BoundaryCharacteristic::Interpolate(_) => {
|
||||||
Some(ndarray::Array2::zeros((4, grid.nx())))
|
Some(ndarray::Array2::zeros((4, grid.nx())))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
s: match bt.south {
|
south: match bt.south {
|
||||||
BoundaryCharacteristic::Vortex(_) | BoundaryCharacteristic::Interpolate(_) => {
|
BoundaryCharacteristic::Vortex(_) | BoundaryCharacteristic::Interpolate(_) => {
|
||||||
Some(ndarray::Array2::zeros((4, grid.nx())))
|
Some(ndarray::Array2::zeros((4, grid.nx())))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
e: match bt.east {
|
east: match bt.east {
|
||||||
BoundaryCharacteristic::Vortex(_) | BoundaryCharacteristic::Interpolate(_) => {
|
BoundaryCharacteristic::Vortex(_) | BoundaryCharacteristic::Interpolate(_) => {
|
||||||
Some(ndarray::Array2::zeros((4, grid.ny())))
|
Some(ndarray::Array2::zeros((4, grid.ny())))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
w: match bt.west {
|
west: match bt.west {
|
||||||
BoundaryCharacteristic::Vortex(_) | BoundaryCharacteristic::Interpolate(_) => {
|
BoundaryCharacteristic::Vortex(_) | BoundaryCharacteristic::Interpolate(_) => {
|
||||||
Some(ndarray::Array2::zeros((4, grid.ny())))
|
Some(ndarray::Array2::zeros((4, grid.ny())))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue