API & Types
LevelSetRep is the general geometric backend for broad interface topologies. GlobalHFRep is a specialized backend for interfaces representable as a single-valued graph along one chosen axis.
Interface representations
PenguinStefan.AbstractInterfaceRep — Type
AbstractInterfaceRep{N,T}Abstract interface-representation backend used by Stefan solvers.
Concrete implementations provide geometry update/prediction hooks such as phi_values, predict_phi, advance!, and optional nonlinear coupled_step! support.
PenguinStefan.LevelSetRep — Type
LevelSetRep(grid, phi0; bc=..., integrator=..., reinit_cfg=..., reinit_tau=0, coupling=:explicit)Level-set interface representation backend.
LevelSetRep stores and evolves a signed-distance-like field on a Cartesian grid. Use this backend for general interfaces, including non-graph geometries.
The coupling keyword selects:
:explicit(default) explicit interface update,:ls_newtonnonlinear inner iteration on the Stefan residual.
PenguinStefan.GlobalHFRep — Type
GlobalHFRep{N,T,AT} <: AbstractInterfaceRep{N,T}Global height-function interface representation for graph-like fronts.
GlobalHFRep stores the interface as a single-valued graph along one selected axis (axis). In 1D this is a single position x_f(t), in 2D a line graph x = x_f(y, t), and in 3D a surface graph x = x_f(y, z, t) (after axis selection).
Supported scope:
- Single-valued graph interfaces along the chosen axis in 1D/2D/3D.
- Optional periodic transverse directions (
periodic_transverse=true).
Out of scope:
- Multi-valued/overturning fronts for the chosen axis.
- Topology change (breakup/merging) and closed non-graph interfaces.
Interface coupling hooks
PenguinStefan.coupling_mode — Function
coupling_mode(rep)Return interface coupling mode symbol (for example :explicit, :ghf_newton, or :ls_newton).
coupling_mode(rep::GlobalHFRep)Return :ghf_newton, selecting the GlobalHF coupled nonlinear iteration.
PenguinStefan.predict_phi — Function
predict_phi(rep, v_prev_nodes, t, dt; kwargs...)Predict interface level-set values at t + dt from representation rep. Backend-specific keyword arguments (e.g. frozen) are forwarded to the concrete implementation.
predict_phi(rep::GlobalHFRep, speed_prev, t, dt)Predict the next interface signed field by extrapolating the graph positions from previously accepted xf values, then reconstructing ϕ from that graph.
For GlobalHFRep, the predictor uses a one-step secant extrapolation of xf when a previous time step is available.
predict_phi(rep::FrontTrackingRep, speed_nodal, t, dt; kwargs...)Predict the phi field at t + dt by:
- Sampling
speed_nodal(Cartesian grid array) at the current front vertices. - Moving the mesh forward one Euler step with those vertex speeds.
- Reconstructing the signed-distance phi from the predicted mesh.
The representation state is NOT modified.
Problem / state containers
PenguinStefan.StefanMonoProblem — Type
StefanMonoProblem(grid, bc_border, params, interface_rep[, options])Problem container for monophasic Stefan simulations.
PenguinStefan.StefanDiphProblem — Type
StefanDiphProblem(grid, bc_border, params, interface_rep[, options])Problem container for diphasic Stefan simulations.
PenguinStefan.StefanMonoState — Type
StefanMonoStateMutable runtime state for monophasic simulations (time, temperatures, speed, frozen-mask, and diagnostics logs).
PenguinStefan.StefanDiphState — Type
StefanDiphStateMutable runtime state for diphasic simulations (time, phase temperatures, speed, frozen-mask, and diagnostics logs).
Solver entry points
PenguinStefan.build_solver — Function
build_solver(prob::StefanMonoProblem; t0=0, uω0=nothing, uγ0=nothing, speed0=nothing)Build a monophasic solver from problem definition and initial conditions.
PenguinStefan.step! — Function
step!(solver::StefanMonoSolver, dt; method=:direct, kwargs...)Advance one monophasic time step of size dt.
Coupled backends (ghf_newton, ls_newton) are handled by their own routines. For explicit backends the call is forwarded to step_explicit!, which is dispatched on the concrete interface_rep type.
PenguinSolverCore.solve! — Function
solve!(solver::StefanMonoSolver, (t0, tend); dt, save_history=true, method=:direct, kwargs...)Run repeated step! calls over tspan with fixed step size dt.
PenguinStefan.coupled_step! — Function
coupled_step!(solver, dt; kwargs...)Run one nonlinear coupled step for interface backends that implement coupled iterations.
coupled_step!(solver::StefanMonoSolver, dt; method=:direct, kwargs...)
coupled_step!(solver::StefanDiphSolver, dt; method=:direct, kwargs...)Run one coupled nonlinear iteration step for GlobalHFRep backends.
Workflow per step:
- predict interface graph/geometry,
- solve moving diffusion,
- assemble Stefan residual,
- update graph heights/positions,
- reconstruct
ϕand repeat until tolerance orcoupling_max_iter.
Diagnostics are written in solver.state.logs and exposed via stefan_coupling_history(solver).
PenguinStefan.stefan_coupling_history — Function
stefan_coupling_history(solver)Return a named tuple of logged nonlinear coupling diagnostics: (iters, residual_abs, residual_rel).
For GlobalHFRep, residual_abs maps to the infinity norm residual history stored by the GHF coupled iteration.
Validation helpers
PenguinStefan.stefan_lambda_neumann — Function
stefan_lambda_neumann(Ste; atol=1e-12, maxiter=200)Compute the similarity parameter λ for the 1D Neumann Stefan solution.
PenguinStefan.neumann_1d_similarity — Function
neumann_1d_similarity(x, t; Ts=1, Tm=0, α=1, Ste=1, λ=nothing)Evaluate the 1D Neumann similarity solution and return (T, s, Vn, λ).
PenguinStefan.manufactured_planar_1d — Function
manufactured_planar_1d(x, t; s0, V, Tm=0, A=1, kappa=1, rhoL=1)Evaluate a planar 1D manufactured Stefan field and return (T, s, source, flux, vflux).
PenguinStefan.manufactured_graph_3d — Function
manufactured_graph_3d(x, y, z, t; s0, epsf, ωy, ωz, V, Tm=0, A=1, kappa=1)Analytical manufactured mono-phase graph case in 3D, with interface
x_f(y, z, t) = s0 + epsf*sin(ωy*y)*sin(ωz*z) + V*t
and temperature
T(x, y, z, t) = Tm + A*(x_f(y, z, t) - x).
Returns (T, xf, source), where source satisfies ∂t T = kappa*ΔT + source exactly for this field.
Diagnostics
PenguinStefan.active_mask — Function
active_mask(cap; tol=0)Return a boolean mask selecting finite active cut cells with volume > tol.
PenguinStefan.phase_volume — Function
phase_volume(cap; tol=0)
phase_volume(V; tol=0)Compute total active phase volume from assembled capacity or volume vector.
PenguinStefan.interface_position_from_volume — Function
interface_position_from_volume(cap; tol=0)
interface_position_from_volume(V; tol=0)In 1D planar geometry, infer interface position from phase volume.
PenguinStefan.radius_from_volume — Function
radius_from_volume(cap; complement=false, tol=0)
radius_from_volume(V; dim=2, complement=false, domain_measure=nothing, tol=0)Infer equivalent circular/spherical radius from volume in 2D or 3D.
PenguinStefan.temperature_error_norms — Function
temperature_error_norms(uω, Texact, cap, t; tol=0, weights=nothing)Compute weighted (L1, L2, Linf) temperature errors against exact callback.
PenguinStefan.stefan_residual_metrics — Function
stefan_residual_metrics(Vn, Vn1, Γ, vflux; tol=sqrt(eps(T)))Compute Stefan residual diagnostics from swept-volume and flux-based speed.
PenguinStefan.fit_order — Function
fit_order(hs, errs)Compute pairwise and global log-log convergence order from mesh sizes and errors.