Unverified Commit 2321789d authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1993 from akohlmey/strncmp-update

Use utils::strmatch() in USER-DPD and KOKKOS for safer style matches
parents 61871c33 11b069ff
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "comm.h"
#include "domain.h"
#include "kokkos.h"
#include "utils.h"

#include <cfloat> // DBL_EPSILON

@@ -128,7 +129,7 @@ void FixRxKokkos<DeviceType>::init()

  bool eos_flag = false;
  for (int i = 0; i < modify->nfix; i++)
    if (strncmp(modify->fix[i]->style,"eos/table/rx",3) == 0) eos_flag = true;
    if (utils::strmatch(modify->fix[i]->style,"^eos/table/rx")) eos_flag = true;
  if(!eos_flag) error->all(FLERR,"fix rx requires fix eos/table/rx to be specified");

  if (update_kinetics_data)
+2 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "kokkos_few.h"
#include "kokkos.h"
#include "modify.h"
#include "utils.h"
#include <cassert>

using namespace LAMMPS_NS;
@@ -1022,7 +1023,7 @@ void PairTableRXKokkos<DeviceType>::coeff(int narg, char **arg)

  bool rx_flag = false;
  for (int i = 0; i < modify->nfix; i++)
    if (strncmp(modify->fix[i]->style,"rx",2) == 0) rx_flag = true;
    if (utils::strmatch(modify->fix[i]->style,"^rx")) rx_flag = true;
  if (!rx_flag) error->all(FLERR,"PairTableRX requires a fix rx command.");

  int ilo,ihi,jlo,jhi;
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ FixEOStableRX::FixEOStableRX(LAMMPS *lmp, int narg, char **arg) :
  rx_flag = false;
  nspecies = 1;
  for (int i = 0; i < modify->nfix; i++)
    if (strncmp(modify->fix[i]->style,"rx",2) == 0){
    if (utils::strmatch(modify->fix[i]->style,"^rx")) {
      rx_flag = true;
      nspecies = atom->nspecies_dpd;
      if(nspecies==0) error->all(FLERR,"There are no rx species specified.");
+2 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "neigh_request.h"
#include "math_special.h"
#include "pair_dpd_fdt_energy.h"
#include "utils.h"

#include <vector> // std::vector<>
#include <algorithm> // std::max
@@ -256,7 +257,7 @@ void FixRX::post_constructor()
  bool match;

  for (int i = 0; i < modify->nfix; i++)
    if (strncmp(modify->fix[i]->style,"property/atom",13) == 0)
    if (utils::strmatch(modify->fix[i]->style,"^property/atom") == 0)
      error->all(FLERR,"fix rx cannot be combined with fix property/atom");

  char **tmpspecies = new char*[maxspecies];
+6 −4
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@
#include "pair_dpd_fdt_energy.h"
#include "npair_half_bin_newton_ssa.h"
#include "citeme.h"
#include "utils.h"

using namespace LAMMPS_NS;
using namespace FixConst;
@@ -155,12 +156,13 @@ void FixShardlow::setup(int /*vflag*/)
  bool fixShardlow = false;

  for (int i = 0; i < modify->nfix; i++)
    if (strncmp(modify->fix[i]->style,"nvt",3) == 0 || strncmp(modify->fix[i]->style,"npt",3) == 0)
      error->all(FLERR,"Cannot use constant temperature integration routines with DPD.");
    if (strstr(modify->fix[i]->style,"nvt") || strstr(modify->fix[i]->style,"npt") ||
        strstr(modify->fix[i]->style,"gle") || strstr(modify->fix[i]->style,"gld"))
      error->all(FLERR,"Cannot use constant temperature integration routines with USER-DPD.");

  for (int i = 0; i < modify->nfix; i++){
    if (strncmp(modify->fix[i]->style,"shardlow",3) == 0) fixShardlow = true;
    if (strncmp(modify->fix[i]->style,"nve",3) == 0 || (strncmp(modify->fix[i]->style,"nph",3) == 0)){
    if (utils::strmatch(modify->fix[i]->style,"^shardlow")) fixShardlow = true;
    if (utils::strmatch(modify->fix[i]->style,"^nve") || utils::strmatch(modify->fix[i]->style,"^nph")){
      if(fixShardlow) break;
      else error->all(FLERR,"The deterministic integrator must follow fix shardlow in the input file.");
    }
Loading