Skip to content

Commit

Permalink
Add test of entity_closure_dofs (#18)
Browse files Browse the repository at this point in the history
* add test of entity_closure_dofs

* fmt
  • Loading branch information
mscroggs authored Aug 19, 2024
1 parent a5541c0 commit dfce3d3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 15 deletions.
44 changes: 44 additions & 0 deletions src/ciarlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ impl<T: RlstScalar + MatrixInverse> FiniteElement for CiarletElement<T> {
mod test {
use super::*;
use approx::*;
use paste::paste;
use rlst::rlst_dynamic_array4;

fn check_dofs(e: impl FiniteElement<CellType = ReferenceCellType>) {
Expand Down Expand Up @@ -735,4 +736,47 @@ mod test {
}
check_dofs(e);
}

macro_rules! test_entity_closure_dofs {
($cell:ident, $degree:expr) => {
paste! {
#[test]
fn [<test_entity_closure_dofs_ $cell:lower _ $degree>]() {
let e = lagrange::create::<f64>(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);
}
23 changes: 8 additions & 15 deletions src/reference_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,7 @@ mod test {
use paste::paste;

macro_rules! test_cell {

($($cell:ident),+) => {

$(
($cell:ident) => {
paste! {

#[test]
Expand Down Expand Up @@ -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);
}

0 comments on commit dfce3d3

Please sign in to comment.