Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/simulation_components/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,19 @@ 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; messages_per_tstep = 1)
# 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!")
return
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)
Expand Down Expand Up @@ -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; messages_per_tstep)
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

Expand Down
7 changes: 6 additions & 1 deletion src/tools/geom_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,12 @@ 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
@info "Voronoi failed - floe to fracture likely really small." tstep = tstep
Polys{FT}[]
end
else
Polys{FT}[]
end
Expand Down
Loading