Пример #1
0
void EspressoSystemInterface::gatherParticles() {
    Cell *cell;
    Particle *p;
    int i,c,np;

    // get particles from other nodes
#ifdef CUDA
    if (m_gpu)
    {
        if(gpu_get_global_particle_vars_pointer_host()->communication_enabled) {
            ESIF_TRACE(puts("Calling copy_part_data_to_gpu()"));
            copy_part_data_to_gpu();
            reallocDeviceMemory(gpu_get_global_particle_vars_pointer_host()->number_of_particles);
            if(m_splitParticleStructGpu && (this_node == 0))
                split_particle_struct();
        }
    }
#endif

    if (needsQ() || needsR()) {
        R.clear();
#ifdef ELECTROSTATICS
        Q.clear();
#endif

        for (c = 0; c < local_cells.n; c++) {
            cell = local_cells.cell[c];
            p  = cell->part;
            np = cell->n;
            if(needsR())
                R.reserve(R.size()+np);
#ifdef ELECTROSTATICS
            if(needsQ())
                Q.reserve(Q.size()+np);
#endif
            for(i = 0; i < np; i++) {
                if(needsR())
                    R.push_back(Vector3(p[i].r.p));
#ifdef ELECTROSTATICS
                if(needsQ())
                    Q.push_back(p[i].p.q);
#endif
            }
        }
    }
}
Пример #2
0
void on_coulomb_change()
{
  EVENT_TRACE(fprintf(stderr, "%d: on_coulomb_change\n", this_node));
  invalidate_obs();

  recalc_coulomb_prefactor();

#ifdef ELECTROSTATICS
  switch (coulomb.method) {
  case COULOMB_DH:
    break;    
#ifdef P3M
#ifdef CUDA
  case COULOMB_P3M_GPU:
    if ( box_l[0] != box_l[1] || box_l[0] != box_l[2] ) {
      fprintf (stderr, "P3M on the GPU requires a cubic box!\n");
      exit(1);
    }
    p3m_gpu_init(p3m.params.cao, p3m.params.mesh[0], p3m.params.alpha, box_l[0]);
    MPI_Bcast(gpu_get_global_particle_vars_pointer_host(), sizeof(CUDA_global_part_vars), MPI_BYTE, 0, comm_cart);
    p3m_init();
    break;
#endif
  case COULOMB_ELC_P3M:
    ELC_init();
    // fall through
  case COULOMB_P3M:
    p3m_init();
    break;
#endif
  case COULOMB_MMM1D:
    MMM1D_init();
    break;
  case COULOMB_MMM2D:
    MMM2D_init();
    break;
  case COULOMB_MAGGS: 
    maggs_init();
    /* Maggs electrostatics needs ghost velocities */
    on_ghost_flags_change();
    break;
  default: break;
  }
#endif  /* ifdef ELECTROSTATICS */

#ifdef DIPOLES
  switch (coulomb.Dmethod) {
#ifdef DP3M
  case DIPOLAR_MDLC_P3M:
    // fall through
  case DIPOLAR_P3M:
    dp3m_init();
    break;
#endif
  default: break;
  }
#endif  /* ifdef DIPOLES */

  /* all Coulomb methods have a short range part, aka near field
     correction. Even in case of switching off, we should call this,
     since the required cutoff might have reduced. */
  on_short_range_ia_change();

  recalc_forces = 1;
}
Пример #3
0
void on_integration_start()
{
  EVENT_TRACE(fprintf(stderr, "%d: on_integration_start\n", this_node));
  INTEG_TRACE(fprintf(stderr,"%d: on_integration_start: reinit_thermo = %d, resort_particles=%d\n",
		      this_node,reinit_thermo,resort_particles));

  /********************************************/
  /* sanity checks                            */
  /********************************************/

  integrator_sanity_checks();
#ifdef NPT
  integrator_npt_sanity_checks();
#endif
  interactions_sanity_checks();
#ifdef CATALYTIC_REACTIONS
  reactions_sanity_checks();
#endif
#ifdef LB
  if(lattice_switch & LATTICE_LB) {
    lb_sanity_checks();
  }
#endif
#ifdef LB_GPU
  if(lattice_switch & LATTICE_LB_GPU) {
    lb_GPU_sanity_checks();
  }
#endif

  /********************************************/
  /* end sanity checks                        */
  /********************************************/


#ifdef LB_GPU
  if(this_node == 0){
    if (lb_reinit_particles_gpu) {
      lb_realloc_particles_gpu();
      lb_reinit_particles_gpu = 0;
    }
  }
#endif

#ifdef CUDA
  if (reinit_particle_comm_gpu){
    gpu_change_number_of_part_to_comm();
    reinit_particle_comm_gpu = 0;
  }
  MPI_Bcast(gpu_get_global_particle_vars_pointer_host(), sizeof(CUDA_global_part_vars), MPI_BYTE, 0, comm_cart);
#endif

#ifdef METADYNAMICS
  meta_init();
#endif

  /* Prepare the thermostat */
  if (reinit_thermo) {
    thermo_init();
    reinit_thermo = 0;
    recalc_forces = 1;
  }

  /* Ensemble preparation: NVT or NPT */
  integrate_ensemble_init();

  /* Update particle and observable information for routines in statistics.cpp */
  invalidate_obs();
  freePartCfg();

  on_observable_calc();
}