pub struct FDM;Expand description
Finite Difference Method utilities.
Implementations§
Source§impl FDM
impl FDM
Sourcepub fn d1_central<S: Scalar>(u: &[S], dx: S, i: usize) -> S
pub fn d1_central<S: Scalar>(u: &[S], dx: S, i: usize) -> S
Compute first derivative using central differences.
du/dx ≈ (u[i+1] - u[i-1]) / (2*dx)
Sourcepub fn d1_forward<S: Scalar>(u: &[S], dx: S, i: usize) -> S
pub fn d1_forward<S: Scalar>(u: &[S], dx: S, i: usize) -> S
Compute first derivative using forward difference.
du/dx ≈ (u[i+1] - u[i]) / dx
Sourcepub fn d1_backward<S: Scalar>(u: &[S], dx: S, i: usize) -> S
pub fn d1_backward<S: Scalar>(u: &[S], dx: S, i: usize) -> S
Compute first derivative using backward difference.
du/dx ≈ (u[i] - u[i-1]) / dx
Sourcepub fn d2_central<S: Scalar>(u: &[S], dx: S, i: usize) -> S
pub fn d2_central<S: Scalar>(u: &[S], dx: S, i: usize) -> S
Compute second derivative using central differences.
d²u/dx² ≈ (u[i+1] - 2*u[i] + u[i-1]) / dx²
Sourcepub fn d2_central4<S: Scalar>(u: &[S], dx: S, i: usize) -> S
pub fn d2_central4<S: Scalar>(u: &[S], dx: S, i: usize) -> S
Compute second derivative using fourth-order central differences.
d²u/dx² ≈ (-u[i+2] + 16*u[i+1] - 30*u[i] + 16*u[i-1] - u[i-2]) / (12*dx²)
Sourcepub fn d1_left_boundary<S: Scalar>(u: &[S], dx: S) -> S
pub fn d1_left_boundary<S: Scalar>(u: &[S], dx: S) -> S
Compute first derivative at left boundary using one-sided differences.
du/dx ≈ (-3*u[0] + 4*u[1] - u[2]) / (2*dx)
Sourcepub fn d1_right_boundary<S: Scalar>(u: &[S], dx: S) -> S
pub fn d1_right_boundary<S: Scalar>(u: &[S], dx: S) -> S
Compute first derivative at right boundary using one-sided differences.
du/dx ≈ (3*u[n-1] - 4*u[n-2] + u[n-3]) / (2*dx)
Sourcepub fn laplacian_1d<S: Scalar>(u: &[S], dx: S) -> Vec<S>
pub fn laplacian_1d<S: Scalar>(u: &[S], dx: S) -> Vec<S>
Apply Laplacian operator to entire field (interior points only).
Returns vector of size n-2 (excluding boundary points).
Sourcepub fn laplacian_2d<S: Scalar>(
u: &[S],
nx: usize,
ny: usize,
dx: S,
dy: S,
) -> Vec<S>
pub fn laplacian_2d<S: Scalar>( u: &[S], nx: usize, ny: usize, dx: S, dy: S, ) -> Vec<S>
Apply Laplacian operator to entire 2D field (interior points only).
Uses a 5-point stencil.
Sourcepub fn gradient_1d<S: Scalar>(u: &[S], dx: S) -> Vec<S>
pub fn gradient_1d<S: Scalar>(u: &[S], dx: S) -> Vec<S>
Compute gradient at all interior points.
Auto Trait Implementations§
impl Freeze for FDM
impl RefUnwindSafe for FDM
impl Send for FDM
impl Sync for FDM
impl Unpin for FDM
impl UnsafeUnpin for FDM
impl UnwindSafe for FDM
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more