From 2adf91e1cebaee8f73edbcbc1d6b067a73823a38 Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Mon, 13 Apr 2020 18:39:21 +0200 Subject: [PATCH] relax Fn bound on integrate functions --- multigrid/src/main.rs | 22 ++++++++++------------ sbp/src/integrate.rs | 8 ++++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/multigrid/src/main.rs b/multigrid/src/main.rs index 4f2684f..bfda683 100644 --- a/multigrid/src/main.rs +++ b/multigrid/src/main.rs @@ -105,21 +105,19 @@ impl System { } fn advance(&mut self, dt: Float, pool: &rayon::ThreadPool) { - type MT<'a> = ( - &'a mut [euler::WorkBuffers], - &'a mut [euler::BoundaryStorage], - ); let metrics = &self.metrics; + let grids = &self.grids; + let bt = &self.bt; + let wb = &mut self.wb; + let mut eb = &mut self.eb; + let rhs = move |fut: &mut [euler::Field], prev: &[euler::Field], time: Float, - c: &(&[grid::Grid], &[euler::BoundaryCharacteristics]), - mt: &mut MT| { - let (grids, bt) = c; - let (wb, eb) = mt; - + _c: (), + _mt: &mut ()| { let bc = euler::extract_boundaries::( - prev, *bt, *eb, *grids, time, + prev, &bt, &mut eb, &grids, time, ); pool.scope(|s| { for ((((fut, prev), bc), wb), metrics) in fut @@ -168,8 +166,8 @@ impl System { &mut self.time, dt, &mut k, - &(&self.grids, &self.bt), - &mut (&mut self.wb, &mut self.eb), + (), + &mut (), pool, ); diff --git a/sbp/src/integrate.rs b/sbp/src/integrate.rs index 0b7fe31..c11e8b3 100644 --- a/sbp/src/integrate.rs +++ b/sbp/src/integrate.rs @@ -89,7 +89,7 @@ impl ButcherTableau for Rk6 { #[allow(clippy::too_many_arguments)] pub fn integrate<'a, BTableau, F: 'a, RHS, MT, C>( - rhs: RHS, + mut rhs: RHS, prev: &F, fut: &mut F, time: &mut Float, @@ -101,7 +101,7 @@ pub fn integrate<'a, BTableau, F: 'a, RHS, MT, C>( ) where C: Copy, F: std::ops::Deref> + std::ops::DerefMut>, - RHS: Fn(&mut F, &F, Float, C, &mut MT), + RHS: FnMut(&mut F, &F, Float, C, &mut MT), BTableau: ButcherTableau, { assert_eq!(prev.shape(), fut.shape()); @@ -147,7 +147,7 @@ pub fn integrate<'a, BTableau, F: 'a, RHS, MT, C>( #[cfg(feature = "rayon")] #[allow(clippy::too_many_arguments)] pub fn integrate_multigrid<'a, BTableau, F: 'a, RHS, MT, C>( - rhs: RHS, + mut rhs: RHS, prev: &[F], fut: &mut [F], time: &mut Float, @@ -163,7 +163,7 @@ pub fn integrate_multigrid<'a, BTableau, F: 'a, RHS, MT, C>( + std::ops::DerefMut> + Send + Sync, - RHS: Fn(&mut [F], &[F], Float, C, &mut MT), + RHS: FnMut(&mut [F], &[F], Float, C, &mut MT), BTableau: ButcherTableau, { for i in 0.. {