Struct Voxel

pub struct Voxel {
    pub index: usize,
    pub result: f64,
    pub error: f64,
}
Expand description

Representation of a single voxel in the mesh

The global index of the voxel is included to maintain consistency between output Format variants. Parsing line-by-line rather than trying to load an entire file into memory leaves the voxels in an inconsistent order for several formats.

§Memory usage

The minimum information required would be just the result and uncertainty (16 Bytes), and the maximum would include the cooridinates and energy/time groups (80 Bytes).

The current implementation is a compromise between the two at 24 Bytes, and all other values may be derived from the Mesh given the voxel index.

Several operators are implemented for convenience where it makes sense, including Addition (+, +=), Subtraction (-, -=), Multiplication (*, *=), and Division (/, /=).

In all cases, the LHS index is taken, and the RHS may be either another Voxel or anything that can be converted into an f64 primitive.

Fields§

§index: usize

Global voxel index

§result: f64

Tallied voxel result

§error: f64

Relative error on result

Implementations§

§

impl Voxel

pub fn absolute_error(&self) -> f64

Returns the absolute error for the voxel

Example:

 let voxel = Voxel {
     result: 50.0,
     error: 0.10,
     ..Default::default()
 };

 /// 10% relative error => 50.0 +/-5.0
 assert_eq!(voxel.absolute_error(), 5.0);

pub fn relative_error(&self) -> f64

Returns the relative error for the voxel

The MCNP mesh results are output and stored as the relative uncertainty anyway. However, having both absolute_error() and relative_error() methods makes intent explicit.

For example:

let voxel = Voxel {
    result: 50.0,
    error: 0.10,
    ..Default::default()
};
/// 10% relative error => 50.0 +/-5.0
assert_eq!(voxel.relative_error(), 0.1);

pub fn powf(self, value: impl Into<f64>) -> Voxel

Raise the voxel to some power

 let voxel = Voxel {
     result: 10.0,
     error: 0.10,
     ..Default::default()
 };

 /// 10% relative error => 50.0 +/-5.0
 assert_eq!(voxel.powf(2.0).result, 100.0);
 assert_eq!(voxel.powf(2.0).error, 2.0);

Trait Implementations§

§

impl<T> Add<T> for Voxel
where T: Into<f64>,

§

type Output = Voxel

The resulting type after applying the + operator.
§

fn add(self, other: T) -> Self

Performs the + operation. Read more
§

impl Add for Voxel

§

type Output = Voxel

The resulting type after applying the + operator.
§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
§

impl<T> AddAssign<T> for Voxel
where T: Into<f64>,

§

fn add_assign(&mut self, other: T)

Performs the += operation. Read more
§

impl AddAssign for Voxel

§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
§

impl Clone for Voxel

§

fn clone(&self) -> Voxel

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Voxel

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for Voxel

§

fn default() -> Voxel

Returns the “default value” for a type. Read more
§

impl Display for Voxel

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<T> Div<T> for Voxel
where T: Into<f64>,

§

type Output = Voxel

The resulting type after applying the / operator.
§

fn div(self, other: T) -> Self

Performs the / operation. Read more
§

impl Div for Voxel

§

type Output = Voxel

The resulting type after applying the / operator.
§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
§

impl<T> DivAssign<T> for Voxel
where T: Into<f64>,

§

fn div_assign(&mut self, other: T)

Performs the /= operation. Read more
§

impl DivAssign for Voxel

§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
§

impl<T> Mul<T> for Voxel
where T: Into<f64>,

§

type Output = Voxel

The resulting type after applying the * operator.
§

fn mul(self, other: T) -> Self

Performs the * operation. Read more
§

impl Mul for Voxel

§

type Output = Voxel

The resulting type after applying the * operator.
§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
§

impl<T> MulAssign<T> for Voxel
where T: Into<f64>,

§

fn mul_assign(&mut self, other: T)

Performs the *= operation. Read more
§

impl MulAssign for Voxel

§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
§

impl PartialEq for Voxel

§

fn eq(&self, other: &Voxel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T> Sub<T> for Voxel
where T: Into<f64>,

§

type Output = Voxel

The resulting type after applying the - operator.
§

fn sub(self, other: T) -> Self

Performs the - operation. Read more
§

impl Sub for Voxel

§

type Output = Voxel

The resulting type after applying the - operator.
§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
§

impl<T> SubAssign<T> for Voxel
where T: Into<f64>,

§

fn sub_assign(&mut self, other: T)

Performs the -= operation. Read more
§

impl SubAssign for Voxel

§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
§

impl Copy for Voxel

§

impl StructuralPartialEq for Voxel

Auto Trait Implementations§

§

impl Freeze for Voxel

§

impl RefUnwindSafe for Voxel

§

impl Send for Voxel

§

impl Sync for Voxel

§

impl Unpin for Voxel

§

impl UnwindSafe for Voxel

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

§

impl<T, Right> ClosedAddAssign<Right> for T
where T: ClosedAdd<Right> + AddAssign<Right>,

§

impl<T, Right> ClosedDiv<Right> for T
where T: Div<Right, Output = T> + DivAssign<Right>,

§

impl<T, Right> ClosedDivAssign<Right> for T
where T: ClosedDiv<Right> + DivAssign<Right>,

§

impl<T, Right> ClosedMul<Right> for T
where T: Mul<Right, Output = T> + MulAssign<Right>,

§

impl<T, Right> ClosedMulAssign<Right> for T
where T: ClosedMul<Right> + MulAssign<Right>,

§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

§

impl<T, Right> ClosedSubAssign<Right> for T
where T: ClosedSub<Right> + SubAssign<Right>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,