Skip to content

Commit

Permalink
Working on KickDriftKernel #93
Browse files Browse the repository at this point in the history
  • Loading branch information
luchete80 committed Jun 10, 2022
1 parent f702a8f commit 48dc553
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/cuda/Domain_d.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ __device__ inline void CalcDensInc(
__device__ inline void UpdateDensity(const double &dt);

__device__ inline void UpdateVel(const double &dt);

__device__ inline void UpdatePos(const double &dt);

__device__ /*__forceinline__*/inline void CalcRateTensors(const uint *particlenbcount,
const uint *neighborWriteOffsets,
const uint *neighbors);
Expand Down
20 changes: 9 additions & 11 deletions src/cuda/KickDriftSolver.cu
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,8 @@ void Domain_d::MechKickDriftSolve(const double &tf, const double &dt_out){
CudaHelper::GetPointer(nsearch.deviceData->d_Neighbors)
);
cudaDeviceSynchronize(); //REQUIRED!!!!
UpdateDensityKernel<<<blocksPerGrid,threadsPerBlock >>>(this,
CudaHelper::GetPointer(nsearch.deviceData->d_NeighborCounts),
CudaHelper::GetPointer(nsearch.deviceData->d_NeighborWriteOffsets),
CudaHelper::GetPointer(nsearch.deviceData->d_Neighbors)
);

UpdateDensityKernel<<<blocksPerGrid,threadsPerBlock >>>(this,deltat);
cudaDeviceSynchronize(); //REQUIRED!!!!

if (contact){
Expand Down Expand Up @@ -225,12 +222,13 @@ void Domain_d::MechKickDriftSolve(const double &tf, const double &dt_out){
}

//Move particle and then calculate streses and strains ()
MoveKernelExt<<<blocksPerGrid,threadsPerBlock >>> (v, va,vb,
rho, rhoa, rhob, drho,
x, a,
u, /*Mat3_t I, */deltat,
isfirst_step, particle_count);
cudaDeviceSynchronize(); //REQUIRED!!!!
// MoveKernelExt<<<blocksPerGrid,threadsPerBlock >>> (v, va,vb,
// rho, rhoa, rhob, drho,
// x, a,
// u, /*Mat3_t I, */deltat,
// isfirst_step, particle_count);
UpdatePosKernel<<<blocksPerGrid,threadsPerBlock >>>(this,deltat);
cudaDeviceSynchronize(); //REQUIRED!!!!

//If kernel is the external, calculate pressure
//Calculate pressure!
Expand Down
12 changes: 12 additions & 0 deletions src/cuda/Mechanical.cu
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ __global__ void UpdateVelKernel(Domain_d *dom, const double &dt) {
dom->UpdateVel(dt);
}

__device__ inline void Domain_d::UpdatePos(const double &dt){
int i = threadIdx.x + blockDim.x*blockIdx.x;

if ( i < particle_count ) {
x[i] += dt*v[i];
}
}

__global__ void UpdatePosKernel(Domain_d *dom, const double &dt) {
dom->UpdatePos(dt);
}

__global__ void UpdateDensityKernel(Domain_d *dom, const double &dt) {
dom->UpdateDensity(dt);
}
Expand Down

0 comments on commit 48dc553

Please sign in to comment.