Skip to content

Commit

Permalink
construct higher degree elements in example run, not test (#68)
Browse files Browse the repository at this point in the history
* construct higher degree elements in example run, not test

* update version numbers
  • Loading branch information
mscroggs authored Dec 9, 2024
1 parent 38a7d0c commit 9394d5b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default = ["sleef"]

[package]
name = "ndelement"
version = "0.2.0-dev"
version = "0.2.1"
edition = "2021"
authors = ["Matthew Scroggs <[email protected]>"]
description = "n-dimensional finite element definition library."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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);
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
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 9394d5b

Please sign in to comment.