From 2f6018b099ddb58ca95d005e970fb360bc423e0a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 3 Jan 2020 01:39:35 -0500 Subject: [PATCH] use regex pattern matching to make style lookup more specific with less code --- src/USER-INTEL/fix_intel.cpp | 21 +++++---------------- src/USER-INTEL/fix_intel.h | 5 ++--- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/USER-INTEL/fix_intel.cpp b/src/USER-INTEL/fix_intel.cpp index 507ffa6d6f..be9d0c49b0 100644 --- a/src/USER-INTEL/fix_intel.cpp +++ b/src/USER-INTEL/fix_intel.cpp @@ -312,12 +312,7 @@ void FixIntel::init() #endif const int nstyles = _pair_intel_count; - if (force->pair_match("hybrid", 1) != NULL) { - _pair_hybrid_flag = 1; - if (force->newton_pair != 0 && force->pair->no_virial_fdotr_compute) - error->all(FLERR, - "Intel package requires fdotr virial with newton on."); - } else if (force->pair_match("hybrid/overlay", 1) != NULL) { + if (force->pair_match("^hybrid", 0) != NULL) { _pair_hybrid_flag = 1; if (force->newton_pair != 0 && force->pair->no_virial_fdotr_compute) error->all(FLERR, @@ -513,12 +508,9 @@ void FixIntel::bond_init_check() "USER-INTEL package requires same setting for newton bond and non-bond."); int intel_pair = 0; - if (force->pair_match("/intel", 0) != NULL) + if (force->pair_match("/intel$", 0) != NULL) intel_pair = 1; - else if (force->pair_match("hybrid", 1) != NULL) { - _hybrid_nonpair = 1; - if (_pair_intel_count) intel_pair = 1; - } else if (force->pair_match("hybrid/overlay", 1) != NULL) { + else if (force->pair_match("^hybrid", 1) != NULL) { _hybrid_nonpair = 1; if (_pair_intel_count) intel_pair = 1; } @@ -533,12 +525,9 @@ void FixIntel::bond_init_check() void FixIntel::kspace_init_check() { int intel_pair = 0; - if (force->pair_match("/intel", 0) != NULL) + if (force->pair_match("/intel$", 0) != NULL) intel_pair = 1; - else if (force->pair_match("hybrid", 1) != NULL) { - _hybrid_nonpair = 1; - if (_pair_intel_count) intel_pair = 1; - } else if (force->pair_match("hybrid/overlay", 1) != NULL) { + else if (force->pair_match("^hybrid", 0) != NULL) { _hybrid_nonpair = 1; if (_pair_intel_count) intel_pair = 1; } diff --git a/src/USER-INTEL/fix_intel.h b/src/USER-INTEL/fix_intel.h index 7c176fb069..a699a6d2b9 100644 --- a/src/USER-INTEL/fix_intel.h +++ b/src/USER-INTEL/fix_intel.h @@ -85,13 +85,12 @@ class FixIntel : public Fix { } inline void set_reduce_flag() { if (_nthreads > 1) _need_reduce = 1; } inline int lrt() { - if (force->kspace_match("pppm/intel", 0) && update->whichflag == 1) + if (force->kspace_match("^pppm/.*intel$", 0) && update->whichflag == 1) return _lrt; else return 0; } inline int pppm_table() { - if (force->kspace_match("pppm/intel", 0) || - force->kspace_match("pppm/disp/intel",0)) + if (force->kspace_match("^pppm/.*intel$", 0)) return INTEL_P3M_TABLE; else return 0; }