diff --git a/meshmode/mesh/refinement/__init__.py b/meshmode/mesh/refinement/__init__.py
index ac2f9833eb74326ba5ffa452728e753a736afefe..cb001e3266192a9280e313ae95ef6b93ff988d7d 100644
--- a/meshmode/mesh/refinement/__init__.py
+++ b/meshmode/mesh/refinement/__init__.py
@@ -348,6 +348,10 @@ class Refiner(object):
             indicating which elements should be split.
         """
 
+        if len(refine_flags) != self.last_mesh.nelements:
+            raise ValueError("length of refine_flags does not match "
+                    "element count of last generated mesh")
+
         #vertices and groups for next generation
         nvertices = len(self.last_mesh.vertices[0])