Skip to content

Commit

Permalink
Update rlst version (#4)
Browse files Browse the repository at this point in the history
* bump rlst version

* rlst updates

* fmt
  • Loading branch information
mscroggs authored Jul 15, 2024
1 parent 41b6520 commit 6b3d683
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ libc = "0.2"
log = "0.4"
rayon = "1.9"
rand = "0.8.5"
rlst = "0.1.0"
rlst = "0.2.0"
thiserror="1.*"

[dev-dependencies]
Expand Down
13 changes: 5 additions & 8 deletions src/ciarlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::reference_cell;
use crate::traits::FiniteElement;
use crate::types::{Continuity, MapType, ReferenceCellType};
use rlst::{
dense::array::views::ArrayViewMut, rlst_dynamic_array2, rlst_dynamic_array3, Array, BaseArray,
MatrixInverse, RandomAccessByRef, RandomAccessMut, RlstScalar, Shape, VectorContainer,
rlst_dynamic_array2, rlst_dynamic_array3, Array, BaseArray, MatrixInverse, RandomAccessByRef,
RandomAccessMut, RlstScalar, Shape, VectorContainer,
};

pub mod lagrange;
Expand All @@ -32,7 +32,7 @@ fn compute_derivative_count(nderivs: usize, cell_type: ReferenceCellType) -> usi
}

/// A Ciarlet element
pub struct CiarletElement<T: RlstScalar> {
pub struct CiarletElement<T: RlstScalar + MatrixInverse> {
cell_type: ReferenceCellType,
degree: usize,
embedded_superdegree: usize,
Expand All @@ -47,10 +47,7 @@ pub struct CiarletElement<T: RlstScalar> {
interpolation_weights: EntityWeights<T>,
}

impl<T: RlstScalar> CiarletElement<T>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
impl<T: RlstScalar + MatrixInverse> CiarletElement<T> {
/// Create a Ciarlet element
#[allow(clippy::too_many_arguments)]
pub fn create(
Expand Down Expand Up @@ -246,7 +243,7 @@ where
&self.interpolation_weights
}
}
impl<T: RlstScalar> FiniteElement for CiarletElement<T> {
impl<T: RlstScalar + MatrixInverse> FiniteElement for CiarletElement<T> {
type CellType = ReferenceCellType;
type MapType = MapType;
type T = T;
Expand Down
27 changes: 6 additions & 21 deletions src/ciarlet/lagrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@ use crate::polynomials::polynomial_count;
use crate::reference_cell;
use crate::traits::ElementFamily;
use crate::types::{Continuity, MapType, ReferenceCellType};
use rlst::{
dense::array::views::ArrayViewMut, rlst_dynamic_array2, rlst_dynamic_array3, Array, BaseArray,
MatrixInverse, RandomAccessMut, RlstScalar, VectorContainer,
};
use rlst::{rlst_dynamic_array2, rlst_dynamic_array3, MatrixInverse, RandomAccessMut, RlstScalar};
use std::marker::PhantomData;

/// Create a Lagrange element
pub fn create<T: RlstScalar>(
pub fn create<T: RlstScalar + MatrixInverse>(
cell_type: ReferenceCellType,
degree: usize,
continuity: Continuity,
) -> CiarletElement<T>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
) -> CiarletElement<T> {
let dim = polynomial_count(cell_type, degree);
let tdim = reference_cell::dim(cell_type);
let mut wcoeffs = rlst_dynamic_array3!(T, [dim, 1, dim]);
Expand Down Expand Up @@ -178,19 +172,13 @@ where
}

/// Lagrange element family
pub struct LagrangeElementFamily<T: RlstScalar>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
pub struct LagrangeElementFamily<T: RlstScalar + MatrixInverse> {
degree: usize,
continuity: Continuity,
_t: PhantomData<T>,
}

impl<T: RlstScalar> LagrangeElementFamily<T>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
impl<T: RlstScalar + MatrixInverse> LagrangeElementFamily<T> {
/// Create new family
pub fn new(degree: usize, continuity: Continuity) -> Self {
Self {
Expand All @@ -201,10 +189,7 @@ where
}
}

impl<T: RlstScalar> ElementFamily for LagrangeElementFamily<T>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
impl<T: RlstScalar + MatrixInverse> ElementFamily for LagrangeElementFamily<T> {
type T = T;
type FiniteElement = CiarletElement<T>;
type CellType = ReferenceCellType;
Expand Down
27 changes: 6 additions & 21 deletions src/ciarlet/raviart_thomas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ use crate::traits::ElementFamily;
use crate::types::{Continuity, MapType, ReferenceCellType};
use rlst::MatrixInverse;
use rlst::RlstScalar;
use rlst::{
dense::array::views::ArrayViewMut, rlst_dynamic_array2, rlst_dynamic_array3, Array, BaseArray,
RandomAccessMut, VectorContainer,
};
use rlst::{rlst_dynamic_array2, rlst_dynamic_array3, RandomAccessMut};
use std::marker::PhantomData;

/// Create a Raviart-Thomas element
pub fn create<T: RlstScalar>(
pub fn create<T: RlstScalar + MatrixInverse>(
cell_type: ReferenceCellType,
degree: usize,
continuity: Continuity,
) -> CiarletElement<T>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
) -> CiarletElement<T> {
if cell_type != ReferenceCellType::Triangle && cell_type != ReferenceCellType::Quadrilateral {
panic!("Unsupported cell type");
}
Expand Down Expand Up @@ -99,19 +93,13 @@ where
}

/// Raviart-Thomas element family
pub struct RaviartThomasElementFamily<T: RlstScalar>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
pub struct RaviartThomasElementFamily<T: RlstScalar + MatrixInverse> {
degree: usize,
continuity: Continuity,
_t: PhantomData<T>,
}

impl<T: RlstScalar> RaviartThomasElementFamily<T>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
impl<T: RlstScalar + MatrixInverse> RaviartThomasElementFamily<T> {
/// Create new family
pub fn new(degree: usize, continuity: Continuity) -> Self {
Self {
Expand All @@ -122,10 +110,7 @@ where
}
}

impl<T: RlstScalar> ElementFamily for RaviartThomasElementFamily<T>
where
for<'a> Array<T, ArrayViewMut<'a, T, BaseArray<T, VectorContainer<T>, 2>, 2>, 2>: MatrixInverse,
{
impl<T: RlstScalar + MatrixInverse> ElementFamily for RaviartThomasElementFamily<T> {
type T = T;
type CellType = ReferenceCellType;
type FiniteElement = CiarletElement<T>;
Expand Down

0 comments on commit 6b3d683

Please sign in to comment.