+/*! \brief Determine whether the local domain has responsibility for
+ * any of the position restraints for local atom \p atomIndex
+ * and assign those to the local domain.
+ *
+ * \returns The total number of bonded interactions for this atom for
+ * which this domain is responsible.
+ */
+static inline int assignPositionRestraintsForAtom(const int atomIndex,
+ const int mol,
+ const int atomIndexInMolecule,
+ const int numAtomsInMolecule,
+ gmx::ArrayRef<const int> rtil,
+ const int ind_start,
+ const int ind_end,
+ const gmx_molblock_t& molb,
+ const t_iparams* ip_in,
+ InteractionDefinitions* idef)
+{
+ constexpr int nral = 1;
+
+ int numBondedInteractions = 0;
+
+ int j = ind_start;
+ while (j < ind_end)
+ {
+ const int ftype = rtil[j++];
+ auto iatoms = gmx::constArrayRefFromArray(rtil.data() + j, rtil.size() - j);
+
+ if (ftype == F_POSRES || ftype == F_FBPOSRES)
+ {
+ std::array<int, 1 + nral> tiatoms = { iatoms[0], atomIndex };
+ if (ftype == F_POSRES)
+ {
+ add_posres(mol, atomIndexInMolecule, numAtomsInMolecule, molb, tiatoms, ip_in, idef);
+ }
+ else
+ {
+ add_fbposres(mol, atomIndexInMolecule, numAtomsInMolecule, molb, tiatoms, ip_in, idef);
+ }
+ idef->il[ftype].push_back(tiatoms[0], nral, tiatoms.data() + 1);
+ numBondedInteractions++;
+ }
+ j += 1 + nral_rt(ftype);
+ }
+
+ return numBondedInteractions;
+}
+