Skip to content

Commit

Permalink
construct higher degree elements in example run, not test
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Dec 9, 2024
1 parent 38a7d0c commit df9c545
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 33 deletions.
56 changes: 56 additions & 0 deletions examples/test_high_degree.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//! Finite element definitions
use ndelement::ciarlet::{lagrange, nedelec, raviart_thomas};
use ndelement::types::{Continuity, ReferenceCellType};
use paste::paste;

fn main() {
macro_rules! construct_lagrange {
($cell:ident, $max_degree:expr) => {
paste! {
for d in 1..[<$max_degree>] {
println!("Constructing Lagrange(degree={d}, cell={:?})", ReferenceCellType::[<$cell>]);
let _e = lagrange::create::<f64>(ReferenceCellType::[<$cell>], d, Continuity::Standard);
}
}
};
}

macro_rules! construct_raviart_thomas {
($cell:ident, $max_degree:expr) => {
paste! {
for d in 1..[<$max_degree>] {
println!("Constructing RaviartThomas(degree={d}, cell={:?})", ReferenceCellType::[<$cell>]);
let _e = raviart_thomas::create::<f64>(ReferenceCellType::[<$cell>], d, Continuity::Standard);
}
}
};
}

macro_rules! construct_nedelec {
($cell:ident, $max_degree:expr) => {
paste! {
for d in 1..[<$max_degree>] {
println!("Constructing Nedelec(degree={d}, cell={:?})", ReferenceCellType::[<$cell>]);
let _e = nedelec::create::<f64>(ReferenceCellType::[<$cell>], d, Continuity::Standard);
}
}
};
}

construct_lagrange!(Interval, 14);
construct_lagrange!(Triangle, 8);
construct_lagrange!(Quadrilateral, 8);
construct_lagrange!(Tetrahedron, 6);
construct_lagrange!(Hexahedron, 6);

construct_raviart_thomas!(Triangle, 8);
construct_raviart_thomas!(Quadrilateral, 8);
construct_raviart_thomas!(Tetrahedron, 6);
construct_raviart_thomas!(Hexahedron, 6);

construct_nedelec!(Triangle, 8);
construct_nedelec!(Quadrilateral, 8);
construct_nedelec!(Tetrahedron, 6);
construct_nedelec!(Hexahedron, 6);
}
32 changes: 0 additions & 32 deletions python/ndelement/ciarlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,38 +228,6 @@ def continuity(self) -> Continuity:

def element(self, cell: ReferenceCellType) -> CiarletElement:
"""Create an element."""
# TODO: remove these error once https://github.com/linalg-rs/rlst/issues/98 is fixed
msg = "Cannot create element due to bug in RLST"
if self.family == Family.Lagrange:
if cell == ReferenceCellType.Interval and self.degree >= 99:
raise RuntimeError(msg)
if cell == ReferenceCellType.Triangle and self.degree >= 13:
raise RuntimeError(msg)
if cell == ReferenceCellType.Quadrilateral and self.degree >= 10:
raise RuntimeError(msg)
if cell == ReferenceCellType.Tetrahedron and self.degree >= 7:
raise RuntimeError(msg)
if cell == ReferenceCellType.Hexahedron and self.degree >= 5:
raise RuntimeError(msg)
if self.family == Family.RaviartThomas:
if cell == ReferenceCellType.Triangle and self.degree >= 10:
raise RuntimeError(msg)
if cell == ReferenceCellType.Quadrilateral and self.degree >= 7:
raise RuntimeError(msg)
if cell == ReferenceCellType.Tetrahedron and self.degree >= 5:
raise RuntimeError(msg)
if cell == ReferenceCellType.Hexahedron and self.degree >= 3:
raise RuntimeError(msg)
if self.family == Family.NedelecFirstKind:
if cell == ReferenceCellType.Triangle and self.degree >= 10:
raise RuntimeError(msg)
if cell == ReferenceCellType.Quadrilateral and self.degree >= 7:
raise RuntimeError(msg)
if cell == ReferenceCellType.Tetrahedron and self.degree >= 5:
raise RuntimeError(msg)
if cell == ReferenceCellType.Hexahedron and self.degree >= 3:
raise RuntimeError(msg)

return CiarletElement(_lib.element_family_create_element(self._rs_family, cell.value))


Expand Down
1 change: 0 additions & 1 deletion src/ciarlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,5 +1275,4 @@ mod test {
test_entity_closure_dofs_lagrange!(Tetrahedron, 5);
test_entity_closure_dofs_lagrange!(Hexahedron, 2);
test_entity_closure_dofs_lagrange!(Hexahedron, 3);
test_entity_closure_dofs_lagrange!(Hexahedron, 4);
}

0 comments on commit df9c545

Please sign in to comment.