pub struct ScalarField { /* private fields */ }Expand description
A finite, rectangular scalar grid for dense simulation data.
Implementations§
Source§impl ScalarField
impl ScalarField
Sourcepub const DEFAULT_MAX_FILLED_BYTES: usize
pub const DEFAULT_MAX_FILLED_BYTES: usize
Default maximum allocation performed by ScalarField::filled.
Hosts needing a different explicit budget can use
ScalarField::filled_with_byte_limit or pass an already allocated
buffer to ScalarField::new.
Sourcepub fn new(
width: usize,
height: usize,
values: Vec<f32>,
) -> Result<Self, ScalarFieldError>
pub fn new( width: usize, height: usize, values: Vec<f32>, ) -> Result<Self, ScalarFieldError>
Creates a field from row-major values, validating dimensions and finiteness.
Sourcepub fn filled(
width: usize,
height: usize,
value: f32,
) -> Result<Self, ScalarFieldError>
pub fn filled( width: usize, height: usize, value: f32, ) -> Result<Self, ScalarFieldError>
Creates a finite field filled with one finite scalar value.
Allocation is limited to ScalarField::DEFAULT_MAX_FILLED_BYTES and
uses fallible reservation before initialization.
Sourcepub fn filled_with_byte_limit(
width: usize,
height: usize,
value: f32,
maximum_bytes: usize,
) -> Result<Self, ScalarFieldError>
pub fn filled_with_byte_limit( width: usize, height: usize, value: f32, maximum_bytes: usize, ) -> Result<Self, ScalarFieldError>
Creates a filled field under an explicit host-memory byte limit.
maximum_bytes applies to the row-major f32 value buffer. Reservation
failure is returned without partially constructing the field. Supplying
a larger limit is an explicit host decision; system overcommit can still
make physical memory exhaustion unrecoverable on some platforms.
Sourcepub fn value_at(&self, x: usize, y: usize) -> Option<f32>
pub fn value_at(&self, x: usize, y: usize) -> Option<f32>
Returns a cell value, or None outside field bounds.
Sourcepub fn set(
&mut self,
x: usize,
y: usize,
value: f32,
) -> Result<(), ScalarFieldError>
pub fn set( &mut self, x: usize, y: usize, value: f32, ) -> Result<(), ScalarFieldError>
Replaces one cell with a finite value.
Sourcepub fn replace_values(
&mut self,
values: Vec<f32>,
) -> Result<(), ScalarFieldError>
pub fn replace_values( &mut self, values: Vec<f32>, ) -> Result<(), ScalarFieldError>
Replaces all values while preserving the field dimensions.
Sourcepub fn replace_region(
&mut self,
x: usize,
y: usize,
width: usize,
height: usize,
values: &[f32],
) -> Result<(), ScalarFieldError>
pub fn replace_region( &mut self, x: usize, y: usize, width: usize, height: usize, values: &[f32], ) -> Result<(), ScalarFieldError>
Replaces a contiguous rectangular region with finite row-major values.
Sourcepub fn value_range(&self) -> (f32, f32)
pub fn value_range(&self) -> (f32, f32)
Returns finite minimum and maximum scalar values.