Could you have a look at this code?

edited November 2016 in DualSPHysics_v4.0
Hi Alex or someone else,

I have written some code to dissipate the wave energy in the end of the flume.
However it does not make any difference in the simulated results. Could you have a look at the code:

1. in JSphGpu_ker.cu

//##############################################################################
//# PY add Kernels for wave damping 2016/11/05
//# Kernels for wave damping
//##############################################################################
__global__ void PYKerWvDamp(unsigned n,const double2 *posxypre
,const float4 *velrhop,float3 *ace,const float YWDP1,const float YWDP2)
{
unsigned p=blockIdx.y*gridDim.x*blockDim.x + blockIdx.x*blockDim.x + threadIdx.x; //-NI of the particle.

const double2 Lposxy = posxypre[p];
const float4 Lvelrhop = velrhop[p];
float3 Lace = ace[p];
const float pi = 3.1416;

if(pYWDP1&&float(Lposxy.x)0.)Lace.x*=fdamp;
if(Lace.y*Lvelrhop.y>0.)Lace.y*=fdamp;
if(Lace.z*Lvelrhop.z>0.)Lace.z*=fdamp;
ace[p] = Lace;
}
}

//==============================================================================
/// PY add wave damping 2016/11/05
/// GPU code Wave damping at the end of the flume
//==============================================================================
void PYWvDampGpu(unsigned np,unsigned npb,const double2 *posxypre
,const float4 *velrhop,float3 *ace,float YWDP1,float YWDP2)
{
const unsigned n=np-npb;
if(n){
dim3 sgrid=GetGridSize(n,SPHBSIZE);
PYKerWvDamp <<<sgrid,SPHBSIZE>>> (n,posxypre,velrhop,ace,YWDP1,YWDP2);
}
}

2. in JSphGpu.cpp

//==============================================================================
/// PY add wave damping 2016/11/05
/// Wave damping at the end of the flume
//==============================================================================
void JSphGpu::PYWvDamp(){
cusph::PYWvDampGpu(Np,Npb,Posxyg,Velrhopg,Aceg,YWDP1,YWDP2);
}

3. in in JSphGpuSingle.cpp
//==============================================================================
/// Realiza interaccion y actualizacion de particulas segun las fuerzas
/// calculadas en la interaccion usando Symplectic.
///
/// Particle interaction and update of particle data according to
/// the computed forces using the Symplectic time stepping scheme
//==============================================================================
double JSphGpuSingle::ComputeStep_Sym(){
...
...
if(TShifting)RunShifting(dt); //-Shifting
if(TYWvdamp!=YWvdamp_None)PYWvDamp(); // PY add wave damping 2016/11/09
ComputeSymplecticCorr(dt); //-Aplica Symplectic-Corrector a las particulas //Applies Symplectic-Corrector to the particles
...
...
}

These are basic code where YWDP1 and YWDP2 are the starting and ending points of the wave dissipating zone. Other declaration are added correctly and the parameters seems to be read correctly. The code is compiled without troubles, but the results show no different with before.

Thank you very much!

Regards,

Yi



Comments

  • Hi
    Could you find the solution?
  • Hi moh,

    Recently I was occupied by other stuff.
    I just have got a little progress which is that the code is really weird. In order to check where the problem is, I removed all the modifications, and set the acceleration to 0 directly in the interaction force subroutine. However, the result kept the same, that is the particles which are in the damping zone in the first time step keep unmoved, but the new particles which get into the damping zone seems not influenced.
    I think the reason is that I could not totally understand how the cuda works.

    Do you have any ideas?

    Yi
  • If you do not fully understand CUDA the best way to proceed is to implement this first on the CPU code. In this way you can check if it works and then you can move on CUDA.

    Regards
  • Lazycatyi,

    two simple questions:
    1) Are you running the simulation in the GPU? If not all of this won't make any difference.
    2) Shouldn't the dissipation occur after the Sympletic step?
Sign In or Register to comment.