Skip to content
Snippets Groups Projects
Commit 49ec7262 authored by cmaffeo2's avatar cmaffeo2
Browse files

improved RBGrid->getPosition by eschewing modulo; now performance on par with 3D kernel

parent f3b002a1
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,7 @@ void computeGridGridForce(const RigidBodyGrid* rho, const RigidBodyGrid* u, ...@@ -34,7 +34,7 @@ void computeGridGridForce(const RigidBodyGrid* rho, const RigidBodyGrid* u,
/* Vector3 tmpf = Vector3(0.0f); */ /* Vector3 tmpf = Vector3(0.0f); */
/* float tmpe = 0.0f; */ /* float tmpe = 0.0f; */
/* const ForceEnergy fe = ForceEnergy( tmpf, tmpe); */ /* 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; force[tid] = fe.f;
const float r_val = rho->val[r_id]; /* maybe move to beginning of function? */ const float r_val = rho->val[r_id]; /* maybe move to beginning of function? */
......
...@@ -178,11 +178,17 @@ float RigidBodyGrid::getValue(int ix, int iy, int iz) const { ...@@ -178,11 +178,17 @@ float RigidBodyGrid::getValue(int ix, int iy, int iz) const {
} }
Vector3 RigidBodyGrid::getPosition(const int j) const { Vector3 RigidBodyGrid::getPosition(const int j) const {
const int iz = j%nz; /* const int iz = j%nz; */
const int iy = (j/nz)%ny; /* const int iy = (j/nz)%ny; */
const int ix = 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 { Vector3 RigidBodyGrid::getPosition(int j, Matrix3 basis, Vector3 origin) const {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment