generalized integrate in euler

This commit is contained in:
Magnus Ulimoen 2020-01-29 20:44:55 +01:00
parent b92e1412d3
commit 92c86c2c41
1 changed files with 10 additions and 9 deletions

View File

@ -224,23 +224,24 @@ impl Field {
} }
} }
pub(crate) fn integrate_rk4<SBP, RHS, WB>( pub(crate) fn integrate_rk4<'a, F: 'a, SBP, RHS, WB>(
rhs: RHS, rhs: RHS,
prev: &Field, prev: &F,
fut: &mut Field, fut: &mut F,
dt: f32, dt: f32,
grid: &Grid<SBP>, grid: &Grid<SBP>,
k: &mut [Field; 4], k: &mut [F; 4],
mut wb: &mut WB, mut wb: &mut WB,
) where ) where
F: std::ops::Deref<Target = Array3<f32>> + std::ops::DerefMut<Target = Array3<f32>>,
SBP: SbpOperator, SBP: SbpOperator,
RHS: Fn(&mut Field, &Field, &Grid<SBP>, &mut WB), RHS: Fn(&mut F, &F, &Grid<SBP>, &mut WB),
{ {
assert_eq!(prev.0.shape(), fut.0.shape()); assert_eq!(prev.shape(), fut.shape());
for i in 0..4 { for i in 0..4 {
// y = y0 + c*kn // y = y0 + c*kn
fut.assign(&prev); fut.assign(prev);
match i { match i {
0 => {} 0 => {}
1 | 2 => { 1 | 2 => {
@ -257,8 +258,8 @@ pub(crate) fn integrate_rk4<SBP, RHS, WB>(
rhs(&mut k[i], &fut, grid, &mut wb); rhs(&mut k[i], &fut, grid, &mut wb);
} }
Zip::from(&mut fut.0) Zip::from(&mut **fut)
.and(&prev.0) .and(&**prev)
.and(&*k[0]) .and(&*k[0])
.and(&*k[1]) .and(&*k[1])
.and(&*k[2]) .and(&*k[2])