zoomy_core.fvm.reconstruction module

zoomy_core.fvm.reconstruction module#

FVM face reconstruction and diffusion operators.

Reconstruction classes#

All reconstruction classes share the same interface: recon(Q) (Q_L, Q_R). The solver calls this once per flux evaluation — no if-clauses in the flux loop.

  • ConstantReconstruction: 1st-order piecewise-constant (identity).

  • MUSCLReconstruction: 2nd-order piecewise-linear with slope limiting (Barth-Jespersen or Venkatakrishnan).

  • FreeSurfaceMUSCL: MUSCL with wet-dry fallback and h-positivity.

Diffusion operators#

  • FaceGradient: corrected face-normal gradient for diffusion.

  • DiffusionOperator: sparse discrete Laplacian (explicit + implicit).

class zoomy_core.fvm.reconstruction.ConstantReconstruction(mesh, dim)#

Bases: object

First-order piecewise-constant reconstruction.

Returns cell-center values at each face: Q_L = Q[:, iA], Q_R = Q[:, iB].

class zoomy_core.fvm.reconstruction.MUSCLReconstruction(mesh, dim, limiter='venkatakrishnan')#

Bases: object

Second-order MUSCL reconstruction with slope limiting.

Green-Gauss gradients + slope limiter. Call signature matches ConstantReconstruction: recon(Q) (Q_L, Q_R).

Parameters:
  • mesh (FVMMesh or LSQMesh) –

  • dim (int) –

  • limiter (str) – “venkatakrishnan” — smooth, 2nd-order at extrema (default). “barth_jespersen” — strict DMP, clips to 1st order at extrema. “minmod” — classic TVD, most diffusive, clips to 1st order at extrema.

class zoomy_core.fvm.reconstruction.FreeSurfaceMUSCL(mesh, dim, h_index, eps_wet=0.001, limiter='venkatakrishnan')#

Bases: MUSCLReconstruction

MUSCL with wet-dry fallback for free-surface flows.

In dry cells (h < eps_wet), falls back to 1st order (φ = 0). Clamps h ≥ 0 at face states after reconstruction.

Parameters:
  • mesh (same as MUSCLReconstruction) –

  • dim (same as MUSCLReconstruction) –

  • limiter (same as MUSCLReconstruction) –

  • h_index (int) – Index of water depth h in the Q array.

  • eps_wet (float) – Dry-cell threshold.

class zoomy_core.fvm.reconstruction.FaceGradient(mesh, dim)#

Bases: object

Precomputes face geometry and provides face gradient reconstruction.

This class is instantiated once per mesh and reused across timesteps.

compute_cell_gradients(u, cell_volumes, face_volumes, normals)#

Green-Gauss cell-center gradients.

face_normal_gradient(u)#

Corrected face-normal gradient: (u_B - u_A) / d_AB / (n·e).

Returns shape (n_faces,).

class zoomy_core.fvm.reconstruction.DiffusionOperator(mesh, dim, nu=1.0)#

Bases: object

Sparse discrete diffusion operator: L(u) = nabla·(nu nabla u).

Assembled once per mesh + viscosity. Can be used for: - Explicit diffusion: dQ += dt * L @ Q - Implicit diffusion: solve (I - dt * L) @ Q^{n+1} = Q^*

explicit(u)#

Compute L @ u (for explicit stepping). Returns shape (nc,).

implicit_solve(u_star, dt, tol=1e-08, maxiter=100)#

Crank-Nicolson: (I - dt/2 * L) u^{n+1} = (I + dt/2 * L) u*.

Second-order in time for diffusion (backward Euler was first-order).