8e2bdd548af5375c7aca1748c7eb143bdf149957
[alexxy/gromacs.git] / include / split.h
1 /*
2  * $Id$
3  * 
4  *       This source code is part of
5  * 
6  *        G   R   O   M   A   C   S
7  * 
8  * GROningen MAchine for Chemical Simulations
9  * 
10  *               VERSION 2.0
11  * 
12  * Copyright (c) 1991-1999
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * Please refer to:
17  * GROMACS: A message-passing parallel molecular dynamics implementation
18  * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19  * Comp. Phys. Comm. 91, 43-56 (1995)
20  * 
21  * Also check out our WWW page:
22  * http://md.chem.rug.nl/~gmx
23  * or e-mail to:
24  * gromacs@chem.rug.nl
25  * 
26  * And Hey:
27  * Green Red Orange Magenta Azure Cyan Skyblue
28  */
29
30 #ifndef _split_h
31 #define _split_h
32
33 static char *SRCID_split_h = "$Id$";
34
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
38
39 #ifdef HAVE_IDENT
40 #ident  "@(#) split.h 1.20 12/16/92"
41 #endif /* HAVE_IDENT */
42
43 /*
44  * Determine on which node a particle should reside and on which
45  * node is also should be available. The distribution algorithm
46  * should account for the actual ring architecture and how nodes
47  * are numbered. The typedef t_splitd has two separate structures that
48  * describe the distribution:
49  *
50  * The nodeinfo part describes which node containst which particles, 
51  * while the nodeids part describes on which node(s) a particle can be 
52  * found and what local particle number is assigned to it.
53  *
54  */
55
56 #include <stdio.h>
57 #include "typedefs.h"
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 extern 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 extern 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 extern long wr_split(FILE *fp,t_splitd *splitd);
117      /*
118       * Writes the split descriptor (splitd) to the file specified by fp.
119       */
120
121 extern long rd_split(FILE *fp,t_splitd *splitd);
122      /*
123       * Reads the split descriptor (splitd) from the file specified by fp.
124       */
125
126 extern void rm_splitd(t_splitd *splitd);
127      /*
128       * Frees all allocated space for the splitd data structure.
129       */
130
131 extern 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 extern 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
149 #endif  /* _split_h */