1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
4 * This source code is part of
8 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
9 * Copyright (c) 2001-2009, The GROMACS Development Team
11 * Gromacs is a library for molecular simulation and trajectory analysis,
12 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
13 * a full list of developers and information, check out http://www.gromacs.org
15 * This program is free software; you can redistribute it and/or modify it under
16 * the terms of the GNU Lesser General Public License as published by the Free
17 * Software Foundation; either version 2 of the License, or (at your option) any
19 * As a special exception, you may use this file as part of a free software
20 * library without restriction. Specifically, if other files instantiate
21 * templates or use macros or inline functions from this file, or you compile
22 * this file and link it with other files to produce an executable, this
23 * file does not by itself cause the resulting executable to be covered by
24 * the GNU Lesser General Public License.
26 * In plain-speak: do not worry about classes/macros/templates either - only
27 * changes to the library have to be LGPL, not an application linking with it.
29 * To help fund GROMACS development, we humbly ask that you cite
30 * the papers people have written on it - you can find them on the website!
42 #include "gmx_omp_nthreads.h"
43 #include "nbnxn_kernel_ref.h"
44 #include "../nbnxn_consts.h"
45 #include "nbnxn_kernel_common.h"
47 /* Analytical reaction-field kernels */
50 /* Include the force+energy kernels */
52 #include "nbnxn_kernel_ref_outer.h"
55 /* Include the force+energygroups kernels */
58 #include "nbnxn_kernel_ref_outer.h"
62 /* Include the force only kernels */
63 #include "nbnxn_kernel_ref_outer.h"
68 /* Tabulated exclusion interaction electrostatics kernels */
71 /* Include the force+energy kernels */
73 #include "nbnxn_kernel_ref_outer.h"
76 /* Include the force+energygroups kernels */
79 #include "nbnxn_kernel_ref_outer.h"
83 /* Include the force only kernels */
84 #include "nbnxn_kernel_ref_outer.h"
86 /* Twin-range cut-off kernels */
87 #define VDW_CUTOFF_CHECK
89 /* Include the force+energy kernels */
91 #include "nbnxn_kernel_ref_outer.h"
94 /* Include the force+energygroups kernels */
97 #include "nbnxn_kernel_ref_outer.h"
101 /* Include the force only kernels */
102 #include "nbnxn_kernel_ref_outer.h"
104 #undef VDW_CUTOFF_CHECK
109 typedef void (*p_nbk_func_ener
)(const nbnxn_pairlist_t
*nbl
,
110 const nbnxn_atomdata_t
*nbat
,
111 const interaction_const_t
*ic
,
118 typedef void (*p_nbk_func_noener
)(const nbnxn_pairlist_t
*nbl
,
119 const nbnxn_atomdata_t
*nbat
,
120 const interaction_const_t
*ic
,
125 enum { coultRF
, coultTAB
, coultTAB_TWIN
, coultNR
};
127 p_nbk_func_ener p_nbk_c_ener
[coultNR
] =
128 { nbnxn_kernel_ref_rf_ener
,
129 nbnxn_kernel_ref_tab_ener
,
130 nbnxn_kernel_ref_tab_twin_ener
};
132 p_nbk_func_ener p_nbk_c_energrp
[coultNR
] =
133 { nbnxn_kernel_ref_rf_energrp
,
134 nbnxn_kernel_ref_tab_energrp
,
135 nbnxn_kernel_ref_tab_twin_energrp
};
137 p_nbk_func_noener p_nbk_c_noener
[coultNR
] =
138 { nbnxn_kernel_ref_rf_noener
,
139 nbnxn_kernel_ref_tab_noener
,
140 nbnxn_kernel_ref_tab_twin_noener
};
143 nbnxn_kernel_ref(const nbnxn_pairlist_set_t
*nbl_list
,
144 const nbnxn_atomdata_t
*nbat
,
145 const interaction_const_t
*ic
,
154 nbnxn_pairlist_t
**nbl
;
158 nnbl
= nbl_list
->nnbl
;
161 if (EEL_RF(ic
->eeltype
) || ic
->eeltype
== eelCUT
)
167 if (ic
->rcoulomb
== ic
->rvdw
)
173 coult
= coultTAB_TWIN
;
177 #pragma omp parallel for schedule(static) num_threads(gmx_omp_nthreads_get(emntNonbonded))
178 for(nb
=0; nb
<nnbl
; nb
++)
180 nbnxn_atomdata_output_t
*out
;
183 out
= &nbat
->out
[nb
];
185 if (clearF
== enbvClearFYes
)
187 clear_f(nbat
,out
->f
);
190 if ((force_flags
& GMX_FORCE_VIRIAL
) && nnbl
== 1)
196 fshift_p
= out
->fshift
;
198 if (clearF
== enbvClearFYes
)
200 clear_fshift(fshift_p
);
204 if (!(force_flags
& GMX_FORCE_ENERGY
))
206 /* Don't calculate energies */
207 p_nbk_c_noener
[coult
](nbl
[nb
],nbat
,
213 else if (out
->nV
== 1)
215 /* No energy groups */
219 p_nbk_c_ener
[coult
](nbl
[nb
],nbat
,
229 /* Calculate energy group contributions */
232 for(i
=0; i
<out
->nV
; i
++)
236 for(i
=0; i
<out
->nV
; i
++)
241 p_nbk_c_energrp
[coult
](nbl
[nb
],nbat
,
251 if (force_flags
& GMX_FORCE_ENERGY
)
253 /* Reduce the energies */
254 for(nb
=0; nb
<nnbl
; nb
++)
258 for(i
=0; i
<nbat
->out
[nb
].nV
; i
++)
260 Vvdw
[i
] += nbat
->out
[nb
].Vvdw
[i
];
261 Vc
[i
] += nbat
->out
[nb
].Vc
[i
];