Granular.jl

Julia package for granular dynamics simulation
git clone git://src.adamsgaard.dk/Granular.jl
Log | Files | Refs | README | LICENSE

commit 4cb1c336f00a3cb7613e7ad2efb5a5de5e3cbc16
parent a7fa502a0cabd43a48bc28050cde84c0616e792d
Author: Anders Damsgaard <andersd@riseup.net>
Date:   Wed,  3 Jan 2018 15:09:17 -0500

Clamp interpolation values for better performance with regular grids

Diffstat:
Msrc/atmosphere.jl | 12++++--------
Msrc/ocean.jl | 9++-------
2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/atmosphere.jl b/src/atmosphere.jl @@ -174,18 +174,14 @@ function addAtmosphereDrag!(simulation::Simulation) atmosphere, i, j, grain.lin_pos) - if x_tilde < 0. || x_tilde > 1. || y_tilde < 0. || y_tilde > 1. - warn(""" - relative coordinates outside bounds ($(x_tilde), $(y_tilde)), - pos = $(grain.lin_pos) at i,j = $(i), $(j). - - """) - end + x_tilde = clamp(x_tilde, 0., 1.) + y_tilde = clamp(y_tilde, 0., 1.) bilinearInterpolation!(uv_interp, u, v, x_tilde, y_tilde, i, j, k, 1) applyAtmosphereDragToGrain!(grain, uv_interp[1], uv_interp[2]) applyAtmosphereVorticityToGrain!(grain, - curl(simulation.atmosphere, x_tilde, y_tilde, + curl(simulation.atmosphere, + x_tilde, y_tilde, i, j, k, 1, sw, se, ne, nw)) end nothing diff --git a/src/ocean.jl b/src/ocean.jl @@ -289,13 +289,8 @@ function addOceanDrag!(simulation::Simulation) x_tilde, y_tilde = getNonDimensionalCellCoordinates(simulation.ocean, i, j, grain.lin_pos) - if x_tilde < 0. || x_tilde > 1. || y_tilde < 0. || y_tilde > 1. - warn(""" - relative coordinates outside bounds ($(x_tilde), $(y_tilde)), - pos = $(grain.lin_pos) at i,j = $(i), $(j). - - """) - end + x_tilde = clamp(x_tilde, 0., 1.) + y_tilde = clamp(y_tilde, 0., 1.) bilinearInterpolation!(uv_interp, u, v, x_tilde, y_tilde, i, j, k, 1) applyOceanDragToGrain!(grain, uv_interp[1], uv_interp[2])