change macro to inlined func

This commit is contained in:
Magnus Ulimoen
2020-04-12 17:42:18 +02:00
parent 59c8509a98
commit a9e4a7e0cc
5 changed files with 89 additions and 72 deletions

View File

@@ -1,13 +1,10 @@
use super::SbpOperator;
use crate::diff_op_1d;
use crate::Float;
use ndarray::{s, ArrayView1, ArrayViewMut1};
use ndarray::{ArrayView1, ArrayViewMut1};
#[derive(Debug)]
pub struct SBP4 {}
diff_op_1d!(diff_1d, SBP4::BLOCK, SBP4::DIAG);
impl SBP4 {
#[rustfmt::skip]
const HBLOCK: &'static [Float] = &[
@@ -28,7 +25,13 @@ impl SBP4 {
impl SbpOperator for SBP4 {
fn diff1d(prev: ArrayView1<Float>, fut: ArrayViewMut1<Float>) {
diff_1d(prev, fut)
super::diff_op_1d(
ndarray::arr2(Self::BLOCK).view(),
ndarray::arr1(Self::DIAG).view(),
false,
prev,
fut,
)
}
fn h() -> &'static [Float] {

View File

@@ -1,13 +1,10 @@
use super::SbpOperator;
use crate::diff_op_1d;
use crate::Float;
use ndarray::{s, ArrayView1, ArrayViewMut1};
use ndarray::{ArrayView1, ArrayViewMut1};
#[derive(Debug)]
pub struct SBP8 {}
diff_op_1d!(diff_1d, SBP8::BLOCK, SBP8::DIAG);
impl SBP8 {
#[rustfmt::skip]
const HBLOCK: &'static [Float] = &[
@@ -32,7 +29,13 @@ impl SBP8 {
impl SbpOperator for SBP8 {
fn diff1d(prev: ArrayView1<Float>, fut: ArrayViewMut1<Float>) {
diff_1d(prev, fut)
super::diff_op_1d(
ndarray::arr2(Self::BLOCK).view(),
ndarray::arr1(Self::DIAG).view(),
false,
prev,
fut,
)
}
fn h() -> &'static [Float] {

View File

@@ -1,7 +1,6 @@
use super::{SbpOperator, UpwindOperator};
use crate::diff_op_1d;
use crate::Float;
use ndarray::{s, ArrayView1, ArrayView2, ArrayViewMut1, ArrayViewMut2, Axis};
use ndarray::{ArrayView1, ArrayView2, ArrayViewMut1, ArrayViewMut2, Axis};
#[derive(Debug)]
pub struct Upwind4 {}
@@ -12,9 +11,6 @@ type SimdT = packed_simd::f32x8;
#[cfg(not(feature = "f32"))]
type SimdT = packed_simd::f64x8;
diff_op_1d!(diff_1d, Upwind4::BLOCK, Upwind4::DIAG);
diff_op_1d!(diss_1d, Upwind4::DISS_BLOCK, Upwind4::DISS_DIAG, true);
macro_rules! diff_simd_row_7_47 {
($name: ident, $BLOCK: expr, $DIAG: expr, $symmetric: expr) => {
#[inline(never)]
@@ -281,7 +277,13 @@ impl Upwind4 {
impl SbpOperator for Upwind4 {
fn diff1d(prev: ArrayView1<Float>, fut: ArrayViewMut1<Float>) {
diff_1d(prev, fut)
super::diff_op_1d(
ndarray::arr2(Self::BLOCK).view(),
ndarray::arr1(Self::DIAG).view(),
false,
prev,
fut,
)
}
fn diffxi(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
@@ -399,7 +401,13 @@ fn upwind4_test() {
impl UpwindOperator for Upwind4 {
fn diss1d(prev: ArrayView1<Float>, fut: ArrayViewMut1<Float>) {
diss_1d(prev, fut)
super::diff_op_1d(
ndarray::arr2(Self::DISS_BLOCK).view(),
ndarray::arr1(Self::DISS_DIAG).view(),
true,
prev,
fut,
)
}
fn dissxi(prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());

View File

@@ -1,14 +1,10 @@
use super::{SbpOperator, UpwindOperator};
use crate::diff_op_1d;
use crate::Float;
use ndarray::{s, ArrayView1, ArrayViewMut1};
use ndarray::{ArrayView1, ArrayViewMut1};
#[derive(Debug)]
pub struct Upwind9 {}
diff_op_1d!(diff_1d, Upwind9::BLOCK, Upwind9::DIAG);
diff_op_1d!(diss_1d, Upwind9::DISS_BLOCK, Upwind9::DISS_DIAG, true);
impl Upwind9 {
#[rustfmt::skip]
const HBLOCK: &'static [Float] = &[
@@ -50,7 +46,13 @@ impl Upwind9 {
impl SbpOperator for Upwind9 {
fn diff1d(prev: ArrayView1<Float>, fut: ArrayViewMut1<Float>) {
diff_1d(prev, fut)
super::diff_op_1d(
ndarray::arr2(Self::BLOCK).view(),
ndarray::arr1(Self::DIAG).view(),
false,
prev,
fut,
)
}
fn h() -> &'static [Float] {
@@ -60,7 +62,13 @@ impl SbpOperator for Upwind9 {
impl UpwindOperator for Upwind9 {
fn diss1d(prev: ArrayView1<Float>, fut: ArrayViewMut1<Float>) {
diss_1d(prev, fut)
super::diff_op_1d(
ndarray::arr2(Self::DISS_BLOCK).view(),
ndarray::arr1(Self::DISS_DIAG).view(),
true,
prev,
fut,
)
}
}