RaviartThomasElementFamily

Struct RaviartThomasElementFamily 

Source
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>

Source

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 89)
86fn test_rt_mass_matrix() {
87    let grid = regular_sphere(0);
88
89    let family = RaviartThomasElementFamily::<f64>::new(1, Continuity::Standard);
90    let space = FunctionSpaceImpl::new(&grid, &family);
91
92    let mut mass_matrix = rlst_dynamic_array!(f64, [space.local_size(), space.local_size()]);
93
94    let element = &space.elements()[0];
95
96    let (p, w) = single_integral_quadrature(
97        QuadratureRule::XiaoGimbutas,
98        Domain::Triangle,
99        2 * element.lagrange_superdegree(),
100    )
101    .unwrap();
102    let npts = w.len();
103    let mut pts = rlst_dynamic_array!(f64, [2, npts]);
104    for i in 0..w.len() {
105        for j in 0..2 {
106            *pts.get_mut([j, i]).unwrap() = p[3 * i + j];
107        }
108    }
109    let wts = w.iter().map(|i| *i / 2.0).collect::<Vec<_>>();
110
111    let mut table = DynArray::<f64, 4>::from_shape(element.tabulate_array_shape(0, npts));
112    element.tabulate(&pts, 0, &mut table);
113    let mut pushed_table = rlst_dynamic_array!(
114        f64,
115        [table.shape()[0], table.shape()[1], table.shape()[2], 3]
116    );
117
118    let gmap = grid.geometry_map(ReferenceCellType::Triangle, 1, &pts);
119    let mut jacobians = rlst_dynamic_array!(f64, [grid.geometry_dim(), grid.topology_dim(), npts]);
120    let mut jinv = rlst_dynamic_array!(f64, [grid.topology_dim(), grid.geometry_dim(), npts]);
121    let mut jdets = vec![0.0; npts];
122
123    for cell in grid.entity_iter(ReferenceCellType::Triangle) {
124        let dofs = space
125            .entity_closure_dofs(ReferenceCellType::Triangle, cell.local_index())
126            .unwrap();
127        gmap.jacobians_inverses_dets(cell.local_index(), &mut jacobians, &mut jinv, &mut jdets);
128        element.push_forward(&table, 0, &jacobians, &jdets, &jinv, &mut pushed_table);
129
130        for (test_i, test_dof) in dofs.iter().enumerate() {
131            for (trial_i, trial_dof) in dofs.iter().enumerate() {
132                *mass_matrix.get_mut([*test_dof, *trial_dof]).unwrap() += wts
133                    .iter()
134                    .enumerate()
135                    .map(|(i, w)| {
136                        jdets[i]
137                            * *w
138                            * (0..3)
139                                .map(|j| {
140                                    *pushed_table.get([0, i, test_i, j]).unwrap()
141                                        * *pushed_table.get([0, i, trial_i, j]).unwrap()
142                                })
143                                .sum::<f64>()
144                    })
145                    .sum::<f64>();
146            }
147        }
148    }
149
150    // Compare matrix entries to FEniCS
151    for i in 0..12 {
152        assert_relative_eq!(mass_matrix[[i, i]], 0.4811252243246884, epsilon = 1e-10);
153    }
154    for i in 0..12 {
155        for j in 0..12 {
156            if i != j && mass_matrix[[i, j]].abs() > 0.001 {
157                assert_relative_eq!(
158                    mass_matrix[[i, j]].abs(),
159                    0.0481125224324689,
160                    epsilon = 1e-10
161                );
162            }
163        }
164    }
165}

Trait Implementations§

Source§

impl<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar> ElementFamily for RaviartThomasElementFamily<T, TGeo>

Source§

type T = T

The scalar type
Source§

type CellType = ReferenceCellType

Cell type
Source§

type FiniteElement = CiarletElement<T, ContravariantPiolaMap, TGeo>

The finite element type
Source§

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>
where T: Unpin, TGeo: Unpin,

§

impl<T, TGeo> UnwindSafe for RaviartThomasElementFamily<T, TGeo>
where T: UnwindSafe, TGeo: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

§

type Err = NoError

The error type produced by a failed conversion.
§

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 Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, Dst> ConvAsUtil<Dst> for T

§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
§

impl<T> ConvUtil for T

§

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,

Approximate the subject to a given type with a specific scheme.
§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<Src> TryFrom<Src> for Src

§

type Err = NoError

The error type produced by a failed conversion.
§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<Src> ValueFrom<Src> for Src

§

type Err = NoError

The error type produced by a failed conversion.
§

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 Src
where Dst: ValueFrom<Src>,

§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.
§

impl<T, U> Imply<T> for U