pub struct LagrangeElementFamily<T: RlstScalar + Getrf + Getri = f64, TGeo: RlstScalar = f64> { /* private fields */ }Expand description
Lagrange element family.
A family of Lagrange elements on multiple cell types with appropriate continuity across different cell types.
Implementations§
Source§impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> LagrangeElementFamily<T, TGeo>
impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> LagrangeElementFamily<T, TGeo>
Sourcepub fn new(degree: usize, continuity: Continuity) -> Self
pub fn new(degree: usize, continuity: Continuity) -> Self
Create new family with given degree and continuity.
Examples found in repository?
ndfunctionspace/examples/test_parallel_space.rs (line 26)
16fn test_parallel_function_space<C: Communicator>(comm: &C) {
17 let grid = unit_cube_distributed::<f64, _>(
18 comm,
19 GraphPartitioner::None,
20 4,
21 4,
22 4,
23 ReferenceCellType::Tetrahedron,
24 );
25
26 let family = LagrangeElementFamily::<f64>::new(2, Continuity::Standard);
27 let space = ParallelFunctionSpaceImpl::new(&grid, &family);
28 let serial_grid = unit_cube::<f64>(4, 4, 4, ReferenceCellType::Tetrahedron);
29 let serial_space = FunctionSpaceImpl::new(&serial_grid, &family);
30
31 assert_eq!(space.global_size(), serial_space.global_size());
32}More examples
ndelement/examples/element_family.rs (line 8)
5fn main() {
6 // Create the degree 2 Lagrange element family. A family is a set of finite elements with the
7 // same family type, degree, and continuity across a set of cells
8 let family = LagrangeElementFamily::<f64, f64>::new(2, Continuity::Standard);
9
10 // Get the element in the family on a triangle
11 let element = family.element(ReferenceCellType::Triangle);
12 println!("Cell: {:?}", element.cell_type());
13
14 // Get the element in the family on a quadrilateral
15 let element = family.element(ReferenceCellType::Quadrilateral);
16 println!("Cell: {:?}", element.cell_type());
17}ndfunctionspace/examples/test_mass_matrix.rs (line 21)
18fn test_lagrange_mass_matrix() {
19 let grid = regular_sphere(0);
20
21 let family = LagrangeElementFamily::<f64>::new(1, Continuity::Standard);
22 let space = FunctionSpaceImpl::new(&grid, &family);
23
24 let mut mass_matrix = rlst_dynamic_array!(f64, [space.local_size(), space.local_size()]);
25
26 let element = &space.elements()[0];
27
28 let (p, w) = single_integral_quadrature(
29 QuadratureRule::XiaoGimbutas,
30 Domain::Triangle,
31 2 * element.lagrange_superdegree(),
32 )
33 .unwrap();
34 let npts = w.len();
35 let mut pts = rlst_dynamic_array!(f64, [2, npts]);
36 for i in 0..w.len() {
37 for j in 0..2 {
38 *pts.get_mut([j, i]).unwrap() = p[3 * i + j];
39 }
40 }
41 let wts = w.iter().map(|i| *i / 2.0).collect::<Vec<_>>();
42
43 let mut table = DynArray::<f64, 4>::from_shape(element.tabulate_array_shape(0, npts));
44 element.tabulate(&pts, 0, &mut table);
45
46 let gmap = grid.geometry_map(ReferenceCellType::Triangle, 1, &pts);
47 let mut jacobians = rlst_dynamic_array!(f64, [grid.geometry_dim(), grid.topology_dim(), npts]);
48 let mut jinv = rlst_dynamic_array!(f64, [grid.topology_dim(), grid.geometry_dim(), npts]);
49 let mut jdets = vec![0.0; npts];
50
51 for cell in grid.entity_iter(ReferenceCellType::Triangle) {
52 let dofs = space
53 .entity_closure_dofs(ReferenceCellType::Triangle, cell.local_index())
54 .unwrap();
55 gmap.jacobians_inverses_dets(cell.local_index(), &mut jacobians, &mut jinv, &mut jdets);
56 for (test_i, test_dof) in dofs.iter().enumerate() {
57 for (trial_i, trial_dof) in dofs.iter().enumerate() {
58 *mass_matrix.get_mut([*test_dof, *trial_dof]).unwrap() += wts
59 .iter()
60 .enumerate()
61 .map(|(i, w)| {
62 jdets[i]
63 * *w
64 * *table.get([0, i, test_i, 0]).unwrap()
65 * *table.get([0, i, trial_i, 0]).unwrap()
66 })
67 .sum::<f64>();
68 }
69 }
70 }
71
72 // Compare matrix entries to values from Bempp
73 for i in 0..6 {
74 assert_relative_eq!(mass_matrix[[i, i]], 0.5773502691896255, epsilon = 1e-10);
75 }
76 for i in 0..6 {
77 for j in 0..6 {
78 if i != j && mass_matrix[[i, j]].abs() > 0.001 {
79 assert_relative_eq!(mass_matrix[[i, j]], 0.1443375672974061, epsilon = 1e-10);
80 }
81 }
82 }
83}Trait Implementations§
Source§impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> ElementFamily for LagrangeElementFamily<T, TGeo>
impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> ElementFamily for LagrangeElementFamily<T, TGeo>
Source§type FiniteElement = CiarletElement<T, IdentityMap, TGeo>
type FiniteElement = CiarletElement<T, IdentityMap, TGeo>
The finite element type
Source§type CellType = ReferenceCellType
type CellType = ReferenceCellType
Cell type
Source§fn element(
&self,
cell_type: ReferenceCellType,
) -> CiarletElement<T, IdentityMap, TGeo>
fn element( &self, cell_type: ReferenceCellType, ) -> CiarletElement<T, IdentityMap, TGeo>
Create an element for the given cell type.
Auto Trait Implementations§
impl<T, TGeo> Freeze for LagrangeElementFamily<T, TGeo>
impl<T, TGeo> RefUnwindSafe for LagrangeElementFamily<T, TGeo>where
T: RefUnwindSafe,
TGeo: RefUnwindSafe,
impl<T, TGeo> Send for LagrangeElementFamily<T, TGeo>
impl<T, TGeo> Sync for LagrangeElementFamily<T, TGeo>
impl<T, TGeo> Unpin for LagrangeElementFamily<T, TGeo>
impl<T, TGeo> UnwindSafe for LagrangeElementFamily<T, TGeo>where
T: UnwindSafe,
TGeo: UnwindSafe,
Blanket Implementations§
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<Src> TryFrom<Src> for Src
impl<Src> TryFrom<Src> for Src
§impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
§impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
§fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.
§impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
§fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
Convert the subject into an exactly equivalent representation.