Skip to main content

MOLSystem2D

Struct MOLSystem2D 

Source
pub struct MOLSystem2D<S: SparseScalar> { /* private fields */ }
Expand description

2D Method of Lines system.

Converts a 2D PDE of the form u_t = L[u] + R(t, x, y, u) into an ODE system, where L is a linear spatial operator assembled as a sparse matrix and R is an optional nonlinear reaction term.

Implementations§

Source§

impl<S: SparseScalar> MOLSystem2D<S>

Source

pub fn heat(grid: Grid2D<S>, alpha: S, bc: &BoundaryConditions2D<S>) -> Self

Create a 2D MOL system for the heat equation: u_t = alpha * laplacian(u).

Source

pub fn laplacian(grid: Grid2D<S>, bc: &BoundaryConditions2D<S>) -> Self

Create a 2D MOL system for the Laplacian: u_t = laplacian(u).

Source

pub fn with_operator( grid: Grid2D<S>, coeffs: &Operator2DCoefficients<S>, bc: &BoundaryConditions2D<S>, ) -> Self

Create a 2D MOL system with a general linear operator.

Source

pub fn with_reaction<F>(self, reaction: F) -> Self
where F: Fn(S, S, S, S) -> S + Send + Sync + 'static,

Add a nonlinear reaction term R(t, x, y, u) to the system.

The full PDE becomes: u_t = L[u] + R(t, x, y, u).

Source

pub fn grid(&self) -> &Grid2D<S>

Get the spatial grid.

Source

pub fn n_interior(&self) -> usize

Number of interior points (ODE dimension).

Source

pub fn build_full_solution(&self, u_interior: &[S]) -> Vec<S>

Build the full solution array including boundaries.

Interior values are stored in column-major order: u[jj * nx_int + ii]. The full array has nx*ny entries in the same column-major layout.

Trait Implementations§

Source§

impl<S: SparseScalar> OdeSystem<S> for MOLSystem2D<S>

Source§

fn jacobian(&self, t: S, y: &[S], jac: &mut [S])

Analytical Jacobian: copy the assembled sparse spatial operator (which already equals ∂(L[u])/∂u by construction) into the row-major dense buffer the solver expects, then add the reaction term’s contribution to the diagonal.

The reaction Jacobian is diagonal because the reaction is pointwise: R(t, x_i, y_j, u_i) depends only on the local state u_i, so ∂R_i/∂u_k is identically zero for any k != i. Off- diagonal entries cannot be populated by a pointwise reaction, no matter what the closure contains. This is what makes the FD-on-the-diagonal fallback affordable: one extra closure call per interior point versus the O(N) rhs evaluations the trait-default FD would need to populate the same entries through perturbation. If a future reaction model couples grid points (nonlocal / integro-PDE / multi-component), the trait default’s full FD path is the correct fallback — but that’s out of scope for v1.

Source§

fn dim(&self) -> usize

Dimension of the system.
Source§

fn rhs(&self, t: S, y: &[S], dydt: &mut [S])

Compute the right-hand side: dydt = f(t, y)
Source§

fn is_autonomous(&self) -> bool

Is the system autonomous? (f does not depend on t explicitly)
Source§

fn has_mass_matrix(&self) -> bool

Does this system have a mass matrix?
Source§

fn mass_matrix(&self, mass: &mut [S])

Get the mass matrix M for the DAE: M * y’ = f(t, y) Read more
Source§

fn is_singular_mass(&self) -> bool

Is the mass matrix singular? (i.e., is this a DAE?)
Source§

fn algebraic_indices(&self) -> Vec<usize>

Return indices of algebraic variables (where M[i,i] = 0). Read more

Auto Trait Implementations§

§

impl<S> Freeze for MOLSystem2D<S>

§

impl<S> !RefUnwindSafe for MOLSystem2D<S>

§

impl<S> Send for MOLSystem2D<S>

§

impl<S> Sync for MOLSystem2D<S>

§

impl<S> Unpin for MOLSystem2D<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for MOLSystem2D<S>

§

impl<S> !UnwindSafe for MOLSystem2D<S>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V