add blockend SBP8

This commit is contained in:
Magnus Ulimoen 2021-01-29 08:51:26 +01:00
parent a7660281c8
commit f7c238f6a7
1 changed files with 26 additions and 1 deletions

View File

@ -40,6 +40,17 @@ 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], [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], [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],
]); ]);
#[rustfmt::skip]
const BLOCKEND_MATRIX: Matrix<Float, 8, 12> = Matrix::new([
[0.0035384016230155199, -0.037742950645498902, 0.19815049088886899, -0.79260196355547696, -0.0, 0.75166824372712304, -0.11941174319355199, 0.012224423573111201, -0.035091936128702303, 0.0142810403117803, 0.010833666120933699, -0.0058476727216045096],
[-0.0, 0.0038681313433548601, -0.041260067662451799, 0.21661535522787201, -0.821713248844682, -0.0, 0.75587358166357999, -0.046018121340651898, -0.076822925360096897, -0.050113507756358401, 0.087129564256063705, -0.027558761526617698],
[-0.0, -0.0, 0.0027934857464329702, -0.029797181295285, 0.094272792663829805, -0.54587651996612696, -0.0, 0.205756876210586, 0.39561116774840099, 0.020799982439143602, -0.22287532317150199, 0.079314719624520302],
[-0.0, -0.0, -0.0, 0.0086536439119011006, -0.029896495621603899, 0.102950081118829, -0.63739245543855805, -0.0, 0.54336288636530095, 0.085109057027750595, -0.090998664615454999, 0.01821194725190089],
[-0.0, -0.0, -0.0, -0.0, 0.019698131073842998, 0.039447042394264102, -0.28128521251909999, -0.124714160903055, -0.0, 0.055770702144577897, 0.41917213003600801, -0.128088632226564],
[-0.0, -0.0, -0.0, -0.0, -0.055988255885229599, 0.179720579323281, -0.10329058280084499, -0.13643348652854601, -0.389516189693211, -0.0, 0.54432974445498405, -0.038821808870425301],
[-0.0, -0.0, -0.0, -0.0, -0.0071669648308011497, -0.052726783847581303, 0.18675940343293501, 0.024615176293723499, -0.49400862680798402, -0.091851192507295606, -0.0, 0.43437898826698501],
[-0.0, -0.0, -0.0, -0.0, 0.020015058331576099, 0.086285816263333495, -0.34386522738887298, -0.0254881486107905, 0.78102816812674902, 0.033893192260150001, -2.2474124634140402, 1.6955436044319001],
]);
} }
impl SbpOperator1d for SBP8 { impl SbpOperator1d for SBP8 {
@ -75,8 +86,10 @@ impl SbpOperator1d for SBP8 {
} }
fn diff_op_row_local(prev: ndarray::ArrayView2<Float>, mut fut: ndarray::ArrayViewMut2<Float>) { fn diff_op_row_local(prev: ndarray::ArrayView2<Float>, mut fut: ndarray::ArrayViewMut2<Float>) {
/*
let mut flipmatrix = SBP8::BLOCK_MATRIX; let mut flipmatrix = SBP8::BLOCK_MATRIX;
flipmatrix *= &-1.0; flipmatrix *= &-1.0;
*/
for (p, mut f) in prev for (p, mut f) in prev
.axis_iter(ndarray::Axis(0)) .axis_iter(ndarray::Axis(0))
@ -84,7 +97,8 @@ fn diff_op_row_local(prev: ndarray::ArrayView2<Float>, mut fut: ndarray::ArrayVi
{ {
super::diff_op_1d_slice_matrix( super::diff_op_1d_slice_matrix(
&SBP8::BLOCK_MATRIX, &SBP8::BLOCK_MATRIX,
&flipmatrix, &SBP8::BLOCKEND_MATRIX,
//&flipmatrix,
&SBP8::DIAG_MATRIX, &SBP8::DIAG_MATRIX,
super::OperatorType::Normal, super::OperatorType::Normal,
p.as_slice().unwrap(), p.as_slice().unwrap(),
@ -189,3 +203,14 @@ fn test_trad8() {
1e-4, 1e-4,
); );
} }
#[test]
fn block_equality() {
let mut flipped_inverted = SBP8::BLOCK_MATRIX.flip();
flipped_inverted *= &-1.0;
assert!(flipped_inverted
.iter()
.zip(SBP8::BLOCKEND_MATRIX.iter())
.all(|(x, y)| (x - y).abs() < 1e-12))
}