Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test of entity_closure_dofs #18

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Loading