Commit bd87b112 authored by Trung Nguyen's avatar Trung Nguyen
Browse files

Allowed pppm/gpu to fall back to pppm for triclinic boxes

parent 229203ba
Loading
Loading
Loading
Loading
+28 −15
Original line number Original line Diff line number Diff line
@@ -91,7 +91,6 @@ void PPPM_GPU_API(forces)(double **f);


PPPMGPU::PPPMGPU(LAMMPS *lmp) : PPPM(lmp)
PPPMGPU::PPPMGPU(LAMMPS *lmp) : PPPM(lmp)
{
{
  triclinic_support = 0;
  density_brick_gpu = vd_brick = NULL;
  density_brick_gpu = vd_brick = NULL;
  kspace_split = false;
  kspace_split = false;
  im_real_space = false;
  im_real_space = false;
@@ -210,6 +209,7 @@ void PPPMGPU::compute(int eflag, int vflag)
    cg_peratom->setup();
    cg_peratom->setup();
  }
  }


  if (triclinic == 0) {
    bool success = true;
    bool success = true;
    int flag=PPPM_GPU_API(spread)(nago, atom->nlocal, atom->nlocal +
    int flag=PPPM_GPU_API(spread)(nago, atom->nlocal, atom->nlocal +
                              atom->nghost, atom->x, atom->type, success,
                              atom->nghost, atom->x, atom->type, success,
@@ -219,6 +219,7 @@ void PPPMGPU::compute(int eflag, int vflag)
      error->one(FLERR,"Insufficient memory on accelerator");
      error->one(FLERR,"Insufficient memory on accelerator");
    if (flag != 0)
    if (flag != 0)
      error->one(FLERR,"Out of range atoms - cannot compute PPPM");
      error->one(FLERR,"Out of range atoms - cannot compute PPPM");
  }


  // convert atoms from box to lamda coords
  // convert atoms from box to lamda coords


@@ -229,9 +230,10 @@ void PPPMGPU::compute(int eflag, int vflag)
  }
  }


  // If need per-atom energies/virials, also do particle map on host
  // If need per-atom energies/virials, also do particle map on host
  // concurrently with GPU calculations
  // concurrently with GPU calculations,
  // or if the box is triclinic, particle map is done on host


  if (evflag_atom) {
  if (evflag_atom || triclinic) {


    // extend size of per-atom arrays if necessary
    // extend size of per-atom arrays if necessary


@@ -244,14 +246,24 @@ void PPPMGPU::compute(int eflag, int vflag)
    particle_map();
    particle_map();
  }
  }


  // if the box is triclinic,
  // map my particle charge onto my local 3d density grid on the host

  if (triclinic) make_rho();

  double t3 = MPI_Wtime();
  double t3 = MPI_Wtime();


  // all procs communicate density values from their ghost cells
  // all procs communicate density values from their ghost cells
  //   to fully sum contribution in their 3d bricks
  //   to fully sum contribution in their 3d bricks
  // remap from 3d decomposition to FFT decomposition
  // remap from 3d decomposition to FFT decomposition


  if (triclinic == 0) {
    cg->reverse_comm(this,REVERSE_RHO_GPU);
    cg->reverse_comm(this,REVERSE_RHO_GPU);
    brick2fft_gpu();
    brick2fft_gpu();
  } else {
    cg->reverse_comm(this,REVERSE_RHO);
    PPPM::brick2fft();
  }


  // compute potential gradient on my FFT grid and
  // compute potential gradient on my FFT grid and
  //   portion of e_long on this proc's FFT grid
  //   portion of e_long on this proc's FFT grid
@@ -279,7 +291,8 @@ void PPPMGPU::compute(int eflag, int vflag)
  // calculate the force on my particles
  // calculate the force on my particles


  FFT_SCALAR qscale = force->qqrd2e * scale;
  FFT_SCALAR qscale = force->qqrd2e * scale;
  PPPM_GPU_API(interp)(qscale);
  if (triclinic == 0) PPPM_GPU_API(interp)(qscale);
  else fieldforce();


  // per-atom energy/virial
  // per-atom energy/virial
  // energy includes self-energy correction
  // energy includes self-energy correction