2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2009, The GROMACS Development Team
6 * Copyright (c) 2012,2013, by the GROMACS development team, led by
7 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
8 * others, as listed in the AUTHORS file in the top-level source
9 * directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
47 #include "gmx_omp_nthreads.h"
48 #include "nbnxn_kernel_ref.h"
49 #include "../nbnxn_consts.h"
50 #include "nbnxn_kernel_common.h"
52 /* Analytical reaction-field kernels */
55 /* Include the force+energy kernels */
57 #include "nbnxn_kernel_ref_outer.h"
60 /* Include the force+energygroups kernels */
63 #include "nbnxn_kernel_ref_outer.h"
67 /* Include the force only kernels */
68 #include "nbnxn_kernel_ref_outer.h"
73 /* Tabulated exclusion interaction electrostatics kernels */
76 /* Include the force+energy kernels */
78 #include "nbnxn_kernel_ref_outer.h"
81 /* Include the force+energygroups kernels */
84 #include "nbnxn_kernel_ref_outer.h"
88 /* Include the force only kernels */
89 #include "nbnxn_kernel_ref_outer.h"
91 /* Twin-range cut-off kernels */
92 #define VDW_CUTOFF_CHECK
94 /* Include the force+energy kernels */
96 #include "nbnxn_kernel_ref_outer.h"
99 /* Include the force+energygroups kernels */
100 #define CALC_ENERGIES
101 #define ENERGY_GROUPS
102 #include "nbnxn_kernel_ref_outer.h"
106 /* Include the force only kernels */
107 #include "nbnxn_kernel_ref_outer.h"
109 #undef VDW_CUTOFF_CHECK
114 typedef void (*p_nbk_func_ener)(const nbnxn_pairlist_t *nbl,
115 const nbnxn_atomdata_t *nbat,
116 const interaction_const_t *ic,
123 typedef void (*p_nbk_func_noener)(const nbnxn_pairlist_t *nbl,
124 const nbnxn_atomdata_t *nbat,
125 const interaction_const_t *ic,
130 enum { coultRF, coultTAB, coultTAB_TWIN, coultNR };
132 p_nbk_func_ener p_nbk_c_ener[coultNR] =
133 { nbnxn_kernel_ref_rf_ener,
134 nbnxn_kernel_ref_tab_ener,
135 nbnxn_kernel_ref_tab_twin_ener };
137 p_nbk_func_ener p_nbk_c_energrp[coultNR] =
138 { nbnxn_kernel_ref_rf_energrp,
139 nbnxn_kernel_ref_tab_energrp,
140 nbnxn_kernel_ref_tab_twin_energrp};
142 p_nbk_func_noener p_nbk_c_noener[coultNR] =
143 { nbnxn_kernel_ref_rf_noener,
144 nbnxn_kernel_ref_tab_noener,
145 nbnxn_kernel_ref_tab_twin_noener };
148 nbnxn_kernel_ref(const nbnxn_pairlist_set_t *nbl_list,
149 const nbnxn_atomdata_t *nbat,
150 const interaction_const_t *ic,
159 nbnxn_pairlist_t **nbl;
163 nnbl = nbl_list->nnbl;
166 if (EEL_RF(ic->eeltype) || ic->eeltype == eelCUT)
172 if (ic->rcoulomb == ic->rvdw)
178 coult = coultTAB_TWIN;
182 #pragma omp parallel for schedule(static) num_threads(gmx_omp_nthreads_get(emntNonbonded))
183 for(nb=0; nb<nnbl; nb++)
185 nbnxn_atomdata_output_t *out;
188 out = &nbat->out[nb];
190 if (clearF == enbvClearFYes)
192 clear_f(nbat,nb,out->f);
195 if ((force_flags & GMX_FORCE_VIRIAL) && nnbl == 1)
201 fshift_p = out->fshift;
203 if (clearF == enbvClearFYes)
205 clear_fshift(fshift_p);
209 if (!(force_flags & GMX_FORCE_ENERGY))
211 /* Don't calculate energies */
212 p_nbk_c_noener[coult](nbl[nb],nbat,
218 else if (out->nV == 1)
220 /* No energy groups */
224 p_nbk_c_ener[coult](nbl[nb],nbat,
234 /* Calculate energy group contributions */
237 for(i=0; i<out->nV; i++)
241 for(i=0; i<out->nV; i++)
246 p_nbk_c_energrp[coult](nbl[nb],nbat,
256 if (force_flags & GMX_FORCE_ENERGY)
258 reduce_energies_over_lists(nbat,nnbl,Vvdw,Vc);