add sparse matrix creating to all diff ops

This commit is contained in:
Magnus Ulimoen
2020-06-14 21:52:25 +02:00
parent 4f772b8dc5
commit e2a3bed1ff
10 changed files with 432 additions and 7 deletions

View File

@@ -38,6 +38,21 @@ impl SbpOperator1d for SBP4 {
fn h(&self) -> &'static [Float] {
Self::HBLOCK
}
#[cfg(feature = "sparse")]
fn diff_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::sparse_from_block(
Self::BLOCK,
Self::DIAG,
super::Symmetry::AntiSymmetric,
super::OperatorType::Normal,
n,
)
}
#[cfg(feature = "sparse")]
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::DIAG, n, self.is_h2())
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP4) {

View File

@@ -42,6 +42,21 @@ impl SbpOperator1d for SBP8 {
fn h(&self) -> &'static [Float] {
Self::HBLOCK
}
#[cfg(feature = "sparse")]
fn diff_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::sparse_from_block(
Self::BLOCK,
Self::DIAG,
super::Symmetry::AntiSymmetric,
super::OperatorType::Normal,
n,
)
}
#[cfg(feature = "sparse")]
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::DIAG, n, self.is_h2())
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &SBP8) {

View File

@@ -56,6 +56,21 @@ impl SbpOperator1d for Upwind4h2 {
fn is_h2(&self) -> bool {
true
}
#[cfg(feature = "sparse")]
fn diff_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::sparse_from_block(
Self::BLOCK,
Self::DIAG,
super::Symmetry::AntiSymmetric,
super::OperatorType::H2,
n,
)
}
#[cfg(feature = "sparse")]
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::DIAG, n, self.is_h2())
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind4h2) {

View File

@@ -61,6 +61,21 @@ impl SbpOperator1d for Upwind9 {
fn h(&self) -> &'static [Float] {
Self::HBLOCK
}
#[cfg(feature = "sparse")]
fn diff_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::sparse_from_block(
Self::BLOCK,
Self::DIAG,
super::Symmetry::AntiSymmetric,
super::OperatorType::Normal,
n,
)
}
#[cfg(feature = "sparse")]
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::DIAG, n, self.is_h2())
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9) {

View File

@@ -64,6 +64,21 @@ impl SbpOperator1d for Upwind9h2 {
fn is_h2(&self) -> bool {
true
}
#[cfg(feature = "sparse")]
fn diff_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::sparse_from_block(
Self::BLOCK,
Self::DIAG,
super::Symmetry::AntiSymmetric,
super::OperatorType::H2,
n,
)
}
#[cfg(feature = "sparse")]
fn h_matrix(&self, n: usize) -> sprs::CsMat<Float> {
super::h_matrix(Self::DIAG, n, self.is_h2())
}
}
impl<SBP: SbpOperator1d> SbpOperator2d for (&SBP, &Upwind9h2) {