revisit SBP Traits

This commit is contained in:
2021-01-17 15:37:45 +01:00
parent 6f3a810cd3
commit 1f15bcc056
13 changed files with 229 additions and 219 deletions

View File

@@ -71,7 +71,7 @@ impl SbpOperator1d for SBP4 {
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP4) {
impl SbpOperator2d for SBP4 {
fn diffxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * SBP4::BLOCK.len());
@@ -95,6 +95,12 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP4) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn SbpOperator1d {
&Self
}
fn op_eta(&self) -> &dyn SbpOperator1d {
&Self
}
}
impl super::SbpOperator1d2 for SBP4 {

View File

@@ -59,7 +59,7 @@ impl SbpOperator1d for SBP8 {
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP8) {
impl SbpOperator2d for SBP8 {
fn diffxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * SBP8::BLOCK.len());
@@ -83,6 +83,12 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP8) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn SbpOperator1d {
&Self
}
fn op_eta(&self) -> &dyn SbpOperator1d {
&Self
}
}
#[test]

View File

@@ -229,7 +229,7 @@ impl SbpOperator1d for Upwind4 {
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind4) {
impl SbpOperator2d for Upwind4 {
fn diffxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Upwind4::BLOCK.len());
@@ -259,6 +259,15 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind4) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn SbpOperator1d {
&Self
}
fn op_eta(&self) -> &dyn SbpOperator1d {
&Self
}
fn upwind(&self) -> Option<Box<dyn UpwindOperator2d>> {
Some(Box::new(Self))
}
}
#[test]
@@ -377,7 +386,7 @@ impl UpwindOperator1d for Upwind4 {
}
}
impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind4) {
impl UpwindOperator2d for Upwind4 {
fn dissxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Upwind4::BLOCK.len());
@@ -407,6 +416,13 @@ impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind4) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn UpwindOperator1d {
&Self
}
fn op_eta(&self) -> &dyn UpwindOperator1d {
&Self
}
}
#[test]

View File

@@ -77,7 +77,7 @@ impl SbpOperator1d for Upwind4h2 {
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind4h2) {
impl SbpOperator2d for Upwind4h2 {
fn diffxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Upwind4h2::BLOCK.len());
@@ -101,9 +101,18 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind4h2) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn SbpOperator1d {
&Self
}
fn op_eta(&self) -> &dyn SbpOperator1d {
&Self
}
fn upwind(&self) -> Option<Box<dyn UpwindOperator2d>> {
Some(Box::new(Self))
}
}
impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind4h2) {
impl UpwindOperator2d for Upwind4h2 {
fn dissxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Upwind4h2::BLOCK.len());
@@ -137,6 +146,12 @@ impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind4h2) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn UpwindOperator1d {
&Self
}
fn op_eta(&self) -> &dyn UpwindOperator1d {
&Self
}
}
#[test]

View File

@@ -82,7 +82,7 @@ impl SbpOperator1d for Upwind9 {
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9) {
impl SbpOperator2d for Upwind9 {
fn diffxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Upwind9::BLOCK.len());
@@ -106,6 +106,15 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn SbpOperator1d {
&Self
}
fn op_eta(&self) -> &dyn SbpOperator1d {
&Self
}
fn upwind(&self) -> Option<Box<dyn UpwindOperator2d>> {
Some(Box::new(Self))
}
}
impl UpwindOperator1d for Upwind9 {
@@ -136,7 +145,7 @@ impl UpwindOperator1d for Upwind9 {
}
}
impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind9) {
impl UpwindOperator2d for Upwind9 {
fn dissxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Upwind9::BLOCK.len());
@@ -160,6 +169,12 @@ impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind9) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn UpwindOperator1d {
&Self
}
fn op_eta(&self) -> &dyn UpwindOperator1d {
&Self
}
}
#[test]

View File

@@ -85,7 +85,7 @@ impl SbpOperator1d for Upwind9h2 {
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9h2) {
impl SbpOperator2d for Upwind9h2 {
fn diffxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Upwind9h2::BLOCK.len());
@@ -109,6 +109,15 @@ impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9h2) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn SbpOperator1d {
&Self
}
fn op_eta(&self) -> &dyn SbpOperator1d {
&Self
}
fn upwind(&self) -> Option<Box<dyn UpwindOperator2d>> {
Some(Box::new(Self))
}
}
#[test]
@@ -163,7 +172,7 @@ impl UpwindOperator1d for Upwind9h2 {
}
}
impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind9h2) {
impl UpwindOperator2d for Upwind9h2 {
fn dissxi(&self, prev: ArrayView2<Float>, mut fut: ArrayViewMut2<Float>) {
assert_eq!(prev.shape(), fut.shape());
assert!(prev.shape()[1] >= 2 * Upwind9h2::BLOCK.len());
@@ -197,4 +206,10 @@ impl<UO: UpwindOperator1d> UpwindOperator2d for (&UO, &Upwind9h2) {
_ => unreachable!("Should only be two elements in the strides vectors"),
}
}
fn op_xi(&self) -> &dyn UpwindOperator1d {
&Self
}
fn op_eta(&self) -> &dyn UpwindOperator1d {
&Self
}
}