BlueGene/Q Verlet cut-off scheme kernels
[alexxy/gromacs.git] / src / mdlib / nbnxn_search.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2012, The GROMACS development team,
6  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012,2013, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38
39 #ifndef _nbnxn_search_h
40 #define _nbnxn_search_h
41 #include "visibility.h"
42 #include "typedefs.h"
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /* Returns the j-cluster size for kernel of type nb_kernel_type */
49 int nbnxn_kernel_to_cj_size(int nb_kernel_type);
50
51 /* Tells if the pair-list corresponding to nb_kernel_type is simple.
52  * Returns FALSE for super-sub type pair-list.
53  */
54 gmx_bool nbnxn_kernel_pairlist_simple(int nb_kernel_type);
55
56 /* Due to the cluster size the effective pair-list is longer than
57  * that of a simple atom pair-list. This function gives the extra distance.
58  */
59 GMX_LIBMD_EXPORT
60 real nbnxn_get_rlist_effective_inc(int cluster_size, real atom_density);
61
62 /* Allocates and initializes a pair search data structure */
63 void nbnxn_init_search(nbnxn_search_t    * nbs_ptr,
64                        ivec               *n_dd_cells,
65                        gmx_domdec_zones_t *zones,
66                        int                 nthread_max);
67
68 /* Put the atoms on the pair search grid.
69  * Only atoms a0 to a1 in x are put on the grid.
70  * The atom_density is used to determine the grid size.
71  * When atom_density=-1, the density is determined from a1-a0 and the corners.
72  * With domain decomposition part of the n particles might have migrated,
73  * but have not been removed yet. This count is given by nmoved.
74  * When move[i] < 0 particle i has migrated and will not be put on the grid.
75  * Without domain decomposition move will be NULL.
76  */
77 void nbnxn_put_on_grid(nbnxn_search_t nbs,
78                        int ePBC, matrix box,
79                        int dd_zone,
80                        rvec corner0, rvec corner1,
81                        int a0, int a1,
82                        real atom_density,
83                        const int *atinfo,
84                        rvec *x,
85                        int nmoved, int *move,
86                        int nb_kernel_type,
87                        nbnxn_atomdata_t *nbat);
88
89 /* As nbnxn_put_on_grid, but for the non-local atoms
90  * with domain decomposition. Should be called after calling
91  * nbnxn_search_put_on_grid for the local atoms / home zone.
92  */
93 void nbnxn_put_on_grid_nonlocal(nbnxn_search_t            nbs,
94                                 const gmx_domdec_zones_t *zones,
95                                 const int                *atinfo,
96                                 rvec                     *x,
97                                 int                       nb_kernel_type,
98                                 nbnxn_atomdata_t         *nbat);
99
100 /* Add simple grid type information to the local super/sub grid */
101 void nbnxn_grid_add_simple(nbnxn_search_t    nbs,
102                            nbnxn_atomdata_t *nbat);
103
104 /* Return the number of x and y cells in the local grid */
105 void nbnxn_get_ncells(nbnxn_search_t nbs, int *ncx, int *ncy);
106
107 /* Return the order indices *a of the atoms on the ns grid, size n */
108 void nbnxn_get_atomorder(nbnxn_search_t nbs, int **a, int *n);
109
110 /* Renumber the atom indices on the grid to consecutive order */
111 void nbnxn_set_atomorder(nbnxn_search_t nbs);
112
113 /* Initializes a set of pair lists stored in nbnxn_pairlist_set_t */
114 void nbnxn_init_pairlist_set(nbnxn_pairlist_set_t *nbl_list,
115                              gmx_bool simple, gmx_bool combined,
116                              nbnxn_alloc_t *alloc,
117                              nbnxn_free_t  *free);
118
119 /* Make a apir-list with radius rlist, store it in nbl.
120  * The parameter min_ci_balanced sets the minimum required
121  * number or roughly equally sized ci blocks in nbl.
122  * When set >0 ci lists will be chopped up when the estimate
123  * for the number of equally sized lists is below min_ci_balanced.
124  */
125 void nbnxn_make_pairlist(const nbnxn_search_t  nbs,
126                          nbnxn_atomdata_t     *nbat,
127                          const t_blocka       *excl,
128                          real                  rlist,
129                          int                   min_ci_balanced,
130                          nbnxn_pairlist_set_t *nbl_list,
131                          int                   iloc,
132                          int                   nb_kernel_type,
133                          t_nrnb               *nrnb);
134
135 #ifdef __cplusplus
136 }
137 #endif
138
139 #endif