Unverified Commit 53b8e329 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1552 from akohlmey/validate-data-file-numbers

Validate more numbers read from data files
parents 64faa6c6 cbdc5dba
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -17,10 +17,12 @@
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "force.h"
#include "modify.h"
#include "fix.h"
#include "memory.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

@@ -780,19 +782,19 @@ void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values)
  if (nlocal == nmax) grow(0);

  tag[nlocal] = ATOTAGINT(values[0]);
  type[nlocal] = atoi(values[1]);
  type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
  if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");

  q[nlocal] = atof(values[2]);
  q[nlocal] = utils::numeric(FLERR,values[2],true,lmp);

  x[nlocal][0] = coord[0];
  x[nlocal][1] = coord[1];
  x[nlocal][2] = coord[2];

  mu[nlocal][0] = atof(values[6]);
  mu[nlocal][1] = atof(values[7]);
  mu[nlocal][2] = atof(values[8]);
  mu[nlocal][0] = utils::numeric(FLERR,values[6],true,lmp);
  mu[nlocal][1] = utils::numeric(FLERR,values[7],true,lmp);
  mu[nlocal][2] = utils::numeric(FLERR,values[8],true,lmp);
  mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] +
                       mu[nlocal][1]*mu[nlocal][1] +
                       mu[nlocal][2]*mu[nlocal][2]);
@@ -814,10 +816,10 @@ void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values)

int AtomVecDipole::data_atom_hybrid(int nlocal, char **values)
{
  q[nlocal] = atof(values[0]);
  mu[nlocal][0] = atof(values[1]);
  mu[nlocal][1] = atof(values[2]);
  mu[nlocal][2] = atof(values[3]);
  q[nlocal] = utils::numeric(FLERR,values[0],true,lmp);
  mu[nlocal][0] = utils::numeric(FLERR,values[1],true,lmp);
  mu[nlocal][1] = utils::numeric(FLERR,values[2],true,lmp);
  mu[nlocal][2] = utils::numeric(FLERR,values[3],true,lmp);
  mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] +
                       mu[nlocal][1]*mu[nlocal][1] +
                       mu[nlocal][2]*mu[nlocal][2]);
+6 −4
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@
#include "atom_kokkos.h"
#include "comm_kokkos.h"
#include "domain.h"
#include "force.h"
#include "modify.h"
#include "fix.h"
#include "atom_masks.h"
#include "memory_kokkos.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

@@ -1632,9 +1634,9 @@ void AtomVecAngleKokkos::data_atom(double *coord, imageint imagetmp,
  if (nlocal == nmax) grow(0);
  atomKK->modified(Host,ALL_MASK);

  h_tag(nlocal) = atoi(values[0]);
  h_molecule(nlocal) = atoi(values[1]);
  h_type(nlocal) = atoi(values[2]);
  h_tag(nlocal) = utils::inumeric(FLERR,values[0],true,lmp);
  h_molecule(nlocal) = utils::inumeric(FLERR,values[1],true,lmp);
  h_type(nlocal) = utils::inumeric(FLERR,values[2],true,lmp);
  if (h_type(nlocal) <= 0 || h_type(nlocal) > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");

@@ -1661,7 +1663,7 @@ void AtomVecAngleKokkos::data_atom(double *coord, imageint imagetmp,

int AtomVecAngleKokkos::data_atom_hybrid(int nlocal, char **values)
{
  h_molecule(nlocal) = atoi(values[0]);
  h_molecule(nlocal) = utils::inumeric(FLERR,values[0],true,lmp);
  h_num_bond(nlocal) = 0;
  h_num_angle(nlocal) = 0;
  return 1;
+4 −2
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@
#include "atom_kokkos.h"
#include "comm_kokkos.h"
#include "domain.h"
#include "force.h"
#include "modify.h"
#include "fix.h"
#include "atom_masks.h"
#include "memory_kokkos.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

@@ -823,8 +825,8 @@ void AtomVecAtomicKokkos::data_atom(double *coord, tagint imagetmp,
  int nlocal = atom->nlocal;
  if (nlocal == nmax) grow(0);

  h_tag[nlocal] = atoi(values[0]);
  h_type[nlocal] = atoi(values[1]);
  h_tag[nlocal] = utils::inumeric(FLERR,values[0],true,lmp);
  h_type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
  if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");

+6 −4
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@
#include "atom_kokkos.h"
#include "comm_kokkos.h"
#include "domain.h"
#include "force.h"
#include "modify.h"
#include "fix.h"
#include "atom_masks.h"
#include "memory_kokkos.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

@@ -1058,9 +1060,9 @@ void AtomVecBondKokkos::data_atom(double *coord, imageint imagetmp,
  if (nlocal == nmax) grow(0);
  atomKK->modified(Host,ALL_MASK);

  h_tag(nlocal) = atoi(values[0]);
  h_molecule(nlocal) = atoi(values[1]);
  h_type(nlocal) = atoi(values[2]);
  h_tag(nlocal) = utils::inumeric(FLERR,values[0],true,lmp);
  h_molecule(nlocal) = utils::inumeric(FLERR,values[1],true,lmp);
  h_type(nlocal) = utils::inumeric(FLERR,values[2],true,lmp);
  if (h_type(nlocal) <= 0 || h_type(nlocal) > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");

@@ -1086,7 +1088,7 @@ void AtomVecBondKokkos::data_atom(double *coord, imageint imagetmp,

int AtomVecBondKokkos::data_atom_hybrid(int nlocal, char **values)
{
  h_molecule(nlocal) = atoi(values[0]);
  h_molecule(nlocal) = utils::inumeric(FLERR,values[0],true,lmp);
  h_num_bond(nlocal) = 0;
  return 1;
}
+6 −4
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@
#include "atom_kokkos.h"
#include "comm_kokkos.h"
#include "domain.h"
#include "force.h"
#include "modify.h"
#include "fix.h"
#include "atom_masks.h"
#include "memory_kokkos.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

@@ -959,12 +961,12 @@ void AtomVecChargeKokkos::data_atom(double *coord, imageint imagetmp,
  int nlocal = atom->nlocal;
  if (nlocal == nmax) grow(0);

  h_tag[nlocal] = atoi(values[0]);
  h_type[nlocal] = atoi(values[1]);
  h_tag[nlocal] = utils::inumeric(FLERR,values[0],true,lmp);
  h_type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
  if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
    error->one(FLERR,"Invalid atom type in Atoms section of data file");

  h_q[nlocal] = atof(values[2]);
  h_q[nlocal] = utils::numeric(FLERR,values[2],true,lmp);

  h_x(nlocal,0) = coord[0];
  h_x(nlocal,1) = coord[1];
@@ -988,7 +990,7 @@ void AtomVecChargeKokkos::data_atom(double *coord, imageint imagetmp,

int AtomVecChargeKokkos::data_atom_hybrid(int nlocal, char **values)
{
  h_q[nlocal] = atof(values[0]);
  h_q[nlocal] = utils::numeric(FLERR,values[0],true,lmp);

  return 1;
}
Loading