From 251dcdf8a20a9aad519dc6ac8064286e50bd3b9e Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 16 Nov 2020 15:33:15 -0500 Subject: [PATCH] Make use of ENERGY_ and VIRIAL_ constants --- src/KOKKOS/pair_hybrid_kokkos.cpp | 12 +-- src/KOKKOS/pair_reaxc_kokkos.cpp | 8 +- src/USER-INTEL/intel_preprocess.h | 4 +- src/USER-INTEL/pair_buck_coul_cut_intel.cpp | 2 +- src/USER-INTEL/pair_buck_intel.cpp | 2 +- src/USER-INTEL/pair_dpd_intel.cpp | 2 +- src/USER-INTEL/pair_eam_intel.cpp | 2 +- src/USER-INTEL/pair_gayberne_intel.cpp | 2 +- .../pair_lj_charmm_coul_charmm_intel.cpp | 2 +- .../pair_lj_charmm_coul_long_intel.cpp | 2 +- .../pair_lj_cut_coul_long_intel.cpp | 2 +- src/USER-INTEL/pair_lj_cut_intel.cpp | 2 +- src/USER-OMP/thr_omp.cpp | 90 +++++++++---------- src/angle.cpp | 10 +-- src/bond.cpp | 8 +- src/dihedral.cpp | 10 +-- src/fix.cpp | 12 +-- src/improper.cpp | 10 +-- src/kspace.cpp | 8 +- src/min.cpp | 8 +- src/pair_hybrid.cpp | 16 ++-- 21 files changed, 108 insertions(+), 106 deletions(-) diff --git a/src/KOKKOS/pair_hybrid_kokkos.cpp b/src/KOKKOS/pair_hybrid_kokkos.cpp index d4888883b0..0d28e4a15d 100644 --- a/src/KOKKOS/pair_hybrid_kokkos.cpp +++ b/src/KOKKOS/pair_hybrid_kokkos.cpp @@ -64,23 +64,23 @@ void PairHybridKokkos::compute(int eflag, int vflag) int i,j,m,n; // if no_virial_fdotr_compute is set and global component of - // incoming vflag = 2, then - // reset vflag as if global component were 1 + // incoming vflag = VIRIAL_FDOTR, then + // reset vflag as if global component were VIRIAL_PAIR // necessary since one or more sub-styles cannot compute virial as F dot r int neighflag = lmp->kokkos->neighflag; if (neighflag == FULL) no_virial_fdotr_compute = 1; - if (no_virial_fdotr_compute && vflag % 4 == 2) vflag = 1 + vflag/4 * 4; + if (no_virial_fdotr_compute && vflag & VIRIAL_FDOTR) vflag = VIRIAL_PAIR | (vflag & ~VIRIAL_FDOTR); ev_init(eflag,vflag); - // check if global component of incoming vflag = 2 - // if so, reset vflag passed to substyle as if it were 0 + // check if global component of incoming vflag = VIRIAL_FDOTR + // if so, reset vflag passed to substyle as if it were VIRIAL_NONE // necessary so substyle will not invoke virial_fdotr_compute() int vflag_substyle; - if (vflag % 4 == 2) vflag_substyle = vflag/4 * 4; + if (vflag & VIRIAL_FDOTR) vflag_substyle = VIRIAL_NONE | (vflag & ~VIRIAL_FDOTR); else vflag_substyle = vflag; double *saved_special = save_special(); diff --git a/src/KOKKOS/pair_reaxc_kokkos.cpp b/src/KOKKOS/pair_reaxc_kokkos.cpp index 12d4c3924a..b281897b0d 100644 --- a/src/KOKKOS/pair_reaxc_kokkos.cpp +++ b/src/KOKKOS/pair_reaxc_kokkos.cpp @@ -3640,12 +3640,12 @@ void PairReaxCKokkos::ev_setup(int eflag, int vflag, int) evflag = 1; eflag_either = eflag; - eflag_global = eflag % 2; - eflag_atom = eflag / 2; + eflag_global = eflag & ENERGY_GLOBAL; + eflag_atom = eflag & ENERGY_ATOM; vflag_either = vflag; - vflag_global = vflag % 4; - vflag_atom = vflag / 4; + vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR); + vflag_atom = vflag / 4; // TODO // reallocate per-atom arrays if necessary diff --git a/src/USER-INTEL/intel_preprocess.h b/src/USER-INTEL/intel_preprocess.h index 3e547b58a0..3c285871cf 100644 --- a/src/USER-INTEL/intel_preprocess.h +++ b/src/USER-INTEL/intel_preprocess.h @@ -502,7 +502,7 @@ enum {TIME_PACK, TIME_HOST_NEIGHBOR, TIME_HOST_PAIR, TIME_OFFLOAD_NEIGHBOR, acc_t *f_scalar = &f_start[0].x; \ int f_stride4 = f_stride * 4; \ int t; \ - if (vflag == 2) t = 4; else t = 1; \ + if (vflag == VIRIAL_FDOTR) t = 4; else t = 1; \ acc_t *f_scalar2 = f_scalar + f_stride4 * t; \ for ( ; t < nthreads; t++) { \ _use_simd_pragma("vector aligned") \ @@ -512,7 +512,7 @@ enum {TIME_PACK, TIME_HOST_NEIGHBOR, TIME_HOST_PAIR, TIME_OFFLOAD_NEIGHBOR, f_scalar2 += f_stride4; \ } \ \ - if (vflag == 2) { \ + if (vflag == VIRIAL_FDOTR) { \ int nt_min = MIN(4,nthreads); \ IP_PRE_fdotr_acc_force_l5(iifrom, iito, minlocal, nt_min, f_start, \ f_stride, pos, ov0, ov1, ov2, ov3, ov4, \ diff --git a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp index 80993f212e..3da131684c 100644 --- a/src/USER-INTEL/pair_buck_coul_cut_intel.cpp +++ b/src/USER-INTEL/pair_buck_coul_cut_intel.cpp @@ -245,7 +245,7 @@ void PairBuckCoulCutIntel::eval(const int offload, const int vflag, fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = secoul = (acc_t)0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; #if defined(LMP_SIMD_COMPILER) #pragma vector aligned diff --git a/src/USER-INTEL/pair_buck_intel.cpp b/src/USER-INTEL/pair_buck_intel.cpp index 95b37796ba..afa9b448b5 100644 --- a/src/USER-INTEL/pair_buck_intel.cpp +++ b/src/USER-INTEL/pair_buck_intel.cpp @@ -227,7 +227,7 @@ void PairBuckIntel::eval(const int offload, const int vflag, fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = (acc_t)0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; #if defined(LMP_SIMD_COMPILER) #pragma vector aligned diff --git a/src/USER-INTEL/pair_dpd_intel.cpp b/src/USER-INTEL/pair_dpd_intel.cpp index 5adcb4c6ea..a0a71e4a37 100644 --- a/src/USER-INTEL/pair_dpd_intel.cpp +++ b/src/USER-INTEL/pair_dpd_intel.cpp @@ -265,7 +265,7 @@ void PairDPDIntel::eval(const int offload, const int vflag, fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = (acc_t)0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; if (rngi + jnum > rng_size) { #ifdef LMP_USE_MKL_RNG diff --git a/src/USER-INTEL/pair_eam_intel.cpp b/src/USER-INTEL/pair_eam_intel.cpp index 6ebd7abe3d..a25d588ecf 100644 --- a/src/USER-INTEL/pair_eam_intel.cpp +++ b/src/USER-INTEL/pair_eam_intel.cpp @@ -481,7 +481,7 @@ void PairEAMIntel::eval(const int offload, const int vflag, fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = (acc_t)0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; int ej = 0; #if defined(LMP_SIMD_COMPILER) diff --git a/src/USER-INTEL/pair_gayberne_intel.cpp b/src/USER-INTEL/pair_gayberne_intel.cpp index a9aa00340e..c34c6965de 100644 --- a/src/USER-INTEL/pair_gayberne_intel.cpp +++ b/src/USER-INTEL/pair_gayberne_intel.cpp @@ -399,7 +399,7 @@ void PairGayBerneIntel::eval(const int offload, const int vflag, if (EFLAG) fwtmp = sevdwl = (acc_t)0.0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0.0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0.0; bool multiple_forms = false; int packed_j = 0; diff --git a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp index bf55a53981..8f4dba4a24 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp @@ -265,7 +265,7 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = secoul = (acc_t)0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; int ej = 0; #if defined(LMP_SIMD_COMPILER) diff --git a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp index 2f375fd08c..ffed4853ba 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_long_intel.cpp @@ -282,7 +282,7 @@ void PairLJCharmmCoulLongIntel::eval(const int offload, const int vflag, fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = secoul = (acc_t)0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; int ej = 0; #if defined(LMP_SIMD_COMPILER) diff --git a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp index fa3cfd7bc3..c1d85ad37f 100644 --- a/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_coul_long_intel.cpp @@ -275,7 +275,7 @@ void PairLJCutCoulLongIntel::eval(const int offload, const int vflag, fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = secoul = (acc_t)0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; int ej = 0; #if defined(LMP_SIMD_COMPILER) diff --git a/src/USER-INTEL/pair_lj_cut_intel.cpp b/src/USER-INTEL/pair_lj_cut_intel.cpp index 426abb7660..8697a4f548 100644 --- a/src/USER-INTEL/pair_lj_cut_intel.cpp +++ b/src/USER-INTEL/pair_lj_cut_intel.cpp @@ -233,7 +233,7 @@ void PairLJCutIntel::eval(const int offload, const int vflag, fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = (acc_t)0; if (NEWTON_PAIR == 0) - if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; + if (vflag == VIRIAL_PAIR) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; #if defined(LMP_SIMD_COMPILER) #pragma vector aligned nog2s diff --git a/src/USER-OMP/thr_omp.cpp b/src/USER-OMP/thr_omp.cpp index 0a8611707b..e590aedc87 100644 --- a/src/USER-OMP/thr_omp.cpp +++ b/src/USER-OMP/thr_omp.cpp @@ -70,20 +70,20 @@ void ThrOMP::ev_setup_thr(int eflag, int vflag, int nall, double *eatom, if (tid == 0) thr_error = 0; if (thr_style & THR_PAIR) { - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { thr->eatom_pair = eatom + tid*nall; if (nall > 0) memset(&(thr->eatom_pair[0]),0,nall*sizeof(double)); } // per-atom virial and per-atom centroid virial are the same for two-body // many-body pair styles not yet implemented - if (vflag & 12) { + if (vflag & (VIRIAL_ATOM | VIRIAL_CENTROID)) { thr->vatom_pair = vatom + tid*nall; if (nall > 0) memset(&(thr->vatom_pair[0][0]),0,nall*6*sizeof(double)); } // check cvatom_pair, because can't access centroidstressflag - if ((vflag & 8) && cvatom) { + if ((vflag & VIRIAL_CENTROID) && cvatom) { thr->cvatom_pair = cvatom + tid*nall; if (nall > 0) memset(&(thr->cvatom_pair[0][0]),0,nall*9*sizeof(double)); @@ -94,13 +94,13 @@ void ThrOMP::ev_setup_thr(int eflag, int vflag, int nall, double *eatom, } if (thr_style & THR_BOND) { - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { thr->eatom_bond = eatom + tid*nall; if (nall > 0) memset(&(thr->eatom_bond[0]),0,nall*sizeof(double)); } // per-atom virial and per-atom centroid virial are the same for bonds - if (vflag & 12) { + if (vflag & (VIRIAL_ATOM | VIRIAL_CENTROID)) { thr->vatom_bond = vatom + tid*nall; if (nall > 0) memset(&(thr->vatom_bond[0][0]),0,nall*6*sizeof(double)); @@ -108,17 +108,17 @@ void ThrOMP::ev_setup_thr(int eflag, int vflag, int nall, double *eatom, } if (thr_style & THR_ANGLE) { - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { thr->eatom_angle = eatom + tid*nall; if (nall > 0) memset(&(thr->eatom_angle[0]),0,nall*sizeof(double)); } - if (vflag & 4) { + if (vflag & VIRIAL_ATOM) { thr->vatom_angle = vatom + tid*nall; if (nall > 0) memset(&(thr->vatom_angle[0][0]),0,nall*6*sizeof(double)); } - if (vflag & 8) { + if (vflag & VIRIAL_CENTROID) { thr->cvatom_angle = cvatom + tid*nall; if (nall > 0) memset(&(thr->cvatom_angle[0][0]),0,nall*9*sizeof(double)); @@ -126,17 +126,17 @@ void ThrOMP::ev_setup_thr(int eflag, int vflag, int nall, double *eatom, } if (thr_style & THR_DIHEDRAL) { - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { thr->eatom_dihed = eatom + tid*nall; if (nall > 0) memset(&(thr->eatom_dihed[0]),0,nall*sizeof(double)); } - if (vflag & 4) { + if (vflag & VIRIAL_ATOM) { thr->vatom_dihed = vatom + tid*nall; if (nall > 0) memset(&(thr->vatom_dihed[0][0]),0,nall*6*sizeof(double)); } - if (vflag & 8) { + if (vflag & VIRIAL_CENTROID) { thr->cvatom_dihed = cvatom + tid*nall; if (nall > 0) memset(&(thr->cvatom_dihed[0][0]),0,nall*9*sizeof(double)); @@ -144,17 +144,17 @@ void ThrOMP::ev_setup_thr(int eflag, int vflag, int nall, double *eatom, } if (thr_style & THR_IMPROPER) { - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { thr->eatom_imprp = eatom + tid*nall; if (nall > 0) memset(&(thr->eatom_imprp[0]),0,nall*sizeof(double)); } - if (vflag & 4) { + if (vflag & VIRIAL_ATOM) { thr->vatom_imprp = vatom + tid*nall; if (nall > 0) memset(&(thr->vatom_imprp[0][0]),0,nall*6*sizeof(double)); } - if (vflag & 8) { + if (vflag & VIRIAL_CENTROID) { thr->cvatom_imprp = cvatom + tid*nall; if (nall > 0) memset(&(thr->cvatom_imprp[0][0]),0,nall*9*sizeof(double)); @@ -222,29 +222,29 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, #pragma omp critical #endif { - if (eflag & 1) { + if (eflag & ENERGY_GLOBAL) { pair->eng_vdwl += thr->eng_vdwl; pair->eng_coul += thr->eng_coul; thr->eng_vdwl = 0.0; thr->eng_coul = 0.0; } - if (vflag & 3) + if (vflag & (VIRIAL_PAIR | VIRIAL_FDOTR)) for (int i=0; i < 6; ++i) { pair->virial[i] += thr->virial_pair[i]; thr->virial_pair[i] = 0.0; } } - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { data_reduce_thr(&(pair->eatom[0]), nall, nthreads, 1, tid); } // per-atom virial and per-atom centroid virial are the same for two-body // many-body pair styles not yet implemented - if (vflag & 12) { + if (vflag & (VIRIAL_ATOM | VIRIAL_CENTROID)) { data_reduce_thr(&(pair->vatom[0][0]), nall, nthreads, 6, tid); } // check cvatom_pair, because can't access centroidstressflag - if ((vflag & 8) && thr->cvatom_pair) { + if ((vflag & VIRIAL_CENTROID) && thr->cvatom_pair) { data_reduce_thr(&(pair->cvatom[0][0]), nall, nthreads, 9, tid); } } @@ -259,12 +259,12 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, #pragma omp critical #endif { - if (eflag & 1) { + if (eflag & ENERGY_GLOBAL) { bond->energy += thr->eng_bond; thr->eng_bond = 0.0; } - if (vflag & 3) { + if (vflag & (VIRIAL_PAIR | VIRIAL_FDOTR)) { for (int i=0; i < 6; ++i) { bond->virial[i] += thr->virial_bond[i]; thr->virial_bond[i] = 0.0; @@ -272,11 +272,11 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, } } - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { data_reduce_thr(&(bond->eatom[0]), nall, nthreads, 1, tid); } // per-atom virial and per-atom centroid virial are the same for bonds - if (vflag & 12) { + if (vflag & (VIRIAL_ATOM | VIRIAL_CENTROID)) { data_reduce_thr(&(bond->vatom[0][0]), nall, nthreads, 6, tid); } @@ -291,12 +291,12 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, #pragma omp critical #endif { - if (eflag & 1) { + if (eflag & ENERGY_GLOBAL) { angle->energy += thr->eng_angle; thr->eng_angle = 0.0; } - if (vflag & 3) { + if (vflag & (VIRIAL_PAIR | VIRIAL_FDOTR)) { for (int i=0; i < 6; ++i) { angle->virial[i] += thr->virial_angle[i]; thr->virial_angle[i] = 0.0; @@ -304,13 +304,13 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, } } - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { data_reduce_thr(&(angle->eatom[0]), nall, nthreads, 1, tid); } - if (vflag & 4) { + if (vflag & VIRIAL_ATOM) { data_reduce_thr(&(angle->vatom[0][0]), nall, nthreads, 6, tid); } - if (vflag & 8) { + if (vflag & VIRIAL_CENTROID) { data_reduce_thr(&(angle->cvatom[0][0]), nall, nthreads, 9, tid); } @@ -325,12 +325,12 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, #pragma omp critical #endif { - if (eflag & 1) { + if (eflag & ENERGY_GLOBAL) { dihedral->energy += thr->eng_dihed; thr->eng_dihed = 0.0; } - if (vflag & 3) { + if (vflag & (VIRIAL_PAIR | VIRIAL_FDOTR)) { for (int i=0; i < 6; ++i) { dihedral->virial[i] += thr->virial_dihed[i]; thr->virial_dihed[i] = 0.0; @@ -338,13 +338,13 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, } } - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { data_reduce_thr(&(dihedral->eatom[0]), nall, nthreads, 1, tid); } - if (vflag & 4) { + if (vflag & VIRIAL_ATOM) { data_reduce_thr(&(dihedral->vatom[0][0]), nall, nthreads, 6, tid); } - if (vflag & 8) { + if (vflag & VIRIAL_CENTROID) { data_reduce_thr(&(dihedral->cvatom[0][0]), nall, nthreads, 9, tid); } @@ -360,7 +360,7 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, #pragma omp critical #endif { - if (eflag & 1) { + if (eflag & ENERGY_GLOBAL) { dihedral->energy += thr->eng_dihed; pair->eng_vdwl += thr->eng_vdwl; pair->eng_coul += thr->eng_coul; @@ -369,7 +369,7 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, thr->eng_coul = 0.0; } - if (vflag & 3) { + if (vflag & (VIRIAL_PAIR | VIRIAL_FDOTR)) { for (int i=0; i < 6; ++i) { dihedral->virial[i] += thr->virial_dihed[i]; pair->virial[i] += thr->virial_pair[i]; @@ -379,23 +379,23 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, } } - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { data_reduce_thr(&(dihedral->eatom[0]), nall, nthreads, 1, tid); data_reduce_thr(&(pair->eatom[0]), nall, nthreads, 1, tid); } - if (vflag & 4) { + if (vflag & VIRIAL_ATOM) { data_reduce_thr(&(dihedral->vatom[0][0]), nall, nthreads, 6, tid); } - if (vflag & 8) { + if (vflag & VIRIAL_CENTROID) { data_reduce_thr(&(dihedral->cvatom[0][0]), nall, nthreads, 9, tid); } // per-atom virial and per-atom centroid virial are the same for two-body // many-body pair styles not yet implemented - if (vflag & 12) { + if (vflag & (VIRIAL_ATOM | VIRIAL_CENTROID)) { data_reduce_thr(&(pair->vatom[0][0]), nall, nthreads, 6, tid); } // check cvatom_pair, because can't access centroidstressflag - if ((vflag & 8) && thr->cvatom_pair) { + if ((vflag & VIRIAL_CENTROID) && thr->cvatom_pair) { data_reduce_thr(&(pair->cvatom[0][0]), nall, nthreads, 9, tid); } } @@ -409,12 +409,12 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, #pragma omp critical #endif { - if (eflag & 1) { + if (eflag & ENERGY_GLOBAL) { improper->energy += thr->eng_imprp; thr->eng_imprp = 0.0; } - if (vflag & 3) { + if (vflag & (VIRIAL_PAIR | VIRIAL_FDOTR)) { for (int i=0; i < 6; ++i) { improper->virial[i] += thr->virial_imprp[i]; thr->virial_imprp[i] = 0.0; @@ -422,13 +422,13 @@ void ThrOMP::reduce_thr(void *style, const int eflag, const int vflag, } } - if (eflag & 2) { + if (eflag & ENERGY_ATOM) { data_reduce_thr(&(improper->eatom[0]), nall, nthreads, 1, tid); } - if (vflag & 4) { + if (vflag & VIRIAL_ATOM) { data_reduce_thr(&(improper->vatom[0][0]), nall, nthreads, 6, tid); } - if (vflag & 8) { + if (vflag & VIRIAL_CENTROID) { data_reduce_thr(&(improper->cvatom[0][0]), nall, nthreads, 9, tid); } diff --git a/src/angle.cpp b/src/angle.cpp index 75925b7b94..83f5431683 100644 --- a/src/angle.cpp +++ b/src/angle.cpp @@ -94,12 +94,12 @@ void Angle::ev_setup(int eflag, int vflag, int alloc) evflag = 1; eflag_either = eflag; - eflag_global = eflag % 2; - eflag_atom = eflag / 2; + eflag_global = eflag & ENERGY_GLOBAL; + eflag_atom = eflag & ENERGY_ATOM; - vflag_global = vflag % 4; - vflag_atom = vflag & 4; - cvflag_atom = vflag & 8; + vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR); + vflag_atom = vflag & VIRIAL_ATOM; + cvflag_atom = vflag & VIRIAL_CENTROID; vflag_either = vflag_global || vflag_atom; // reallocate per-atom arrays if necessary diff --git a/src/bond.cpp b/src/bond.cpp index f29d9c8b5a..ddd1ae9b37 100644 --- a/src/bond.cpp +++ b/src/bond.cpp @@ -98,13 +98,13 @@ void Bond::ev_setup(int eflag, int vflag, int alloc) evflag = 1; eflag_either = eflag; - eflag_global = eflag % 2; - eflag_atom = eflag / 2; + eflag_global = eflag & ENERGY_GLOBAL; + eflag_atom = eflag & ENERGY_ATOM; vflag_either = vflag; - vflag_global = vflag % 4; + vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR); // per-atom virial and per-atom centroid virial are the same for bonds - vflag_atom = vflag / 4; + vflag_atom = vflag & (VIRIAL_ATOM | VIRIAL_CENTROID); // reallocate per-atom arrays if necessary diff --git a/src/dihedral.cpp b/src/dihedral.cpp index f7e9f9fb4a..1d77598e38 100644 --- a/src/dihedral.cpp +++ b/src/dihedral.cpp @@ -93,12 +93,12 @@ void Dihedral::ev_setup(int eflag, int vflag, int alloc) evflag = 1; eflag_either = eflag; - eflag_global = eflag % 2; - eflag_atom = eflag / 2; + eflag_global = eflag & ENERGY_GLOBAL; + eflag_atom = eflag & ENERGY_ATOM; - vflag_global = vflag % 4; - vflag_atom = vflag & 4; - cvflag_atom = vflag & 8; + vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR); + vflag_atom = vflag & VIRIAL_ATOM; + cvflag_atom = vflag & VIRIAL_CENTROID; vflag_either = vflag_global || vflag_atom; // reallocate per-atom arrays if necessary diff --git a/src/fix.cpp b/src/fix.cpp index 16628e5374..3814cd4cb8 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -189,12 +189,12 @@ void Fix::ev_setup(int eflag, int vflag) evflag = 1; eflag_either = eflag; - eflag_global = eflag % 2; - eflag_atom = eflag / 2; + eflag_global = eflag % 2; // TODO + eflag_atom = eflag / 2; // TODO vflag_either = vflag; - vflag_global = vflag % 4; - vflag_atom = vflag / 4; + vflag_global = vflag % 4; // TODO + vflag_atom = vflag / 4; // TODO // reallocate per-atom arrays if necessary @@ -250,8 +250,8 @@ void Fix::v_setup(int vflag) evflag = 1; - vflag_global = vflag % 4; - vflag_atom = vflag / 4; + vflag_global = vflag % 4; // TODO + vflag_atom = vflag / 4; // TODO // reallocate per-atom array if necessary diff --git a/src/improper.cpp b/src/improper.cpp index f1accf25c7..f716f84969 100644 --- a/src/improper.cpp +++ b/src/improper.cpp @@ -91,12 +91,12 @@ void Improper::ev_setup(int eflag, int vflag, int alloc) evflag = 1; eflag_either = eflag; - eflag_global = eflag % 2; - eflag_atom = eflag / 2; + eflag_global = eflag & ENERGY_GLOBAL; + eflag_atom = eflag & ENERGY_ATOM; - vflag_global = vflag % 4; - vflag_atom = vflag & 4; - cvflag_atom = vflag & 8; + vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR); + vflag_atom = vflag & VIRIAL_ATOM; + cvflag_atom = vflag & VIRIAL_CENTROID; vflag_either = vflag_global || vflag_atom; // reallocate per-atom arrays if necessary diff --git a/src/kspace.cpp b/src/kspace.cpp index 9ca35b9e72..a373c65a9d 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -232,12 +232,12 @@ void KSpace::ev_setup(int eflag, int vflag, int alloc) evflag = 1; eflag_either = eflag; - eflag_global = eflag % 2; - eflag_atom = eflag / 2; + eflag_global = eflag & ENERGY_GLOBAL; + eflag_atom = eflag & ENERGY_ATOM; vflag_either = vflag; - vflag_global = vflag % 4; - vflag_atom = vflag / 4; + vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR); + vflag_atom = vflag / 4; // TODO if (eflag_atom || vflag_atom) evflag_atom = 1; else evflag_atom = 0; diff --git a/src/min.cpp b/src/min.cpp index 1db5c8b239..b62bceba7a 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -798,6 +798,8 @@ void Min::ev_setup() } /* ---------------------------------------------------------------------- + TODO: comment + set eflag,vflag for current iteration invoke matchstep() on all timestep-dependent computes to clear their arrays eflag/vflag based on computes that need info on this ntimestep @@ -829,7 +831,7 @@ void Min::ev_set(bigint ntimestep) int eflag_atom = 0; for (i = 0; i < nelist_atom; i++) if (elist_atom[i]->matchstep(ntimestep)) flag = 1; - if (flag) eflag_atom = 2; + if (flag) eflag_atom = ENERGY_ATOM; if (eflag_global) update->eflag_global = update->ntimestep; if (eflag_atom) update->eflag_atom = update->ntimestep; @@ -845,13 +847,13 @@ void Min::ev_set(bigint ntimestep) int vflag_atom = 0; for (i = 0; i < nvlist_atom; i++) if (vlist_atom[i]->matchstep(ntimestep)) flag = 1; - if (flag) vflag_atom = 4; + if (flag) vflag_atom = VIRIAL_ATOM; flag = 0; int cvflag_atom = 0; for (i = 0; i < ncvlist_atom; i++) if (cvlist_atom[i]->matchstep(ntimestep)) flag = 1; - if (flag) cvflag_atom = 8; + if (flag) cvflag_atom = VIRIAL_CENTROID; if (vflag_global) update->vflag_global = update->ntimestep; if (vflag_atom || cvflag_atom) update->vflag_atom = update->ntimestep; diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 1c3ef45307..8f58d14e20 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -82,10 +82,10 @@ PairHybrid::~PairHybrid() /* ---------------------------------------------------------------------- call each sub-style's compute() or compute_outer() function accumulate sub-style global/peratom energy/virial in hybrid - for global vflag = 1: + for global vflag = VIRIAL_PAIR: each sub-style computes own virial[6] sum sub-style virial[6] to hybrid's virial[6] - for global vflag = 2: + for global vflag = VIRIAL_FDOTR: call sub-style with adjusted vflag to prevent it calling virial_fdotr_compute() hybrid calls virial_fdotr_compute() on final accumulated f @@ -96,20 +96,20 @@ void PairHybrid::compute(int eflag, int vflag) int i,j,m,n; // if no_virial_fdotr_compute is set and global component of - // incoming vflag = 2, then - // reset vflag as if global component were 1 + // incoming vflag = VIRIAL_FDOTR, then + // reset vflag as if global component were VIRIAL_PAIR // necessary since one or more sub-styles cannot compute virial as F dot r - if (no_virial_fdotr_compute && vflag % 4 == 2) vflag = 1 + vflag/4 * 4; + if (no_virial_fdotr_compute && (vflag & VIRIAL_FDOTR)) vflag = VIRIAL_PAIR | (vflag & ~VIRIAL_FDOTR); ev_init(eflag,vflag); - // check if global component of incoming vflag = 2 - // if so, reset vflag passed to substyle as if it were 0 + // check if global component of incoming vflag = VIRIAL_FDOTR + // if so, reset vflag passed to substyle as if it were VIRIAL_NONE // necessary so substyle will not invoke virial_fdotr_compute() int vflag_substyle; - if (vflag % 4 == 2) vflag_substyle = vflag/4 * 4; + if (vflag & VIRIAL_FDOTR) vflag_substyle = vflag & ~VIRIAL_FDOTR; else vflag_substyle = vflag; double *saved_special = save_special();