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