Skip to content
Snippets Groups Projects
Commit 740230b8 authored by cmaffeo2's avatar cmaffeo2
Browse files

removed possible bug in computeGridGrid kernel

parent eb5ef427
No related branches found
No related tags found
No related merge requests found
...@@ -16,33 +16,30 @@ void computeGridGridForce(const RigidBodyGrid* rho, const RigidBodyGrid* u, ...@@ -16,33 +16,30 @@ void computeGridGridForce(const RigidBodyGrid* rho, const RigidBodyGrid* u,
const int tid = threadIdx.x; const int tid = threadIdx.x;
const int r_id = blockIdx.x * blockDim.x + threadIdx.x; const int r_id = blockIdx.x * blockDim.x + threadIdx.x;
if (r_id >= rho->getSize()) { // skip threads with nothing to do force[tid] = Vector3(0.0f);
force[tid] = Vector3(0.0f); torque[tid] = Vector3(0.0f);
torque[tid] = Vector3(0.0f); if (r_id < rho->getSize()) { // skip threads with nothing to do
return; // RBTODO: reduce registers used;
} // commenting out interpolateForceD still uses ~40 registers
// -- the innocuous-looking fn below is responsible; consumes ~17 registers!
// RBTODO: reduce registers used; Vector3 r_pos= rho->getPosition(r_id); /* i,j,k value of voxel */
// commenting out interpolateForceD still uses ~40 registers
// -- the innocuous-looking fn below is responsible; consumes ~17 registers!
Vector3 r_pos= rho->getPosition(r_id); /* i,j,k value of voxel */
r_pos = basis_rho.transform( r_pos ) + origin_rho_minus_origin_u; /* real space */ r_pos = basis_rho.transform( r_pos ) + origin_rho_minus_origin_u; /* real space */
const Vector3 u_ijk_float = basis_u_inv.transform( r_pos ); const Vector3 u_ijk_float = basis_u_inv.transform( r_pos );
// RBTODO What about non-unit delta? // RBTODO What about non-unit delta?
/* 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->interpolateForceDLinearly( 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? */
force[tid] = basis_u_inv.transpose().transform( r_val*force[tid] ); /* transform to lab frame, with correct scaling factor */ force[tid] = basis_u_inv.transpose().transform( r_val*force[tid] ); /* transform to lab frame, with correct scaling factor */
// Calculate torque about origin_u in the lab frame // Calculate torque about origin_u in the lab frame
torque[tid] = r_pos.cross(force[tid]); // RBTODO: test if sign is correct! torque[tid] = r_pos.cross(force[tid]); // RBTODO: test if sign is correct!
}
// Reduce force and torques // Reduce force and torques
// http://www.cuvilib.com/Reduction.pdf // http://www.cuvilib.com/Reduction.pdf
......
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