pub struct Grid {
pub dim: [usize; 3],
pub origin: [f64; 3],
pub cell: [[f64; 3]; 3],
pub pbc: [bool; 3],
/* private fields */
}Expand description
A collection of named scalar arrays on a shared uniform spatial grid.
Cell vectors are stored as columns (same convention as SimBox).
The Cartesian position of voxel (i, j, k) is:
origin + (i/nx)*cell_col0 + (j/ny)*cell_col1 + (k/nz)*cell_col2Fields§
§dim: [usize; 3]Grid dimensions [nx, ny, nz].
origin: [f64; 3]Cartesian origin in Ångström.
cell: [[f64; 3]; 3]Cell matrix: columns are the three lattice vectors (Å).
pbc: [bool; 3]Periodic boundary flags for each axis.
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn new(
dim: [usize; 3],
origin: [f64; 3],
cell: [[f64; 3]; 3],
pbc: [bool; 3],
) -> Grid
pub fn new( dim: [usize; 3], origin: [f64; 3], cell: [[f64; 3]; 3], pbc: [bool; 3], ) -> Grid
Create an empty grid with the given spatial definition.
Sourcepub fn insert(
&mut self,
name: impl Into<String>,
data: Vec<f64>,
) -> Result<(), MolRsError>
pub fn insert( &mut self, name: impl Into<String>, data: Vec<f64>, ) -> Result<(), MolRsError>
Insert (or replace) a named array.
data must have length nx * ny * nz in row-major (ix, iy, iz) order.
Sourcepub fn get(
&self,
name: &str,
) -> Option<ArrayBase<OwnedRepr<f64>, Dim<IxDynImpl>>>
pub fn get( &self, name: &str, ) -> Option<ArrayBase<OwnedRepr<f64>, Dim<IxDynImpl>>>
Return a named array reshaped to (nx, ny, nz), or None if absent.
Sourcepub fn get_raw(&self, name: &str) -> Option<&[f64]>
pub fn get_raw(&self, name: &str) -> Option<&[f64]>
Borrow the raw flat slice for a named array, or None if absent.
Sourcepub fn raw_arrays(&self) -> impl Iterator<Item = (&str, &[f64])>
pub fn raw_arrays(&self) -> impl Iterator<Item = (&str, &[f64])>
Iterate over (name, flat_data) pairs.
Trait Implementations§
impl StructuralPartialEq for Grid
Auto Trait Implementations§
impl Freeze for Grid
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnsafeUnpin for Grid
impl UnwindSafe for Grid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more