tDrop compatibility with Julia versions prior to 1.0, remove Compat.jl - Granul… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 8ce80d28d0c181205aa5674159f7e8a88caa01d6 | |
parent 04f42947eb5779be0ef3eab670bb72953ca3d531 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Sun, 12 Aug 2018 16:23:28 +0200 | |
Drop compatibility with Julia versions prior to 1.0, remove Compat.jl | |
Diffstat: | |
M REQUIRE | 1 - | |
M examples/double_gyre.jl | 13 ++++++------- | |
M examples/image.jl | 9 ++++----- | |
M examples/logo.jl | 25 ++++++++++++------------- | |
M examples/shear.jl | 3 +-- | |
M examples/strait.jl | 38 +++++++++++++++--------------… | |
M examples/two-grains.jl | 6 ++---- | |
M src/atmosphere.jl | 23 +++++++++++------------ | |
M src/contact_search.jl | 7 +++---- | |
M src/grain.jl | 5 ++--- | |
M src/grid.jl | 36 +++++++++++++++--------------… | |
M src/interaction.jl | 3 +-- | |
M src/io.jl | 84 +++++++++++++++--------------… | |
M src/ocean.jl | 40 ++++++++++++++++-------------… | |
M src/packing.jl | 9 ++++----- | |
M src/simulation.jl | 9 ++++----- | |
M src/temporal.jl | 6 ++---- | |
M src/temporal_integration.jl | 1 - | |
M src/wall.jl | 6 ++---- | |
M test/grain.jl | 2 +- | |
M test/vtk.jl | 4 ++-- | |
21 files changed, 153 insertions(+), 177 deletions(-) | |
--- | |
diff --git a/REQUIRE b/REQUIRE | |
t@@ -1,4 +1,3 @@ | |
julia 1.0 | |
WriteVTK | |
Documenter | |
-Compat 0.63.0 | |
diff --git a/examples/double_gyre.jl b/examples/double_gyre.jl | |
t@@ -1,7 +1,6 @@ | |
#!/usr/bin/env julia | |
import Granular | |
-import Compat | |
-using Compat.Random | |
+using Random | |
sim = Granular.createSimulation(id="double_gyre") | |
t@@ -36,7 +35,7 @@ r = minimum(L[1:2]./n[1:2])/2. | |
h = 1. | |
## N-S wall segments | |
-for y in Compat.range(r, stop=L[2]-r, length=Int(round((L[2] - 2.*r)/(r*2)))) | |
+for y in range(r, stop=L[2]-r, length=Int(round((L[2] - 2.*r)/(r*2)))) | |
Granular.addGrainCylindrical!(sim, [r, y], r, h, fixed=true, | |
verbose=false) | |
Granular.addGrainCylindrical!(sim, [L[1]-r, y], r, h, fixed=true, | |
t@@ -44,8 +43,8 @@ for y in Compat.range(r, stop=L[2]-r, length=Int(round((L[2]… | |
end | |
## E-W wall segments | |
-for x in Compat.range(3.*r, stop=L[1]-3.*r, | |
- length=Int(round((L[1] - 6.*r)/(r*2)))) | |
+for x in range(3.*r, stop=L[1]-3.*r, | |
+ length=Int(round((L[1] - 6.*r)/(r*2)))) | |
Granular.addGrainCylindrical!(sim, [x, r], r, h, fixed=true, | |
verbose=false) | |
Granular.addGrainCylindrical!(sim, [x, L[2]-r], r, h, fixed=true, | |
t@@ -53,7 +52,7 @@ for x in Compat.range(3.*r, stop=L[1]-3.*r, | |
end | |
n_walls = length(sim.grains) | |
-Compat.@info "added $(n_walls) fixed ice floes as walls" | |
+@info "added $(n_walls) fixed ice floes as walls" | |
t@@ -77,7 +76,7 @@ for y in (4.*r + noise_amplitude):(2.*r + floe_padding):(L[2… | |
end | |
end | |
n = length(sim.grains) - n_walls | |
-Compat.@info "added $(n) ice floes" | |
+@info "added $n ice floes" | |
# Remove old simulation files | |
Granular.removeSimulationFiles(sim) | |
diff --git a/examples/image.jl b/examples/image.jl | |
t@@ -3,8 +3,7 @@ | |
import Granular | |
import FileIO | |
import Colors | |
-import Compat | |
-using Compat.Random | |
+using Random | |
const verbose = true | |
t@@ -45,7 +44,7 @@ const h = .5 | |
sim = Granular.createSimulation(id="image") | |
-Compat.@info "nx = $nx, ny = $ny" | |
+@info "nx = $nx, ny = $ny" | |
for iy=1:size(img_bw, 1) | |
for ix=1:size(img_bw, 2) | |
t@@ -109,7 +108,7 @@ end | |
r = dx/4. | |
## N-S wall segments | |
-for y in Compat.range(r, stop=Ly-r, length=Int(round((Ly - 2.*r)/(r*2)))) | |
+for y in range(r, stop=Ly-r, length=Int(round((Ly - 2.*r)/(r*2)))) | |
Granular.addGrainCylindrical!(sim, [r, y], r, h, fixed=true, | |
youngs_modulus=youngs_modulus, | |
verbose=false) | |
t@@ -119,7 +118,7 @@ for y in Compat.range(r, stop=Ly-r, length=Int(round((Ly -… | |
end | |
## E-W wall segments | |
-for x in Compat.range(3.*r, stop=Lx-3.*r, length=Int(round((Lx - 6.*r)/(r*2)))) | |
+for x in range(3.*r, stop=Lx-3.*r, length=Int(round((Lx - 6.*r)/(r*2)))) | |
Granular.addGrainCylindrical!(sim, [x, r], r, h, fixed=true, | |
youngs_modulus=youngs_modulus, | |
verbose=false) | |
diff --git a/examples/logo.jl b/examples/logo.jl | |
t@@ -1,8 +1,7 @@ | |
#!/usr/bin/env julia | |
import Granular | |
-import Compat | |
-using Compat.Random | |
+using Random | |
const verbose = true | |
t@@ -55,7 +54,7 @@ const youngs_modulus = 2e6 | |
sim = Granular.createSimulation(id="logo") | |
print(logo_string) | |
-Compat.@info "nx = $nx, ny = $ny" | |
+@info "nx = $nx, ny = $ny" | |
for iy=1:length(logo_string_split) | |
for ix=1:length(logo_string_split[iy]) | |
t@@ -139,23 +138,23 @@ end | |
r = dx/4. | |
## N-S wall segments | |
-for y in Compat.range(r, stop=Ly-r, length=Int(round((Ly - 2.*r)/(r*2)))) | |
+for y in range(r, stop=Ly-r, length=Int(round((Ly - 2.*r)/(r*2)))) | |
Granular.addGrainCylindrical!(sim, [r, y], r, h, fixed=true, | |
- youngs_modulus=youngs_modulus, | |
- verbose=false) | |
+ youngs_modulus=youngs_modulus, | |
+ verbose=false) | |
Granular.addGrainCylindrical!(sim, [Lx-r, y], r, h, fixed=true, | |
- youngs_modulus=youngs_modulus, | |
- verbose=false) | |
+ youngs_modulus=youngs_modulus, | |
+ verbose=false) | |
end | |
## E-W wall segments | |
-for x in Compat.range(3.*r, stop=Lx-3.*r, length=Int(round((Lx - 6.*r)/(r*2)))) | |
+for x in range(3.*r, stop=Lx-3.*r, length=Int(round((Lx - 6.*r)/(r*2)))) | |
Granular.addGrainCylindrical!(sim, [x, r], r, h, fixed=true, | |
- youngs_modulus=youngs_modulus, | |
- verbose=false) | |
+ youngs_modulus=youngs_modulus, | |
+ verbose=false) | |
Granular.addGrainCylindrical!(sim, [x, Ly-r], r, h, fixed=true, | |
- youngs_modulus=youngs_modulus, | |
- verbose=false) | |
+ youngs_modulus=youngs_modulus, | |
+ verbose=false) | |
end | |
diff --git a/examples/shear.jl b/examples/shear.jl | |
t@@ -3,7 +3,6 @@ ENV["MPLBACKEND"] = "Agg" | |
import Granular | |
import JLD | |
import PyPlot | |
-import Compat | |
##############################################################################… | |
#### SIMULATION PARAMETERS … | |
t@@ -133,7 +132,7 @@ end | |
Granular.addWallLinearFrictionless!(sim, [0., 1.], y_top, | |
bc="normal stress", normal_stress=-N, | |
contact_viscosity_normal=1e3) | |
-Compat.@info "Placing top wall at y=$y_top" | |
+@info "Placing top wall at y=$y_top" | |
# Resize the grid to span the current state | |
Granular.fitGridToGrains!(sim, sim.ocean) | |
diff --git a/examples/strait.jl b/examples/strait.jl | |
t@@ -1,7 +1,6 @@ | |
#!/usr/bin/env julia | |
import SeaIce | |
-import Compat | |
-using Compat.Random | |
+using Random | |
sim = SeaIce.createSimulation(id="strait") | |
n = [10, 10, 2] | |
t@@ -24,15 +23,15 @@ h = 1. | |
## N-S segments | |
r_walls = r_min | |
-for y in Compat.range((L[2] - Ly_constriction)/2., | |
- stop=Ly_constriction + (L[2] - Ly_constriction)/2., | |
- length=Int(round(Ly_constriction/(r_walls*2)))) | |
+for y in range((L[2] - Ly_constriction)/2., | |
+ stop=Ly_constriction + (L[2] - Ly_constriction)/2., | |
+ length=Int(round(Ly_constriction/(r_walls*2)))) | |
SeaIce.addIceFloeCylindrical!(sim, [(Lx - Lx_constriction)/2., y], r_walls… | |
h, fixed=true, verbose=false) | |
end | |
-for y in Compat.range((L[2] - Ly_constriction)/2., | |
- stop=Ly_constriction + (L[2] - Ly_constriction)/2., | |
- length=Int(round(Ly_constriction/(r_walls*2)))) | |
+for y in range((L[2] - Ly_constriction)/2., | |
+ stop=Ly_constriction + (L[2] - Ly_constriction)/2., | |
+ length=Int(round(Ly_constriction/(r_walls*2)))) | |
SeaIce.addIceFloeCylindrical!(sim, | |
[Lx_constriction + | |
(L[1] - Lx_constriction)/2., y], r_walls, h… | |
t@@ -43,9 +42,9 @@ dx = 2.*r_walls*sin(atan((Lx - Lx_constriction)/(L[2] - Ly_c… | |
## NW diagonal | |
x = r_walls:dx:((Lx - Lx_constriction)/2.) | |
-y = Compat.range(L[2] - r_walls, | |
- stop=(L[2] - Ly_constriction)/2. + Ly_constriction + r_walls, | |
- length=length(x)) | |
+y = range(L[2] - r_walls, | |
+ stop=(L[2] - Ly_constriction)/2. + Ly_constriction + r_walls, | |
+ length=length(x)) | |
for i in 1:length(x) | |
SeaIce.addIceFloeCylindrical!(sim, [x[i], y[i]], r_walls, h, fixed=true, | |
verbose=false) | |
t@@ -53,9 +52,9 @@ end | |
## NE diagonal | |
x = (L[1] - r_walls):(-dx):((Lx - Lx_constriction)/2. + Lx_constriction) | |
-y = Compat.range(L[2] - r_walls, | |
- stop=(L[2] - Ly_constriction)/2. + Ly_constriction + r_walls, | |
- length=length(x)) | |
+y = range(L[2] - r_walls, | |
+ stop=(L[2] - Ly_constriction)/2. + Ly_constriction + r_walls, | |
+ length=length(x)) | |
for i in 1:length(x) | |
SeaIce.addIceFloeCylindrical!(sim, [x[i], y[i]], r_walls, h, fixed=true, | |
verbose=false) | |
t@@ -63,8 +62,8 @@ end | |
## SW diagonal | |
x = r_walls:dx:((Lx - Lx_constriction)/2.) | |
-y = Compat.range(r, stop=(L[2] - Ly_constriction)/2. - r_walls, | |
- length=length(x)) | |
+y = range(r, stop=(L[2] - Ly_constriction)/2. - r_walls, | |
+ length=length(x)) | |
for i in 1:length(x) | |
SeaIce.addIceFloeCylindrical!(sim, [x[i], y[i]], r_walls, h, fixed=true, | |
verbose=false) | |
t@@ -72,15 +71,14 @@ end | |
## SE diagonal | |
x = (L[1] - r_walls):(-dx):((Lx - Lx_constriction)/2. + Lx_constriction) | |
-y = Compat.range(r_walls, stop=(L[2] - Ly_constriction)/2. - r_walls, | |
- length=length(x)) | |
+y = range(r_walls, stop=(L[2] - Ly_constriction)/2. - r_walls, length=length(x… | |
for i in 1:length(x) | |
SeaIce.addIceFloeCylindrical!(sim, [x[i], y[i]], r_walls, h, fixed=true, | |
verbose=false) | |
end | |
n_walls = length(sim.ice_floes) | |
-Compat.@info "added $(n_walls) fixed ice floes as walls" | |
+@info "added $(n_walls) fixed ice floes as walls" | |
# Initialize ice floes in wedge north of the constriction | |
iy = 1 | |
t@@ -114,7 +112,7 @@ for y in (L[2] - r - noise_amplitude):(-(2.*r + floe_paddi… | |
iy += 1 | |
end | |
n = length(sim.ice_floes) - n_walls | |
-Compat.@info "added $(n) ice floes" | |
+@info "added $n ice floes" | |
# Remove old simulation files | |
SeaIce.removeSimulationFiles(sim) | |
diff --git a/examples/two-grains.jl b/examples/two-grains.jl | |
t@@ -1,6 +1,5 @@ | |
#!/usr/bin/env julia | |
import Granular | |
-import Compat | |
# Create the simulation object which, among other things, will hold all | |
# imformation on the simulated grains. You can call this object whatever you | |
t@@ -36,8 +35,7 @@ Granular.run!(sim) | |
E_kin_after = Granular.totalGrainKineticTranslationalEnergy(sim) | |
# Report these values to console | |
-Compat.@info "Kinetic energy before: $E_kin_before J" | |
-Compat.@info "Kinetic energy after: $E_kin_after J" | |
- | |
+@info "Kinetic energy before: $E_kin_before J" | |
+@info "Kinetic energy after: $E_kin_after J" | |
Granular.render(sim, animation=true) | |
diff --git a/src/atmosphere.jl b/src/atmosphere.jl | |
t@@ -1,6 +1,5 @@ | |
-import Compat | |
-using Compat.Test | |
-using Compat.LinearAlgebra | |
+using Test | |
+using LinearAlgebra | |
export createEmptyAtmosphere | |
"Returns empty ocean type for initialization purposes." | |
t@@ -81,22 +80,22 @@ function createRegularAtmosphereGrid(n::Vector{Int}, | |
bc_east::Integer = 1, | |
bc_north::Integer = 1) | |
- xq = repeat(Compat.range(origo[1], stop=origo[1] + L[1], length=n[1] + 1), | |
+ xq = repeat(range(origo[1], stop=origo[1] + L[1], length=n[1] + 1), | |
outer=[1, n[2] + 1]) | |
- yq = repeat(Compat.range(origo[2], stop=origo[2] + L[2], length=n[2] + 1)', | |
+ yq = repeat(range(origo[2], stop=origo[2] + L[2], length=n[2] + 1)', | |
outer=[n[1] + 1, 1]) | |
dx = L./n | |
- xh = repeat(Compat.range(origo[1] + .5*dx[1], | |
- stop=origo[1] + L[1] - .5*dx[1], | |
- length=n[1]), | |
+ xh = repeat(range(origo[1] + .5*dx[1], | |
+ stop=origo[1] + L[1] - .5*dx[1], | |
+ length=n[1]), | |
outer=[1, n[2]]) | |
- yh = repeat(Compat.range(origo[2] + .5*dx[2], | |
- stop=origo[1] + L[2] - .5*dx[2], | |
- length=n[2])', | |
+ yh = repeat(range(origo[2] + .5*dx[2], | |
+ stop=origo[1] + L[2] - .5*dx[2], | |
+ length=n[2])', | |
outer=[n[1], 1]) | |
- zl = -Compat.range(.5*dx[3], stop=L[3] - .5*dx[3], length=n[3]) | |
+ zl = -range(.5*dx[3], stop=L[3] - .5*dx[3], length=n[3]) | |
u = zeros(n[1] + 1, n[2] + 1, n[3], length(time)) | |
v = zeros(n[1] + 1, n[2] + 1, n[3], length(time)) | |
diff --git a/src/contact_search.jl b/src/contact_search.jl | |
t@@ -1,5 +1,4 @@ | |
-import Compat | |
-using Compat.LinearAlgebra | |
+using LinearAlgebra | |
## Contact mapping | |
export findContacts! | |
t@@ -308,9 +307,9 @@ function checkAndAddContact!(sim::Simulation, i::Int, j::I… | |
# Test if this contact exceeds the number of contacts | |
if ic == (sim.Nc_max + 1) | |
for ic=1:sim.Nc_max | |
- Compat.@warn "grains[$i].contacts[$ic] = " * | |
+ @warn "grains[$i].contacts[$ic] = " * | |
"$(sim.grains[i].contacts[ic])" | |
- Compat.@warn "grains[$i].contact_age[$ic] = " * | |
+ @warn "grains[$i].contact_age[$ic] = " * | |
"$(sim.grains[i].contact_age[ic])" | |
end | |
error("contact $i-$j exceeds max. number of " * | |
diff --git a/src/grain.jl b/src/grain.jl | |
t@@ -1,8 +1,7 @@ | |
## Manage grains in the model | |
-import Compat | |
-using Compat.Test | |
-using Compat.LinearAlgebra | |
+using Test | |
+using LinearAlgebra | |
export addGrainCylindrical! | |
""" | |
diff --git a/src/grid.jl b/src/grid.jl | |
t@@ -1,7 +1,6 @@ | |
import Random | |
-using Compat | |
-using Compat.LinearAlgebra | |
-using Compat.Random | |
+using LinearAlgebra | |
+using Random | |
""" | |
bilinearInterpolation(field, x_tilde, y_tilde, i, j, k, it) | |
t@@ -218,7 +217,7 @@ function sortGrainsInGrid!(simulation::Simulation, grid::A… | |
i > grid.n[1] || j > grid.n[2])) | |
if verbose | |
- Compat.@info "Disabling grain $idx at pos (" * | |
+ @info "Disabling grain $idx at pos (" * | |
"$(simulation.grains[idx].lin_pos))" | |
end | |
disableGrain!(simulation, idx) | |
t@@ -595,7 +594,7 @@ function findEmptyPositionInGridCell(simulation::Simulatio… | |
y_tilde = rand() | |
bilinearInterpolation!(pos, grid.xq, grid.yq, x_tilde, y_tilde, i, j) | |
if verbose | |
- Compat.@info "trying position $pos in cell $i,$j" | |
+ @info "trying position $pos in cell $i,$j" | |
end | |
# do not penetrate outside of grid boundaries | |
t@@ -629,8 +628,7 @@ function findEmptyPositionInGridCell(simulation::Simulatio… | |
if overlap < 0. | |
if verbose | |
- Compat.@info "overlap with $grain_idx in " * | |
- "cell $i,$j" | |
+ @info "overlap with $grain_idx in cell $i,$j" | |
end | |
overlap_found = true | |
break | |
t@@ -652,12 +650,12 @@ function findEmptyPositionInGridCell(simulation::Simulat… | |
if spot_found | |
if verbose | |
- Compat.@info "Found position $pos in cell $i,$j" | |
+ @info "Found position $pos in cell $i,$j" | |
end | |
return pos | |
else | |
if verbose | |
- Compat.@warn "could not insert an grain into " * | |
+ @warn "could not insert an grain into " * | |
"$(typeof(grid)) grid cell ($i, $j)" | |
end | |
return false | |
t@@ -743,22 +741,22 @@ function setGridBoundaryConditions!(grid::Any, | |
error("Mode '$mode' not recognized as a valid boundary condition type") | |
end | |
- if Compat.occursin("west", grid_face) || Compat.occursin("-x", grid_face) | |
+ if occursin("west", grid_face) || occursin("-x", grid_face) | |
grid.bc_west = grid_bc_flags[mode] | |
something_changed = true | |
end | |
- if Compat.occursin("south", grid_face) || Compat.occursin("-y", grid_face) | |
+ if occursin("south", grid_face) || occursin("-y", grid_face) | |
grid.bc_south = grid_bc_flags[mode] | |
something_changed = true | |
end | |
- if Compat.occursin("east", grid_face) || Compat.occursin("+x", grid_face) | |
+ if occursin("east", grid_face) || occursin("+x", grid_face) | |
grid.bc_east = grid_bc_flags[mode] | |
something_changed = true | |
end | |
- if Compat.occursin("north", grid_face) || Compat.occursin("+y", grid_face) | |
+ if occursin("north", grid_face) || occursin("+y", grid_face) | |
grid.bc_north = grid_bc_flags[mode] | |
something_changed = true | |
end | |
t@@ -1044,7 +1042,7 @@ function fitGridToGrains!(simulation::Simulation, grid::… | |
end | |
if verbose | |
- Compat.@info "Created regular $(typeof(grid)) grid from " * | |
+ @info "Created regular $(typeof(grid)) grid from " * | |
"[$min_x, $min_y] to [$max_x, $max_y] " * | |
"with a cell size of $dx ($n)." | |
end | |
t@@ -1055,14 +1053,14 @@ end | |
function findPorosity!(sim::Simulation, grid::Any; verbose::Bool=true) | |
if !isassigned(grid.grain_list) | |
- Compat.@info "Sorting grains in grid" | |
+ @info "Sorting grains in grid" | |
sortGrainsInGrid!(sim, grid, verbose=verbose) | |
end | |
- @compat sw = Vector{Float64}(undef, 2) | |
- @compat se = Vector{Float64}(undef, 2) | |
- @compat ne = Vector{Float64}(undef, 2) | |
- @compat nw = Vector{Float64}(undef, 2) | |
+ sw = Vector{Float64}(undef, 2) | |
+ se = Vector{Float64}(undef, 2) | |
+ ne = Vector{Float64}(undef, 2) | |
+ nw = Vector{Float64}(undef, 2) | |
cell_area = 0.0 | |
p = zeros(2) | |
r = 0.0 | |
diff --git a/src/interaction.jl b/src/interaction.jl | |
t@@ -1,6 +1,5 @@ | |
## Interaction functions | |
-import Compat | |
-using Compat.LinearAlgebra | |
+using LinearAlgebra | |
export interact! | |
""" | |
diff --git a/src/io.jl b/src/io.jl | |
t@@ -1,13 +1,11 @@ | |
import WriteVTK | |
-import Compat | |
-using Compat.LinearAlgebra | |
-using Compat.DelimitedFiles | |
-using Compat.Dates | |
- | |
+import Pkg | |
+import Dates | |
+using DelimitedFiles | |
hasJLD = false | |
if VERSION < v"0.7.0-alpha" | |
- if typeof(Compat.Pkg.installed("JLD")) == VersionNumber | |
+ if typeof(Pkg.installed("JLD")) == VersionNumber | |
import JLD | |
hasJLD = true | |
end | |
t@@ -37,7 +35,7 @@ function writeSimulation(simulation::Simulation; | |
folder::String=".", | |
verbose::Bool=true) | |
if !hasJLD | |
- Compat.@warn "Package JLD not found. " * | |
+ @warn "Package JLD not found. " * | |
"Simulation save/read not supported. " * | |
"Please install JLD and its " * | |
"requirements with `Pkg.add(\"JLD\")`." | |
t@@ -52,7 +50,7 @@ function writeSimulation(simulation::Simulation; | |
JLD.save(filename, "simulation", simulation) | |
if verbose | |
- Compat.@info "simulation written to $filename" | |
+ @info "simulation written to $filename" | |
end | |
end | |
nothing | |
t@@ -73,7 +71,7 @@ Return `Simulation` content read from disk using the JDL for… | |
function readSimulation(filename::String; | |
verbose::Bool=true) | |
if !hasJLD | |
- Compat.@warn "Package JLD not found. " * | |
+ @warn "Package JLD not found. " * | |
"Simulation save/read not supported. " * | |
"Please install JLD and its " * | |
"requirements with `Pkg.add(\"JLD\")`." | |
t@@ -81,7 +79,7 @@ function readSimulation(filename::String; | |
else | |
return JLD.load(filename, "simulation") | |
if verbose | |
- Compat.@info "Read simulation from $filename" | |
+ @info "Read simulation from $filename" | |
end | |
end | |
end | |
t@@ -104,7 +102,7 @@ function readSimulation(simulation::Simulation; | |
step::Integer = -1, | |
verbose::Bool = true) | |
if !hasJLD | |
- Compat.@warn "Package JLD not found. Simulation save/read not supporte… | |
+ @warn "Package JLD not found. Simulation save/read not supported. " * | |
"Please install JLD and its " * | |
"requirements with `Pkg.add(\"JLD\")`." | |
nothing | |
t@@ -114,7 +112,7 @@ function readSimulation(simulation::Simulation; | |
end | |
filename = string(simulation.id, "/", simulation.id, ".$step.jld") | |
if verbose | |
- Compat.@info "Read simulation from $filename" | |
+ @info "Read simulation from $filename" | |
end | |
return JLD.load(filename, "simulation") | |
end | |
t@@ -139,7 +137,7 @@ function writeSimulationStatus(simulation::Simulation; | |
simulation.time/simulation.time_total*100. | |
float(simulation.file_number)]) | |
if verbose | |
- Compat.@info "Wrote status to $filename" | |
+ @info "Wrote status to $filename" | |
end | |
nothing | |
end | |
t@@ -165,7 +163,7 @@ function readSimulationStatus(simulation_id::String; | |
data = readdlm(filename) | |
if verbose | |
- Compat.@info "$simulation_id:\n" * | |
+ @info "$simulation_id:\n" * | |
" time: $(data[1]) s\n" * | |
" complete: $(data[2])%\n" * | |
" last output file: $(Int(round(data[3])))\n" | |
t@@ -233,12 +231,12 @@ function status(folder::String="."; | |
status_files = String[] | |
println() | |
- println(Dates.format(DateTime(now()), Dates.RFC1123Format)) | |
+ println(Dates.format(Dates.DateTime(Dates.now()), Dates.RFC1123Format)) | |
for (root, dirs, files) in walkdir(folder, follow_symlinks=false) | |
for file in files | |
- if Compat.occursin(".status.txt", file) | |
+ if occursin(".status.txt", file) | |
push!(status_files, joinpath(root, file)) | |
end | |
end | |
t@@ -246,7 +244,7 @@ function status(folder::String="."; | |
if length(status_files) > 0 | |
- if Compat.Sys.iswindows() | |
+ if Sys.iswindows() | |
cols = 80 | |
else | |
cols = parse(Int, read(`tput cols`, String)) | |
t@@ -258,14 +256,14 @@ function status(folder::String="."; | |
println() | |
left_label_width = 36 | |
- Compat.printstyled("simulation folder ", color=:default) | |
+ printstyled("simulation folder ", color=:default) | |
right_labels_width = 22 | |
for i=18:cols-right_labels_width | |
print(' ') | |
end | |
- Compat.printstyled("time ", color=time_color) | |
- Compat.printstyled("complete ", color=percentage_color) | |
- Compat.printstyled("files\n", color=lastfile_color) | |
+ printstyled("time ", color=time_color) | |
+ printstyled("complete ", color=percentage_color) | |
+ printstyled("files\n", color=lastfile_color) | |
for i=1:cols | |
print('-') | |
end | |
t@@ -274,15 +272,15 @@ function status(folder::String="."; | |
for file in status_files | |
data = readdlm(file) | |
- id = Compat.replace(file, ".status.txt" => "") | |
- id = Compat.replace(id, "./" => "") | |
- id = Compat.replace(id, r".*/" => "") | |
+ id = replace(file, ".status.txt" => "") | |
+ id = replace(id, "./" => "") | |
+ id = replace(id, r".*/" => "") | |
percentage = @sprintf "%9.0f%%" data[2] | |
lastfile = @sprintf "%7d" data[3] | |
if data[2] < 99. | |
- Compat.printstyled("$id", color=id_color_in_progress) | |
+ printstyled("$id", color=id_color_in_progress) | |
else | |
- Compat.printstyled("$id", color=id_color_complete) | |
+ printstyled("$id", color=id_color_complete) | |
end | |
right_fields_width = 25 | |
for i=length(id):cols-right_fields_width | |
t@@ -297,9 +295,9 @@ function status(folder::String="."; | |
else # days | |
time = @sprintf "%6.2fd" data[1]/(60.0 * 60.0 * 24.0) | |
end | |
- Compat.printstyled("$time", color=time_color) | |
- Compat.printstyled("$percentage", color=percentage_color) | |
- Compat.printstyled("$lastfile\n", color=lastfile_color) | |
+ printstyled("$time", color=time_color) | |
+ printstyled("$percentage", color=percentage_color) | |
+ printstyled("$lastfile\n", color=lastfile_color) | |
if visualize | |
sim = createSimulation(id) | |
t@@ -313,7 +311,7 @@ function status(folder::String="."; | |
println() | |
end | |
else | |
- Compat.@warn "no simulations found in $(pwd())/$folder" | |
+ @warn "no simulations found in $(pwd())/$folder" | |
end | |
if loop && t_int > 0 | |
t@@ -485,7 +483,7 @@ function writeGrainVTK(simulation::Simulation, | |
outfiles = WriteVTK.vtk_save(vtkfile) | |
if verbose | |
- Compat.@info "Output file: $(outfiles[1])" | |
+ @info "Output file: $(outfiles[1])" | |
end | |
nothing | |
end | |
t@@ -849,7 +847,7 @@ function writeGridVTK(grid::Any, | |
outfiles = WriteVTK.vtk_save(vtkfile) | |
if verbose | |
- Compat.@info "Output file: $(outfiles[1])" | |
+ @info "Output file: $(outfiles[1])" | |
end | |
nothing | |
end | |
t@@ -1122,7 +1120,7 @@ FrameWindow=[0, $(simulation.file_number)]) | |
end | |
end | |
if verbose | |
- Compat.@info "$(filename) written, execute with " * | |
+ @info "$(filename) written, execute with " * | |
"'pvpython $(vtk_folder)/$(simulation.id).py'" | |
end | |
end | |
t@@ -1170,8 +1168,8 @@ function render(simulation::Simulation; pvpython::String… | |
rm("$(simulation.id)/$(simulation.id).avi") | |
end | |
catch return_signal | |
- if isa(return_signal, Base.UVError) | |
- Compat.@warn "Could not run external ffmpeg command, " * | |
+ if isa(return_signal, IOError) | |
+ @warn "Could not run external ffmpeg command, " * | |
"skipping conversion from " * | |
"$(simulation.id)/$(simulation.id).avi to mp4." | |
end | |
t@@ -1202,14 +1200,14 @@ function render(simulation::Simulation; pvpython::Stri… | |
$(simulation.id)/$(simulation.id)-reverse.gif`) | |
end | |
catch return_signal | |
- if isa(return_signal, Base.UVError) | |
- Compat.@warn "Skipping gif merge since `$convert` " * | |
+ if isa(return_signal, IOError) | |
+ @warn "Skipping gif merge since `$convert` " * | |
"was not found." | |
end | |
end | |
end | |
catch return_signal | |
- if isa(return_signal, Base.UVError) | |
+ if isa(return_signal, IOError) | |
error("`pvpython` was not found.") | |
end | |
end | |
t@@ -1293,7 +1291,7 @@ function plotGrainSizeDistribution(simulation::Simulatio… | |
gnuplotscript = Base.Filesystem.tempname() | |
#if maximum(diameters) ≈ minimum(diameters) | |
- #Compat.@info "Overriding `nbins = $nbins` -> `nbins = 1`." | |
+ #@info "Overriding `nbins = $nbins` -> `nbins = 1`." | |
#nbins = 1 | |
#end | |
t@@ -1320,13 +1318,13 @@ function plotGrainSizeDistribution(simulation::Simulat… | |
try | |
run(`gnuplot $gnuplotscript`) | |
catch return_signal | |
- if isa(return_signal, Base.UVError) | |
+ if isa(return_signal, IOError) | |
error("Could not launch external gnuplot process") | |
end | |
end | |
if verbose | |
- Compat.@info filename | |
+ @info filename | |
end | |
end | |
t@@ -1547,13 +1545,13 @@ function plotGrains(sim::Simulation; | |
try | |
run(`gnuplot $gnuplotscript`) | |
catch return_signal | |
- if isa(return_signal, Base.UVError) | |
+ if isa(return_signal, IOError) | |
error("Could not launch external gnuplot process") | |
end | |
end | |
if verbose | |
- Compat.@info filename | |
+ @info filename | |
end | |
if show_figure | |
diff --git a/src/ocean.jl b/src/ocean.jl | |
t@@ -1,10 +1,10 @@ | |
-import Compat | |
-using Compat.Test | |
-using Compat.LinearAlgebra | |
+import Pkg | |
+using Test | |
+using LinearAlgebra | |
hasNetCDF = false | |
if VERSION < v"0.7.0-alpha" | |
- if typeof(Compat.Pkg.installed("NetCDF")) == VersionNumber | |
+ if typeof(Pkg.installed("NetCDF")) == VersionNumber | |
import NetCDF | |
hasNetCDF = true | |
end | |
t@@ -16,7 +16,7 @@ else | |
end | |
end | |
if !hasNetCDF | |
- Compat.@warn "Package NetCDF not found. " * | |
+ @warn "Package NetCDF not found. " * | |
"Ocean/atmosphere grid read not supported. " * | |
"If required, install NetCDF and its " * | |
"requirements with `Pkg.add(\"NetCDF\")`." | |
t@@ -64,7 +64,7 @@ function readOceanNetCDF(velocity_file::String, grid_file::S… | |
regular_grid::Bool=false) | |
if !hasNetCDF | |
- Compat.@warn "Package NetCDF not found. " * | |
+ @warn "Package NetCDF not found. " * | |
"Ocean/atmosphere grid read not supported. " * | |
"Please install NetCDF and its " * | |
"requirements with `Pkg.add(\"NetCDF\")`." | |
t@@ -128,7 +128,7 @@ layer thicknesses, interface heights, and vertical coordin… | |
function readOceanStateNetCDF(filename::String) | |
if !hasNetCDF | |
- Compat.@warn "Package NetCDF not found. " * | |
+ @warn "Package NetCDF not found. " * | |
"Ocean/atmosphere grid read not supported. " * | |
"Please install NetCDF and its " * | |
"requirements with `Pkg.add(\"NetCDF\")`." | |
t@@ -169,7 +169,7 @@ located in the simulation `INPUT/` subdirectory. | |
function readOceanGridNetCDF(filename::String) | |
if !hasNetCDF | |
- Compat.@warn "Package NetCDF not found. " * | |
+ @warn "Package NetCDF not found. " * | |
"Ocean/atmosphere grid read not supported. " * | |
"Please install NetCDF and its " * | |
"requirements with `Pkg.add(\"NetCDF\")`." | |
t@@ -296,25 +296,25 @@ function createRegularOceanGrid(n::Vector{Int}, | |
bc_east::Integer = 1, | |
bc_north::Integer = 1) | |
- xq = repeat(Compat.range(origo[1], stop=origo[1] + L[1], | |
- length=n[1] + 1), | |
+ xq = repeat(range(origo[1], stop=origo[1] + L[1], | |
+ length=n[1] + 1), | |
outer=[1, n[2] + 1]) | |
- yq = repeat(Compat.range(origo[2], stop=origo[2] + L[2], | |
- length=n[2] + 1)', | |
+ yq = repeat(range(origo[2], stop=origo[2] + L[2], | |
+ length=n[2] + 1)', | |
outer=[n[1] + 1, 1]) | |
dx = L./n | |
- xh = repeat(Compat.range(origo[1] + .5*dx[1], | |
- stop=origo[1] + L[1] - .5*dx[1], | |
- length=n[1]), | |
+ xh = repeat(range(origo[1] + .5*dx[1], | |
+ stop=origo[1] + L[1] - .5*dx[1], | |
+ length=n[1]), | |
outer=[1, n[2]]) | |
- yh = repeat(Compat.range(origo[2] + .5*dx[2], | |
- stop=origo[2] + L[2] - .5*dx[2], | |
- length=n[2])', | |
+ yh = repeat(range(origo[2] + .5*dx[2], | |
+ stop=origo[2] + L[2] - .5*dx[2], | |
+ length=n[2])', | |
outer=[n[1], 1]) | |
- zl = -Compat.range(.5*dx[3], stop=L[3] - .5*dx[3], length=n[3]) | |
- zi = -Compat.range(0., stop=L[3], length=n[3] + 1) | |
+ zl = -range(.5*dx[3], stop=L[3] - .5*dx[3], length=n[3]) | |
+ zi = -range(0., stop=L[3], length=n[3] + 1) | |
u = zeros(n[1] + 1, n[2] + 1, n[3], length(time)) | |
v = zeros(n[1] + 1, n[2] + 1, n[3], length(time)) | |
diff --git a/src/packing.jl b/src/packing.jl | |
t@@ -1,8 +1,7 @@ | |
## Functions for creating grain packings | |
-import Compat | |
import Random | |
-using Compat.LinearAlgebra | |
-using Compat.Random | |
+using LinearAlgebra | |
+using Random | |
export regularPacking! | |
""" | |
t@@ -355,7 +354,7 @@ function irregularPacking!(simulation::Simulation; | |
if verbose | |
println("") | |
- Compat.@info "Generated $(length(simulation.grains) - np_init) points" | |
+ @info "Generated $(length(simulation.grains) - np_init) points" | |
end | |
end | |
t@@ -407,7 +406,7 @@ function rasterPacking!(sim::Simulation, | |
end | |
end | |
if verbose | |
- Compat.@info "Generated $(length(sim.grains) - np_init) points" | |
+ @info "Generated $(length(sim.grains) - np_init) points" | |
end | |
end | |
diff --git a/src/simulation.jl b/src/simulation.jl | |
t@@ -1,5 +1,4 @@ | |
-import Compat | |
-using Compat.Printf | |
+using Printf | |
## General simulation functions | |
t@@ -112,7 +111,7 @@ function run!(simulation::Simulation; | |
if simulation.ocean.xq ≈ simulation.atmosphere.xq && | |
simulation.ocean.yq ≈ simulation.atmosphere.yq | |
if verbose | |
- Compat.@info "identical ocean and atmosphere grids, " * | |
+ @info "identical ocean and atmosphere grids, " * | |
"turning on grid optimizations" | |
end | |
simulation.atmosphere.collocated_with_ocean_grid = true | |
t@@ -219,7 +218,7 @@ function addGrain!(simulation::Simulation, | |
push!(simulation.grains, grain) | |
if verbose | |
- Compat.@info "Added grain $(length(simulation.grains))" | |
+ @info "Added grain $(length(simulation.grains))" | |
end | |
nothing | |
end | |
t@@ -239,7 +238,7 @@ function addWall!(simulation::Simulation, | |
push!(simulation.walls, wall) | |
if verbose | |
- Compat.@info "Added wall $(length(simulation.walls))" | |
+ @info "Added wall $(length(simulation.walls))" | |
end | |
nothing | |
end | |
diff --git a/src/temporal.jl b/src/temporal.jl | |
t@@ -1,5 +1,3 @@ | |
-import Compat | |
- | |
export setTotalTime! | |
""" | |
setTotalTime!(simulation::Simulation, t::Float64) | |
t@@ -56,7 +54,7 @@ this value is zero or negative, no output files will be writ… | |
function setOutputFileInterval!(simulation::Simulation, t::Float64; | |
verbose=true) | |
if t <= 0.0 && verbose | |
- Compat.@info "No output files will be written" | |
+ @info "No output files will be written" | |
end | |
simulation.file_time_step = t | |
nothing | |
t@@ -163,7 +161,7 @@ function setTimeStep!(simulation::Simulation; | |
end | |
if verbose | |
- Compat.@info "Time step length t=$(simulation.time_step) s" | |
+ @info "Time step length t=$(simulation.time_step) s" | |
end | |
nothing | |
end | |
diff --git a/src/temporal_integration.jl b/src/temporal_integration.jl | |
t@@ -1,4 +1,3 @@ | |
-import Compat | |
export updateGrainKinematics! | |
""" | |
diff --git a/src/wall.jl b/src/wall.jl | |
t@@ -1,7 +1,5 @@ | |
## Manage dynamic walls in the model | |
-import Compat | |
- | |
export addWallLinearFrictionless! | |
""" | |
function addWallLinear!(simulation, normal, pos[, bc, mass, thickness, | |
t@@ -112,7 +110,7 @@ function addWallLinearFrictionless!(simulation::Simulation, | |
mass += grain.mass | |
end | |
if verbose | |
- Compat.@info "Setting wall mass to total grain mass: $mass kg" | |
+ @info "Setting wall mass to total grain mass: $mass kg" | |
end | |
end | |
t@@ -129,7 +127,7 @@ function addWallLinearFrictionless!(simulation::Simulation, | |
end | |
end | |
if verbose | |
- Compat.@info "Setting wall thickness to max grain thickness: $thic… | |
+ @info "Setting wall thickness to max grain thickness: $thickness m" | |
end | |
end | |
diff --git a/test/grain.jl b/test/grain.jl | |
t@@ -33,7 +33,7 @@ global gnuplot = true | |
try | |
run(`gnuplot --version`) | |
catch return_signal | |
- if isa(return_signal, Base.UVError) | |
+ if isa(return_signal, IOError) | |
@warn "Skipping plotting routines: Could not launch gnuplot process" | |
global gnuplot = false | |
end | |
diff --git a/test/vtk.jl b/test/vtk.jl | |
t@@ -76,7 +76,7 @@ Granular.writeParaviewPythonScript(sim, | |
try | |
run(`pvpython $(sim.id)/$(sim.id).py`) | |
catch return_signal | |
- if !isa(return_signal, Base.UVError) | |
+ if !isa(return_signal, IOError) | |
@test isfile("$(sim.id)/$(sim.id).avi") | |
end | |
end | |
t@@ -87,7 +87,7 @@ Granular.writeParaviewPythonScript(sim, | |
try | |
run(`pvpython $(sim.id)/$(sim.id).py`) | |
catch return_signal | |
- if !isa(return_signal, Base.UVError) | |
+ if !isa(return_signal, IOError) | |
@test isfile("$(sim.id)/$(sim.id).0000.png") | |
@test isfile("$(sim.id)/$(sim.id).0014.png") | |
Granular.render(sim) |