revamp boundary struct

This commit is contained in:
Magnus Ulimoen 2020-02-19 20:00:52 +01:00
parent 264b483aef
commit c8bed50d96
1 changed files with 19 additions and 48 deletions

View File

@ -260,10 +260,10 @@ pub(crate) fn RHS_trad<SBP: SbpOperator>(
}); });
let boundaries = BoundaryTerms { let boundaries = BoundaryTerms {
north: Boundary::This, north: y.south(),
south: Boundary::This, south: y.north(),
west: Boundary::This, west: y.east(),
east: Boundary::This, east: y.west(),
}; };
SAT_characteristics(k, y, grid, &boundaries); SAT_characteristics(k, y, grid, &boundaries);
@ -306,11 +306,12 @@ pub(crate) fn RHS_upwind<UO: UpwindOperator>(
}); });
let boundaries = BoundaryTerms { let boundaries = BoundaryTerms {
north: Boundary::This, north: y.south(),
south: Boundary::This, south: y.north(),
west: Boundary::This, west: y.east(),
east: Boundary::This, east: y.west(),
}; };
SAT_characteristics(k, y, grid, &boundaries); SAT_characteristics(k, y, grid, &boundaries);
} }
@ -429,16 +430,11 @@ fn fluxes<SBP: SbpOperator>(k: (&mut Field, &mut Field), y: &Field, grid: &Grid<
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum Boundary { pub struct BoundaryTerms<'a> {
This, pub north: ArrayView2<'a, f32>,
} pub south: ArrayView2<'a, f32>,
pub east: ArrayView2<'a, f32>,
#[derive(Clone, Debug)] pub west: ArrayView2<'a, f32>,
pub struct BoundaryTerms {
pub north: Boundary,
pub south: Boundary,
pub east: Boundary,
pub west: Boundary,
} }
#[allow(non_snake_case)] #[allow(non_snake_case)]
@ -447,18 +443,8 @@ fn SAT_characteristics<SBP: SbpOperator>(
k: &mut Field, k: &mut Field,
y: &Field, y: &Field,
grid: &Grid<SBP>, grid: &Grid<SBP>,
_boundaries: &BoundaryTerms, boundaries: &BoundaryTerms,
) { ) {
/* // Whean using infinite boundaries, use this...
let steady_v = [1.0, 1.0, 0.0, {
let M = 0.1;
let p_inf = 1.0 / (GAMMA * M * M);
p_inf / (GAMMA - 1.0) + 0.5
}];
let steady_a = ndarray::Array1::from(steady_v.to_vec());
let steady = steady_a.broadcast((k.nx(), 4)).unwrap().reversed_axes();
assert_eq!(steady.shape(), [4, k.nx()]);
*/
// North boundary // North boundary
{ {
let hi = (k.ny() - 1) as f32 * SBP::h()[0]; let hi = (k.ny() - 1) as f32 * SBP::h()[0];
@ -468,8 +454,7 @@ fn SAT_characteristics<SBP: SbpOperator>(
SAT_characteristic( SAT_characteristic(
k.north_mut(), k.north_mut(),
y.north(), y.north(),
y.south(), // Self South boundaries.north,
//steady.view(),
hi, hi,
sign, sign,
tau, tau,
@ -487,8 +472,7 @@ fn SAT_characteristics<SBP: SbpOperator>(
SAT_characteristic( SAT_characteristic(
k.south_mut(), k.south_mut(),
y.south(), y.south(),
y.north(), // Self North boundaries.south,
//steady.view(),
hi, hi,
sign, sign,
tau, tau,
@ -497,17 +481,6 @@ fn SAT_characteristics<SBP: SbpOperator>(
grid.detj_deta_dy.slice(slice), grid.detj_deta_dy.slice(slice),
); );
} }
/*let steady = ndarray::Array2::from_shape_fn((4, k.ny()), |(k, _)| match k {
0 => 1.0,
1 => 1.0,
2 => 0.0,
3 => {
let M = 0.1;
let p_inf = 1.0 / (GAMMA * M * M);
p_inf / (GAMMA - 1.0) + 0.5
}
_ => unreachable!(),
});*/
// West Boundary // West Boundary
{ {
let hi = (k.nx() - 1) as f32 * SBP::h()[0]; let hi = (k.nx() - 1) as f32 * SBP::h()[0];
@ -517,8 +490,7 @@ fn SAT_characteristics<SBP: SbpOperator>(
SAT_characteristic( SAT_characteristic(
k.west_mut(), k.west_mut(),
y.west(), y.west(),
y.east(), // Self East boundaries.west,
//steady.view(),
hi, hi,
sign, sign,
tau, tau,
@ -536,8 +508,7 @@ fn SAT_characteristics<SBP: SbpOperator>(
SAT_characteristic( SAT_characteristic(
k.east_mut(), k.east_mut(),
y.east(), y.east(),
y.west(), // Self West boundaries.east,
//steady.view(),
hi, hi,
sign, sign,
tau, tau,