From 9394d5b5441ec33dcba3cb9dd88b4df23ae85a16 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 9 Dec 2024 16:31:45 +0000 Subject: [PATCH] construct higher degree elements in example run, not test (#68) * construct higher degree elements in example run, not test * update version numbers --- Cargo.toml | 2 +- README.md | 2 +- RELEASE.md | 14 ++++----- examples/test_high_degree.rs | 56 ++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- python/ndelement/ciarlet.py | 32 --------------------- src/ciarlet.rs | 1 - 7 files changed, 65 insertions(+), 44 deletions(-) create mode 100644 examples/test_high_degree.rs diff --git a/Cargo.toml b/Cargo.toml index a2b30ac..658379a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ default = ["sleef"] [package] name = "ndelement" -version = "0.2.0-dev" +version = "0.2.1" edition = "2021" authors = ["Matthew Scroggs "] description = "n-dimensional finite element definition library." diff --git a/README.md b/README.md index 636230e..e6f85b8 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ndelement is an open-source library written in Rust that can be used to create n You can use the latest release of ndelement by adding the following to `[dependencies]` section of your Cargo.toml file: ```toml -ndelement = "0.2.0" +ndelement = "0.2.1" ``` ### Python diff --git a/RELEASE.md b/RELEASE.md index 6304c05..dfc5f29 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -19,22 +19,20 @@ To make a new release of ndelement, follow the following steps: If you are releasing a minor version, you should increment `[y]` and set `[z]` to zero. If you are releasing a bugfix, you should increment `[z]`. -3) Update the version number in the "Using ndelement" section of README.md. +3) Run `cargo publish --dry-run` and fix any errors. -4) Run `cargo publish --dry-run` and fix any errors. - -5) Commit your changes and push to GitHub, open a pull request to merge changes back into main, and merge the +4) Commit your changes and push to GitHub, open a pull request to merge changes back into main, and merge the pull request. -6) [Create a release on GitHub](https://github.com/bempp/ndelement/releases/new) from the `main` branch. +5) [Create a release on GitHub](https://github.com/bempp/ndelement/releases/new) from the `main` branch. The release tag and title should be `v[x].[y].[z]` (where `[x]`, `[y]` and `[z]` are as in step 2). In the "Describe this release" box, you should bullet point the main changes since the last release. -7) Run `cargo publish`. This will push the new version to crates.io. +6) Run `cargo publish`. This will push the new version to crates.io. Note: this cannot be undone, but you can use `cargo yank` to mark a version as unsuitable for use. -8) Open a pull request to `main` to update the version numbers in `Cargo.toml` and `pyproject.toml` +7) Open a pull request to `main` to update the version numbers in `Cargo.toml` and `pyproject.toml` to `[x].[y].[z]-dev` -9) Add the release to the next issue of [Scientific Computing in Rust Monthly](https://github.com/rust-scicomp/scientific-computing-in-rust-monthly) +8) Add the release to the next issue of [Scientific Computing in Rust Monthly](https://github.com/rust-scicomp/scientific-computing-in-rust-monthly) diff --git a/examples/test_high_degree.rs b/examples/test_high_degree.rs new file mode 100644 index 0000000..776a4bf --- /dev/null +++ b/examples/test_high_degree.rs @@ -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::(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::(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::(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); +} diff --git a/pyproject.toml b/pyproject.toml index 8ffcca4..c512c80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "ndelement" -version = "0.2.0-dev" +version = "0.2.1" description = "n-dimensional finite element definition library." readme = "README.md" requires-python = ">=3.8" diff --git a/python/ndelement/ciarlet.py b/python/ndelement/ciarlet.py index b942b2d..ecf8e43 100644 --- a/python/ndelement/ciarlet.py +++ b/python/ndelement/ciarlet.py @@ -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)) diff --git a/src/ciarlet.rs b/src/ciarlet.rs index e317d8e..5fe82a2 100644 --- a/src/ciarlet.rs +++ b/src/ciarlet.rs @@ -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); }