Fixing copyright issues and code contributors
[alexxy/gromacs.git] / include / split.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-2004, 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 _split_h
40 #define _split_h
41
42 /*
43  * Determine on which node a particle should reside and on which
44  * node is also should be available. The distribution algorithm
45  * should account for the actual ring architecture and how nodes
46  * are numbered. The typedef t_splitd has two separate structures that
47  * describe the distribution:
48  *
49  * The nodeinfo part describes which node containst which particles, 
50  * while the nodeids part describes on which node(s) a particle can be 
51  * found and what local particle number is assigned to it.
52  *
53  */
54
55 #include <stdio.h>
56 #include "typedefs.h"
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62 typedef enum {SPLIT_NONE,SPLIT_SORTX,SPLIT_REDUCE,SPLIT_NR} t_splitalg;
63
64 typedef struct
65 {
66   int hid;
67   atom_id *nodeid;
68 } t_nodeids;
69
70 typedef struct
71 {
72   int nr;               /* Length of the long list.                         */
73   int *lst;             /* The actual list.                                 */
74 } t_nlist;
75
76 typedef struct
77 {
78   t_nlist home;         /* List of home particles.                          */
79 } t_nodeinfo;
80
81 typedef struct
82 {
83   int nnodes;           /* Number of nodes this splitinfo is for.      */
84   t_nodeinfo *nodeinfo; /* Home and available particles for each node. */
85   int nnodeids;         /* Number of particles this splitinfo is for.       */
86   t_nodeids *nodeids;   /* List of node id's for every particle,       */
87                         /* entry[nodeid] gives the local atom id (NO_ATID if*/
88                         /* not available). Entry[MAXNODES] contains home    */
89                         /* node's id.                                  */
90 } t_splitd;
91
92 void init_splitd(t_splitd *splitd,int nnodes,int nnodeids);
93      /*
94       * Initialises the splitd data structure for the specified number of
95       * nodes (nnodes) and number of atoms (nnodeids).
96       */
97  
98 void make_splitd(t_splitalg algorithm,int nnodes,t_topology *top,
99                         rvec *x,t_splitd *splitd,char *loadfile);
100      /*
101       * Initialises the splitd data structure for the specified number of
102       * nodes (nnodes) and number of atoms (top) and fills it using
103       * the specified algorithm (algorithm):
104       *
105       *    SPLIT_NONE   : Generate partial systems by dividing it into nnodes
106       *                   consecutive, equal, parts without any intelligence.
107       *    SPLIT_SORTX  : Like SPLIT_NONE but sort the coordinates before 
108       *                   dividing the system into nnodes consecutive, equal, 
109       *                   parts.
110       *    SPLIT_REDUCE : Like SPLIT_NONE but minimise the bond lengths, i.e
111       *                   invoke the reduce algorithm before dividing the 
112       *                   system into nnodes consecutive, equal, parts.
113       *
114       * The topology (top) and the coordinates (x) are not modified. The 
115       * calculations of bonded forces are assigned to the node with
116       * the highest id that has one of the needed particles as home particle.
117       */
118                   
119 long wr_split(FILE *fp,t_splitd *splitd);
120      /*
121       * Writes the split descriptor (splitd) to the file specified by fp.
122       */
123
124 long rd_split(FILE *fp,t_splitd *splitd);
125      /*
126       * Reads the split descriptor (splitd) from the file specified by fp.
127       */
128
129 void rm_splitd(t_splitd *splitd);
130      /*
131       * Frees all allocated space for the splitd data structure.
132       */
133
134 void pr_splitd(FILE *fp,int indent,char *title,t_splitd *splitd);
135      /*
136       * This routine prints out a (human) readable representation of 
137       * the split descriptor to the file fp. Ident specifies the
138       * number of spaces the text should be indented. Title is used
139       * to print a header text.
140       */
141
142 void split_topology(t_splitalg algorithm,int nnodes,t_topology *top,
143                            rvec x[],char *loadfile);
144      /*
145       * Distributes the non-bonded forces defined in top over nnodes nodes
146       * using the algoritm specified by algorithm. The distribution is made
147       * by creating a split descriptor and then putting a bonded force on the 
148       * highest home node number of the paricles involved.
149       */
150
151 #ifdef __cplusplus
152 }
153 #endif
154
155 #endif  /* _split_h */