From 6f3a810cd3c3c50e1056e5d8aca21758ce3262bd Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Thu, 14 Jan 2021 22:53:36 +0100 Subject: [PATCH] add upwind/d2 to SbpOperators1d trait --- sbp/src/operators.rs | 7 +++++++ sbp/src/operators/traditional4.rs | 4 ++++ sbp/src/operators/upwind4.rs | 4 ++++ sbp/src/operators/upwind4h2.rs | 4 ++++ sbp/src/operators/upwind9.rs | 4 ++++ sbp/src/operators/upwind9h2.rs | 4 ++++ 6 files changed, 27 insertions(+) diff --git a/sbp/src/operators.rs b/sbp/src/operators.rs index 380ef25..41a8864 100644 --- a/sbp/src/operators.rs +++ b/sbp/src/operators.rs @@ -19,6 +19,13 @@ pub trait SbpOperator1d: Send + Sync { fn diff_matrix(&self, n: usize) -> sprs::CsMat; #[cfg(feature = "sparse")] fn h_matrix(&self, n: usize) -> sprs::CsMat; + + fn upwind(&self) -> Option<&dyn UpwindOperator1d> { + None + } + fn d2(&self) -> Option<&dyn SbpOperator1d2> { + None + } } pub trait SbpOperator1d2: SbpOperator1d { diff --git a/sbp/src/operators/traditional4.rs b/sbp/src/operators/traditional4.rs index 5ca4ed6..0d2af67 100644 --- a/sbp/src/operators/traditional4.rs +++ b/sbp/src/operators/traditional4.rs @@ -65,6 +65,10 @@ impl SbpOperator1d for SBP4 { fn h_matrix(&self, n: usize) -> sprs::CsMat { super::h_matrix(Self::HBLOCK, n, self.is_h2()) } + + fn d2(&self) -> Option<&dyn super::SbpOperator1d2> { + Some(&Self) + } } impl SbpOperator2d for (&SBP, &SBP4) { diff --git a/sbp/src/operators/upwind4.rs b/sbp/src/operators/upwind4.rs index f5c38d5..3f1aca9 100644 --- a/sbp/src/operators/upwind4.rs +++ b/sbp/src/operators/upwind4.rs @@ -223,6 +223,10 @@ impl SbpOperator1d for Upwind4 { fn h_matrix(&self, n: usize) -> sprs::CsMat { super::h_matrix(Self::HBLOCK, n, self.is_h2()) } + + fn upwind(&self) -> Option<&dyn UpwindOperator1d> { + Some(&Self) + } } impl SbpOperator2d for (&SBP, &Upwind4) { diff --git a/sbp/src/operators/upwind4h2.rs b/sbp/src/operators/upwind4h2.rs index 6346313..d1cdf75 100644 --- a/sbp/src/operators/upwind4h2.rs +++ b/sbp/src/operators/upwind4h2.rs @@ -71,6 +71,10 @@ impl SbpOperator1d for Upwind4h2 { fn h_matrix(&self, n: usize) -> sprs::CsMat { super::h_matrix(Self::HBLOCK, n, self.is_h2()) } + + fn upwind(&self) -> Option<&dyn UpwindOperator1d> { + Some(&Self) + } } impl SbpOperator2d for (&SBP, &Upwind4h2) { diff --git a/sbp/src/operators/upwind9.rs b/sbp/src/operators/upwind9.rs index e4e473a..1464b4a 100644 --- a/sbp/src/operators/upwind9.rs +++ b/sbp/src/operators/upwind9.rs @@ -76,6 +76,10 @@ impl SbpOperator1d for Upwind9 { fn h_matrix(&self, n: usize) -> sprs::CsMat { super::h_matrix(Self::HBLOCK, n, self.is_h2()) } + + fn upwind(&self) -> Option<&dyn UpwindOperator1d> { + Some(&Self) + } } impl SbpOperator2d for (&SBP, &Upwind9) { diff --git a/sbp/src/operators/upwind9h2.rs b/sbp/src/operators/upwind9h2.rs index 143af1f..957c549 100644 --- a/sbp/src/operators/upwind9h2.rs +++ b/sbp/src/operators/upwind9h2.rs @@ -79,6 +79,10 @@ impl SbpOperator1d for Upwind9h2 { fn h_matrix(&self, n: usize) -> sprs::CsMat { super::h_matrix(Self::HBLOCK, n, self.is_h2()) } + + fn upwind(&self) -> Option<&dyn UpwindOperator1d> { + Some(&Self) + } } impl SbpOperator2d for (&SBP, &Upwind9h2) {