Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: delete the i-cell collection structures #251

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ honeycomb-render = { version = "0.6.0", path = "./honeycomb-render" }

# common
cfg-if = "1"
itertools = "0.13.0"
rayon = "1.10.0"
rustversion = "1.0.18"
thiserror = "2.0.3"
Expand Down
18 changes: 9 additions & 9 deletions benches/benches/core/cmap2/constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,32 @@ library_benchmark_group!(
#[bench::small(&mut get_map(16))]
#[bench::medium(&mut get_map(64))]
#[bench::large(&mut get_map(256))]
fn fetch_vertices(map: &mut CMap2<FloatType>) {
black_box(map.fetch_vertices());
fn iter_vertices(map: &mut CMap2<FloatType>) {
black_box(map.iter_vertices().collect::<Vec<_>>());
}

#[library_benchmark]
#[bench::small(&mut get_map(16))]
#[bench::medium(&mut get_map(64))]
#[bench::large(&mut get_map(256))]
fn fetch_edges(map: &mut CMap2<FloatType>) {
black_box(map.fetch_edges());
fn iter_edges(map: &mut CMap2<FloatType>) {
black_box(map.iter_edges().collect::<Vec<_>>());
}

#[library_benchmark]
#[bench::small(&mut get_map(16))]
#[bench::medium(&mut get_map(64))]
#[bench::large(&mut get_map(256))]
fn fetch_faces(map: &mut CMap2<FloatType>) {
black_box(map.fetch_faces());
fn iter_faces(map: &mut CMap2<FloatType>) {
black_box(map.iter_faces().collect::<Vec<_>>());
}

library_benchmark_group!(
name = bench_fetches;
benchmarks =
fetch_vertices,
fetch_edges,
fetch_faces,
iter_vertices,
iter_edges,
iter_faces,
);

// --- i-cell group
Expand Down
6 changes: 3 additions & 3 deletions benches/benches/core/cmap2/fetch_icells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ pub fn criterion_benchmark(c: &mut Criterion) {

group.bench_with_input(BenchmarkId::new("fetch-vertices", ""), &map, |b, m| {
b.iter(|| {
let mut vertices = m.fetch_vertices();
let mut vertices: Vec<_> = m.iter_vertices().collect();
black_box(&mut vertices);
})
});
group.bench_with_input(BenchmarkId::new("fetch-edges", ""), &map, |b, m| {
b.iter(|| {
let mut edges = m.fetch_edges();
let mut edges: Vec<_> = m.iter_edges().collect();
black_box(&mut edges);
})
});
group.bench_with_input(BenchmarkId::new("fetch-faces", ""), &map, |b, m| {
b.iter(|| {
let mut faces = m.fetch_faces();
let mut faces: Vec<_> = m.iter_faces().collect();
black_box(&mut faces);
})
});
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/triangulate/quads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn fan_bench() -> Result<(), TriangulateError> {
let mut map: CMap2<FloatType> = CMapBuilder::default().vtk_file(PATH).build().unwrap();

// prealloc darts
let faces = map.fetch_faces().identifiers.clone();
let faces: Vec<_> = map.iter_faces().collect();
let n_darts_per_face: Vec<_> = faces
.iter()
.map(|id| (Orbit2::new(&map, OrbitPolicy::Face, *id as DartIdType).count() - 3) * 2)
Expand Down Expand Up @@ -49,7 +49,7 @@ fn earclip_bench() -> Result<(), TriangulateError> {
let mut map: CMap2<FloatType> = CMapBuilder::default().vtk_file(PATH).build().unwrap();

// prealloc darts
let faces = map.fetch_faces().identifiers.clone();
let faces: Vec<_> = map.iter_faces().collect();
let n_darts_per_face: Vec<_> = faces
.iter()
.map(|id| (Orbit2::new(&map, OrbitPolicy::Face, *id as DartIdType).count() - 3) * 2)
Expand Down
4 changes: 1 addition & 3 deletions benches/src/shift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ fn main() {

// fetch all vertices that are not on the boundary of the map
let tmp: Vec<(VertexIdType, Vec<VertexIdType>)> = map
.fetch_vertices()
.identifiers
.into_iter()
.iter_vertices()
.filter_map(|v| {
if Orbit2::new(&map, OrbitPolicy::Vertex, v as DartIdType)
.any(|d| map.beta::<2>(d) == NULL_DART_ID)
Expand Down
32 changes: 14 additions & 18 deletions benches/src/shift_no_conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,20 @@ fn main() {
let map: CMap2<f64> = CMapBuilder::unit_grid(n_squares).build().unwrap();

// fetch all vertices that are not on the boundary of the map
let tmp = map
.fetch_vertices()
.identifiers
.into_iter()
.filter_map(|v| {
if Orbit2::new(&map, OrbitPolicy::Vertex, v as DartIdType)
.any(|d| map.beta::<2>(d) == NULL_DART_ID)
{
None
} else {
Some((
v,
Orbit2::new(&map, OrbitPolicy::Vertex, v as DartIdType)
.map(|d| map.vertex_id(map.beta::<2>(d)))
.collect(),
))
}
});
let tmp = map.iter_vertices().filter_map(|v| {
if Orbit2::new(&map, OrbitPolicy::Vertex, v as DartIdType)
.any(|d| map.beta::<2>(d) == NULL_DART_ID)
{
None
} else {
Some((
v,
Orbit2::new(&map, OrbitPolicy::Vertex, v as DartIdType)
.map(|d| map.vertex_id(map.beta::<2>(d)))
.collect(),
))
}
});

#[allow(clippy::type_complexity)]
let (first_batch, second_batch): (
Expand Down
4 changes: 2 additions & 2 deletions examples/examples/io/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ fn main() {

println!("I: Start quad split process...");
let now = Instant::now();
map.fetch_faces()
.identifiers
let faces: Vec<_> = map.iter_faces().collect();
faces
.iter()
.filter(|square| splits[**square as usize % n_split])
.for_each(|square| {
Expand Down
4 changes: 1 addition & 3 deletions examples/examples/parallel_shift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ fn main() {

// fetch all vertices that are not on the boundary of the map
let nodes: Vec<(VertexIdType, Vec<VertexIdType>)> = map
.fetch_vertices()
.identifiers
.into_iter()
.iter_vertices()
.filter_map(|v| {
// the condition detects if we're on the boundary
if Orbit2::new(&map, OrbitPolicy::Vertex, v as DartIdType)
Expand Down
1 change: 1 addition & 0 deletions honeycomb-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ utils = []

[dependencies]
downcast-rs.workspace = true
itertools.workspace = true
loom.workspace= true
num-traits.workspace = true
stm.workspace = true
Expand Down
7 changes: 2 additions & 5 deletions honeycomb-core/src/cmap/builder/grid/building_routines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub fn build_2d_grid<T: CoordsFloat>(
// check the number of built faces
// this is set as debug only because the operation cost scales with map size
// this can quickly overshadow the exectime of all previous code
debug_assert_eq!(map.fetch_faces().identifiers.len(), n_square_x * n_square_y);
debug_assert_eq!(map.iter_faces().count(), n_square_x * n_square_y);

map
}
Expand Down Expand Up @@ -202,10 +202,7 @@ pub fn build_2d_splitgrid<T: CoordsFloat>(
// check the number of built faces
// this is set as debug only because the operation cost scales with map size
// this can quickly overshadow the exectime of all previous code
debug_assert_eq!(
map.fetch_faces().identifiers.len(),
2 * n_square_x * n_square_y
);
debug_assert_eq!(map.iter_faces().count(), 2 * n_square_x * n_square_y);

map
}
Expand Down
9 changes: 4 additions & 5 deletions honeycomb-core/src/cmap/builder/io/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ fn io_read() {
let cmap: CMap2<f32> = super::build_2d_from_vtk(vtk, AttrStorageManager::default()).unwrap();

// check result
let faces = cmap.fetch_faces();
assert_eq!(faces.identifiers.len(), 4);
assert_eq!(cmap.fetch_edges().identifiers.len(), 12);
assert_eq!(cmap.fetch_vertices().identifiers.len(), 9);
let faces: Vec<_> = cmap.iter_faces().collect();
assert_eq!(faces.len(), 4);
assert_eq!(cmap.iter_edges().count(), 12);
assert_eq!(cmap.iter_vertices().count(), 9);

let mut n_vertices_per_face: Vec<usize> = faces
.identifiers
.iter()
.map(|id| Orbit2::new(&cmap, OrbitPolicy::Face, *id as DartIdType).count())
.collect();
Expand Down
112 changes: 0 additions & 112 deletions honeycomb-core/src/cmap/components/collections.rs

This file was deleted.

1 change: 0 additions & 1 deletion honeycomb-core/src/cmap/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Common components of the `CMap2` implementation

pub mod betas;
pub mod collections;
pub mod identifiers;
pub mod orbits;
pub mod unused;
Loading
Loading