use regex pattern matching to make style lookup more specific with less code

This commit is contained in:
Axel Kohlmeyer 2020-01-03 01:39:35 -05:00
parent e11374d433
commit 2f6018b099
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
2 changed files with 7 additions and 19 deletions

View File

@ -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;
}

View File

@ -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;
}