+/*! \brief Set the exclusion data for i-zone \p iz */
+static void make_exclusions_zone(gmx_domdec_t *dd,
+ gmx_domdec_zones_t *zones,
+ const gmx_moltype_t *moltype,
+ const int *cginfo,
+ t_blocka *lexcls,
+ int iz,
+ int at_start, int at_end)
+{
+ gmx_ga2la_t ga2la;
+ int jla0, jla1;
+ int n_excl_at_max, n, at;
+
+ ga2la = dd->ga2la;
+
+ jla0 = dd->cgindex[zones->izone[iz].jcg0];
+ jla1 = dd->cgindex[zones->izone[iz].jcg1];
+
+ n_excl_at_max = dd->reverse_top->n_excl_at_max;
+
+ /* We set the end index, but note that we might not start at zero here */
+ lexcls->nr = at_end;
+
+ n = lexcls->nra;
+ for (at = at_start; at < at_end; at++)
+ {
+ if (n + 1000 > lexcls->nalloc_a)
+ {
+ lexcls->nalloc_a = over_alloc_large(n + 1000);
+ srenew(lexcls->a, lexcls->nalloc_a);
+ }
+ if (GET_CGINFO_EXCL_INTER(cginfo[at]))
+ {
+ int a_gl, mb, mt, mol, a_mol, j;
+ const t_blocka *excls;
+
+ if (n + n_excl_at_max > lexcls->nalloc_a)
+ {
+ lexcls->nalloc_a = over_alloc_large(n + n_excl_at_max);
+ srenew(lexcls->a, lexcls->nalloc_a);
+ }
+
+ /* Copy the exclusions from the global top */
+ lexcls->index[at] = n;
+ a_gl = dd->gatindex[at];
+ global_atomnr_to_moltype_ind(dd->reverse_top, a_gl,
+ &mb, &mt, &mol, &a_mol);
+ excls = &moltype[mt].excls;
+ for (j = excls->index[a_mol]; j < excls->index[a_mol + 1]; j++)
+ {
+ int aj_mol, at_j, cell;
+
+ aj_mol = excls->a[j];
+
+ if (ga2la_get(ga2la, a_gl + aj_mol - a_mol, &at_j, &cell))
+ {
+ /* This check is not necessary, but it can reduce
+ * the number of exclusions in the list, which in turn
+ * can speed up the pair list construction a bit.
+ */
+ if (at_j >= jla0 && at_j < jla1)
+ {
+ lexcls->a[n++] = at_j;
+ }
+ }
+ }
+ }
+ else
+ {
+ /* We don't need exclusions for this atom */
+ lexcls->index[at] = n;
+ }
+ }
+
+ lexcls->index[lexcls->nr] = n;
+ lexcls->nra = n;
+}
+
+