Use optional instead of magic numbers in preprocessing
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / grompp.cpp
index 97d6d6ffcfe31e598e52d0a6f7d9bf4ad068b8d0..b8567d2a5328d33cc1a0fcf94b424ee5f18fdf67 100644 (file)
@@ -1149,13 +1149,17 @@ static void set_wall_atomtype(PreprocessingAtomTypes* at,
     }
     for (i = 0; i < ir->nwall; i++)
     {
-        ir->wall_atomtype[i] = at->atomTypeFromName(opts->wall_atomtype[i]);
-        if (ir->wall_atomtype[i] == NOTSET)
+        auto atomType = at->atomTypeFromName(opts->wall_atomtype[i]);
+        if (!atomType.has_value())
         {
             std::string warningMessage = gmx::formatString(
                     "Specified wall atom type %s is not defined", opts->wall_atomtype[i]);
             warning_error(wi, warningMessage.c_str());
         }
+        else
+        {
+            ir->wall_atomtype[i] = *atomType;
+        }
     }
 }