use ndelement::types::ReferenceCellType;
use ndgrid::grid::local_grid::SingleElementGridBuilder;
use ndgrid::traits::{Builder, Entity, Geometry, Grid, Point, Topology};
fn main() {
let mut b = SingleElementGridBuilder::<f64>::new(3, (ReferenceCellType::Quadrilateral, 1));
b.add_point(0, &[0.0, 0.0, 0.0]);
b.add_point(1, &[1.0, 0.0, 0.0]);
b.add_point(2, &[2.0, 0.0, 0.2]);
b.add_point(3, &[0.0, 1.0, 0.0]);
b.add_point(4, &[1.0, 1.0, -0.2]);
b.add_point(5, &[2.0, 1.0, 0.0]);
b.add_cell(0, &[0, 1, 3, 4]);
b.add_cell(1, &[1, 2, 4, 5]);
let grid = b.create_grid();
let mut coords = vec![0.0; grid.geometry_dim()];
for point in grid.entity_iter(ReferenceCellType::Point) {
point.geometry().points().collect::<Vec<_>>()[0].coords(coords.as_mut_slice());
println!("point {}: {:#?}", point.local_index(), coords);
}
for cell in grid.entity_iter(ReferenceCellType::Quadrilateral) {
println!(
"cell {}: {:?} ",
cell.local_index(),
cell.topology()
.sub_entity_iter(ReferenceCellType::Point)
.collect::<Vec<_>>()
);
}
}