Skip to content

Commit

Permalink
Remove unneeded time argument
Browse files Browse the repository at this point in the history
  • Loading branch information
skygering committed Jul 1, 2024
1 parent 3c0a2d7 commit aca4f19
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 94 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ floe_arr = initialize_floe_field(
[0.7], # floe concentration
domain,
0.5, # average floe height
0.05, # floe height variability
10; # length of timestep in seconds
0.05; # floe height variability
floe_settings = floe_settings,
)
# Create model
Expand Down
6 changes: 2 additions & 4 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ floe_field = initialize_floe_field(
[floe1, floe2],
domain,
0.25, # mean height of 0.25
0.0, # all floes will be the same height
Δt; # timestep of simulation in seconds
0.0; # all floes will be the same height
rng = Xoshiro(1),
floe_settings = floe_settings,
)
Expand All @@ -336,8 +335,7 @@ floe_arr = initialize_floe_field(
[1.0; 0.0], # the top half of the domain is fully packed and the bottom has no floes
domain,
0.25, # mean height of 0.25
0.10, # floe heights will range from 0.15-0.35
Δt; # Simulation timestep in seconds
0.10; # floe heights will range from 0.15-0.35
floe_settings = floe_settings,
rng = Xoshiro(1),
)
Expand Down
3 changes: 1 addition & 2 deletions examples/converge_diverge_flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ floe_arr = initialize_floe_field(
[0.8],
domain,
hmean,
Δh,
Δt;
Δh;
rng = Xoshiro(1),
)

Expand Down
3 changes: 1 addition & 2 deletions examples/forcing_contained_floes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ floe_arr = initialize_floe_field(
[0.4],
domain,
hmean,
Δh,
Δt;
Δh;
floe_bounds = floe_bounds,
rng = Xoshiro(1),
floe_settings = floe_settings
Expand Down
2 changes: 1 addition & 1 deletion examples/many_floes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ nfloes = 100
file = jldopen("examples/floe_shapes.jld2", "r")
nfloes = nfloes > size(file["floe_vertices"], 1) ? size(file["floe_vertices"], 1) : nfloes
floe_coords = file["floe_vertices"][1:1]
floe_arr = initialize_floe_field(FT, floe_coords, domain, hmean, Δh, Δt)
floe_arr = initialize_floe_field(FT, floe_coords, domain, hmean, Δh)
close(file)

model = Model(grid, ocean, atmos, domain, floe_arr)
Expand Down
3 changes: 1 addition & 2 deletions examples/moving_bounds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ floe_arr = initialize_floe_field(
[1.0],
domain,
hmean,
Δh,
Δt;
Δh;
rng = Xoshiro(1),
)
nfloes = length(floe_arr)
Expand Down
3 changes: 1 addition & 2 deletions examples/restart_sim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ floe_arr = initialize_floe_field(
[concentration],
domain,
hmean,
0,
Δt;
0;
rng = Xoshiro(1),
floe_settings = floe_settings
)
Expand Down
3 changes: 1 addition & 2 deletions examples/shear_flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ floe_arr = initialize_floe_field(
[0.8],
domain,
hmean,
Δh,
Δt;
Δh;
rng = Xoshiro(1),
floe_settings = floe_settings
)
Expand Down
3 changes: 1 addition & 2 deletions examples/simple_strait.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ floe_arr = initialize_floe_field(
[0.7],
domain,
hmean,
Δh,
Δt;
Δh;
rng = Xoshiro(3),
floe_settings = floe_settings,
)
Expand Down
6 changes: 2 additions & 4 deletions examples/test_run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ function setup_floes_with_inters(coords, domain, consts,
coords,
domain,
1.0,
0.0,
Δt,
0.0;
)
if !isnothing(Δx)
for i in eachindex(Δx)
Expand Down Expand Up @@ -165,8 +164,7 @@ floe_arr = initialize_floe_field(
[0.8],
domain,
0.5,
0.0,
Δt;
0.0;
floe_settings = floe_settings,
rng = Xoshiro(1),
)
Expand Down
3 changes: 1 addition & 2 deletions examples/uniform_flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ floe_arr = initialize_floe_field(
[0.4],
domain,
hmean,
Δh,
Δt;
Δh;
rng = Xoshiro(1),
)

Expand Down
1 change: 0 additions & 1 deletion src/physical_processes/fractures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ function split_floe(
pieces_polys[i],
height,
0, # Δh - range of random height difference between floes
Δt,
floe.rmax;
floe_settings = floe_settings,
rng = rng,
Expand Down
21 changes: 5 additions & 16 deletions src/simulation_components/floe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ end
poly,
hmean,
Δh,
Δt,
rmax;
floe_settings,
rng = Xoshiro(),
Expand All @@ -265,7 +264,6 @@ Inputs:
hmean <AbstratFloat> average floe height
Δh <AbstratFloat> height range - floes will range in height
from hmean - Δh to hmean + Δh
Δt <Int> timestep of simulation in seconds
rmax <AbstractFloat> maximum radius of floe (could be larger given context)
floe_settings <FloeSettings> settings needed to initialize floe
settings
Expand All @@ -279,7 +277,6 @@ function poly_to_floes!(
poly,
hmean,
Δh,
Δt,
rmax;
floe_settings = FloeSettings(min_floe_area = 0),
rng = Xoshiro(),
Expand All @@ -304,7 +301,7 @@ function poly_to_floes!(
new_regions = GO.cut(poly, GI.Line([(cx - rmax, cy), (cx + rmax, cy)]), FT)
n = 0
for r in new_regions
n += poly_to_floes!(FT, floes, r, hmean, Δh, Δt, rmax;
n += poly_to_floes!(FT, floes, r, hmean, Δh, rmax;
floe_settings = floe_settings, rng = rng, kwargs...)
end
return n
Expand Down Expand Up @@ -339,8 +336,7 @@ initialize_floe_field(::Type{FT}, args...; kwargs...) where FT =
coords,
domain,
hmean,
Δh,
Δt;
Δh;
floe_settings,
rng,
)
Expand All @@ -355,7 +351,6 @@ Inputs:
hmean <Float> average floe height
Δh <Float> height range - floes will range in height from
hmean ± Δh
Δt <Int> simulation timestep in seconds
floe_settings <FloeSettings> settings needed to initialize floes
rng <RNG> random number generator to generate random floe
attributes - default uses Xoshiro256++ algorithm
Expand All @@ -368,8 +363,7 @@ function _initialize_floe_field(
coords::V,
domain,
hmean,
Δh,
Δt;
Δh;
floe_settings = FloeSettings(min_floe_area = 0.0),
rng = Xoshiro(),
supress_warnings = false,
Expand All @@ -388,7 +382,6 @@ function _initialize_floe_field(
p,
hmean,
Δh,
Δt,
domain.east.val - domain.west.val;
floe_settings = floe_settings,
rng = rng,
Expand Down Expand Up @@ -519,8 +512,7 @@ end
concentrations,
domain,
hmean,
Δh,
Δt;
Δh;
floe_settings,
rng,
)
Expand All @@ -543,7 +535,6 @@ Inputs:
hmean <Float> average floe height
Δh <Float> height range - floes will range in height from
hmean - Δh to hmean + Δh
Δt <Int> simulation timestep in seconds
floe_bounds <PolyVec> coordinates of boundary within which to populate floes. This
can be smaller that the domain, but will be limited to open space
within the domain
Expand All @@ -560,8 +551,7 @@ function _initialize_floe_field(
concentrations,
domain,
hmean,
Δh,
Δt;
Δh;
floe_bounds = _make_bounding_box_polygon(FT, domain.west.val, domain.east.val, domain.south.val, domain.north.val),
floe_settings = FloeSettings(FT, min_floe_area = 0),
rng = Xoshiro(),
Expand Down Expand Up @@ -626,7 +616,6 @@ function _initialize_floe_field(
piece,
hmean,
Δh,
Δt,
domain.east.val - domain.west.val;
floe_settings = floe_settings,
rng = rng,
Expand Down
6 changes: 2 additions & 4 deletions test/qualitative_behavior.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ zonal_3rect_floes = initialize_floe_field(
],
collision_domain_topo,
hmean,
Δh,
Δt,
Δh;
)
zonal_3rect_floes.u .= [3.0, -3.0, 0.0]

Expand Down Expand Up @@ -298,8 +297,7 @@ funky_floe_arr = initialize_floe_field(
funky_floe_coords,
collision_domain_topo,
hmean,
Δh,
Δt,
Δh;
)
close(file)
funky_floe_arr.u .= (-1)^rand(0:1) * (0.1 * rand(length(funky_floe_arr)))
Expand Down
15 changes: 5 additions & 10 deletions test/test_conservation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ end
[floe1, floe2],
open_domain, # Just affects shape, type doesn't matter
0.25,
0.0,
Δt;
0.0;
rng = rng,
floe_settings = floe_settings,
)
Expand All @@ -124,8 +123,7 @@ end
[floe1, Subzero.translate(floe2, 0.0, 1e4)],
open_domain, # Just affects shape, type doesn't matter
0.25,
0.0,
Δt;
0.0;
rng = rng,
floe_settings = floe_settings,
)
Expand All @@ -147,8 +145,7 @@ end
[floe1, floe2, floe3],
open_domain, # Just affects shape, type doesn't matter
0.25,
0.0,
Δt;
0.0;
rng = rng,
floe_settings = floe_settings,
)
Expand Down Expand Up @@ -176,8 +173,7 @@ end
],
open_domain,
0.25,
0.0,
Δt;
0.0;
rng = rng,
)
close(file)
Expand All @@ -202,8 +198,7 @@ end
[floe_on_wall_topo],
open_domain_w_topography,
0.25,
0.0,
Δt;
0.0;
rng = rng,
)
close(file)
Expand Down
24 changes: 9 additions & 15 deletions test/test_floe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@
rmax_cpoly = 2sqrt(5^2 + 5^2)
# Test polygon with no holes
floe_arr = StructArray{Floe{FT}}(undef, 0)
n_new = Subzero.poly_to_floes!(FT, floe_arr, rect_poly, hmean, Δh, Δt, rmax_rect)
n_new = Subzero.poly_to_floes!(FT, floe_arr, rect_poly, hmean, Δh, rmax_rect)
@test n_new == 1 && length(floe_arr) == 1
@test !Subzero.hashole(floe_arr.coords[1])

# Test with polygon below minimum floe area
n_new = Subzero.poly_to_floes!(FT, floe_arr, rect_poly, hmean, Δh, Δt, rmax_rect; floe_settings = fs_small_min_area)
n_new = Subzero.poly_to_floes!(FT, floe_arr, rect_poly, hmean, Δh, rmax_rect; floe_settings = fs_small_min_area)
@test n_new == 0 && length(floe_arr) == 1

# Test with polygon with a hole that is split into 3 polyons
n_new = Subzero.poly_to_floes!(FT, floe_arr, c_hole_poly, hmean, Δh, Δt, rmax_cpoly)
n_new = Subzero.poly_to_floes!(FT, floe_arr, c_hole_poly, hmean, Δh, rmax_cpoly)
@test n_new == 3 && length(floe_arr) == 4
@test !any(Subzero.hashole.(floe_arr.coords))

Expand Down Expand Up @@ -94,8 +94,7 @@
floe_coords,
domain_no_topo,
0.5,
0.1,
Δt;
0.1;
))
nfloes = length(floe_coords)
@test typeof(floe_arr) <: StructArray{<:Floe}
Expand All @@ -115,8 +114,7 @@
floe_coords,
small_domain_no_topo,
hmean,
Δh,
Δt;
Δh;
floe_settings = FloeSettings(min_floe_area = 1e5),
))
@test typeof(floe_arr) <: StructArray{<:Floe}
Expand All @@ -128,8 +126,7 @@
floe_coords,
domain_with_topo,
hmean,
Δh,
Δt;
Δh;
floe_settings = FloeSettings(min_floe_area = 10),
rng = Xoshiro(0)
)
Expand Down Expand Up @@ -178,8 +175,7 @@
[0.5],
domain_with_topo,
0.5,
0.1,
Δt;
0.1;
floe_settings = FloeSettings(min_floe_area = 1e4),
rng = Xoshiro(1)
)
Expand All @@ -204,8 +200,7 @@
concentrations,
domain_with_topo,
0.5,
0.1,
Δt;
0.1;
floe_settings = FloeSettings(min_floe_area = 1e4),
rng = rng
)
Expand Down Expand Up @@ -236,7 +231,6 @@
concentrations,
domain_with_topo,
0.5,
0.1,
Δt;
0.1;
)) <: StructArray{<:Floe{Float32}}
end
Loading

0 comments on commit aca4f19

Please sign in to comment.