Merge branch origin/release-2020 into master
[alexxy/gromacs.git] / src / gromacs / topology / mtop_util.cpp
index 8aee144a462b0a4edcd33766424bbc88d6945fe5..6f6a9d64b03c7a882eb919b9d97e80b30b65116b 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2008,2009,2010.
- * Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team.
+ * Copyright (c) 2008,2009,2010, The GROMACS development team.
+ * Copyright (c) 2012,2013,2014,2015,2016 The GROMACS development team.
  * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
@@ -525,6 +525,22 @@ int gmx_mtop_interaction_count(const gmx_mtop_t& mtop, const int unsigned if_fla
     return n;
 }
 
+std::array<int, eptNR> gmx_mtop_particletype_count(const gmx_mtop_t& mtop)
+{
+    std::array<int, eptNR> count = { { 0 } };
+
+    for (const auto& molblock : mtop.molblock)
+    {
+        const t_atoms& atoms = mtop.moltype[molblock.type].atoms;
+        for (int a = 0; a < atoms.nr; a++)
+        {
+            count[atoms.atom[a].ptype] += molblock.nmol;
+        }
+    }
+
+    return count;
+}
+
 static void atomcat(t_atoms* dest, const t_atoms* src, int copies, int maxres_renum, int* maxresnr)
 {
     int i, j, l, size;