From 8338969af5ffa9e2796846a51ba589b2d7d04b28 Mon Sep 17 00:00:00 2001
From: Axel Kohlmeyer <akohlmey@gmail.com>
Date: Thu, 31 Jan 2019 11:46:03 +0100
Subject: [PATCH] bugfix for create_atoms region optimization

---
 src/create_atoms.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp
index c3d55d76a4..ddbf2e6b59 100644
--- a/src/create_atoms.cpp
+++ b/src/create_atoms.cpp
@@ -68,6 +68,7 @@ void CreateAtoms::command(int narg, char **arg)
   if (strcmp(arg[1],"box") == 0) {
     style = BOX;
     iarg = 2;
+    nregion = -1;
   } else if (strcmp(arg[1],"region") == 0) {
     style = REGION;
     if (narg < 3) error->all(FLERR,"Illegal create_atoms command");
@@ -727,7 +728,7 @@ void CreateAtoms::add_lattice()
 
   // narrow down min/max further by extent of the region, if possible
 
-  if (domain->regions[nregion]->bboxflag) {
+  if ((style == REGION) && domain->regions[nregion]->bboxflag) {
     const double rxmin = domain->regions[nregion]->extent_xlo;
     const double rxmax = domain->regions[nregion]->extent_xhi;
     const double rymin = domain->regions[nregion]->extent_ylo;
-- 
GitLab