From dfce3d3eb692c9af41ea19a76f58abb45a129423 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 19 Aug 2024 08:40:32 +0100 Subject: [PATCH] Add test of entity_closure_dofs (#18) * add test of entity_closure_dofs * fmt --- src/ciarlet.rs | 44 +++++++++++++++++++++++++++++++++++++++++++ src/reference_cell.rs | 23 ++++++++-------------- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/ciarlet.rs b/src/ciarlet.rs index 4f5cbc0..83c1d7b 100644 --- a/src/ciarlet.rs +++ b/src/ciarlet.rs @@ -349,6 +349,7 @@ impl FiniteElement for CiarletElement { mod test { use super::*; use approx::*; + use paste::paste; use rlst::rlst_dynamic_array4; fn check_dofs(e: impl FiniteElement) { @@ -735,4 +736,47 @@ mod test { } check_dofs(e); } + + macro_rules! test_entity_closure_dofs { + ($cell:ident, $degree:expr) => { + paste! { + #[test] + fn []() { + let e = lagrange::create::(ReferenceCellType::[<$cell>], [<$degree>], Continuity::Standard); + let c = reference_cell::connectivity(ReferenceCellType::[<$cell>]); + println!("{c:?}"); + + for (dim, entities) in c.iter().enumerate() { + for (n, entity) in entities.iter().enumerate() { + let ecd = e.entity_closure_dofs(dim, n).unwrap(); + let mut len = 0; + for (sub_dim, sub_entities) in entity.iter().take(dim + 1).enumerate() { + for sub_entity in sub_entities { + let dofs = e.entity_dofs(sub_dim, *sub_entity).unwrap(); + len += dofs.len(); + for dof in dofs { + assert!(ecd.contains(dof)); + } + } + } + assert_eq!(ecd.len(), len); + } + } + } + } + }; + } + + test_entity_closure_dofs!(Interval, 2); + test_entity_closure_dofs!(Interval, 3); + test_entity_closure_dofs!(Interval, 4); + test_entity_closure_dofs!(Interval, 5); + test_entity_closure_dofs!(Triangle, 2); + test_entity_closure_dofs!(Triangle, 3); + test_entity_closure_dofs!(Triangle, 4); + test_entity_closure_dofs!(Triangle, 5); + test_entity_closure_dofs!(Quadrilateral, 2); + test_entity_closure_dofs!(Quadrilateral, 3); + test_entity_closure_dofs!(Quadrilateral, 4); + test_entity_closure_dofs!(Quadrilateral, 5); } diff --git a/src/reference_cell.rs b/src/reference_cell.rs index c88be9c..331c3ba 100644 --- a/src/reference_cell.rs +++ b/src/reference_cell.rs @@ -442,10 +442,7 @@ mod test { use paste::paste; macro_rules! test_cell { - - ($($cell:ident),+) => { - - $( + ($cell:ident) => { paste! { #[test] @@ -504,19 +501,15 @@ mod test { } } } - } - )* }; } - test_cell!( - Interval, - Triangle, - Quadrilateral, - Tetrahedron, - Hexahedron, - Prism, - Pyramid - ); + test_cell!(Interval); + test_cell!(Triangle); + test_cell!(Quadrilateral); + test_cell!(Tetrahedron); + test_cell!(Hexahedron); + test_cell!(Prism); + test_cell!(Pyramid); }