create

Function create 

Source
pub fn create<T: RlstScalar + Getrf + Getri, TGeo: RlstScalar>(
    cell_type: ReferenceCellType,
    degree: usize,
    continuity: Continuity,
) -> CiarletElement<T, ContravariantPiolaMap, TGeo>
Expand description

Create a Raviart-Thomas element

Examples found in repository?
ndgrid/examples/test_push_forward.rs (line 84)
73fn test_rt_push_forward() {
74    let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Triangle, 1));
75    b.add_point(0, &[0.0, 0.0, 0.0]);
76    b.add_point(1, &[1.0, 0.0, 0.0]);
77    b.add_point(2, &[2.0, 0.0, 1.0]);
78    b.add_point(3, &[0.0, 1.0, 0.0]);
79    b.add_cell(0, &[0, 1, 3]);
80    b.add_cell(1, &[1, 2, 3]);
81    let grid = b.create_grid();
82
83    let e =
84        raviart_thomas::create::<f64, f64>(ReferenceCellType::Triangle, 4, Continuity::Standard);
85
86    let npts = 5;
87
88    let mut cell0_points = rlst_dynamic_array!(f64, [2, npts]);
89    for i in 0..npts {
90        cell0_points[[1, i]] = i as f64 / (npts - 1) as f64;
91        cell0_points[[0, i]] = 1.0 - cell0_points[[1, i]];
92    }
93    let mut cell0_table = DynArray::<f64, 4>::from_shape(e.tabulate_array_shape(0, npts));
94    e.tabulate(&cell0_points, 0, &mut cell0_table);
95
96    let mut points = rlst_dynamic_array!(f64, [2, npts]);
97    for i in 0..npts {
98        points[[0, i]] = 0.0;
99        points[[1, i]] = i as f64 / (npts - 1) as f64;
100    }
101
102    let mut table = DynArray::<f64, 4>::from_shape(e.tabulate_array_shape(0, npts));
103    e.tabulate(&points, 0, &mut table);
104
105    let gmap = grid.geometry_map(ReferenceCellType::Triangle, 1, &points);
106
107    let mut jacobians = rlst_dynamic_array!(f64, [grid.geometry_dim(), grid.topology_dim(), npts]);
108    let mut jinv = rlst_dynamic_array!(f64, [grid.topology_dim(), grid.geometry_dim(), npts]);
109    let mut jdets = vec![0.0; npts];
110
111    gmap.jacobians_inverses_dets(1, &mut jacobians, &mut jinv, &mut jdets);
112
113    let mut cell1_table =
114        DynArray::<f64, 4>::from_shape([table.shape()[0], table.shape()[1], table.shape()[2], 3]);
115    e.push_forward(&table, 0, &jacobians, &jdets, &jinv, &mut cell1_table);
116
117    // Check that basis functions dotted with normal to edge are continuous between cells
118    for (cell0_dof, cell1_dof) in izip!(
119        e.entity_closure_dofs(1, 0).unwrap(),
120        e.entity_closure_dofs(1, 1).unwrap()
121    ) {
122        for i in 0..npts {
123            assert_relative_eq!(
124                (cell0_table[[0, i, *cell0_dof, 0]] + cell0_table[[0, i, *cell0_dof, 1]])
125                    / f64::sqrt(2.0),
126                (cell1_table[[0, i, *cell1_dof, 0]]
127                    + cell1_table[[0, i, *cell1_dof, 1]]
128                    + 2.0 * cell1_table[[0, i, *cell1_dof, 2]])
129                    / f64::sqrt(6.0),
130                epsilon = 1e-10
131            );
132        }
133    }
134}