Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
start working on connectivity refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Feb 23, 2024
1 parent 544e14c commit 28f8404
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/grid/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ use crate::traits::cell::ReferenceCellType;
use bempp_element::cell;
use bempp_traits::cell::ReferenceCell;

use std::collections::HashMap;

/// Topology of a serial grid
pub struct SerialTopology {
dim: usize,
connectivity: Vec<Vec<Vec<Vec<usize>>>>,
cell_connectivity: Vec<Vec<usize>>, // TODO: get rid of this input
connectivity_neww: Vec<Vec<HashMap<ReferenceCellType, Vec<usize>>>>,

Check failure on line 16 in src/grid/topology.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, mpich)

field `connectivity_neww` is never read

Check failure on line 16 in src/grid/topology.rs

View workflow job for this annotation

GitHub Actions / Rust style checks

field `connectivity_neww` is never read

Check failure on line 16 in src/grid/topology.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, openmpi)

field `connectivity_neww` is never read
index_map: Vec<usize>,
starts: Vec<usize>,
cell_types: Vec<ReferenceCellType>,
Expand Down Expand Up @@ -46,12 +49,21 @@ impl SerialTopology {
}
}

let mut connectivity_neww = vec![];
for i in 0..dim + 1 {
connectivity_neww.push(vec![]);
for _j in 0..dim + 1 {
connectivity_neww[i].push(HashMap::new());
}
}

// dim0 = dim, dim1 = 0
for c in cell_types {
if dim != reference_cell::dim(*c) {
panic!("Grids with cells of mixed topological dimension not supported.");
}
if !cell_types_new.contains(c) {
let mut cty = vec![];
starts.push(connectivity[dim][0].len());
cell_types_new.push(*c);
let n = reference_cell::entity_counts(*c)[0];
Expand All @@ -67,10 +79,12 @@ impl SerialTopology {
}
row.push(vertices.iter().position(|&r| r == *v).unwrap());
}
cty.extend_from_slice(&row);
connectivity[dim][0].push(row);
}
start += reference_cell::entity_counts(*ct)[0];
}
connectivity_neww[dim][0].insert(*c, cty);
}
}

Expand Down Expand Up @@ -261,6 +275,7 @@ impl SerialTopology {
dim,
connectivity,
cell_connectivity,
connectivity_neww,
index_map,
starts,
cell_types: cell_types_new,
Expand Down

0 comments on commit 28f8404

Please sign in to comment.