-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//! n-dimensional grid | ||
#![cfg_attr(feature = "strict", deny(warnings))] | ||
#![warn(missing_docs)] | ||
|
||
pub mod traits; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//! Traits | ||
mod element; | ||
|
||
pub use element::{ElementFamily, FiniteElement}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! Finite element trait | ||
use rlst::{RandomAccessByRef, RandomAccessMut, RlstScalar, Shape}; | ||
use std::fmt::Debug; | ||
use std::hash::Hash; | ||
|
||
pub trait FiniteElement { | ||
//! A finite element defined on a reference cell | ||
/// The scalar type | ||
type T: RlstScalar; | ||
/// Cell type | ||
type CellType: Debug + PartialEq + Eq + Clone + Copy + Hash; | ||
/// Map type | ||
type MapType: Debug + PartialEq + Eq + Clone + Copy + Hash; | ||
|
||
/// The reference cell type | ||
fn cell_type(&self) -> Self::CellType; | ||
|
||
/// The highest degree polynomial in the element's polynomial set | ||
fn embedded_superdegree(&self) -> usize; | ||
|
||
/// The number of basis functions | ||
fn dim(&self) -> usize; | ||
|
||
/// The value shape | ||
fn value_shape(&self) -> &[usize]; | ||
|
||
/// The value size | ||
fn value_size(&self) -> usize; | ||
|
||
/// Tabulate the values of the basis functions and their derivatives at a set of points | ||
fn tabulate<Array2: RandomAccessByRef<2, Item = <Self::T as RlstScalar>::Real> + Shape<2>>( | ||
&self, | ||
points: &Array2, | ||
nderivs: usize, | ||
data: &mut impl RandomAccessMut<4, Item = Self::T>, | ||
); | ||
|
||
/// The DOFs that are associated with a subentity of the reference cell | ||
fn entity_dofs(&self, entity_dim: usize, entity_number: usize) -> Option<&[usize]>; | ||
|
||
/// The push forward / pull back map to use for this element | ||
fn map_type(&self) -> Self::MapType; | ||
|
||
/// Get the required shape for a tabulation array | ||
fn tabulate_array_shape(&self, nderivs: usize, npoints: usize) -> [usize; 4]; | ||
} | ||
|
||
pub trait ElementFamily { | ||
//! A family of finite elements | ||
/// The scalar type | ||
type T: RlstScalar; | ||
/// Cell type | ||
type CellType: Debug + PartialEq + Eq + Clone + Copy + Hash; | ||
/// The finite element type | ||
type FiniteElement: FiniteElement<T = Self::T, CellType = Self::CellType>; | ||
|
||
/// Get an elenent for a cell type | ||
fn element(&self, cell_type: Self::CellType) -> Self::FiniteElement; | ||
} |