void force_calc() { // Communication step: distribute ghost positions cells_update_ghosts(); // VIRTUAL_SITES pos (and vel for DPD) update for security reason !!! #ifdef VIRTUAL_SITES update_mol_vel_pos(); ghost_communicator(&cell_structure.update_ghost_pos_comm); #endif #if defined(VIRTUAL_SITES_RELATIVE) && defined(LB) // This is on a workaround stage: // When using virtual sites relative and LB at the same time, it is necessary // to reassemble the cell lists after all position updates, also of virtual // particles. if ((lattice_switch & LATTICE_LB) && cell_structure.type == CELL_STRUCTURE_DOMDEC && (!dd.use_vList) ) cells_update_ghosts(); #endif espressoSystemInterface.update(); #ifdef COLLISION_DETECTION prepare_collision_queue(); #endif #ifdef LB_GPU #ifdef SHANCHEN if (lattice_switch & LATTICE_LB_GPU && this_node == 0) lattice_boltzmann_calc_shanchen_gpu(); #endif // SHANCHEN // transfer_momentum_gpu check makes sure the LB fluid doesn't get updated on integrate 0 // this_node==0 makes sure it is the master node where the gpu exists if (lattice_switch & LATTICE_LB_GPU && transfer_momentum_gpu && (this_node == 0) ) lb_calc_particle_lattice_ia_gpu(); #endif // LB_GPU #ifdef ELECTROSTATICS if (iccp3m_initialized && iccp3m_cfg.set_flag) iccp3m_iteration(); #endif init_forces(); for (ActorList::iterator actor = forceActors.begin(); actor != forceActors.end(); ++actor) { (*actor)->computeForces(espressoSystemInterface); #ifdef ROTATION (*actor)->computeTorques(espressoSystemInterface); #endif } calc_long_range_forces(); switch (cell_structure.type) { case CELL_STRUCTURE_LAYERED: layered_calculate_ia(); break; case CELL_STRUCTURE_DOMDEC: if(dd.use_vList) { if (rebuild_verletlist) build_verlet_lists_and_calc_verlet_ia(); else calculate_verlet_ia(); } else calc_link_cell(); break; case CELL_STRUCTURE_NSQUARE: nsq_calculate_ia(); } #ifdef OIF_GLOBAL_FORCES double area_volume[2]; //There are two global quantities that need to be evaluated: object's surface and object's volume. One can add another quantity. area_volume[0] = 0.0; area_volume[1] = 0.0; for (int i=0;i< MAX_OBJECTS_IN_FLUID;i++){ calc_oif_global(area_volume,i); if (fabs(area_volume[0])<1e-100 && fabs(area_volume[1])<1e-100) break; add_oif_global_forces(area_volume,i); } #endif #ifdef IMMERSED_BOUNDARY // Must be done here. Forces need to be ghost-communicated IBM_VolumeConservation(); #endif #ifdef LB if (lattice_switch & LATTICE_LB) calc_particle_lattice_ia() ; #endif #ifdef COMFORCE calc_comforce(); #endif #ifdef METADYNAMICS /* Metadynamics main function */ meta_perform(); #endif #ifdef CUDA copy_forces_from_GPU(); #endif // VIRTUAL_SITES distribute forces #ifdef VIRTUAL_SITES ghost_communicator(&cell_structure.collect_ghost_force_comm); init_forces_ghosts(); distribute_mol_force(); #endif // Communication Step: ghost forces ghost_communicator(&cell_structure.collect_ghost_force_comm); // apply trap forces to trapped molecules #ifdef MOLFORCES calc_and_apply_mol_constraints(); #endif // should be pretty late, since it needs to zero out the total force #ifdef COMFIXED calc_comfixed(); #endif // mark that forces are now up-to-date recalc_forces = 0; }
void force_calc() { espressoSystemInterface.update(); #ifdef LB_GPU #ifdef SHANCHEN if (lattice_switch & LATTICE_LB_GPU && this_node == 0) lattice_boltzmann_calc_shanchen_gpu(); #endif // SHANCHEN // transfer_momentum_gpu check makes sure the LB fluid doesn't get updated on integrate 0 // this_node==0 makes sure it is the master node where the gpu exists if (lattice_switch & LATTICE_LB_GPU && transfer_momentum_gpu && this_node==0 ) lb_calc_particle_lattice_ia_gpu(); #endif // LB_GPU #ifdef ELECTROSTATICS if (iccp3m_initialized && iccp3m_cfg.set_flag) iccp3m_iteration(); else #endif init_forces(); switch (cell_structure.type) { case CELL_STRUCTURE_LAYERED: layered_calculate_ia(); break; case CELL_STRUCTURE_DOMDEC: if(dd.use_vList) { if (rebuild_verletlist) build_verlet_lists_and_calc_verlet_ia(); else calculate_verlet_ia(); } else calc_link_cell(); break; case CELL_STRUCTURE_NSQUARE: nsq_calculate_ia(); } #ifdef VOLUME_FORCE double volume=0.; for (int i=0;i< MAX_OBJECTS_IN_FLUID;i++){ calc_volume(&volume,i); if (volume<1e-100) break; add_volume_force(volume,i); } #endif #ifdef AREA_FORCE_GLOBAL double area=0.; for (int i=0;i< MAX_OBJECTS_IN_FLUID;i++){ calc_area_global(&area,i); if (area<1e-100) break; add_area_global_force(area,i); } #endif calc_long_range_forces(); #ifdef LB if (lattice_switch & LATTICE_LB) calc_particle_lattice_ia() ; #endif #ifdef COMFORCE calc_comforce(); #endif #ifdef METADYNAMICS /* Metadynamics main function */ meta_perform(); #endif #if defined(LB_GPU) || (defined(ELECTROSTATICS) && defined(CUDA)) copy_forces_from_GPU(); #endif }