pub struct RaviartThomasElementFamily<T: RlstScalar + Getrf + Getri = f64, TGeo: RlstScalar = f64> { /* private fields */ }Expand description
Raviart-Thomas element family
A family of Raviart-Thomas elements on multiple cell types with appropriate continuity across different cell types.
Implementations§
Source§impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> RaviartThomasElementFamily<T, TGeo>
impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> RaviartThomasElementFamily<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_mass_matrix.rs (line 90)
87fn test_rt_mass_matrix() {
88 let mesh = regular_sphere(0, ReferenceCellType::Triangle);
89
90 let family = RaviartThomasElementFamily::<f64>::new(1, Continuity::Standard);
91 let space = FunctionSpaceImpl::new(&mesh, &family);
92
93 let mut mass_matrix = rlst_dynamic_array!(f64, [space.local_size(), space.local_size()]);
94
95 let element = &space.elements()[0];
96
97 let (p, w) = single_integral_quadrature(
98 QuadratureRule::XiaoGimbutas,
99 Domain::Triangle,
100 2 * element.lagrange_superdegree(),
101 )
102 .unwrap();
103 let npts = w.len();
104 let mut pts = rlst_dynamic_array!(f64, [2, npts]);
105 for i in 0..w.len() {
106 for j in 0..2 {
107 *pts.get_mut([j, i]).unwrap() = p[3 * i + j];
108 }
109 }
110 let wts = w.iter().map(|i| *i / 2.0).collect::<Vec<_>>();
111
112 let mut table = DynArray::<f64, 4>::from_shape(element.tabulate_array_shape(0, npts));
113 element.tabulate(&pts, 0, &mut table);
114 let mut pushed_table = rlst_dynamic_array!(
115 f64,
116 [table.shape()[0], table.shape()[1], table.shape()[2], 3]
117 );
118
119 let gmap = mesh.geometry_map(ReferenceCellType::Triangle, 1, &pts);
120 let mut jacobians = rlst_dynamic_array!(f64, [mesh.geometry_dim(), mesh.topology_dim(), npts]);
121 let mut jinv = rlst_dynamic_array!(f64, [mesh.topology_dim(), mesh.geometry_dim(), npts]);
122 let mut jdets = vec![0.0; npts];
123
124 for cell in mesh.entity_iter(ReferenceCellType::Triangle) {
125 let dofs = space
126 .entity_closure_dofs(ReferenceCellType::Triangle, cell.local_index())
127 .unwrap();
128 gmap.jacobians_inverses_dets(cell.local_index(), &mut jacobians, &mut jinv, &mut jdets);
129 element.push_forward(&table, 0, &jacobians, &jdets, &jinv, &mut pushed_table);
130
131 for (test_i, test_dof) in dofs.iter().enumerate() {
132 for (trial_i, trial_dof) in dofs.iter().enumerate() {
133 *mass_matrix.get_mut([*test_dof, *trial_dof]).unwrap() += wts
134 .iter()
135 .enumerate()
136 .map(|(i, w)| {
137 jdets[i]
138 * *w
139 * (0..3)
140 .map(|j| {
141 *pushed_table.get([0, i, test_i, j]).unwrap()
142 * *pushed_table.get([0, i, trial_i, j]).unwrap()
143 })
144 .sum::<f64>()
145 })
146 .sum::<f64>();
147 }
148 }
149 }
150
151 // Compare matrix entries to FEniCS
152 for i in 0..12 {
153 assert_relative_eq!(mass_matrix[[i, i]], 0.4811252243246884, epsilon = 1e-10);
154 }
155 for i in 0..12 {
156 for j in 0..12 {
157 if i != j && mass_matrix[[i, j]].abs() > 0.001 {
158 assert_relative_eq!(
159 mass_matrix[[i, j]].abs(),
160 0.0481125224324689,
161 epsilon = 1e-10
162 );
163 }
164 }
165 }
166}Trait Implementations§
Source§impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> ElementFamily for RaviartThomasElementFamily<T, TGeo>
impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> ElementFamily for RaviartThomasElementFamily<T, TGeo>
Source§type CellType = ReferenceCellType
type CellType = ReferenceCellType
Cell type
Source§type FiniteElement = CiarletElement<T, ContravariantPiolaMap, TGeo>
type FiniteElement = CiarletElement<T, ContravariantPiolaMap, TGeo>
The finite element type
Source§fn element(
&self,
cell_type: ReferenceCellType,
) -> CiarletElement<T, ContravariantPiolaMap, TGeo>
fn element( &self, cell_type: ReferenceCellType, ) -> CiarletElement<T, ContravariantPiolaMap, TGeo>
Create an element for the given cell type.
Auto Trait Implementations§
impl<T, TGeo> Freeze for RaviartThomasElementFamily<T, TGeo>
impl<T, TGeo> RefUnwindSafe for RaviartThomasElementFamily<T, TGeo>where
T: RefUnwindSafe,
TGeo: RefUnwindSafe,
impl<T, TGeo> Send for RaviartThomasElementFamily<T, TGeo>
impl<T, TGeo> Sync for RaviartThomasElementFamily<T, TGeo>
impl<T, TGeo> Unpin for RaviartThomasElementFamily<T, TGeo>
impl<T, TGeo> UnsafeUnpin for RaviartThomasElementFamily<T, TGeo>
impl<T, TGeo> UnwindSafe for RaviartThomasElementFamily<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.