commit 9d82b206e18192fe95628cc69abc2984e6634cef
parent 12b44c7478f12efc5b9d145c56bdc32b66e1c43c
Author: Anders Damsgaard <andersd@riseup.net>
Date: Thu, 22 Jun 2017 16:55:57 -0400
avoid allocating unnecessary arrays
Diffstat:
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/grid.jl b/src/grid.jl
@@ -88,6 +88,7 @@ function sortIceFloesInGrid!(simulation::Simulation, grid::Any; verbose=false)
grid.ice_floe_list =
Array{Array{Int, 1}}(size(grid.xh, 1), size(grid.xh, 2))
+ #fill!(grid.ice_floe_list, Int[])
for i=1:size(grid.xh, 1)
for j=1:size(grid.xh, 2)
grid.ice_floe_list[i, j] = Int[]
diff --git a/src/simulation.jl b/src/simulation.jl
@@ -223,7 +223,7 @@ export zeroForcesAndTorques!
"Sets the `force` and `torque` values of all ice floes to zero."
function zeroForcesAndTorques!(simulation::Simulation)
for icefloe in simulation.ice_floes
- icefloe.force = zeros(2)
+ fill!(icefloe.force, 0.)
icefloe.torque = 0.
icefloe.pressure = 0.
end
diff --git a/src/temporal_integration.jl b/src/temporal_integration.jl
@@ -49,7 +49,7 @@ function updateIceFloeKinematicsTwoTermTaylor!(icefloe::IceFloeCylindrical,
icefloe.ang_acc = icefloe.torque/icefloe.moment_of_inertia
if icefloe.fixed
- icefloe.lin_acc = zeros(2)
+ fill!(icefloe.lin_acc, 0.)
icefloe.ang_acc = 0.
elseif !icefloe.rotating
icefloe.ang_acc = 0.
@@ -86,7 +86,7 @@ function updateIceFloeKinematicsThreeTermTaylor!(icefloe::IceFloeCylindrical,
icefloe.ang_acc = icefloe.torque/icefloe.moment_of_inertia
if icefloe.fixed
- icefloe.lin_acc = zeros(2)
+ fill!(icefloe.lin_acc, 0.)
icefloe.ang_acc = 0.
elseif !icefloe.rotating
icefloe.ang_acc = 0.