From 8f18c284d312472ede55c1ad309d7f7da3b4a690 Mon Sep 17 00:00:00 2001
From: Axel Kohlmeyer <akohlmey@gmail.com>
Date: Sat, 10 Jun 2017 17:08:07 -0400
Subject: [PATCH] add crude check to print warning when using compute cnp/atom
 on multi-type system

---
 src/USER-MISC/compute_cnp_atom.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/USER-MISC/compute_cnp_atom.cpp b/src/USER-MISC/compute_cnp_atom.cpp
index bc3296f303..89568c6731 100644
--- a/src/USER-MISC/compute_cnp_atom.cpp
+++ b/src/USER-MISC/compute_cnp_atom.cpp
@@ -61,6 +61,22 @@ ComputeCNPAtom::ComputeCNPAtom(LAMMPS *lmp, int narg, char **arg) :
   if (cutoff < 0.0) error->all(FLERR,"Illegal compute cnp/atom command");
   cutsq = cutoff*cutoff;
 
+  // apply check for single type atoms in compute group
+  int lasttype = -1;
+  int n = -1;
+  for (int i=0; i < atom->nlocal; ++i) {
+    if (atom->mask[i] & groupbit) {
+      if (lasttype != atom->type[i]) {
+        lasttype = atom->type[i];
+        ++n;
+      }
+    }
+  }
+  int all_n = 0;
+  MPI_Allreduce(&n,&all_n,1,MPI_INT,MPI_MAX,world);
+  if (all_n > 0)
+    error->warning(FLERR,"Compute cnp/atom requested on multi-type system");
+
   nmax = 0;
 }
 
-- 
GitLab