diff --git a/sbp/src/operators/algos.rs b/sbp/src/operators/algos.rs index 5a608a6..d66e74c 100644 --- a/sbp/src/operators/algos.rs +++ b/sbp/src/operators/algos.rs @@ -31,18 +31,14 @@ impl DiagonalMatrix { } #[derive(Clone, Debug, PartialEq)] -pub(crate) struct BlockMatrix { - pub start: Matrix, - pub diag: RowVector, - pub end: Matrix, +pub(crate) struct BlockMatrix { + pub start: Matrix, + pub diag: RowVector, + pub end: Matrix, } -impl BlockMatrix { - pub const fn new( - start: Matrix, - diag: RowVector, - end: Matrix, - ) -> Self { +impl BlockMatrix { + pub const fn new(start: Matrix, diag: RowVector, end: Matrix) -> Self { Self { start, diag, end } } } @@ -57,7 +53,7 @@ pub(crate) enum OperatorType { #[inline(always)] /// Works on all 1d vectors pub(crate) fn diff_op_1d_fallback( - matrix: &BlockMatrix, + matrix: &BlockMatrix, optype: OperatorType, prev: ArrayView1, mut fut: ArrayViewMut1, @@ -106,7 +102,7 @@ pub(crate) fn diff_op_1d_fallback( - matrix: &BlockMatrix, + matrix: &BlockMatrix, optype: OperatorType, prev: &[Float], fut: &mut [Float], @@ -181,7 +177,7 @@ pub(crate) fn diff_op_1d_slice( #[inline(always)] /// Will always work on 1d, delegated based on slicedness pub(crate) fn diff_op_1d( - matrix: &BlockMatrix, + matrix: &BlockMatrix, optype: OperatorType, prev: ArrayView1, mut fut: ArrayViewMut1, @@ -201,7 +197,7 @@ pub(crate) fn diff_op_1d( #[allow(unused)] /// 2D diff fallback for when matrices are not slicable pub(crate) fn diff_op_2d_fallback( - matrix: &BlockMatrix, + matrix: &BlockMatrix, optype: OperatorType, prev: ArrayView2, mut fut: ArrayViewMut2, @@ -275,7 +271,7 @@ pub(crate) fn diff_op_2d_fallback( - matrix: &BlockMatrix, + matrix: &BlockMatrix, optype: OperatorType, prev: ArrayView2, mut fut: ArrayViewMut2, @@ -292,7 +288,7 @@ pub(crate) fn diff_op_2d_sliceable( - matrix: &BlockMatrix, + matrix: &BlockMatrix, optype: OperatorType, prev: ArrayView2, fut: ArrayViewMut2, @@ -494,7 +490,7 @@ fn dotproduct<'a>( #[cfg(feature = "sparse")] pub(crate) fn sparse_from_block( - matrix: &BlockMatrix, + matrix: &BlockMatrix, optype: OperatorType, n: usize, ) -> sprs::CsMat { diff --git a/sbp/src/operators/traditional4.rs b/sbp/src/operators/traditional4.rs index 167d36b..e2b59df 100644 --- a/sbp/src/operators/traditional4.rs +++ b/sbp/src/operators/traditional4.rs @@ -27,7 +27,7 @@ impl SBP4 { const DIFF_BLOCKEND: super::Matrix = super::flip_sign(super::flip_ud(super::flip_lr(Self::DIFF_BLOCK))); - const DIFF: BlockMatrix<4, 6, 5> = + const DIFF: BlockMatrix = BlockMatrix::new(Self::DIFF_BLOCK, Self::DIFF_DIAG, Self::DIFF_BLOCKEND); #[rustfmt::skip] @@ -41,7 +41,7 @@ impl SBP4 { [-4.0/43.0, 59.0/43.0, -110.0/43.0, 59.0/43.0, -4.0/43.0, 0.0], [-1.0/49.0, 0.0, 59.0/49.0, -118.0/49.0, 64.0/49.0, -4.0/49.0] ]); - const D2: BlockMatrix<4, 6, 5> = BlockMatrix::new( + const D2: BlockMatrix = BlockMatrix::new( Self::D2BLOCK, Self::D2DIAG, super::flip_ud(super::flip_lr(Self::D2BLOCK)), diff --git a/sbp/src/operators/traditional8.rs b/sbp/src/operators/traditional8.rs index cfd7b8b..d1dcf4c 100644 --- a/sbp/src/operators/traditional8.rs +++ b/sbp/src/operators/traditional8.rs @@ -27,7 +27,7 @@ impl SBP8 { [2.75587615266177e-02, -8.71295642560637e-02, 5.01135077563584e-02, 7.68229253600969e-02, 4.60181213406519e-02, -7.55873581663580e-01, 0.00000000000000e+00, 8.21713248844682e-01, -2.16615355227872e-01, 4.12600676624518e-02, -3.86813134335486e-03, 0.0], [5.84767272160451e-03, -1.08336661209337e-02, -1.42810403117803e-02, 3.50919361287023e-02, -1.22244235731112e-02, 1.19411743193552e-01, -7.51668243727123e-01, 0.00000000000000e+00, 7.92601963555477e-01, -1.98150490888869e-01, 3.77429506454989e-02, -3.53840162301552e-03], ]); - const DIFF: BlockMatrix<8, 12, 9> = BlockMatrix::new( + const DIFF: BlockMatrix = BlockMatrix::new( Self::DIFF_BLOCK, Self::DIFF_DIAG, super::flip_sign(super::flip_ud(super::flip_lr(Self::DIFF_BLOCK))), diff --git a/sbp/src/operators/upwind4.rs b/sbp/src/operators/upwind4.rs index b9742bf..0126a9d 100644 --- a/sbp/src/operators/upwind4.rs +++ b/sbp/src/operators/upwind4.rs @@ -27,7 +27,7 @@ impl Upwind4 { const DIFF_BLOCKEND: Matrix = super::flip_sign(super::flip_ud(super::flip_lr(Self::DIFF_BLOCK))); - const DIFF: BlockMatrix<4, 7, 7> = + const DIFF: BlockMatrix = BlockMatrix::new(Self::DIFF_BLOCK, Self::DIFF_DIAG, Self::DIFF_BLOCKEND); #[rustfmt::skip] @@ -43,7 +43,7 @@ impl Upwind4 { ]]); const DISS_BLOCKEND: Matrix = super::flip_ud(super::flip_lr(Self::DISS_BLOCK)); - const DISS: BlockMatrix<4, 7, 7> = + const DISS: BlockMatrix = BlockMatrix::new(Self::DISS_BLOCK, Self::DISS_DIAG, Self::DISS_BLOCKEND); } diff --git a/sbp/src/operators/upwind4h2.rs b/sbp/src/operators/upwind4h2.rs index e1cbf60..2a270b3 100644 --- a/sbp/src/operators/upwind4h2.rs +++ b/sbp/src/operators/upwind4h2.rs @@ -24,7 +24,7 @@ impl Upwind4h2 { const DIFF_DIAG: RowVector = RowVector::new([[ -1.43229166666667e-02, 1.40625000000000e-01, -7.38281250000000e-01, 0.00000000000000e+00, 7.38281250000000e-01, -1.40625000000000e-01, 1.43229166666667e-02 ]]); - const DIFF: BlockMatrix<4, 7, 7> = BlockMatrix::new( + const DIFF: BlockMatrix = BlockMatrix::new( Self::DIFF_BLOCK, Self::DIFF_DIAG, super::flip_sign(super::flip_ud(super::flip_lr(Self::DIFF_BLOCK))), @@ -42,7 +42,7 @@ impl Upwind4h2 { const DISS_DIAG: RowVector = RowVector::new([[ 1.43229166666667e-02, -8.59375000000000e-02, 2.14843750000000e-01, -2.86458333333333e-01, 2.14843750000000e-01, -8.59375000000000e-02, 1.43229166666667e-02, ]]); - const DISS: BlockMatrix<4, 7, 7> = BlockMatrix::new( + const DISS: BlockMatrix = BlockMatrix::new( Self::DISS_BLOCK, Self::DISS_DIAG, super::flip_ud(super::flip_lr(Self::DISS_BLOCK)), diff --git a/sbp/src/operators/upwind9.rs b/sbp/src/operators/upwind9.rs index c6d374e..192b577 100644 --- a/sbp/src/operators/upwind9.rs +++ b/sbp/src/operators/upwind9.rs @@ -28,7 +28,7 @@ impl Upwind9 { [-6.19425252179959e-03, 3.69595678895333e-02, -7.01892820620398e-02, -3.35233082197107e-03, 2.69304373763091e-01, -8.89857974743355e-01, 0.00000000000000e+00, 8.66656645522330e-01, -2.57919763669076e-01, 6.44799409172690e-02, -1.07466568195448e-02, 8.59732545563586e-04, 0.0], [1.44853491014330e-02, -4.59275574977554e-02, 3.08833474560615e-02, 3.57240610228828e-02, -7.07760049349999e-02, 1.88587240076292e-01, -7.92626447113877e-01, 0.00000000000000e+00, 8.25608497215073e-01, -2.35888142061449e-01, 5.89720355153623e-02, -9.82867258589373e-03, 7.86293806871498e-04], ]); - const DIFF: BlockMatrix<8, 13, 11> = BlockMatrix::new( + const DIFF: BlockMatrix = BlockMatrix::new( Self::DIFF_BLOCK, Self::DIFF_DIAG, super::flip_sign(super::flip_ud(super::flip_lr(Self::DIFF_BLOCK))), @@ -50,7 +50,7 @@ impl Upwind9 { const DISS_DIAG: RowVector = RowVector::new([[ 1.0/1260.0, -1.0/126.0, 1.0/28.0, -2.0/21.0, 1.0/6.0, -1.0/5.0, 1.0/6.0, -2.0/21.0, 1.0/28.0, -1.0/126.0, 1.0/1260.0, ]]); - const DISS: BlockMatrix<8, 13, 11> = BlockMatrix::new( + const DISS: BlockMatrix = BlockMatrix::new( Self::DISS_BLOCK, Self::DISS_DIAG, super::flip_ud(super::flip_lr(Self::DISS_BLOCK)), diff --git a/sbp/src/operators/upwind9h2.rs b/sbp/src/operators/upwind9h2.rs index f099008..9eb6830 100644 --- a/sbp/src/operators/upwind9h2.rs +++ b/sbp/src/operators/upwind9h2.rs @@ -28,7 +28,7 @@ impl Upwind9h2 { [-1.35203347497451e-03, 5.77422023528126e-03, -1.06262408660325e-02, -2.37853245409338e-02, 2.05772021953463e-01, -8.20033622612654e-01, 0.00000000000000e+00, 8.31345778788959e-01, -2.37329555369694e-01, 5.93323888424235e-02, -9.88873147373725e-03, 7.91098517898980e-04, 0.0], [-1.85246767034256e-03, 2.89905176240824e-03, 6.61951741227212e-04, 2.52792141498726e-03, -5.27086038822990e-02, 2.36934258275492e-01, -8.34333946306806e-01, 0.00000000000000e+00, 8.33639122800983e-01, -2.38182606514566e-01, 5.95456516286416e-02, -9.92427527144027e-03, 7.93942021715222e-04] ]); - const DIFF: BlockMatrix<8, 13, 11> = BlockMatrix::new( + const DIFF: BlockMatrix = BlockMatrix::new( Self::DIFF_BLOCK, Self::DIFF_DIAG, super::flip_sign(super::flip_ud(super::flip_lr(Self::DIFF_BLOCK))), @@ -50,7 +50,7 @@ impl Upwind9h2 { const DISS_DIAG: RowVector = RowVector::new([[ 7.93650793650794e-04, -7.93650793650794e-03, 3.57142857142857e-02, -9.52380952380952e-02, 1.66666666666667e-01, -2.00000000000000e-01, 1.66666666666667e-01, -9.52380952380952e-02, 3.57142857142857e-02, -7.93650793650794e-03, 7.93650793650794e-04 ]]); - const DISS: BlockMatrix<8, 13, 11> = BlockMatrix::new( + const DISS: BlockMatrix = BlockMatrix::new( Self::DISS_BLOCK, Self::DISS_DIAG, super::flip_ud(super::flip_lr(Self::DISS_BLOCK)),