Skip to content
Snippets Groups Projects
Unverified Commit 89c06558 authored by ckadding's avatar ckadding Committed by GitHub
Browse files

Add input validation

parent 3a0cfc1d
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "citeme.h" #include "citeme.h"
#include "domain.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
...@@ -56,10 +57,19 @@ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : ...@@ -56,10 +57,19 @@ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) :
zhi=force->numeric(FLERR,arg[4]); zhi=force->numeric(FLERR,arg[4]);
Rmax=force->numeric(FLERR,arg[5]); Rmax=force->numeric(FLERR,arg[5]);
bin_width=force->numeric(FLERR,arg[6]); bin_width=force->numeric(FLERR,arg[6]);
if (bin_width<0.0 || bin_width<Rmax)
error->all(FLERR,"Illegal compute pressure/cylinder command");
if (zhi<zlo || (zhi-zlo)<bin_width)
error->all(FLERR,"Illegal compute pressure/cylinder command");
if (zhi>domain->boxhi[2] || zlo<domain->boxlo[2])
error->all(FLERR,"Illegal compute pressure/cylinder command");
nbins=(int)(Rmax/bin_width); nbins=(int)(Rmax/bin_width);
nzbins=(int)((zhi-zlo)/bin_width); nzbins=(int)((zhi-zlo)/bin_width);
if (nbins<1 or nzbins<1)
error->all(FLERR,"Illegal compute pressure/cylinder command");
array_flag=1; array_flag=1;
vector_flag=0; vector_flag=0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment