update sparse maxwell benches
This commit is contained in:
parent
939eae9af1
commit
3593ee2f52
|
@ -97,32 +97,41 @@ fn sparse_creation(c: &mut Criterion) {
|
|||
let w = 40;
|
||||
let h = 26;
|
||||
group.bench_function("create_rhs_trad4", |b| {
|
||||
let grid = sbp::grid::Grid::new_linspace(0.0..1.0, w, 0.0..1.0, h);
|
||||
b.iter(|| {
|
||||
let _matrix = maxwell::sparse::rhs_matrix(&SBP4, w, h);
|
||||
let _matrix = maxwell::sparse::rhs_matrix(&SBP4, &grid);
|
||||
})
|
||||
});
|
||||
group.bench_function("create_rhs_upwind4", |b| {
|
||||
let grid = sbp::grid::Grid::new_linspace(0.0..1.0, w, 0.0..1.0, h);
|
||||
b.iter(|| {
|
||||
let _matrix = maxwell::sparse::rhs_matrix(&sbp::operators::Upwind4, w, h);
|
||||
let _matrix = maxwell::sparse::rhs_matrix(&sbp::operators::Upwind4, &grid);
|
||||
})
|
||||
});
|
||||
group.bench_function("create_rhs_upwind9", |b| {
|
||||
let grid = sbp::grid::Grid::new_linspace(0.0..1.0, w, 0.0..1.0, h);
|
||||
b.iter(|| {
|
||||
let _matrix = maxwell::sparse::rhs_matrix(&sbp::operators::Upwind9, w, h);
|
||||
let _matrix = maxwell::sparse::rhs_matrix(&sbp::operators::Upwind9, &grid);
|
||||
})
|
||||
});
|
||||
|
||||
group.bench_function("create_rhs_upwind_upwind4", |b| {
|
||||
let grid = sbp::grid::Grid::new_linspace(0.0..1.0, w, 0.0..1.0, h);
|
||||
b.iter(|| {
|
||||
let _matrix =
|
||||
maxwell::sparse::rhs_matrix_with_upwind_dissipation(&sbp::operators::Upwind4, w, h);
|
||||
let _matrix = maxwell::sparse::rhs_matrix_with_upwind_dissipation(
|
||||
&sbp::operators::Upwind4,
|
||||
&grid,
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
group.bench_function("create_rhs_upwind_upwind9", |b| {
|
||||
let grid = sbp::grid::Grid::new_linspace(0.0..1.0, w, 0.0..1.0, h);
|
||||
b.iter(|| {
|
||||
let _matrix =
|
||||
maxwell::sparse::rhs_matrix_with_upwind_dissipation(&sbp::operators::Upwind9, w, h);
|
||||
let _matrix = maxwell::sparse::rhs_matrix_with_upwind_dissipation(
|
||||
&sbp::operators::Upwind9,
|
||||
&grid,
|
||||
);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -21,6 +21,18 @@ pub struct Metrics {
|
|||
}
|
||||
|
||||
impl Grid {
|
||||
pub fn new_linspace(
|
||||
x: std::ops::Range<Float>,
|
||||
nx: usize,
|
||||
y: std::ops::Range<Float>,
|
||||
ny: usize,
|
||||
) -> Self {
|
||||
let dx = (x.end - x.start) / (nx - 1) as Float;
|
||||
let dy = (y.end - y.start) / (ny - 1) as Float;
|
||||
let x = Array2::from_shape_fn((ny, nx), |(_j, i)| i as Float * dx + x.start);
|
||||
let y = Array2::from_shape_fn((ny, nx), |(j, _i)| j as Float * dy + y.start);
|
||||
Self { x, y }
|
||||
}
|
||||
pub fn new(x: Array2<Float>, y: Array2<Float>) -> Result<Self, ndarray::ShapeError> {
|
||||
assert_eq!(x.shape(), y.shape());
|
||||
|
||||
|
|
Loading…
Reference in New Issue