Clean up make_at2con
[gromacs.git] / src / gromacs / mdlib / wnblist.cpp
blob2ef86fbc165329769ef13807d53de6c76de4761d
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014,2015,2018, 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.
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.
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.
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.
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.
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.
37 /* This file is completely threadsafe - keep it that way! */
38 #include "gmxpre.h"
40 #include <stdio.h>
41 #include <string.h>
43 #include <algorithm>
45 #include "gromacs/domdec/domdec.h"
46 #include "gromacs/domdec/domdec_struct.h"
47 #include "gromacs/fileio/gmxfio.h"
48 #include "gromacs/gmxlib/nrnb.h"
49 #include "gromacs/mdlib/ns.h"
50 #include "gromacs/mdtypes/commrec.h"
51 #include "gromacs/mdtypes/forcerec.h"
52 #include "gromacs/mdtypes/md_enums.h"
53 #include "gromacs/mdtypes/nblist.h"
54 #include "gromacs/utility/fatalerror.h"
55 #include "gromacs/utility/futil.h"
56 #include "gromacs/utility/smalloc.h"
58 static void write_nblist(FILE *out, gmx_domdec_t *dd, t_nblist *nblist, int nDNL)
60 int i, nii, ii, j, zi, zj0, zj1, aj, zj, nj;
61 int ca1[DD_MAXZONE], np[DD_MAXZONE];
62 gmx_domdec_zones_t *dd_zones;
64 if (nblist->nri > 0)
66 fprintf(out, "elec: %s, vdw: %s, type: %s, Solvent opt: %s\n",
67 gmx_nbkernel_elec_names[nblist->ielec],
68 gmx_nbkernel_vdw_names[nblist->ivdw],
69 gmx_nblist_interaction_names[nblist->type],
70 gmx_nblist_geometry_names[nblist->igeometry]);
71 fprintf(out, "nri: %d npair: %d\n", nblist->nri, nblist->nrj);
72 if (dd)
74 dd_zones = domdec_zones(dd);
76 for (zi = 0; zi < dd_zones->n; zi++)
78 ca1[zi] = dd->cgindex[dd_zones->cg_range[zi+1]];
80 i = 0;
81 for (zi = 0; zi < dd_zones->nizone && zi < dd_zones->n; zi++)
83 zj0 = dd_zones->izone[zi].j0;
84 zj1 = dd_zones->izone[zi].j1;
85 for (zj = zj0; zj < zj1; zj++)
87 np[zj] = 0;
89 while (i < nblist->nri && nblist->iinr[i] < ca1[zi])
91 for (j = nblist->jindex[i]; (j < nblist->jindex[i+1]); j++)
93 aj = nblist->jjnr[j];
94 zj = zj0;
95 while (aj >= ca1[zj])
97 zj++;
99 np[zj]++;
101 i++;
103 fprintf(out, "DD zone %d:", zi);
104 for (zj = zj0; zj < zj1; zj++)
106 fprintf(out, " %d %d", zj, np[zj]);
108 fprintf(out, "\n");
111 if (nDNL >= 2)
113 for (i = 0; i < nblist->nri; i++)
115 nii = 1;
116 if (nDNL >= 3 && nblist->igeometry != GMX_NBLIST_GEOMETRY_PARTICLE_PARTICLE)
118 nii = 3;
120 nj = nblist->jindex[i+1] - nblist->jindex[i];
121 fprintf(out, "i: %d shift: %d gid: %d nj: %d\n",
122 ddglatnr(dd, nblist->iinr[i]),
123 nblist->shift[i], nblist->gid[i], nj);
124 for (ii = 0; ii < nii; ii++)
126 for (j = nblist->jindex[i]; (j < nblist->jindex[i+1]); j++)
128 fprintf(out, " i: %5d j: %5d\n",
129 ddglatnr(dd, nblist->iinr[i]+ii),
130 ddglatnr(dd, nblist->jjnr[j]));
135 fflush(out);
141 void dump_nblist(FILE *out, const t_commrec *cr, t_forcerec *fr, int nDNL)
143 int n, i;
145 fprintf(out, "Neighborlist:\n");
147 for (n = 0; (n < fr->nnblists); n++)
149 for (i = 0; (i < eNL_NR); i++)
151 write_nblist(out, cr->dd, &fr->nblists[n].nlist_sr[i], nDNL);