From 49ec726252dc21b13aec35ae560b3ac2bf4bcc5c Mon Sep 17 00:00:00 2001 From: Chris Maffeo <cmaffeo2@illinois.edu> Date: Wed, 27 Jan 2016 20:21:50 -0600 Subject: [PATCH] improved RBGrid->getPosition by eschewing modulo; now performance on par with 3D kernel --- ComputeGridGrid.cuh | 2 +- RigidBodyGrid.cu | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ComputeGridGrid.cuh b/ComputeGridGrid.cuh index f78b705..1861ed7 100644 --- a/ComputeGridGrid.cuh +++ b/ComputeGridGrid.cuh @@ -34,7 +34,7 @@ void computeGridGridForce(const RigidBodyGrid* rho, const RigidBodyGrid* u, /* Vector3 tmpf = Vector3(0.0f); */ /* float tmpe = 0.0f; */ /* const ForceEnergy fe = ForceEnergy( tmpf, tmpe); */ - const ForceEnergy fe = u->interpolateForceD( u_ijk_float ); /* in coord frame of u */ + const ForceEnergy fe = u->interpolateForceDLinearly( u_ijk_float ); /* in coord frame of u */ force[tid] = fe.f; const float r_val = rho->val[r_id]; /* maybe move to beginning of function? */ diff --git a/RigidBodyGrid.cu b/RigidBodyGrid.cu index 5c63cf8..f3663d4 100644 --- a/RigidBodyGrid.cu +++ b/RigidBodyGrid.cu @@ -178,11 +178,17 @@ float RigidBodyGrid::getValue(int ix, int iy, int iz) const { } Vector3 RigidBodyGrid::getPosition(const int j) const { - const int iz = j%nz; - const int iy = (j/nz)%ny; - const int ix = j/(nz*ny); + /* const int iz = j%nz; */ + /* const int iy = (j/nz)%ny; */ + /* const int ix = j/(nz*ny); */ + const int jy = j/nz; + const int jx = jy/ny; - return Vector3(ix,iy,iz); + const int iz = j - jy*nz; + const int iy = jy - jx*ny; + // const int ix = jx; + + return Vector3(jx,iy,iz); } Vector3 RigidBodyGrid::getPosition(int j, Matrix3 basis, Vector3 origin) const { -- GitLab