tavoid allocating unnecessary arrays - Granular.jl - Julia package for granular… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 9d82b206e18192fe95628cc69abc2984e6634cef | |
parent 12b44c7478f12efc5b9d145c56bdc32b66e1c43c | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 22 Jun 2017 16:55:57 -0400 | |
avoid allocating unnecessary arrays | |
Diffstat: | |
M src/grid.jl | 1 + | |
M src/simulation.jl | 2 +- | |
M src/temporal_integration.jl | 4 ++-- | |
3 files changed, 4 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/src/grid.jl b/src/grid.jl | |
t@@ -88,6 +88,7 @@ function sortIceFloesInGrid!(simulation::Simulation, grid::A… | |
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 | |
t@@ -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 | |
t@@ -49,7 +49,7 @@ function updateIceFloeKinematicsTwoTermTaylor!(icefloe::IceF… | |
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. | |
t@@ -86,7 +86,7 @@ function updateIceFloeKinematicsThreeTermTaylor!(icefloe::Ic… | |
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. |