Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.
C#
The run's last log line says where its frames landed: in memory and on disk
Alexander Graefec52e9472afc
diff --git a/WaveDudeNext.WPF/MainWindow.Simulation.cs b/WaveDudeNext.WPF/MainWindow.Simulation.csindex c48b0b5..7a8fe79 100644--- a/WaveDudeNext.WPF/MainWindow.Simulation.cs+++ b/WaveDudeNext.WPF/MainWindow.Simulation.cs@@ -114,8 +114,8 @@ public partial class MainWindow}};run.Finished += (_, _) => OnRunFinished();- Logger.Info("{Kind} started: {Steps} steps, {Stored} of {Frames} frames stored as {Width}×{Height} ({Quality}), {RamFrames} in memory ({RamBytes}) and {DiskFrames} on disk; edits made from now on do not affect it",- automatic ? "Re-run" : "Run", spec.Steps, spec.StoredFrameCount, spec.FrameCount, spec.Shape.Width, spec.Shape.Height, spec.Quality, store.RamFrames, FrameMemory.Gigabytes(store.RamBytes), spec.StoredFrameCount - store.RamFrames);+ Logger.Info("{Kind} started: {Steps} steps, {Stored} of {Frames} frames stored as {Width}×{Height} ({Quality}), {RamFrames} in memory ({RamBytes:0.0} GB) and {DiskFrames} on disk; edits made from now on do not affect it",+ automatic ? "Re-run" : "Run", spec.Steps, spec.StoredFrameCount, spec.FrameCount, spec.Shape.Width, spec.Shape.Height, spec.Quality, store.RamFrames, FrameMemory.ToGigabytes(store.RamBytes), spec.StoredFrameCount - store.RamFrames);IsRunStale = false;IsProbesStale = false;Run = run;diff --git a/WaveDudeNext.WPF/MainWindow.xaml.cs b/WaveDudeNext.WPF/MainWindow.xaml.csindex 25100ae..1a9e6b3 100644--- a/WaveDudeNext.WPF/MainWindow.xaml.cs+++ b/WaveDudeNext.WPF/MainWindow.xaml.cs@@ -99,9 +99,16 @@ public partial class MainWindow : Window}else if (args.PropertyName == nameof(Settings.FrameMemoryPercent)){- Logger.Info("RAM cache size: {Bound}, {Budget} right now (Simulation menu)",- Settings.Default.FrameMemoryPercent <= FrameMemory.Automatic ? "automatic (what is free minus " + FrameMemory.Gigabytes(FrameMemory.Margin) + ")" : "at most " + Settings.Default.FrameMemoryPercent + " % of the RAM",- FrameMemory.Gigabytes(FrameMemory.Budget(Settings.Default.FrameMemoryPercent)));+ int percent = Settings.Default.FrameMemoryPercent;+ double budget = FrameMemory.ToGigabytes(FrameMemory.Budget(percent));+ if (percent <= FrameMemory.Automatic)+ {+ Logger.Info("RAM cache size: automatic (what is free minus {Margin:0.0} GB), {Budget:0.0} GB right now (Simulation menu)", FrameMemory.ToGigabytes(FrameMemory.Margin), budget);+ }+ else+ {+ Logger.Info("RAM cache size: at most {Percent} % of the RAM, {Budget:0.0} GB right now (Simulation menu)", percent, budget);+ }}else if (args.PropertyName is nameof(Settings.PreviewResolution) or nameof(Settings.PreviewFrames) or nameof(Settings.PreviewSampleBytes)){diff --git a/WaveDudeNext/Runs/FrameMemory.cs b/WaveDudeNext/Runs/FrameMemory.csindex 9ab9702..0e2c44b 100644--- a/WaveDudeNext/Runs/FrameMemory.cs+++ b/WaveDudeNext/Runs/FrameMemory.cs@@ -89,8 +89,11 @@ public static class FrameMemoryreturn Math.Max(0, Math.Min(byShare, byAvailable));}- /// <summary>A byte count as gigabytes with one decimal, for log lines.</summary>- public static string Gigabytes(long bytes) => (bytes / (double)(1L << 30)).ToString("0.0", System.Globalization.CultureInfo.CurrentCulture) + " GB";+ /// <summary>A byte count as gigabytes with one decimal and the unit, in the current culture, for the UI.</summary>+ public static string Gigabytes(long bytes) => ToGigabytes(bytes).ToString("0.0", System.Globalization.CultureInfo.CurrentCulture) + " GB";++ /// <summary>A byte count in gigabytes (2^30 bytes), for a log line's <c>{Name:0.0} GB</c>, which NLog formats invariantly.</summary>+ public static double ToGigabytes(long bytes) => bytes / (double)(1L << 30);private static bool TryStatus(out MemoryStatus status){diff --git a/WaveDudeNext/Runs/SimulationRun.cs b/WaveDudeNext/Runs/SimulationRun.csindex 80c7054..bbc0126 100644--- a/WaveDudeNext/Runs/SimulationRun.cs+++ b/WaveDudeNext/Runs/SimulationRun.cs@@ -399,6 +399,8 @@ public sealed class SimulationRun : INotifyPropertyChanged, IDisposableTimeSpan elapsed = stopwatch.Elapsed;int finalSteps = stepsDone;int finalFrames = CoveredFrames(Store.Count);+ // where the stored frames landed, which the start line can only plan: a failed allocation sends the rest to disk+ int inMemory = Store.FramesInMemory, onDisk = Store.FramesOnDisk;Post(() =>{StepsDone = finalSteps;@@ -406,7 +408,9 @@ public sealed class SimulationRun : INotifyPropertyChanged, IDisposableElapsed = elapsed;Error = error;State = final;- Logger.Info("Run {0}: {1} of {2} steps, {3} frames, {4:0.0} s", final, finalSteps, Spec.Steps, finalFrames, elapsed.TotalSeconds);+ Logger.Info("Run {0}: {1} of {2} steps, {3} frames, {4:0.0} s; {5} stored, {6} in memory ({7:0.0} GB) and {8} on disk ({9:0.0} GB)",+ final, finalSteps, Spec.Steps, finalFrames, elapsed.TotalSeconds, inMemory + onDisk,+ inMemory, FrameMemory.ToGigabytes(inMemory * Store.FrameBytes), onDisk, FrameMemory.ToGigabytes(onDisk * Store.FrameBytes));Finished?.Invoke(this, EventArgs.Empty);});_completion.TrySetResult();