From fc8af1b3dc4bd6f3d3f908c6c033f8975d596a98 Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Mon, 10 Nov 2025 08:00:05 -0500 Subject: [PATCH 1/7] Update sim startup for ease of use --- src/simulation_components/simulation.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/simulation_components/simulation.jl b/src/simulation_components/simulation.jl index d79910f..486696a 100644 --- a/src/simulation_components/simulation.jl +++ b/src/simulation_components/simulation.jl @@ -219,7 +219,11 @@ function timestep_sim!(sim, tstep, start_tstep = 0) end # Required actions to setup simulation. Right now, this only entails setting up the simulation's logger. -function _startup_sim(sim, logger) +function startup_sim(sim, logger = nothing) + # Set up logger if needed + if isnothing(logger) + logger = SubzeroLogger(; sim, messages_per_tstep) + end global_logger(logger) # Start sim notice sim.verbose && println(sim.name * " is running!") @@ -227,7 +231,7 @@ function _startup_sim(sim, logger) end # Required actions to tear down simulation. Right now, this just involves flushing the simulation's logger and closing the stream. -function _teardown_sim(sim) +function teardown_sim(sim) # Finish logging logger = current_logger() if hasfield(typeof(logger), :stream) @@ -258,18 +262,14 @@ Simulation calculations will be done with Floats of type FT (Float64 of Float32) - None. The simulation will be run and outputs will be saved in the output folder. """ function run!(sim; logger = nothing, messages_per_tstep = 1, start_tstep = 0) - # Set up logger if needed - if isnothing(logger) - logger = SubzeroLogger(; sim, messages_per_tstep) - end - _startup_sim(sim, logger) + startup_sim(sim, logger) tstep = start_tstep while tstep <= (start_tstep + sim.nΔt) # Timestep the simulation forward timestep_sim!(sim, tstep, start_tstep) tstep+=1 end - _teardown_sim(sim) + teardown_sim(sim) return end From 477b9e0dda188381e55e927a967aa61220168c5f Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Sun, 16 Nov 2025 10:06:45 -0500 Subject: [PATCH 2/7] Re-add messages per timestep keyword --- src/simulation_components/simulation.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simulation_components/simulation.jl b/src/simulation_components/simulation.jl index 486696a..415e4ba 100644 --- a/src/simulation_components/simulation.jl +++ b/src/simulation_components/simulation.jl @@ -219,7 +219,7 @@ function timestep_sim!(sim, tstep, start_tstep = 0) end # Required actions to setup simulation. Right now, this only entails setting up the simulation's logger. -function startup_sim(sim, logger = nothing) +function startup_sim(sim, logger = nothing; messages_per_tstep = 1) # Set up logger if needed if isnothing(logger) logger = SubzeroLogger(; sim, messages_per_tstep) @@ -262,7 +262,7 @@ Simulation calculations will be done with Floats of type FT (Float64 of Float32) - None. The simulation will be run and outputs will be saved in the output folder. """ function run!(sim; logger = nothing, messages_per_tstep = 1, start_tstep = 0) - startup_sim(sim, logger) + startup_sim(sim, logger; messages_per_tstep) tstep = start_tstep while tstep <= (start_tstep + sim.nΔt) # Timestep the simulation forward From b6e6a1d5056581b17347fd920f0143a1fcb27e69 Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Sun, 16 Nov 2025 10:54:14 -0500 Subject: [PATCH 3/7] Debugging statment --- src/tools/geom_utils.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tools/geom_utils.jl b/src/tools/geom_utils.jl index 1d63cf7..71212c0 100644 --- a/src/tools/geom_utils.jl +++ b/src/tools/geom_utils.jl @@ -248,6 +248,9 @@ function _generate_voronoi_coords(::Type{FT}, desired_points::Int, Δx, Δy, xmi clip_vertices = (1, 2, 3, 4, 1) clip_polygon = (clip_points, clip_vertices) GO.voronoi(tuple.(xpoints, ypoints), FT; clip_polygon) + println("Voronoi") + println(length(xpoints)) + println(length(ypoints)) else Polys{FT}[] end From d5dd804ce7e44ed41c8b39a962297a8d38d6f07e Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Sun, 16 Nov 2025 11:01:28 -0500 Subject: [PATCH 4/7] Fix debugging statement --- src/tools/geom_utils.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/geom_utils.jl b/src/tools/geom_utils.jl index 71212c0..23523f7 100644 --- a/src/tools/geom_utils.jl +++ b/src/tools/geom_utils.jl @@ -246,11 +246,12 @@ function _generate_voronoi_coords(::Type{FT}, desired_points::Int, Δx, Δy, xmi xmax, ymax = xmin + Δx, ymin + Δy clip_points = GO.tuples(((xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax)), FT) clip_vertices = (1, 2, 3, 4, 1) - clip_polygon = (clip_points, clip_vertices) - GO.voronoi(tuple.(xpoints, ypoints), FT; clip_polygon) println("Voronoi") println(length(xpoints)) println(length(ypoints)) + println(clip_points) + clip_polygon = (clip_points, clip_vertices) + GO.voronoi(tuple.(xpoints, ypoints), FT; clip_polygon) else Polys{FT}[] end From 10932f6d06f5b938268c5e06e817acbdb759ff0b Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Sun, 16 Nov 2025 17:07:41 -0500 Subject: [PATCH 5/7] Remove debug printing --- src/tools/geom_utils.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tools/geom_utils.jl b/src/tools/geom_utils.jl index 23523f7..1d63cf7 100644 --- a/src/tools/geom_utils.jl +++ b/src/tools/geom_utils.jl @@ -246,10 +246,6 @@ function _generate_voronoi_coords(::Type{FT}, desired_points::Int, Δx, Δy, xmi xmax, ymax = xmin + Δx, ymin + Δy clip_points = GO.tuples(((xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax)), FT) clip_vertices = (1, 2, 3, 4, 1) - println("Voronoi") - println(length(xpoints)) - println(length(ypoints)) - println(clip_points) clip_polygon = (clip_points, clip_vertices) GO.voronoi(tuple.(xpoints, ypoints), FT; clip_polygon) else From de13c18b6904c4c3bb1d4cc38b3dd5777e98cb60 Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Sun, 16 Nov 2025 17:42:44 -0500 Subject: [PATCH 6/7] Add in try catch --- src/tools/geom_utils.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/geom_utils.jl b/src/tools/geom_utils.jl index 1d63cf7..fc5da56 100644 --- a/src/tools/geom_utils.jl +++ b/src/tools/geom_utils.jl @@ -247,7 +247,14 @@ function _generate_voronoi_coords(::Type{FT}, desired_points::Int, Δx, Δy, xmi clip_points = GO.tuples(((xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax)), FT) clip_vertices = (1, 2, 3, 4, 1) clip_polygon = (clip_points, clip_vertices) - GO.voronoi(tuple.(xpoints, ypoints), FT; clip_polygon) + try + GO.voronoi(tuple.(xpoints, ypoints), FT; clip_polygon) + catch + print(xpoints) + print(ypoints) + print(clip_points) + Polys{FT}[] + end else Polys{FT}[] end From 400a7b96624bb3f1922c428c4e1c708ec73ebc46 Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Sun, 16 Nov 2025 19:27:41 -0500 Subject: [PATCH 7/7] Add in try/catch and info output when voronoi fails --- src/tools/geom_utils.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tools/geom_utils.jl b/src/tools/geom_utils.jl index fc5da56..da9f13a 100644 --- a/src/tools/geom_utils.jl +++ b/src/tools/geom_utils.jl @@ -250,9 +250,7 @@ function _generate_voronoi_coords(::Type{FT}, desired_points::Int, Δx, Δy, xmi try GO.voronoi(tuple.(xpoints, ypoints), FT; clip_polygon) catch - print(xpoints) - print(ypoints) - print(clip_points) + @info "Voronoi failed - floe to fracture likely really small." tstep = tstep Polys{FT}[] end else