Skip to main content

SymmTensor

Struct SymmTensor 

Source
pub struct SymmTensor {
    pub xx: f64,
    pub xy: f64,
    pub xz: f64,
    pub yy: f64,
    pub yz: f64,
    pub zz: f64,
}
Expand description

Symmetric 3×3 tensor stored in upper-triangle order: xx, xy, xz, yy, yz, zz. Maps to Foam::symmTensor (Foam::SymmTensor<scalar>).

Fields§

§xx: f64§xy: f64§xz: f64§yy: f64§yz: f64§zz: f64

Implementations§

Source§

impl SymmTensor

Source

pub const ZERO: Self

The zero tensor (all components 0).

Source

pub const IDENTITY: Self

The identity tensor (unit diagonal, zero off-diagonal).

Source

pub fn new(xx: f64, xy: f64, xz: f64, yy: f64, yz: f64, zz: f64) -> Self

Construct from the six upper-triangle components (xx, xy, xz, yy, yz, zz).

Source

pub fn from_diag(xx: f64, yy: f64, zz: f64) -> Self

Construct from diagonal only (off-diagonal = 0).

Source

pub fn row_x(self) -> Vector3

Row vectors (yx = xy, zx = xz, zy = yz because symmetric)

Source

pub fn row_y(self) -> Vector3

Source

pub fn row_z(self) -> Vector3

Source

pub fn diag(self) -> Vector3

Diagonal as a vector

Source

pub fn tr(self) -> f64

Trace: xx + yy + zz

Source

pub fn sph(self) -> SphericalTensor

Spherical (isotropic) part: (tr/3) * I

Source

pub fn dev(self) -> Self

Deviatoric part: self - (tr/3)*I

Source

pub fn dev2(self) -> Self

Two-thirds deviatoric part: self - (2*tr/3)*I

Source

pub fn det(self) -> f64

Determinant

Source

pub fn adjunct(self) -> Self

Adjunct (= cofactor matrix, same as adjunct because symmetric)

Source

pub fn inv(self) -> Self

Inverse = adjunct / det. Panics if singular in debug builds.

Source

pub fn safe_inv(self) -> Self

Inverse with fallback: returns ZERO if nearly singular.

Source

pub fn mag_sqr(self) -> f64

Frobenius norm squared (off-diagonal counted twice, matching OpenFOAM)

Source

pub fn mag(self) -> f64

Source

pub fn diag_sqr(self) -> f64

Sum of squared diagonal entries (not Frobenius)

Source

pub fn inner_sqr(self) -> Self

Self² as a SymmTensor (S·S where both factors are symmetric)

Source

pub fn double_inner(self, rhs: Self) -> f64

Double contraction (Frobenius inner product). C++ operator&&. Note: off-diagonal elements contribute twice because the tensor is symmetric.

Source

pub fn mat_vec(self, v: Vector3) -> Vector3

Matrix multiply SymmTensor·Vector → Vector. C++ operator&(SymmTensor, Vector).

Source

pub fn hodge_dual(self) -> Vector3

Hodge dual: returns the axial vector. C++ operator*(SymmTensor).

Source

pub fn from_outer(v: Vector3) -> Self

Outer (dyadic) product of a vector with itself: v ⊗ v → SymmTensor. C++ sqr(Vector).

Source

pub fn invariant_i(self) -> f64

First invariant: trace

Source

pub fn invariant_ii(self) -> f64

Second invariant: (xxyy + yyzz + xx*zz) - (xy² + yz² + xz²)

Source

pub fn invariant_iii(self) -> f64

Third invariant: determinant

Source

pub fn lerp(a: Self, b: Self, t: f64) -> Self

Linear interpolation

Source

pub fn is_identity(self, tol: f64) -> bool

True if the tensor is (approximately) the identity.

Trait Implementations§

Source§

impl Add for SymmTensor

Source§

type Output = SymmTensor

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<SphericalTensor> for SymmTensor

Source§

type Output = SymmTensor

The resulting type after applying the + operator.
Source§

fn add(self, spt: SphericalTensor) -> Self

Performs the + operation. Read more
Source§

impl Add<SymmTensor> for SphericalTensor

Source§

type Output = SymmTensor

The resulting type after applying the + operator.
Source§

fn add(self, st: SymmTensor) -> SymmTensor

Performs the + operation. Read more
Source§

impl Add<SymmTensor> for Tensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, st: SymmTensor) -> Self

Performs the + operation. Read more
Source§

impl Add<Tensor> for SymmTensor

Source§

type Output = Tensor

The resulting type after applying the + operator.
Source§

fn add(self, t: Tensor) -> Tensor

Performs the + operation. Read more
Source§

impl AddAssign for SymmTensor

Source§

fn add_assign(&mut self, r: Self)

Performs the += operation. Read more
Source§

impl Clone for SymmTensor

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for SymmTensor

Source§

impl Debug for SymmTensor

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SymmTensor

Source§

fn default() -> Self

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

impl Div<f64> for SymmTensor

Source§

type Output = SymmTensor

The resulting type after applying the / operator.
Source§

fn div(self, s: f64) -> Self

Performs the / operation. Read more
Source§

impl From<SphericalTensor> for SymmTensor

Source§

fn from(st: SphericalTensor) -> Self

Converts to this type from the input type.
Source§

impl From<SymmTensor> for Tensor

Source§

fn from(st: SymmTensor) -> Self

Converts to this type from the input type.
Source§

impl Mul for SymmTensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, st: SymmTensor) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<SphericalTensor> for SymmTensor

Source§

type Output = SymmTensor

The resulting type after applying the * operator.
Source§

fn mul(self, spt: SphericalTensor) -> Self

Performs the * operation. Read more
Source§

impl Mul<SymmTensor> for f64

Source§

type Output = SymmTensor

The resulting type after applying the * operator.
Source§

fn mul(self, st: SymmTensor) -> SymmTensor

Performs the * operation. Read more
Source§

impl Mul<SymmTensor> for SphericalTensor

Source§

type Output = SymmTensor

The resulting type after applying the * operator.
Source§

fn mul(self, st: SymmTensor) -> SymmTensor

Performs the * operation. Read more
Source§

impl Mul<SymmTensor> for Tensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, st: SymmTensor) -> Self

Performs the * operation. Read more
Source§

impl Mul<Tensor> for SymmTensor

Source§

type Output = Tensor

The resulting type after applying the * operator.
Source§

fn mul(self, t: Tensor) -> Tensor

Performs the * operation. Read more
Source§

impl Mul<f64> for SymmTensor

Source§

type Output = SymmTensor

The resulting type after applying the * operator.
Source§

fn mul(self, s: f64) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<f64> for SymmTensor

Source§

fn mul_assign(&mut self, s: f64)

Performs the *= operation. Read more
Source§

impl Neg for SymmTensor

Source§

type Output = SymmTensor

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for SymmTensor

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SymmTensor

Source§

impl Sub for SymmTensor

Source§

type Output = SymmTensor

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<SphericalTensor> for SymmTensor

Source§

type Output = SymmTensor

The resulting type after applying the - operator.
Source§

fn sub(self, spt: SphericalTensor) -> Self

Performs the - operation. Read more
Source§

impl Sub<SymmTensor> for SphericalTensor

Source§

type Output = SymmTensor

The resulting type after applying the - operator.
Source§

fn sub(self, st: SymmTensor) -> SymmTensor

Performs the - operation. Read more
Source§

impl Sub<SymmTensor> for Tensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, st: SymmTensor) -> Self

Performs the - operation. Read more
Source§

impl Sub<Tensor> for SymmTensor

Source§

type Output = Tensor

The resulting type after applying the - operator.
Source§

fn sub(self, t: Tensor) -> Tensor

Performs the - operation. Read more
Source§

impl SubAssign for SymmTensor

Source§

fn sub_assign(&mut self, r: Self)

Performs the -= operation. Read more

Auto Trait Implementations§

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
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.