/** * SaturationManager — Threshold tracking + phase transition logic. * * Monitors a solver's scalar field and fires events when values * cross warning/critical/recovery thresholds. Supports hysteresis * to prevent oscillation at threshold boundaries. * * Backs the @saturation_* and @phase_transition traits. */ import { RegularGrid3D } from './RegularGrid3D'; export type SaturationType = 'thermal' | 'moisture' | 'pressure' | 'electrical' | 'chemical' | 'structural'; export type CellState = 'normal' | 'warning' | 'critical'; export interface SaturationConfig { /** The scalar field to monitor (grid or flat array) */ field: RegularGrid3D | Float32Array; /** Threshold levels */ thresholds: { warning: number; critical: number; /** Recovery threshold (hysteresis): must drop below this to return to normal */ recovery: number; }; /** Domain type for event labeling */ type: SaturationType; /** Phase transition configuration (optional) */ phaseTransition?: PhaseTransitionConfig; } export interface PhaseTransitionConfig { /** Temperature/pressure at which transition occurs */ transitionPoint: number; /** Latent heat in J/kg (energy absorbed/released during transition) */ latentHeat: number; fromPhase: 'solid' | 'liquid' | 'gas'; toPhase: 'solid' | 'liquid' | 'gas'; } export interface SaturationEvent { /** Cell index (flat) or node index */ index: number; /** Previous state */ from: CellState; /** New state */ to: CellState; /** Current field value at this cell */ value: number; /** Saturation domain type */ type: SaturationType; /** Whether a phase transition was triggered */ phaseTransition: boolean; } export interface SaturationStats { totalCells: number; normalCount: number; warningCount: number; criticalCount: number; saturationFraction: number; phaseTransitionActive: boolean; phaseTransitionCells: number; } export declare class SaturationManager { private config; private cellStates; private phaseTransitionCells; private cellCount; constructor(config: SaturationConfig); /** * Check all cells against thresholds. Returns events for cells that changed state. */ update(): SaturationEvent[]; /** Get per-cell state field: 0=normal, 1=warning, 2=critical */ getStateField(): Uint8Array; /** Fraction of cells at or above warning level */ getSaturationFraction(): number; /** Whether any cell is currently undergoing a phase transition */ isPhaseTransitionActive(): boolean; getStats(): SaturationStats; /** Update the monitored field reference (e.g., after solver re-allocation) */ setField(field: RegularGrid3D | Float32Array): void; /** Update thresholds at runtime */ setThresholds(thresholds: Partial): void; dispose(): void; } //# sourceMappingURL=SaturationManager.d.ts.map