Skip to content

Commit

Permalink
Implement arbitrary degree Lagrange elements (#116)
Browse files Browse the repository at this point in the history
* Fix #111

* rlst

* clippy

* rename CiarletElement -> OldCiarletElement

* OldCiarletElement

* start implementing arbitrary degree elements

* implement tabulte with Legendre basis

* Eq, cargo fmt

* working on arbitrary degree elements

* Fix arbitrary degree Lagrange elements

* remove printing code

* clippy

* replace bool with Continuity

* clippy

* update create_element

* working on RT element

* finish Raviart Thomas degree 1 element

* delete OldCiarletElement

* clippy

* clippy

* clippy

* Tidying

* comment out unused fields (to be uncommented when implementing interpolation)
  • Loading branch information
mscroggs authored Sep 5, 2023
1 parent 83ccc73 commit 245bc79
Show file tree
Hide file tree
Showing 17 changed files with 744 additions and 505 deletions.
6 changes: 3 additions & 3 deletions bem/examples/assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bempp_tools::arrays::Array2D;
use bempp_traits::bem::DofMap;
use bempp_traits::bem::FunctionSpace;
use bempp_traits::cell::ReferenceCellType;
use bempp_traits::element::ElementFamily;
use bempp_traits::element::{Continuity, ElementFamily};
use num::complex::Complex;

fn main() {
Expand All @@ -17,13 +17,13 @@ fn main() {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let element1 = create_element(
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
1,
true,
Continuity::Discontinuous,
);

let space0 = SerialFunctionSpace::new(&grid, &element0);
Expand Down
10 changes: 5 additions & 5 deletions bem/src/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ mod test {
use bempp_traits::arrays::Array2DAccess;
use bempp_traits::bem::DofMap;
use bempp_traits::cell::ReferenceCellType;
use bempp_traits::element::ElementFamily;
use bempp_traits::element::{Continuity, ElementFamily};
use num::complex::Complex;

#[test]
Expand All @@ -135,13 +135,13 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let element1 = create_element(
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
1,
false,
Continuity::Continuous,
);
let space0 = SerialFunctionSpace::new(&grid, &element0);
let space1 = SerialFunctionSpace::new(&grid, &element1);
Expand Down Expand Up @@ -186,13 +186,13 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let element1 = create_element(
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
1,
false,
Continuity::Continuous,
);
let space0 = SerialFunctionSpace::new(&grid, &element0);
let space1 = SerialFunctionSpace::new(&grid, &element1);
Expand Down
26 changes: 13 additions & 13 deletions bem/src/assembly/dense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ mod test {
use bempp_element::element::create_element;
use bempp_grid::shapes::regular_sphere;
use bempp_traits::cell::ReferenceCellType;
use bempp_traits::element::ElementFamily;
use bempp_traits::element::{Continuity, ElementFamily};
use num::complex::Complex;

#[test]
Expand All @@ -509,7 +509,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -623,7 +623,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -737,7 +737,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -851,7 +851,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand All @@ -874,7 +874,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
1,
false,
Continuity::Continuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -936,7 +936,7 @@ mod test {
],
];

let perm = vec![0, 5, 2, 4, 3, 1];
let perm = [0, 5, 2, 4, 3, 1];

for (i, pi) in perm.iter().enumerate() {
for (j, pj) in perm.iter().enumerate() {
Expand All @@ -956,7 +956,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -1069,7 +1069,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -1183,7 +1183,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -1298,7 +1298,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -1413,7 +1413,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
1,
false,
Continuity::Continuous,
);
let space = SerialFunctionSpace::new(&grid, &element);

Expand Down Expand Up @@ -1475,7 +1475,7 @@ mod test {
],
];

let perm = vec![0, 5, 2, 4, 3, 1];
let perm = [0, 5, 2, 4, 3, 1];

for (i, pi) in perm.iter().enumerate() {
for (j, pj) in perm.iter().enumerate() {
Expand Down
8 changes: 4 additions & 4 deletions bem/src/dofmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mod test {
use bempp_element::element::create_element;
use bempp_grid::shapes::regular_sphere;
use bempp_traits::cell::ReferenceCellType;
use bempp_traits::element::ElementFamily;
use bempp_traits::element::{Continuity, ElementFamily};

#[test]
fn test_dofmap_lagrange0() {
Expand All @@ -101,7 +101,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
0,
true,
Continuity::Discontinuous,
);
let dofmap = SerialDofMap::new(&grid, &element);
assert_eq!(dofmap.local_size(), dofmap.global_size());
Expand All @@ -118,7 +118,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
1,
false,
Continuity::Continuous,
);
let dofmap = SerialDofMap::new(&grid, &element);
assert_eq!(dofmap.local_size(), dofmap.global_size());
Expand All @@ -132,7 +132,7 @@ mod test {
ElementFamily::Lagrange,
ReferenceCellType::Triangle,
2,
false,
Continuity::Continuous,
);
let dofmap = SerialDofMap::new(&grid, &element);
assert_eq!(dofmap.local_size(), dofmap.global_size());
Expand Down
5 changes: 5 additions & 0 deletions element/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ bempp-quadrature = { path = "../quadrature" }
paste = "1.*"
libc = "0.2"
approx = "0.5"
rlst = { git = "https://github.com/linalg-rs/rlst.git" }
rlst-blis-src = { git = "https://github.com/linalg-rs/rlst.git" }
rlst-dense = { git = "https://github.com/linalg-rs/rlst.git" }
rlst-algorithms = { git = "https://github.com/linalg-rs/rlst.git" }

13 changes: 13 additions & 0 deletions element/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ pub mod cells_3d;
pub use bempp_traits::cell::{InvalidConnectivity, PhysicalCell, ReferenceCell, ReferenceCellType};
pub use cells_3d::*;

pub fn create_cell(cell_type: ReferenceCellType) -> Box<dyn ReferenceCell> {
match cell_type {
ReferenceCellType::Point => Box::new(Point {}),
ReferenceCellType::Interval => Box::new(Interval {}),
ReferenceCellType::Triangle => Box::new(Triangle {}),
ReferenceCellType::Quadrilateral => Box::new(Quadrilateral {}),
ReferenceCellType::Tetrahedron => Box::new(Tetrahedron {}),
ReferenceCellType::Hexahedron => Box::new(Hexahedron {}),
ReferenceCellType::Prism => Box::new(Prism {}),
ReferenceCellType::Pyramid => Box::new(Pyramid {}),
}
}

#[cfg(test)]
mod test {
use crate::cell::*;
Expand Down
Loading

0 comments on commit 245bc79

Please sign in to comment.