1use itertools::izip;
2use ndelement::{ciarlet::CiarletElement, map::IdentityMap, types::ReferenceCellType};
3use ndgrid::traits::{
4 Builder, Entity, GmshExport, GmshImport, Grid, RONExport, RONImport, Topology,
5};
6use ndgrid::{SingleElementGrid, SingleElementGridBuilder, shapes};
7
8fn main() {
14 let g = shapes::unit_cube_boundary::<f64>(4, 5, 4, ReferenceCellType::Triangle);
16
17 g.export_as_ron("_unit_cube_boundary.ron");
19
20 let g2 = SingleElementGrid::<f64, CiarletElement<f64, IdentityMap>>::import_from_ron(
22 "_unit_cube_boundary.ron",
23 );
24
25 println!("The first 5 cells of the grids");
27 for (cell, cell2) in izip!(
28 g.entity_iter(ReferenceCellType::Triangle),
29 g2.entity_iter(ReferenceCellType::Triangle)
30 )
31 .take(5)
32 {
33 println!(
34 "{:?} {:?}",
35 cell.topology()
36 .sub_entity_iter(ReferenceCellType::Point)
37 .collect::<Vec<_>>(),
38 cell2
39 .topology()
40 .sub_entity_iter(ReferenceCellType::Point)
41 .collect::<Vec<_>>(),
42 );
43 }
44
45 println!();
46
47 g.export_as_gmsh("_unit_cube_boundary.msh");
51
52 let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Triangle, 1));
54 b.import_from_gmsh("_unit_cube_boundary.msh");
55 let g3 = b.create_grid();
56
57 println!("The first 5 cells of the grids");
59 for (cell, cell3) in izip!(
60 g.entity_iter(ReferenceCellType::Triangle),
61 g3.entity_iter(ReferenceCellType::Triangle)
62 )
63 .take(5)
64 {
65 println!(
66 "{:?} {:?}",
67 cell.topology()
68 .sub_entity_iter(ReferenceCellType::Point)
69 .collect::<Vec<_>>(),
70 cell3
71 .topology()
72 .sub_entity_iter(ReferenceCellType::Point)
73 .collect::<Vec<_>>(),
74 );
75 }
76}