change to WB
This commit is contained in:
parent
3e7b45b3be
commit
0f1f115fc3
|
@ -6,14 +6,7 @@ use structopt::StructOpt;
|
||||||
struct System<T: operators::UpwindOperator> {
|
struct System<T: operators::UpwindOperator> {
|
||||||
fnow: Vec<euler::Field>,
|
fnow: Vec<euler::Field>,
|
||||||
fnext: Vec<euler::Field>,
|
fnext: Vec<euler::Field>,
|
||||||
wb: Vec<(
|
wb: Vec<euler::WorkBuffers>,
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
)>,
|
|
||||||
k: [Vec<euler::Field>; 4],
|
k: [Vec<euler::Field>; 4],
|
||||||
grids: Vec<grid::Grid>,
|
grids: Vec<grid::Grid>,
|
||||||
metrics: Vec<grid::Metrics<T>>,
|
metrics: Vec<grid::Metrics<T>>,
|
||||||
|
@ -31,10 +24,7 @@ impl<T: operators::UpwindOperator> System<T> {
|
||||||
let fnext = fnow.clone();
|
let fnext = fnow.clone();
|
||||||
let wb = grids
|
let wb = grids
|
||||||
.iter()
|
.iter()
|
||||||
.map(|g| {
|
.map(|g| euler::WorkBuffers::new(g.ny(), g.nx()))
|
||||||
let f = euler::Field::new(g.ny(), g.nx());
|
|
||||||
(f.clone(), f.clone(), f.clone(), f.clone(), f.clone(), f)
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
let k = [fnow.clone(), fnow.clone(), fnow.clone(), fnow.clone()];
|
let k = [fnow.clone(), fnow.clone(), fnow.clone(), fnow.clone()];
|
||||||
let metrics = grids.iter().map(|g| g.metrics().unwrap()).collect();
|
let metrics = grids.iter().map(|g| g.metrics().unwrap()).collect();
|
||||||
|
@ -65,14 +55,7 @@ impl<T: operators::UpwindOperator> System<T> {
|
||||||
|
|
||||||
fn advance(&mut self, dt: Float, pool: &rayon::ThreadPool) {
|
fn advance(&mut self, dt: Float, pool: &rayon::ThreadPool) {
|
||||||
type MT<'a> = (
|
type MT<'a> = (
|
||||||
&'a mut [(
|
&'a mut [euler::WorkBuffers],
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
euler::Field,
|
|
||||||
)],
|
|
||||||
&'a mut [euler::BoundaryStorage],
|
&'a mut [euler::BoundaryStorage],
|
||||||
);
|
);
|
||||||
let rhs = move |fut: &mut [euler::Field],
|
let rhs = move |fut: &mut [euler::Field],
|
||||||
|
@ -98,7 +81,7 @@ impl<T: operators::UpwindOperator> System<T> {
|
||||||
.zip(wb.iter_mut())
|
.zip(wb.iter_mut())
|
||||||
.zip(metrics.iter())
|
.zip(metrics.iter())
|
||||||
{
|
{
|
||||||
s.spawn(move |_| euler::RHS_upwind(fut, prev, metrics, &bc, wb));
|
s.spawn(move |_| euler::RHS_upwind(fut, prev, metrics, &bc, &mut wb.0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub const GAMMA: Float = 1.4;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct System<SBP: SbpOperator> {
|
pub struct System<SBP: SbpOperator> {
|
||||||
sys: (Field, Field),
|
sys: (Field, Field),
|
||||||
|
k: [Field; 4],
|
||||||
wb: WorkBuffers,
|
wb: WorkBuffers,
|
||||||
grid: (Grid, Metrics<SBP>),
|
grid: (Grid, Metrics<SBP>),
|
||||||
}
|
}
|
||||||
|
@ -27,6 +28,12 @@ impl<SBP: SbpOperator> System<SBP> {
|
||||||
Self {
|
Self {
|
||||||
sys: (Field::new(ny, nx), Field::new(ny, nx)),
|
sys: (Field::new(ny, nx), Field::new(ny, nx)),
|
||||||
grid: (grid, metrics),
|
grid: (grid, metrics),
|
||||||
|
k: [
|
||||||
|
Field::new(ny, nx),
|
||||||
|
Field::new(ny, nx),
|
||||||
|
Field::new(ny, nx),
|
||||||
|
Field::new(ny, nx),
|
||||||
|
],
|
||||||
wb: WorkBuffers::new(ny, nx),
|
wb: WorkBuffers::new(ny, nx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,9 +56,9 @@ impl<SBP: SbpOperator> System<SBP> {
|
||||||
&mut self.sys.1,
|
&mut self.sys.1,
|
||||||
&mut 0.0,
|
&mut 0.0,
|
||||||
dt,
|
dt,
|
||||||
&mut self.wb.k,
|
&mut self.k,
|
||||||
&self.grid,
|
&self.grid,
|
||||||
&mut self.wb.tmp,
|
&mut self.wb.0,
|
||||||
);
|
);
|
||||||
std::mem::swap(&mut self.sys.0, &mut self.sys.1);
|
std::mem::swap(&mut self.sys.0, &mut self.sys.1);
|
||||||
}
|
}
|
||||||
|
@ -109,9 +116,9 @@ impl<UO: UpwindOperator> System<UO> {
|
||||||
&mut self.sys.1,
|
&mut self.sys.1,
|
||||||
&mut 0.0,
|
&mut 0.0,
|
||||||
dt,
|
dt,
|
||||||
&mut self.wb.k,
|
&mut self.k,
|
||||||
&self.grid,
|
&self.grid,
|
||||||
&mut self.wb.tmp,
|
&mut self.wb.0,
|
||||||
);
|
);
|
||||||
std::mem::swap(&mut self.sys.0, &mut self.sys.1);
|
std::mem::swap(&mut self.sys.0, &mut self.sys.1);
|
||||||
}
|
}
|
||||||
|
@ -1008,24 +1015,18 @@ fn SAT_characteristic(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct WorkBuffers {
|
pub struct WorkBuffers(pub (Field, Field, Field, Field, Field, Field));
|
||||||
k: [Field; 4],
|
|
||||||
tmp: (Field, Field, Field, Field, Field, Field),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WorkBuffers {
|
impl WorkBuffers {
|
||||||
pub fn new(nx: usize, ny: usize) -> Self {
|
pub fn new(nx: usize, ny: usize) -> Self {
|
||||||
let arr3 = Field::new(nx, ny);
|
let arr3 = Field::new(nx, ny);
|
||||||
Self {
|
Self((
|
||||||
k: [arr3.clone(), arr3.clone(), arr3.clone(), arr3.clone()],
|
arr3.clone(),
|
||||||
tmp: (
|
arr3.clone(),
|
||||||
arr3.clone(),
|
arr3.clone(),
|
||||||
arr3.clone(),
|
arr3.clone(),
|
||||||
arr3.clone(),
|
arr3.clone(),
|
||||||
arr3.clone(),
|
arr3,
|
||||||
arr3.clone(),
|
))
|
||||||
arr3,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue