add upwind/d2 to SbpOperators1d trait

This commit is contained in:
Magnus Ulimoen 2021-01-14 22:53:36 +01:00
parent 56bba27a4b
commit 6f3a810cd3
6 changed files with 27 additions and 0 deletions

View File

@ -19,6 +19,13 @@ pub trait SbpOperator1d: Send + Sync {
fn diff_matrix(&self, n: usize) -> sprs::CsMat<Float>;
#[cfg(feature = "sparse")]
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float>;
fn upwind(&self) -> Option<&dyn UpwindOperator1d> {
None
}
fn d2(&self) -> Option<&dyn SbpOperator1d2> {
None
}
}
pub trait SbpOperator1d2: SbpOperator1d {

View File

@ -65,6 +65,10 @@ impl SbpOperator1d for SBP4 {
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::HBLOCK, n, self.is_h2())
}
fn d2(&self) -> Option<&dyn super::SbpOperator1d2> {
Some(&Self)
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP4) {

View File

@ -223,6 +223,10 @@ impl SbpOperator1d for Upwind4 {
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::HBLOCK, n, self.is_h2())
}
fn upwind(&self) -> Option<&dyn UpwindOperator1d> {
Some(&Self)
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind4) {

View File

@ -71,6 +71,10 @@ impl SbpOperator1d for Upwind4h2 {
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::HBLOCK, n, self.is_h2())
}
fn upwind(&self) -> Option<&dyn UpwindOperator1d> {
Some(&Self)
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind4h2) {

View File

@ -76,6 +76,10 @@ impl SbpOperator1d for Upwind9 {
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::HBLOCK, n, self.is_h2())
}
fn upwind(&self) -> Option<&dyn UpwindOperator1d> {
Some(&Self)
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9) {

View File

@ -79,6 +79,10 @@ impl SbpOperator1d for Upwind9h2 {
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::HBLOCK, n, self.is_h2())
}
fn upwind(&self) -> Option<&dyn UpwindOperator1d> {
Some(&Self)
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9h2) {