Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / legacyheaders / nsgrid.h
1 /*
2  * 
3  *                This source code is part of
4  * 
5  *                 G   R   O   M   A   C   S
6  * 
7  *          GROningen MAchine for Chemical Simulations
8  * 
9  *                        VERSION 3.2.0
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  * 
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  * 
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  * 
30  * For more info, check our website at http://www.gromacs.org
31  * 
32  * And Hey:
33  * Gromacs Runs On Most of All Computer Systems
34  */
35
36 #include "typedefs.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 #define   GRID_STDDEV_FAC  sqrt(3)
43 #define NSGRID_STDDEV_FAC  2.0
44 /*
45  * GRID_STDDEV_FAC * stddev is used to estimate the interaction density.
46  * sqrt(3) gives a uniform load for a rectangular block of cg's.
47  * For a sphere it is not a bad approximation for 4x1x1 up to 4x2x2.
48  *
49  * The extent of the neighborsearch grid is a bit larger than sqrt(3)
50  * to account for less dense regions at the edges of the system.
51  */
52
53 #define NSGRID_SIGNAL_MOVED_FAC  4
54 /* A cell index of NSGRID_SIGNAL_MOVED_FAC*ncells signals
55  * that a charge group moved to another DD domain.
56  */
57
58 t_grid *init_grid(FILE *fplog,t_forcerec *fr);
59
60 void done_grid(t_grid *grid);
61
62 void get_nsgrid_boundaries(int nboundeddim,matrix box,
63                                   gmx_domdec_t *dd,
64                                   gmx_ddbox_t *ddbox,
65                                   rvec *gr0,rvec *gr1,
66                                   int ncg,rvec *cgcm,
67                                   rvec grid_x0,rvec grid_x1,
68                                   real *grid_density);
69 /* Return the ns grid boundaries grid_x0 and grid_x1
70  * and the estimate for the grid density.
71  * For non-bounded dimensions the boundaries are determined
72  * from the average and std.dev. of cgcm.
73  * The are determined from box, unless gr0!=NULL or gr1!=NULL,
74  * then they are taken from gr0 or gr1.
75  * With dd and unbounded dimensions, the proper grid borders for cells
76  * on the edges are determined from cgcm.
77  */
78
79 void grid_first(FILE *log,t_grid *grid,
80                        gmx_domdec_t *dd,const gmx_ddbox_t *ddbox,
81                        int ePBC,matrix box,rvec izones_x0,rvec izones_x1,
82                        real rlong,real grid_density);
83
84 void fill_grid(FILE *log,
85                       gmx_domdec_zones_t *dd_zones,
86                       t_grid *grid,int ncg_tot,
87                       int cg0,int cg1,rvec cg_cm[]);
88 /* Allocates space on the grid for ncg_tot cg's.
89  * Fills the grid with cg's from cg0 to cg1.
90  * When cg0 is -1, contiues filling from grid->nr to cg1.
91  */
92
93 void calc_elemnr(FILE *log,t_grid *grid,int cg0,int cg1,int ncg);
94
95 void calc_ptrs(t_grid *grid);
96
97 void grid_last(FILE *log,t_grid *grid,int cg0,int cg1,int ncg);
98
99 int xyz2ci_(int nry,int nrz,int x,int y,int z);
100 #define xyz2ci(nry,nrz,x,y,z) ((nry)*(nrz)*(x)+(nrz)*(y)+(z))
101 /* Return the cell index */
102
103 void ci2xyz(t_grid *grid,int i,int *x,int *y,int *z);
104
105 void check_grid(FILE *log,t_grid *grid);
106
107 void print_grid(FILE *log,t_grid *grid);
108
109 void mv_grid(t_commrec *cr,t_grid *grid);
110 /* Move the grid over processors */
111
112 #ifdef __cplusplus
113 }
114 #endif
115
116