Unverified Commit cfaa5372 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

use alternate implementation of numeric conversion functions

these new functions allow to choose between aborting with Error::one()
and exiting with Error::all(). in the long run those should replace
all of the functions in Force.
parent b469ff67
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "fix.h"
#include "memory.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

@@ -781,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] = force->inumeric(FLERR,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] = force->numeric(FLERR,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] = force->numeric(FLERR,values[6]);
  mu[nlocal][1] = force->numeric(FLERR,values[7]);
  mu[nlocal][2] = force->numeric(FLERR,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]);
@@ -815,10 +816,10 @@ void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values)

int AtomVecDipole::data_atom_hybrid(int nlocal, char **values)
{
  q[nlocal] = force->numeric(FLERR,values[0]);
  mu[nlocal][0] = force->numeric(FLERR,values[1]);
  mu[nlocal][1] = force->numeric(FLERR,values[2]);
  mu[nlocal][2] = force->numeric(FLERR,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]);
+5 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "atom_masks.h"
#include "memory_kokkos.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

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

  h_tag(nlocal) = force->inumeric(FLERR,values[0]);
  h_molecule(nlocal) = force->inumeric(FLERR,values[1]);
  h_type(nlocal) = force->inumeric(FLERR,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");

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

int AtomVecAngleKokkos::data_atom_hybrid(int nlocal, char **values)
{
  h_molecule(nlocal) = force->inumeric(FLERR,values[0]);
  h_molecule(nlocal) = utils::inumeric(FLERR,values[0],true,lmp);
  h_num_bond(nlocal) = 0;
  h_num_angle(nlocal) = 0;
  return 1;
+3 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "atom_masks.h"
#include "memory_kokkos.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

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

  h_tag[nlocal] = force->inumeric(FLERR,values[0]);
  h_type[nlocal] = force->inumeric(FLERR,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");

+5 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "atom_masks.h"
#include "memory_kokkos.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

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

  h_tag(nlocal) = force->inumeric(FLERR,values[0]);
  h_molecule(nlocal) = force->inumeric(FLERR,values[1]);
  h_type(nlocal) = force->inumeric(FLERR,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");

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

int AtomVecBondKokkos::data_atom_hybrid(int nlocal, char **values)
{
  h_molecule(nlocal) = force->inumeric(FLERR,values[0]);
  h_molecule(nlocal) = utils::inumeric(FLERR,values[0],true,lmp);
  h_num_bond(nlocal) = 0;
  return 1;
}
+5 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "atom_masks.h"
#include "memory_kokkos.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

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

  h_tag[nlocal] = force->inumeric(FLERR,values[0]);
  h_type[nlocal] = force->inumeric(FLERR,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] = force->numeric(FLERR,values[2]);
  h_q[nlocal] = utils::numeric(FLERR,values[2],true,lmp);

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

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

  return 1;
}
Loading