Merge branch release-5-1 into release-2016
[alexxy/gromacs.git] / src / gromacs / topology / topology.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  * Copyright (c) 2011,2014,2015, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37 #ifndef GMX_TOPOLOGY_TOPOLOGY_H
38 #define GMX_TOPOLOGY_TOPOLOGY_H
39
40 #include <cstdio>
41
42 #include "gromacs/math/vectypes.h"
43 #include "gromacs/topology/atoms.h"
44 #include "gromacs/topology/block.h"
45 #include "gromacs/topology/idef.h"
46 #include "gromacs/topology/symtab.h"
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 enum {
53     egcTC,    egcENER,   egcACC, egcFREEZE,
54     egcUser1, egcUser2,  egcVCM, egcCompressedX,
55     egcORFIT, egcQMMM,
56     egcNR
57 };
58 /* Names corresponding to groups */
59 extern const char *gtypes[egcNR+1];
60
61 typedef struct gmx_moltype_t
62 {
63     char          **name;         /* Name of the molecule type            */
64     t_atoms         atoms;        /* The atoms in this molecule           */
65     t_ilist         ilist[F_NRE]; /* Interaction list with local indices  */
66     t_block         cgs;          /* The charge groups                    */
67     t_blocka        excls;        /* The exclusions                       */
68 } gmx_moltype_t;
69
70 typedef struct gmx_molblock_t
71 {
72     int            type;        /* The molcule type index in mtop.moltype */
73     int            nmol;        /* The number of molecules in this block  */
74     int            natoms_mol;  /* The number of atoms in one molecule    */
75     int            nposres_xA;  /* The number of posres coords for top A  */
76     rvec          *posres_xA;   /* The posres coords for top A            */
77     int            nposres_xB;  /* The number of posres coords for top B  */
78     rvec          *posres_xB;   /* The posres coords for top B            */
79 } gmx_molblock_t;
80
81 typedef struct gmx_groups_t
82 {
83     t_grps            grps[egcNR];  /* Groups of things                     */
84     int               ngrpname;     /* Number of groupnames                 */
85     char           ***grpname;      /* Names of the groups                  */
86     int               ngrpnr[egcNR];
87     unsigned char    *grpnr[egcNR]; /* Group numbers or NULL                */
88 } gmx_groups_t;
89
90 /* This macro gives the group number of group type egc for atom i.
91  * This macro is useful, since the grpnr pointers are NULL
92  * for group types that have all entries 0.
93  */
94 #define ggrpnr(groups, egc, i) ((groups)->grpnr[egc] ? (groups)->grpnr[egc][i] : 0)
95
96 /* The global, complete system topology struct, based on molecule types.
97    This structure should contain no data that is O(natoms) in memory. */
98 typedef struct gmx_mtop_t
99 {
100     char           **name;      /* Name of the topology                 */
101     gmx_ffparams_t   ffparams;
102     int              nmoltype;
103     gmx_moltype_t   *moltype;
104     int              nmolblock;
105     gmx_molblock_t  *molblock;
106     gmx_bool         bIntermolecularInteractions; /* Are there intermolecular
107                                                    * interactions?            */
108     t_ilist         *intermolecular_ilist;        /* List of intermolecular interactions
109                                                    * using system wide atom indices,
110                                                    * either NULL or size F_NRE           */
111     int              natoms;
112     int              maxres_renum;                /* Parameter for residue numbering      */
113     int              maxresnr;                    /* The maximum residue number in moltype */
114     t_atomtypes      atomtypes;                   /* Atomtype properties                  */
115     t_block          mols;                        /* The molecules                        */
116     gmx_groups_t     groups;
117     t_symtab         symtab;                      /* The symbol table                     */
118 } gmx_mtop_t;
119
120 /* The mdrun node-local topology struct, completely written out */
121 typedef struct gmx_localtop_t
122 {
123     t_idef        idef;         /* The interaction function definition  */
124     t_atomtypes   atomtypes;    /* Atomtype properties                  */
125     t_block       cgs;          /* The charge groups                    */
126     t_blocka      excls;        /* The exclusions                       */
127 } gmx_localtop_t;
128
129 /* The old topology struct, completely written out, used in analysis tools */
130 typedef struct t_topology
131 {
132     char          **name;                        /* Name of the topology                 */
133     t_idef          idef;                        /* The interaction function definition  */
134     t_atoms         atoms;                       /* The atoms                            */
135     t_atomtypes     atomtypes;                   /* Atomtype properties                  */
136     t_block         cgs;                         /* The charge groups                    */
137     t_block         mols;                        /* The molecules                        */
138     gmx_bool        bIntermolecularInteractions; /* Inter.mol. int. ?   */
139     t_blocka        excls;                       /* The exclusions                       */
140     t_symtab        symtab;                      /* The symbol table                     */
141 } t_topology;
142
143 void init_mtop(gmx_mtop_t *mtop);
144 void init_top(t_topology *top);
145 void done_moltype(gmx_moltype_t *molt);
146 void done_molblock(gmx_molblock_t *molb);
147 void done_mtop(gmx_mtop_t *mtop, gmx_bool bDoneSymtab);
148 void done_top(t_topology *top);
149
150 t_atoms *mtop2atoms(gmx_mtop_t *mtop);
151 /* generate a t_atoms struct for the system from gmx_mtop_t */
152
153 void pr_mtop(FILE *fp, int indent, const char *title, const gmx_mtop_t *mtop,
154              gmx_bool bShowNumbers);
155 void pr_top(FILE *fp, int indent, const char *title, const t_topology *top, gmx_bool bShowNumbers);
156
157 #ifdef __cplusplus
158 }
159 #endif
160
161 #endif