From 1312a76dec2413ac9cc7643c3bd3e57ad8058cd1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 29 Jan 2021 15:32:19 -0500 Subject: [PATCH 01/26] eliminate use of strtok() by using ValueTokenizer class --- src/MLIAP/mliap_model.cpp | 43 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp index aa198e6085..882f64263f 100644 --- a/src/MLIAP/mliap_model.cpp +++ b/src/MLIAP/mliap_model.cpp @@ -20,6 +20,7 @@ #include "comm.h" #include "error.h" #include "memory.h" +#include "tokenizer.h" #include @@ -30,7 +31,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -MLIAPModel::MLIAPModel(LAMMPS* lmp, char* coefffilename) : Pointers(lmp) +MLIAPModel::MLIAPModel(LAMMPS *lmp, char *) : Pointers(lmp) { nparams = 0; nelements = 0; @@ -44,7 +45,6 @@ MLIAPModel::~MLIAPModel() { } - /* ---------------------------------------------------------------------- placeholder ------------------------------------------------------------------------- */ @@ -74,7 +74,7 @@ void MLIAPModel::set_ndescriptors(int ndescriptors_in) /* ---------------------------------------------------------------------- */ -MLIAPModelSimple::MLIAPModelSimple(LAMMPS* lmp, char* coefffilename) : MLIAPModel(lmp, coefffilename) +MLIAPModelSimple::MLIAPModelSimple(LAMMPS *lmp, char *coefffilename) : MLIAPModel(lmp, coefffilename) { coeffelem = nullptr; if (coefffilename) read_coeffs(coefffilename); @@ -87,6 +87,7 @@ MLIAPModelSimple::~MLIAPModelSimple() memory->destroy(coeffelem); } +/* ---------------------------------------------------------------------- */ void MLIAPModelSimple::read_coeffs(char *coefffilename) { @@ -130,14 +131,14 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) // words = ptrs to all words in line // strip single and double quotes from words - char* words[MAXWORD]; - int iword = 0; - words[iword] = strtok(line,"' \t\n\r\f"); - iword = 1; - words[iword] = strtok(nullptr,"' \t\n\r\f"); - - nelements = atoi(words[0]); - nparams = atoi(words[1]); + try { + ValueTokenizer coeffs(line); + nelements = coeffs.next_int(); + nparams = coeffs.next_int(); + } catch (TokenizerException &e) { + error->all(FLERR,fmt::format("Incorrect format in MLIAPModel coefficient " + "file: {}",e.what())); + } // set up coeff lists @@ -157,19 +158,19 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) MPI_Bcast(&eof,1,MPI_INT,0,world); if (eof) - error->all(FLERR,"Incorrect format in coefficient file"); + error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); - nwords = utils::trim_and_count_words(line); - if (nwords != 1) - error->all(FLERR,"Incorrect format in coefficient file"); - - iword = 0; - words[iword] = strtok(line,"' \t\n\r\f"); - - coeffelem[ielem][icoeff] = atof(words[0]); - + try { + ValueTokenizer coeffs(utils::trim_comment(line)); + if (coeffs.count() != 1) + throw TokenizerException("Wrong number of items",""); + coeffelem[ielem][icoeff] = coeffs.next_double(); + } catch (TokenizerException &e) { + error->all(FLERR,fmt::format("Incorrect format in MLIAPModel " + "coefficient file: {}",e.what())); + } } } From 461364c0060b7f00b48b17d486a54e629450b7ed Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 29 Jan 2021 15:50:26 -0500 Subject: [PATCH 02/26] silence compiler warnings --- src/MLIAP/mliap_model_python.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MLIAP/mliap_model_python.cpp b/src/MLIAP/mliap_model_python.cpp index 823cee711f..4dda7df357 100644 --- a/src/MLIAP/mliap_model_python.cpp +++ b/src/MLIAP/mliap_model_python.cpp @@ -87,7 +87,7 @@ int MLIAPModelPython::get_nparams() return nparams; } -void MLIAPModelPython::read_coeffs(char * fname) +void MLIAPModelPython::read_coeffs(char *fname) { PyGILState_STATE gstate = PyGILState_Ensure(); @@ -134,7 +134,7 @@ void MLIAPModelPython::connect_param_counts() for each atom beta_i = dE(B_i)/dB_i ---------------------------------------------------------------------- */ -void MLIAPModelPython::compute_gradients(MLIAPData* data) +void MLIAPModelPython::compute_gradients(MLIAPData *data) { if (not model_loaded) { error->all(FLERR,"Model not loaded."); @@ -167,7 +167,7 @@ void MLIAPModelPython::compute_gradients(MLIAPData* data) egradient is derivative of energy w.r.t. parameters ---------------------------------------------------------------------- */ -void MLIAPModelPython::compute_gradgrads(class MLIAPData* data) +void MLIAPModelPython::compute_gradgrads(class MLIAPData *) { error->all(FLERR,"compute_gradgrads not implemented"); } @@ -177,7 +177,7 @@ void MLIAPModelPython::compute_gradgrads(class MLIAPData* data) egradient is derivative of energy w.r.t. parameters ---------------------------------------------------------------------- */ -void MLIAPModelPython::compute_force_gradients(class MLIAPData* data) +void MLIAPModelPython::compute_force_gradients(class MLIAPData *) { error->all(FLERR,"compute_force_gradients not implemented"); } @@ -186,7 +186,7 @@ void MLIAPModelPython::compute_force_gradients(class MLIAPData* data) count the number of non-zero entries in gamma matrix ---------------------------------------------------------------------- */ -int MLIAPModelPython::get_gamma_nnz(class MLIAPData* data) +int MLIAPModelPython::get_gamma_nnz(class MLIAPData *) { // todo: get_gamma_nnz return 0; From a23e45cc0c5f01ac0a051cb2e884b56af8e61923 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 29 Jan 2021 15:50:33 -0500 Subject: [PATCH 03/26] remove dead code --- src/SPIN/pair_spin_exchange_biquadratic.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/SPIN/pair_spin_exchange_biquadratic.cpp b/src/SPIN/pair_spin_exchange_biquadratic.cpp index f2baf1333b..352949e5c3 100644 --- a/src/SPIN/pair_spin_exchange_biquadratic.cpp +++ b/src/SPIN/pair_spin_exchange_biquadratic.cpp @@ -474,7 +474,7 @@ double PairSpinExchangeBiquadratic::compute_energy(int i, int j, double rsq, int *type = atom->type; int itype,jtype; double Jex,Kex,ra,sdots; - double rj,rk,r2j,r2k,ir3j,ir3k; + double rj,rk,r2j,r2k; double energy = 0.0; itype = type[i]; jtype = type[j]; @@ -482,10 +482,8 @@ double PairSpinExchangeBiquadratic::compute_energy(int i, int j, double rsq, ra = sqrt(rsq); rj = ra/J3[itype][jtype]; r2j = rsq/J3[itype][jtype]/J3[itype][jtype]; - ir3j = 1.0/(rj*rj*rj); rk = ra/K3[itype][jtype]; r2k = rsq/K3[itype][jtype]/K3[itype][jtype]; - ir3k = 1.0/(rk*rk*rk); Jex = 4.0*J1_mech[itype][jtype]*r2j; Jex *= (1.0-J2[itype][jtype]*r2j); From 48fa5e6736827c7df7f3dd5398110015af38a6ba Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 29 Jan 2021 15:59:52 -0500 Subject: [PATCH 04/26] fix argument bug --- src/KOKKOS/atom_vec_dpd_kokkos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index 8c1668a411..ad47b6f108 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -784,7 +784,7 @@ struct AtomVecDPDKokkos_PackBorder { _uCond(uCond), _uMech(uMech), _uChem(uChem), - _uCG(uCGnew), + _uCG(uCG), _uCGnew(uCGnew), _dx(dx),_dy(dy),_dz(dz) {} From 72b022c5fab61333ee157635a0ffdefba94ead95 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 29 Jan 2021 16:14:06 -0500 Subject: [PATCH 05/26] make implicit copy contructor explicit and thus silence compiler warnings --- src/USER-REAXC/reaxc_types.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/USER-REAXC/reaxc_types.h b/src/USER-REAXC/reaxc_types.h index f038f00bb0..36678ad2b0 100644 --- a/src/USER-REAXC/reaxc_types.h +++ b/src/USER-REAXC/reaxc_types.h @@ -862,14 +862,23 @@ struct cubic_spline_coef cubic_spline_coef() {} LAMMPS_INLINE - void operator = (const cubic_spline_coef& rhs) { + cubic_spline_coef(const cubic_spline_coef &_c) { + a = _c.a; + b = _c.b; + c = _c.c; + d = _c.d; + } + + LAMMPS_INLINE + void operator=(const cubic_spline_coef &rhs) { a = rhs.a; b = rhs.b; c = rhs.c; d = rhs.d; } + LAMMPS_INLINE - void operator = (const cubic_spline_coef& rhs) volatile { + void operator=(const cubic_spline_coef &rhs) volatile { a = rhs.a; b = rhs.b; c = rhs.c; From 95b445a25ae21fd1c77646a888011387c89869a1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 29 Jan 2021 18:38:33 -0500 Subject: [PATCH 06/26] must initialized has_exceptions to avoid false positives in unit tests --- unittest/python/python-open.py | 1 + 1 file changed, 1 insertion(+) diff --git a/unittest/python/python-open.py b/unittest/python/python-open.py index 6153e032e3..67500ea6fa 100644 --- a/unittest/python/python-open.py +++ b/unittest/python/python-open.py @@ -4,6 +4,7 @@ from lammps import lammps has_mpi=False has_mpi4py=False +has_exceptions=False try: from mpi4py import __version__ as mpi4py_version # tested to work with mpi4py versions 2 and 3 From 0e2b5283512039804461c7ab08f557891c14dc5b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 29 Jan 2021 18:40:24 -0500 Subject: [PATCH 07/26] add additional heuristics to prevent python unit tests from failing on MacOS --- python/lammps/core.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index fe23fa587c..6c1300ccf2 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -99,6 +99,7 @@ class lammps(object): # so that LD_LIBRARY_PATH does not need to be set for regular install # fall back to loading with a relative path, # typically requires LD_LIBRARY_PATH to be set appropriately + # guess shared library extension based on OS, if not inferred from actual file if any([f.startswith('liblammps') and f.endswith('.dylib') for f in os.listdir(modpath)]): @@ -111,7 +112,13 @@ class lammps(object): lib_ext = ".dll" modpath = winpath else: - lib_ext = ".so" + import platform + if platform.system() == "Darwin": + lib_ext = ".dylib" + elif platform.system() == "Windows": + lib_ext = ".dll" + else: + lib_ext = ".so" if not self.lib: try: From 065c4939ed405cfb888a50c35731533ae8f71336 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 29 Jan 2021 18:48:05 -0500 Subject: [PATCH 08/26] relax some unit test epsilons, so the tests pass on MacOS --- unittest/force-styles/tests/angle-quartic.yaml | 2 +- unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml | 2 +- unittest/force-styles/tests/fix-timestep-momentum.yaml | 2 +- unittest/force-styles/tests/fix-timestep-temp_csvr.yaml | 2 +- unittest/force-styles/tests/mol-pair-tip4p_table.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/unittest/force-styles/tests/angle-quartic.yaml b/unittest/force-styles/tests/angle-quartic.yaml index 1ffa163732..912825d3a2 100644 --- a/unittest/force-styles/tests/angle-quartic.yaml +++ b/unittest/force-styles/tests/angle-quartic.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:35 202 -epsilon: 2.5e-13 +epsilon: 4e-13 prerequisites: ! | atom full angle quartic diff --git a/unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml b/unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml index 90bfd15f3d..db4bb284fa 100644 --- a/unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml +++ b/unittest/force-styles/tests/atomic-pair-reax_c_lgvdw.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:25 202 -epsilon: 1e-10 +epsilon: 2e-10 prerequisites: ! | pair reax/c fix qeq/reax diff --git a/unittest/force-styles/tests/fix-timestep-momentum.yaml b/unittest/force-styles/tests/fix-timestep-momentum.yaml index 884c71785d..96a3e9d4bb 100644 --- a/unittest/force-styles/tests/fix-timestep-momentum.yaml +++ b/unittest/force-styles/tests/fix-timestep-momentum.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:40 202 -epsilon: 4e-14 +epsilon: 5e-14 prerequisites: ! | atom full fix momentum diff --git a/unittest/force-styles/tests/fix-timestep-temp_csvr.yaml b/unittest/force-styles/tests/fix-timestep-temp_csvr.yaml index d4f77f596c..8716de39de 100644 --- a/unittest/force-styles/tests/fix-timestep-temp_csvr.yaml +++ b/unittest/force-styles/tests/fix-timestep-temp_csvr.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:43 202 -epsilon: 2e-14 +epsilon: 3e-14 prerequisites: ! | atom full fix temp/csvr diff --git a/unittest/force-styles/tests/mol-pair-tip4p_table.yaml b/unittest/force-styles/tests/mol-pair-tip4p_table.yaml index 9a1f5fccec..26e60777d2 100644 --- a/unittest/force-styles/tests/mol-pair-tip4p_table.yaml +++ b/unittest/force-styles/tests/mol-pair-tip4p_table.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:20 202 -epsilon: 1e-13 +epsilon: 2.5e-13 prerequisites: ! | atom full pair tip4p/long From 4747e0496a55f116e97274b77cc2bab7e246f8dd Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 30 Jan 2021 02:22:49 -0500 Subject: [PATCH 09/26] add a bunch of unicode space equivalents --- src/utils.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/utils.cpp b/src/utils.cpp index 80800397d3..44dcc16f0c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -588,6 +588,9 @@ std::string utils::utf8_subst(const std::string &line) // UTF-8 2-byte character if ((in[i] & 0xe0U) == 0xc0U) { if ((i+1) < len) { + // NON-BREAKING SPACE (U+00A0) + if ((in[i] == 0xc2U) && (in[i+1] == 0xa0U)) + out += ' ', ++i; // MODIFIER LETTER PLUS SIGN (U+02D6) if ((in[i] == 0xcbU) && (in[i+1] == 0x96U)) out += '+', ++i; @@ -598,6 +601,48 @@ std::string utils::utf8_subst(const std::string &line) // UTF-8 3-byte character } else if ((in[i] & 0xf0U) == 0xe0U) { if ((i+2) < len) { + // EN QUAD (U+2000) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x80U)) + out += ' ', i += 2; + // EM QUAD (U+2001) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x81U)) + out += ' ', i += 2; + // EN SPACE (U+2002) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x82U)) + out += ' ', i += 2; + // EM SPACE (U+2003) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x83U)) + out += ' ', i += 2; + // THREE-PER-EM SPACE (U+2004) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x84U)) + out += ' ', i += 2; + // FOUR-PER-EM SPACE (U+2005) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x85U)) + out += ' ', i += 2; + // SIX-PER-EM SPACE (U+2006) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x86U)) + out += ' ', i += 2; + // FIGURE SPACE (U+2007) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x87U)) + out += ' ', i += 2; + // PUNCTUATION SPACE (U+2008) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x88U)) + out += ' ', i += 2; + // THIN SPACE (U+2009) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x89U)) + out += ' ', i += 2; + // HAIR SPACE (U+200A) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x8aU)) + out += ' ', i += 2; + // ZERO WIDTH SPACE (U+200B) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0x8bU)) + out += ' ', i += 2; + // NARROW NO-BREAK SPACE (U+202F) + if ((in[i] == 0xe2U) && (in[i+1] == 0x80U) && (in[i+2] == 0xafU)) + out += ' ', i += 2; + // WORD JOINER (U+2060) + if ((in[i] == 0xe2U) && (in[i+1] == 0x81U) && (in[i+2] == 0xa0U)) + out += ' ', i += 2; // INVISIBLE SEPARATOR (U+2063) if ((in[i] == 0xe2U) && (in[i+1] == 0x81U) && (in[i+2] == 0xa3U)) out += ' ', i += 2; @@ -607,6 +652,9 @@ std::string utils::utf8_subst(const std::string &line) // MINUS SIGN (U+2212) if ((in[i] == 0xe2U) && (in[i+1] == 0x88U) && (in[i+2] == 0x92U)) out += '-', i += 2; + // ZERO WIDTH NO-BREAK SPACE (U+FEFF) + if ((in[i] == 0xefU) && (in[i+1] == 0xbbU) && (in[i+2] == 0xbfU)) + out += ' ', i += 2; } // UTF-8 4-byte character } else if ((in[i] & 0xe8U) == 0xf0U) { From 3ce92db405cf31f5ebaaf4c7b37fd7639b0156e0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 30 Jan 2021 06:08:17 -0500 Subject: [PATCH 10/26] correct path to CMake preset folder in example command --- doc/src/Python_install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/Python_install.rst b/doc/src/Python_install.rst index c12644bf4a..dce19ce2c0 100644 --- a/doc/src/Python_install.rst +++ b/doc/src/Python_install.rst @@ -69,7 +69,7 @@ this. cd build # configure LAMMPS compilation - cmake -C cmake/presets/minimal.cmake -D BUILD_SHARED_LIBS=on \ + cmake -C ../cmake/presets/minimal.cmake -D BUILD_SHARED_LIBS=on \ -D LAMMPS_EXCEPTIONS=on -D PKG_PYTHON=on ../cmake # compile LAMMPS From aeaaeed70385dbabeb96e00a947c517e5c10c4b8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 30 Jan 2021 06:08:35 -0500 Subject: [PATCH 11/26] clarify and fix typo --- doc/src/Python_install.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/src/Python_install.rst b/doc/src/Python_install.rst index dce19ce2c0..8d7f9ee83e 100644 --- a/doc/src/Python_install.rst +++ b/doc/src/Python_install.rst @@ -97,10 +97,11 @@ this. For a system-wide installation you need to set ``CMAKE_INSTALL_PREFIX`` to a system folder like ``/usr`` (or - ``/usr/local``). The installation step (**not** the - configuration/compilation) needs to be done with superuser + ``/usr/local``); the default is ``${HOME}/.local``. + The installation step for a system folder installation + (**not** the configuration/compilation) needs to be done with superuser privilege, e.g. by using ``sudo cmake --install .``. The - installation folders will then by changed to: + installation folders will then be changed to (for ``/usr`` as prefix): +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ | File | Location | Notes | From f0e4f906082898120aed33a37072f699fd33e91e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 31 Jan 2021 13:06:10 -0500 Subject: [PATCH 12/26] reformat paragraph --- doc/src/Python_install.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/src/Python_install.rst b/doc/src/Python_install.rst index 8d7f9ee83e..134d3e22d2 100644 --- a/doc/src/Python_install.rst +++ b/doc/src/Python_install.rst @@ -97,11 +97,12 @@ this. For a system-wide installation you need to set ``CMAKE_INSTALL_PREFIX`` to a system folder like ``/usr`` (or - ``/usr/local``); the default is ``${HOME}/.local``. - The installation step for a system folder installation - (**not** the configuration/compilation) needs to be done with superuser + ``/usr/local``); the default is ``${HOME}/.local``. The + installation step for a system folder installation (**not** the + configuration/compilation) needs to be done with superuser privilege, e.g. by using ``sudo cmake --install .``. The - installation folders will then be changed to (for ``/usr`` as prefix): + installation folders will then be changed to (assuming ``/usr`` as + prefix): +------------------------+---------------------------------------------------------+-------------------------------------------------------------+ | File | Location | Notes | From 48f15e485d0a1521ff8943384c65bafc2794389f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 31 Jan 2021 20:13:47 -0500 Subject: [PATCH 13/26] put consistent definition of INVOKED_* constants as enumerator into compute.h --- src/KOKKOS/compute_coord_atom_kokkos.cpp | 5 +- src/LATTE/fix_latte.cpp | 5 +- src/REPLICA/compute_event_displace.cpp | 1 - src/USER-DIFFRACTION/fix_saed_vtk.cpp | 5 +- src/USER-MISC/fix_ave_correlate_long.cpp | 11 ++- src/USER-PHONON/fix_phonon.cpp | 4 +- src/USER-PLUMED/fix_plumed.cpp | 1 - src/USER-VTK/dump_vtk.cpp | 5 +- src/compute.cpp | 2 +- src/compute.h | 8 +++ src/compute_chunk_atom.cpp | 5 +- src/compute_chunk_spread_atom.cpp | 11 ++- src/compute_coord_atom.cpp | 5 +- src/compute_global_atom.cpp | 15 ++-- src/compute_heat_flux.cpp | 13 ++-- src/compute_reduce.cpp | 12 ++-- src/compute_reduce_chunk.cpp | 5 +- src/compute_reduce_region.cpp | 12 ++-- src/compute_slice.cpp | 10 ++- src/dump_custom.cpp | 5 +- src/dump_local.cpp | 5 +- src/fix_ave_atom.cpp | 5 +- src/fix_ave_chunk.cpp | 5 +- src/fix_ave_correlate.cpp | 11 ++- src/fix_ave_histo.cpp | 29 ++++---- src/fix_ave_histo_weight.cpp | 53 +++++++-------- src/fix_ave_time.cpp | 19 +++--- src/fix_controller.cpp | 10 ++- src/fix_store_state.cpp | 5 +- src/fix_vector.cpp | 11 ++- src/modify.cpp | 2 +- src/thermo.cpp | 87 ++++++++++++------------ src/variable.cpp | 48 ++++++------- 33 files changed, 187 insertions(+), 243 deletions(-) diff --git a/src/KOKKOS/compute_coord_atom_kokkos.cpp b/src/KOKKOS/compute_coord_atom_kokkos.cpp index a8fe6562d9..b447d2cd7b 100644 --- a/src/KOKKOS/compute_coord_atom_kokkos.cpp +++ b/src/KOKKOS/compute_coord_atom_kokkos.cpp @@ -27,7 +27,6 @@ using namespace LAMMPS_NS; -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -113,9 +112,9 @@ void ComputeCoordAtomKokkos::compute_peratom() } if (cstyle == ORIENT) { - if (!(c_orientorder->invoked_flag & INVOKED_PERATOM)) { + if (!(c_orientorder->invoked_flag & Compute::INVOKED_PERATOM)) { c_orientorder->compute_peratom(); - c_orientorder->invoked_flag |= INVOKED_PERATOM; + c_orientorder->invoked_flag |= Compute::INVOKED_PERATOM; } nqlist = c_orientorder->nqlist; normv = c_orientorder->array_atom; diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 46b15a60d0..25ddd2036a 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -49,7 +49,6 @@ extern "C" { // difficult to debug crashes or memory corruption. #define LATTE_ABIVERSION 20180622 -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -248,9 +247,9 @@ void FixLatte::post_force(int vflag) if (coulomb) { modify->clearstep_compute(); - if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { + if (!(c_pe->invoked_flag & Compute::INVOKED_PERATOM)) { c_pe->compute_peratom(); - c_pe->invoked_flag |= INVOKED_PERATOM; + c_pe->invoked_flag |= Compute::INVOKED_PERATOM; } modify->addstep_compute(update->ntimestep+1); diff --git a/src/REPLICA/compute_event_displace.cpp b/src/REPLICA/compute_event_displace.cpp index b1592b973c..958c2d3c22 100644 --- a/src/REPLICA/compute_event_displace.cpp +++ b/src/REPLICA/compute_event_displace.cpp @@ -28,7 +28,6 @@ using namespace LAMMPS_NS; -#define INVOKED_SCALAR 1 /* ---------------------------------------------------------------------- */ diff --git a/src/USER-DIFFRACTION/fix_saed_vtk.cpp b/src/USER-DIFFRACTION/fix_saed_vtk.cpp index 9c3666b426..84283a7ca2 100644 --- a/src/USER-DIFFRACTION/fix_saed_vtk.cpp +++ b/src/USER-DIFFRACTION/fix_saed_vtk.cpp @@ -35,7 +35,6 @@ enum{COMPUTE}; enum{ONE,RUNNING,WINDOW}; enum{FIRST,MULTI}; -#define INVOKED_VECTOR 2 /* ---------------------------------------------------------------------- */ @@ -357,9 +356,9 @@ void FixSAEDVTK::invoke_vector(bigint ntimestep) Compute *compute = modify->compute[icompute]; - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } double *vector = compute->vector; diff --git a/src/USER-MISC/fix_ave_correlate_long.cpp b/src/USER-MISC/fix_ave_correlate_long.cpp index a9c8228871..cf9e6c0dca 100644 --- a/src/USER-MISC/fix_ave_correlate_long.cpp +++ b/src/USER-MISC/fix_ave_correlate_long.cpp @@ -42,9 +42,6 @@ using namespace FixConst; enum{COMPUTE,FIX,VARIABLE}; enum{AUTO,UPPER,LOWER,AUTOUPPER,AUTOLOWER,FULL}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 static const char cite_fix_ave_correlate_long[] = "fix ave/correlate/long command:\n\n" @@ -448,15 +445,15 @@ void FixAveCorrelateLong::end_of_step() Compute *compute = modify->compute[m]; if (argindex[i] == 0) { - if (!(compute->invoked_flag & INVOKED_SCALAR)) { + if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); - compute->invoked_flag |= INVOKED_SCALAR; + compute->invoked_flag |= Compute::INVOKED_SCALAR; } scalar = compute->scalar; } else { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } scalar = compute->vector[argindex[i]-1]; } diff --git a/src/USER-PHONON/fix_phonon.cpp b/src/USER-PHONON/fix_phonon.cpp index e3ea7a52e7..320a12d8f9 100644 --- a/src/USER-PHONON/fix_phonon.cpp +++ b/src/USER-PHONON/fix_phonon.cpp @@ -42,8 +42,6 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 #define MAXLINE 512 enum{FORWARD=-1,BACKWARD=1}; @@ -338,7 +336,7 @@ void FixPhonon::end_of_step() double xcur[3]; // to get the current temperature - if (!(temperature->invoked_flag & INVOKED_VECTOR)) temperature->compute_vector(); + if (!(temperature->invoked_flag & Compute::INVOKED_VECTOR)) temperature->compute_vector(); for (idim = 0; idim < sysdim; ++idim) TempSum[idim] += temperature->vector[idim]; // evaluate R(r) on local proc diff --git a/src/USER-PLUMED/fix_plumed.cpp b/src/USER-PLUMED/fix_plumed.cpp index e2246adcd9..779a9b93d8 100644 --- a/src/USER-PLUMED/fix_plumed.cpp +++ b/src/USER-PLUMED/fix_plumed.cpp @@ -49,7 +49,6 @@ static char plumed_default_kernel[] = "PLUMED_KERNEL=" PLUMED_QUOTE(__PLUMED_DEF using namespace LAMMPS_NS; using namespace FixConst; -#define INVOKED_SCALAR 1 FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), diff --git a/src/USER-VTK/dump_vtk.cpp b/src/USER-VTK/dump_vtk.cpp index 518015d688..373680dfc2 100644 --- a/src/USER-VTK/dump_vtk.cpp +++ b/src/USER-VTK/dump_vtk.cpp @@ -89,7 +89,6 @@ enum{X,Y,Z, // required for vtk, must come first enum{LT,LE,GT,GE,EQ,NEQ}; enum{VTK,VTP,VTU,PVTP,PVTU}; // file formats -#define INVOKED_PERATOM 8 #define ONEFIELD 32 #define DELTA 1048576 @@ -302,9 +301,9 @@ int DumpVTK::count() error->all(FLERR,"Compute used in dump between runs is not current"); } else { for (i = 0; i < ncompute; i++) { - if (!(compute[i]->invoked_flag & INVOKED_PERATOM)) { + if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) { compute[i]->compute_peratom(); - compute[i]->invoked_flag |= INVOKED_PERATOM; + compute[i]->invoked_flag |= Compute::INVOKED_PERATOM; } } } diff --git a/src/compute.cpp b/src/compute.cpp index 36364888cb..df2bf9429c 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -84,7 +84,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : invoked_scalar = invoked_vector = invoked_array = -1; invoked_peratom = invoked_local = -1; - invoked_flag = 0; + invoked_flag = INVOKED_NONE; // set modify defaults diff --git a/src/compute.h b/src/compute.h index b6d053dd0e..71c07737d4 100644 --- a/src/compute.h +++ b/src/compute.h @@ -20,6 +20,14 @@ namespace LAMMPS_NS { class Compute : protected Pointers { public: + enum { + INVOKED_NONE = 0, + INVOKED_SCALAR = 1<<0, + INVOKED_VECTOR = 1<<1, + INVOKED_ARRAY = 1<<2, + INVOKED_PERATOM = 1<<3, + INVOKED_LOCAL = 1<<4, + }; static int instance_total; // # of Compute classes ever instantiated char *id,*style; diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index ac878183ed..764f7ac586 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -48,7 +48,6 @@ enum{ONCE,NFREQ,EVERY}; // used in several files enum{LIMITMAX,LIMITEXACT}; #define IDMAX 1024*1024 -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -958,9 +957,9 @@ void ComputeChunkAtom::assign_chunk_ids() } } else if (which == COMPUTE) { - if (!(cchunk->invoked_flag & INVOKED_PERATOM)) { + if (!(cchunk->invoked_flag & Compute::INVOKED_PERATOM)) { cchunk->compute_peratom(); - cchunk->invoked_flag |= INVOKED_PERATOM; + cchunk->invoked_flag |= Compute::INVOKED_PERATOM; } if (argindex == 0) { diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index 1e3f9575d7..f4f9861990 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -28,9 +28,6 @@ using namespace LAMMPS_NS; enum{COMPUTE,FIX}; -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -275,9 +272,9 @@ void ComputeChunkSpreadAtom::compute_peratom() Compute *compute = modify->compute[n]; if (argindex[m] == 0) { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } double *cvector = compute->vector; for (i = 0; i < nlocal; i++, ptr += nstride) { @@ -289,9 +286,9 @@ void ComputeChunkSpreadAtom::compute_peratom() } } else { - if (!(compute->invoked_flag & INVOKED_ARRAY)) { + if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } int icol = argindex[m]-1; double **carray = compute->array; diff --git a/src/compute_coord_atom.cpp b/src/compute_coord_atom.cpp index 21284549b6..686c58e8d9 100644 --- a/src/compute_coord_atom.cpp +++ b/src/compute_coord_atom.cpp @@ -32,7 +32,6 @@ using namespace LAMMPS_NS; -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -198,9 +197,9 @@ void ComputeCoordAtom::compute_peratom() } if (cstyle == ORIENT) { - if (!(c_orientorder->invoked_flag & INVOKED_PERATOM)) { + if (!(c_orientorder->invoked_flag & Compute::INVOKED_PERATOM)) { c_orientorder->compute_peratom(); - c_orientorder->invoked_flag |= INVOKED_PERATOM; + c_orientorder->invoked_flag |= Compute::INVOKED_PERATOM; } nqlist = c_orientorder->nqlist; normv = c_orientorder->array_atom; diff --git a/src/compute_global_atom.cpp b/src/compute_global_atom.cpp index d9919b13b2..10cde42ef9 100644 --- a/src/compute_global_atom.cpp +++ b/src/compute_global_atom.cpp @@ -29,9 +29,6 @@ using namespace LAMMPS_NS; enum{COMPUTE,FIX,VARIABLE}; enum{VECTOR,ARRAY}; -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 -#define INVOKED_PERATOM 8 #define BIG 1.0e20 @@ -340,9 +337,9 @@ void ComputeGlobalAtom::compute_peratom() if (whichref == COMPUTE) { Compute *compute = modify->compute[ref2index]; - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (indexref == 0) { @@ -397,9 +394,9 @@ void ComputeGlobalAtom::compute_peratom() if (which[m] == COMPUTE) { Compute *compute = modify->compute[value2index[m]]; - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } source = compute->vector; @@ -455,9 +452,9 @@ void ComputeGlobalAtom::compute_peratom() if (which[m] == COMPUTE) { Compute *compute = modify->compute[value2index[m]]; - if (!(compute->invoked_flag & INVOKED_ARRAY)) { + if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } double **compute_array = compute->array; diff --git a/src/compute_heat_flux.cpp b/src/compute_heat_flux.cpp index 404cb988e7..91019aef28 100644 --- a/src/compute_heat_flux.cpp +++ b/src/compute_heat_flux.cpp @@ -27,7 +27,6 @@ using namespace LAMMPS_NS; -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -108,17 +107,17 @@ void ComputeHeatFlux::compute_vector() // invoke 3 computes if they haven't been already - if (!(c_ke->invoked_flag & INVOKED_PERATOM)) { + if (!(c_ke->invoked_flag & Compute::INVOKED_PERATOM)) { c_ke->compute_peratom(); - c_ke->invoked_flag |= INVOKED_PERATOM; + c_ke->invoked_flag |= Compute::INVOKED_PERATOM; } - if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { + if (!(c_pe->invoked_flag & Compute::INVOKED_PERATOM)) { c_pe->compute_peratom(); - c_pe->invoked_flag |= INVOKED_PERATOM; + c_pe->invoked_flag |= Compute::INVOKED_PERATOM; } - if (!(c_stress->invoked_flag & INVOKED_PERATOM)) { + if (!(c_stress->invoked_flag & Compute::INVOKED_PERATOM)) { c_stress->compute_peratom(); - c_stress->invoked_flag |= INVOKED_PERATOM; + c_stress->invoked_flag |= Compute::INVOKED_PERATOM; } // heat flux vector = jc[3] + jv[3] diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index 45c0570239..7f2b769d49 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -33,10 +33,6 @@ enum{SUM,SUMSQ,MINN,MAXX,AVE,AVESQ}; // also in ComputeReduceRegion enum{UNKNOWN=-1,X,V,F,COMPUTE,FIX,VARIABLE}; enum{PERATOM,LOCAL}; -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 -#define INVOKED_PERATOM 8 -#define INVOKED_LOCAL 16 #define BIG 1.0e20 @@ -513,9 +509,9 @@ double ComputeReduce::compute_one(int m, int flag) Compute *compute = modify->compute[vidx]; if (flavor[m] == PERATOM) { - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (aidx == 0) { @@ -536,9 +532,9 @@ double ComputeReduce::compute_one(int m, int flag) } } else if (flavor[m] == LOCAL) { - if (!(compute->invoked_flag & INVOKED_LOCAL)) { + if (!(compute->invoked_flag & Compute::INVOKED_LOCAL)) { compute->compute_local(); - compute->invoked_flag |= INVOKED_LOCAL; + compute->invoked_flag |= Compute::INVOKED_LOCAL; } if (aidx == 0) { diff --git a/src/compute_reduce_chunk.cpp b/src/compute_reduce_chunk.cpp index 50e9c767c5..a93d38d721 100644 --- a/src/compute_reduce_chunk.cpp +++ b/src/compute_reduce_chunk.cpp @@ -32,7 +32,6 @@ using namespace LAMMPS_NS; enum{SUM,MINN,MAXX}; enum{UNKNOWN=-1,COMPUTE,FIX,VARIABLE}; -#define INVOKED_PERATOM 8 #define BIG 1.0e20 @@ -374,9 +373,9 @@ void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride) if (which[m] == COMPUTE) { Compute *compute = modify->compute[vidx]; - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (argindex[m] == 0) { diff --git a/src/compute_reduce_region.cpp b/src/compute_reduce_region.cpp index 9dabc5c5d8..fbb1450534 100644 --- a/src/compute_reduce_region.cpp +++ b/src/compute_reduce_region.cpp @@ -31,10 +31,6 @@ enum{SUM,SUMSQ,MINN,MAXX,AVE,AVESQ}; // also in ComputeReduce enum{UNKNOWN=-1,X,V,F,COMPUTE,FIX,VARIABLE}; enum{PERATOM,LOCAL}; -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 -#define INVOKED_PERATOM 8 -#define INVOKED_LOCAL 16 #define BIG 1.0e20 @@ -110,9 +106,9 @@ double ComputeReduceRegion::compute_one(int m, int flag) Compute *compute = modify->compute[n]; if (flavor[m] == PERATOM) { - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (j == 0) { @@ -135,9 +131,9 @@ double ComputeReduceRegion::compute_one(int m, int flag) } } else if (flavor[m] == LOCAL) { - if (!(compute->invoked_flag & INVOKED_LOCAL)) { + if (!(compute->invoked_flag & Compute::INVOKED_LOCAL)) { compute->compute_local(); - compute->invoked_flag |= INVOKED_LOCAL; + compute->invoked_flag |= Compute::INVOKED_LOCAL; } if (j == 0) { diff --git a/src/compute_slice.cpp b/src/compute_slice.cpp index 4de3ad5a9b..aa89359a5e 100644 --- a/src/compute_slice.cpp +++ b/src/compute_slice.cpp @@ -27,8 +27,6 @@ using namespace LAMMPS_NS; enum{COMPUTE,FIX,VARIABLE}; -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 /* ---------------------------------------------------------------------- */ @@ -290,9 +288,9 @@ void ComputeSlice::extract_one(int m, double *vec, int stride) Compute *compute = modify->compute[value2index[m]]; if (argindex[m] == 0) { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } double *cvector = compute->vector; j = 0; @@ -302,9 +300,9 @@ void ComputeSlice::extract_one(int m, double *vec, int stride) } } else { - if (!(compute->invoked_flag & INVOKED_ARRAY)) { + if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } double **carray = compute->array; int icol = argindex[m]-1; diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index d927bca48d..ef45780e91 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -45,7 +45,6 @@ enum{ID,MOL,PROC,PROCP1,TYPE,ELEMENT,MASS, COMPUTE,FIX,VARIABLE,INAME,DNAME}; enum{LT,LE,GT,GE,EQ,NEQ,XOR}; -#define INVOKED_PERATOM 8 #define ONEFIELD 32 #define DELTA 1048576 @@ -584,9 +583,9 @@ int DumpCustom::count() error->all(FLERR,"Compute used in dump between runs is not current"); } else { for (i = 0; i < ncompute; i++) { - if (!(compute[i]->invoked_flag & INVOKED_PERATOM)) { + if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) { compute[i]->compute_peratom(); - compute[i]->invoked_flag |= INVOKED_PERATOM; + compute[i]->invoked_flag |= Compute::INVOKED_PERATOM; } } } diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 211d50f49b..d2608f99f0 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -27,7 +27,6 @@ using namespace LAMMPS_NS; enum{INT,DOUBLE}; -#define INVOKED_LOCAL 16 #define ONEFIELD 32 #define DELTA 1048576 @@ -297,9 +296,9 @@ int DumpLocal::count() error->all(FLERR,"Compute used in dump between runs is not current"); } else { for (i = 0; i < ncompute; i++) { - if (!(compute[i]->invoked_flag & INVOKED_LOCAL)) { + if (!(compute[i]->invoked_flag & Compute::INVOKED_LOCAL)) { compute[i]->compute_local(); - compute[i]->invoked_flag |= INVOKED_LOCAL; + compute[i]->invoked_flag |= Compute::INVOKED_LOCAL; } } } diff --git a/src/fix_ave_atom.cpp b/src/fix_ave_atom.cpp index 7d67744a5c..6b9c01c4b1 100644 --- a/src/fix_ave_atom.cpp +++ b/src/fix_ave_atom.cpp @@ -29,7 +29,6 @@ using namespace FixConst; enum{X,V,F,COMPUTE,FIX,VARIABLE}; -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -341,9 +340,9 @@ void FixAveAtom::end_of_step() } else if (which[m] == COMPUTE) { Compute *compute = modify->compute[n]; - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (j == 0) { diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index d8b5b3e48d..21e56ee697 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -39,7 +39,6 @@ enum{SAMPLE,ALL}; enum{NOSCALE,ATOM}; enum{ONE,RUNNING,WINDOW}; -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -738,9 +737,9 @@ void FixAveChunk::end_of_step() } else if (which[m] == COMPUTE) { Compute *compute = modify->compute[n]; - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } double *vector = compute->vector_atom; double **array = compute->array_atom; diff --git a/src/fix_ave_correlate.cpp b/src/fix_ave_correlate.cpp index 833965e7bc..1cda758e5f 100644 --- a/src/fix_ave_correlate.cpp +++ b/src/fix_ave_correlate.cpp @@ -37,9 +37,6 @@ enum{COMPUTE,FIX,VARIABLE}; enum{ONE,RUNNING}; enum{AUTO,UPPER,LOWER,AUTOUPPER,AUTOLOWER,FULL}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 /* ---------------------------------------------------------------------- */ @@ -442,15 +439,15 @@ void FixAveCorrelate::end_of_step() Compute *compute = modify->compute[m]; if (argindex[i] == 0) { - if (!(compute->invoked_flag & INVOKED_SCALAR)) { + if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); - compute->invoked_flag |= INVOKED_SCALAR; + compute->invoked_flag |= Compute::INVOKED_SCALAR; } scalar = compute->scalar; } else { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } scalar = compute->vector[argindex[i]-1]; } diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index af4a8ba57d..438cc5a0e7 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -34,11 +34,6 @@ enum{SCALAR,VECTOR,WINDOW}; enum{DEFAULT,GLOBAL,PERATOM,LOCAL}; enum{IGNORE,END,EXTRA}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 -#define INVOKED_PERATOM 8 -#define INVOKED_LOCAL 16 #define BIG 1.0e20 /* ---------------------------------------------------------------------- */ @@ -638,29 +633,29 @@ void FixAveHisto::end_of_step() if (kind == GLOBAL && mode == SCALAR) { if (j == 0) { - if (!(compute->invoked_flag & INVOKED_SCALAR)) { + if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); - compute->invoked_flag |= INVOKED_SCALAR; + compute->invoked_flag |= Compute::INVOKED_SCALAR; } bin_one(compute->scalar); } else { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } bin_one(compute->vector[j-1]); } } else if (kind == GLOBAL && mode == VECTOR) { if (j == 0) { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } bin_vector(compute->size_vector,compute->vector,1); } else { - if (!(compute->invoked_flag & INVOKED_ARRAY)) { + if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } if (compute->array) bin_vector(compute->size_array_rows,&compute->array[0][j-1], @@ -668,9 +663,9 @@ void FixAveHisto::end_of_step() } } else if (kind == PERATOM) { - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (j == 0) bin_atoms(compute->vector_atom,1); @@ -678,9 +673,9 @@ void FixAveHisto::end_of_step() bin_atoms(&compute->array_atom[0][j-1],compute->size_peratom_cols); } else if (kind == LOCAL) { - if (!(compute->invoked_flag & INVOKED_LOCAL)) { + if (!(compute->invoked_flag & Compute::INVOKED_LOCAL)) { compute->compute_local(); - compute->invoked_flag |= INVOKED_LOCAL; + compute->invoked_flag |= Compute::INVOKED_LOCAL; } if (j == 0) bin_vector(compute->size_local_rows,compute->vector_local,1); diff --git a/src/fix_ave_histo_weight.cpp b/src/fix_ave_histo_weight.cpp index 61a36819b0..652136f9c6 100644 --- a/src/fix_ave_histo_weight.cpp +++ b/src/fix_ave_histo_weight.cpp @@ -37,11 +37,6 @@ enum{DEFAULT,GLOBAL,PERATOM,LOCAL}; enum{IGNORE,END,EXTRA}; enum{SINGLE,VALUE}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 -#define INVOKED_PERATOM 8 -#define INVOKED_LOCAL 16 #define BIG 1.0e20 @@ -155,38 +150,38 @@ void FixAveHistoWeight::end_of_step() if (kind == GLOBAL && mode == SCALAR) { if (j == 0) { - if (!(compute->invoked_flag & INVOKED_SCALAR)) { + if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); - compute->invoked_flag |= INVOKED_SCALAR; + compute->invoked_flag |= Compute::INVOKED_SCALAR; } weight = compute->scalar; } else { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } weight = compute->vector[j-1]; } } else if (kind == GLOBAL && mode == VECTOR) { if (j == 0) { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } weights = compute->vector; stride = 1; } else { - if (!(compute->invoked_flag & INVOKED_ARRAY)) { + if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } if (compute->array) weights = &compute->array[0][j-1]; stride = compute->size_array_cols; } } else if (kind == PERATOM) { - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (j == 0) { weights = compute->vector_atom; @@ -196,9 +191,9 @@ void FixAveHistoWeight::end_of_step() stride = compute->size_peratom_cols; } } else if (kind == LOCAL) { - if (!(compute->invoked_flag & INVOKED_LOCAL)) { + if (!(compute->invoked_flag & Compute::INVOKED_LOCAL)) { compute->compute_local(); - compute->invoked_flag |= INVOKED_LOCAL; + compute->invoked_flag |= Compute::INVOKED_LOCAL; } if (j == 0) { weights = compute->vector_local; @@ -283,30 +278,30 @@ void FixAveHistoWeight::end_of_step() Compute *compute = modify->compute[m]; if (kind == GLOBAL && mode == SCALAR) { if (j == 0) { - if (!(compute->invoked_flag & INVOKED_SCALAR)) { + if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); - compute->invoked_flag |= INVOKED_SCALAR; + compute->invoked_flag |= Compute::INVOKED_SCALAR; } bin_one_weights(compute->scalar,weight); } else { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } bin_one_weights(compute->vector[j-1],weight); } } else if (kind == GLOBAL && mode == VECTOR) { if (j == 0) { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } bin_vector_weights(compute->size_vector,compute->vector,1, weights,stride); } else { - if (!(compute->invoked_flag & INVOKED_ARRAY)) { + if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } if (compute->array) bin_vector_weights(compute->size_array_rows,&compute->array[0][j-1], @@ -314,9 +309,9 @@ void FixAveHistoWeight::end_of_step() } } else if (kind == PERATOM) { - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (j == 0) bin_atoms_weights(compute->vector_atom,1,weights, stride); @@ -325,9 +320,9 @@ void FixAveHistoWeight::end_of_step() compute->size_peratom_cols,weights,stride); } else if (kind == LOCAL) { - if (!(compute->invoked_flag & INVOKED_LOCAL)) { + if (!(compute->invoked_flag & Compute::INVOKED_LOCAL)) { compute->compute_local(); - compute->invoked_flag |= INVOKED_LOCAL; + compute->invoked_flag |= Compute::INVOKED_LOCAL; } if (j == 0) bin_vector_weights(compute->size_local_rows, diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index f74bb8c3f3..5ee46b42f6 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -35,9 +35,6 @@ enum{COMPUTE,FIX,VARIABLE}; enum{ONE,RUNNING,WINDOW}; enum{SCALAR,VECTOR}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 /* ---------------------------------------------------------------------- */ @@ -587,15 +584,15 @@ void FixAveTime::invoke_scalar(bigint ntimestep) Compute *compute = modify->compute[m]; if (argindex[i] == 0) { - if (!(compute->invoked_flag & INVOKED_SCALAR)) { + if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); - compute->invoked_flag |= INVOKED_SCALAR; + compute->invoked_flag |= Compute::INVOKED_SCALAR; } scalar = compute->scalar; } else { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } if (varlen[i] && compute->size_vector < argindex[i]) scalar = 0.0; else scalar = compute->vector[argindex[i]-1]; @@ -771,18 +768,18 @@ void FixAveTime::invoke_vector(bigint ntimestep) Compute *compute = modify->compute[m]; if (argindex[j] == 0) { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } double *cvector = compute->vector; for (i = 0; i < nrows; i++) column[i] = cvector[i]; } else { - if (!(compute->invoked_flag & INVOKED_ARRAY)) { + if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } double **carray = compute->array; int icol = argindex[j]-1; diff --git a/src/fix_controller.cpp b/src/fix_controller.cpp index 7c07e2a8d2..d9b927a39c 100644 --- a/src/fix_controller.cpp +++ b/src/fix_controller.cpp @@ -27,8 +27,6 @@ using namespace FixConst; enum{COMPUTE,FIX,VARIABLE}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 /* ---------------------------------------------------------------------- */ @@ -200,15 +198,15 @@ void FixController::end_of_step() if (pvwhich == COMPUTE) { if (pvindex == 0) { - if (!(pcompute->invoked_flag & INVOKED_SCALAR)) { + if (!(pcompute->invoked_flag & Compute::INVOKED_SCALAR)) { pcompute->compute_scalar(); - pcompute->invoked_flag |= INVOKED_SCALAR; + pcompute->invoked_flag |= Compute::INVOKED_SCALAR; } current = pcompute->scalar; } else { - if (!(pcompute->invoked_flag & INVOKED_VECTOR)) { + if (!(pcompute->invoked_flag & Compute::INVOKED_VECTOR)) { pcompute->compute_vector(); - pcompute->invoked_flag |= INVOKED_VECTOR; + pcompute->invoked_flag |= Compute::INVOKED_VECTOR; } current = pcompute->vector[pvindex-1]; } diff --git a/src/fix_store_state.cpp b/src/fix_store_state.cpp index b7c54c1103..216e56eefe 100644 --- a/src/fix_store_state.cpp +++ b/src/fix_store_state.cpp @@ -32,7 +32,6 @@ using namespace FixConst; enum{KEYWORD,COMPUTE,FIX,VARIABLE,DNAME,INAME}; -#define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -495,9 +494,9 @@ void FixStoreState::end_of_step() if (which[m] == COMPUTE) { Compute *compute = modify->compute[n]; - if (!(compute->invoked_flag & INVOKED_PERATOM)) { + if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (j == 0) { diff --git a/src/fix_vector.cpp b/src/fix_vector.cpp index c4bf8120e1..dcedd4c3be 100644 --- a/src/fix_vector.cpp +++ b/src/fix_vector.cpp @@ -30,9 +30,6 @@ enum{COMPUTE,FIX,VARIABLE}; enum{ONE,RUNNING,WINDOW}; enum{SCALAR,VECTOR}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 /* ---------------------------------------------------------------------- */ @@ -272,15 +269,15 @@ void FixVector::end_of_step() Compute *compute = modify->compute[m]; if (argindex[i] == 0) { - if (!(compute->invoked_flag & INVOKED_SCALAR)) { + if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); - compute->invoked_flag |= INVOKED_SCALAR; + compute->invoked_flag |= Compute::INVOKED_SCALAR; } result[i] = compute->scalar; } else { - if (!(compute->invoked_flag & INVOKED_VECTOR)) { + if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } result[i] = compute->vector[argindex[i]-1]; } diff --git a/src/modify.cpp b/src/modify.cpp index f3ebb03c38..eab2d82fcf 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -1345,7 +1345,7 @@ int Modify::find_compute(const std::string &id) void Modify::clearstep_compute() { for (int icompute = 0; icompute < ncompute; icompute++) - compute[icompute]->invoked_flag = 0; + compute[icompute]->invoked_flag = Compute::INVOKED_NONE; } /* ---------------------------------------------------------------------- diff --git a/src/thermo.cpp b/src/thermo.cpp index 9197f88084..c58ebe4afc 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -73,9 +73,6 @@ enum{ONELINE,MULTILINE}; enum{INT,FLOAT,BIGINT}; enum{SCALAR,VECTOR,ARRAY}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 #define DELTA 8 @@ -339,19 +336,19 @@ void Thermo::compute(int flag) for (i = 0; i < ncompute; i++) if (compute_which[i] == SCALAR) { - if (!(computes[i]->invoked_flag & INVOKED_SCALAR)) { + if (!(computes[i]->invoked_flag & Compute::INVOKED_SCALAR)) { computes[i]->compute_scalar(); - computes[i]->invoked_flag |= INVOKED_SCALAR; + computes[i]->invoked_flag |= Compute::INVOKED_SCALAR; } } else if (compute_which[i] == VECTOR) { - if (!(computes[i]->invoked_flag & INVOKED_VECTOR)) { + if (!(computes[i]->invoked_flag & Compute::INVOKED_VECTOR)) { computes[i]->compute_vector(); - computes[i]->invoked_flag |= INVOKED_VECTOR; + computes[i]->invoked_flag |= Compute::INVOKED_VECTOR; } } else if (compute_which[i] == ARRAY) { - if (!(computes[i]->invoked_flag & INVOKED_ARRAY)) { + if (!(computes[i]->invoked_flag & Compute::INVOKED_ARRAY)) { computes[i]->compute_array(); - computes[i]->invoked_flag |= INVOKED_ARRAY; + computes[i]->invoked_flag |= Compute::INVOKED_ARRAY; } } @@ -1161,9 +1158,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (temperature->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(temperature->invoked_flag & INVOKED_SCALAR)) { + } else if (!(temperature->invoked_flag & Compute::INVOKED_SCALAR)) { temperature->compute_scalar(); - temperature->invoked_flag |= INVOKED_SCALAR; + temperature->invoked_flag |= Compute::INVOKED_SCALAR; } compute_temp(); @@ -1175,9 +1172,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (pressure->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(pressure->invoked_flag & INVOKED_SCALAR)) { + } else if (!(pressure->invoked_flag & Compute::INVOKED_SCALAR)) { pressure->compute_scalar(); - pressure->invoked_flag |= INVOKED_SCALAR; + pressure->invoked_flag |= Compute::INVOKED_SCALAR; } compute_press(); @@ -1191,7 +1188,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) "is not current"); } else { pe->compute_scalar(); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; } compute_pe(); @@ -1203,9 +1200,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (temperature->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(temperature->invoked_flag & INVOKED_SCALAR)) { + } else if (!(temperature->invoked_flag & Compute::INVOKED_SCALAR)) { temperature->compute_scalar(); - temperature->invoked_flag |= INVOKED_SCALAR; + temperature->invoked_flag |= Compute::INVOKED_SCALAR; } compute_ke(); @@ -1219,7 +1216,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) "is not current"); } else { pe->compute_scalar(); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; } if (!temperature) error->all(FLERR,"Thermo keyword in variable requires " @@ -1228,9 +1225,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (temperature->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(temperature->invoked_flag & INVOKED_SCALAR)) { + } else if (!(temperature->invoked_flag & Compute::INVOKED_SCALAR)) { temperature->compute_scalar(); - temperature->invoked_flag |= INVOKED_SCALAR; + temperature->invoked_flag |= Compute::INVOKED_SCALAR; } compute_etotal(); @@ -1244,7 +1241,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) "is not current"); } else { pe->compute_scalar(); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; } if (!temperature) error->all(FLERR,"Thermo keyword in variable requires " @@ -1253,9 +1250,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (temperature->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(temperature->invoked_flag & INVOKED_SCALAR)) { + } else if (!(temperature->invoked_flag & Compute::INVOKED_SCALAR)) { temperature->compute_scalar(); - temperature->invoked_flag |= INVOKED_SCALAR; + temperature->invoked_flag |= Compute::INVOKED_SCALAR; } if (!pressure) error->all(FLERR,"Thermo keyword in variable requires " @@ -1264,9 +1261,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (pressure->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(pressure->invoked_flag & INVOKED_SCALAR)) { + } else if (!(pressure->invoked_flag & Compute::INVOKED_SCALAR)) { pressure->compute_scalar(); - pressure->invoked_flag |= INVOKED_SCALAR; + pressure->invoked_flag |= Compute::INVOKED_SCALAR; } compute_enthalpy(); @@ -1276,7 +1273,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_evdwl(); } else if (strcmp(word,"ecoul") == 0) { @@ -1285,7 +1282,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_ecoul(); } else if (strcmp(word,"epair") == 0) { @@ -1294,7 +1291,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_epair(); } else if (strcmp(word,"ebond") == 0) { @@ -1303,7 +1300,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_ebond(); } else if (strcmp(word,"eangle") == 0) { @@ -1312,7 +1309,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_eangle(); } else if (strcmp(word,"edihed") == 0) { @@ -1321,7 +1318,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_edihed(); } else if (strcmp(word,"eimp") == 0) { @@ -1330,7 +1327,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_eimp(); } else if (strcmp(word,"emol") == 0) { @@ -1339,7 +1336,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_emol(); } else if (strcmp(word,"elong") == 0) { @@ -1348,7 +1345,7 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (!pe) error->all(FLERR, "Thermo keyword in variable requires thermo to use/init pe"); - pe->invoked_flag |= INVOKED_SCALAR; + pe->invoked_flag |= Compute::INVOKED_SCALAR; compute_elong(); } else if (strcmp(word,"etail") == 0) { @@ -1385,9 +1382,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (pressure->invoked_vector != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(pressure->invoked_flag & INVOKED_VECTOR)) { + } else if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) { pressure->compute_vector(); - pressure->invoked_flag |= INVOKED_VECTOR; + pressure->invoked_flag |= Compute::INVOKED_VECTOR; } compute_pxx(); @@ -1399,9 +1396,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (pressure->invoked_vector != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(pressure->invoked_flag & INVOKED_VECTOR)) { + } else if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) { pressure->compute_vector(); - pressure->invoked_flag |= INVOKED_VECTOR; + pressure->invoked_flag |= Compute::INVOKED_VECTOR; } compute_pyy(); @@ -1413,9 +1410,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (pressure->invoked_vector != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(pressure->invoked_flag & INVOKED_VECTOR)) { + } else if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) { pressure->compute_vector(); - pressure->invoked_flag |= INVOKED_VECTOR; + pressure->invoked_flag |= Compute::INVOKED_VECTOR; } compute_pzz(); @@ -1427,9 +1424,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (pressure->invoked_vector != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(pressure->invoked_flag & INVOKED_VECTOR)) { + } else if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) { pressure->compute_vector(); - pressure->invoked_flag |= INVOKED_VECTOR; + pressure->invoked_flag |= Compute::INVOKED_VECTOR; } compute_pxy(); @@ -1441,9 +1438,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (pressure->invoked_vector != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(pressure->invoked_flag & INVOKED_VECTOR)) { + } else if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) { pressure->compute_vector(); - pressure->invoked_flag |= INVOKED_VECTOR; + pressure->invoked_flag |= Compute::INVOKED_VECTOR; } compute_pxz(); @@ -1455,9 +1452,9 @@ int Thermo::evaluate_keyword(const char *word, double *answer) if (pressure->invoked_vector != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " "is not current"); - } else if (!(pressure->invoked_flag & INVOKED_VECTOR)) { + } else if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) { pressure->compute_vector(); - pressure->invoked_flag |= INVOKED_VECTOR; + pressure->invoked_flag |= Compute::INVOKED_VECTOR; } compute_pyz(); } diff --git a/src/variable.cpp b/src/variable.cpp index bd5fc6cf8c..bd40920d3c 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -72,10 +72,6 @@ enum{DONE,ADD,SUBTRACT,MULTIPLY,DIVIDE,CARAT,MODULO,UNARY, enum{SUM,XMIN,XMAX,AVE,TRAP,SLOPE}; -#define INVOKED_SCALAR 1 -#define INVOKED_VECTOR 2 -#define INVOKED_ARRAY 4 -#define INVOKED_PERATOM 8 #define BIG 1.0e20 @@ -1380,9 +1376,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_scalar != update->ntimestep) print_var_error(FLERR,"Compute used in variable between " "runs is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_SCALAR)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); - compute->invoked_flag |= INVOKED_SCALAR; + compute->invoked_flag |= Compute::INVOKED_SCALAR; } value1 = compute->scalar; @@ -1407,9 +1403,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_vector != update->ntimestep) print_var_error(FLERR,"Compute used in variable between runs " "is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_VECTOR)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } if (compute->size_vector_variable && @@ -1439,9 +1435,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_array != update->ntimestep) print_var_error(FLERR,"Compute used in variable between runs " "is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_ARRAY)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } if (compute->size_array_rows_variable && @@ -1473,9 +1469,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_vector != update->ntimestep) print_var_error(FLERR,"Compute used in variable between " "runs is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_VECTOR)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } Tree *newtree = new Tree(); @@ -1505,9 +1501,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_array != update->ntimestep) print_var_error(FLERR,"Compute used in variable between " "runs is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_ARRAY)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } Tree *newtree = new Tree(); @@ -1529,9 +1525,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_peratom != update->ntimestep) print_var_error(FLERR,"Compute used in variable " "between runs is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_PERATOM)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } peratom2global(1,nullptr,compute->vector_atom,1,index1, @@ -1549,9 +1545,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_peratom != update->ntimestep) print_var_error(FLERR,"Compute used in variable " "between runs is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_PERATOM)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } if (compute->array_atom) @@ -1578,9 +1574,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_peratom != update->ntimestep) print_var_error(FLERR,"Compute used in variable " "between runs is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_PERATOM)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } Tree *newtree = new Tree(); @@ -1610,9 +1606,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (compute->invoked_peratom != update->ntimestep) print_var_error(FLERR,"Compute used in variable " "between runs is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_PERATOM)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); - compute->invoked_flag |= INVOKED_PERATOM; + compute->invoked_flag |= Compute::INVOKED_PERATOM; } Tree *newtree = new Tree(); @@ -4137,9 +4133,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, if (compute->invoked_vector != update->ntimestep) print_var_error(FLERR,"Compute used in variable between runs " "is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_VECTOR)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); - compute->invoked_flag |= INVOKED_VECTOR; + compute->invoked_flag |= Compute::INVOKED_VECTOR; } nvec = compute->size_vector; nstride = 1; @@ -4151,9 +4147,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, if (compute->invoked_array != update->ntimestep) print_var_error(FLERR,"Compute used in variable between runs " "is not current",ivar); - } else if (!(compute->invoked_flag & INVOKED_ARRAY)) { + } else if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); - compute->invoked_flag |= INVOKED_ARRAY; + compute->invoked_flag |= Compute::INVOKED_ARRAY; } nvec = compute->size_array_rows; nstride = compute->size_array_cols; From 829e5a7f85db840358851cc7729d72b08791f85f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 31 Jan 2021 21:06:35 -0500 Subject: [PATCH 14/26] update docs about the organization of sources and relation between classes --- doc/src/Developer_org.rst | 193 ++++++++++++++++++++------------------ 1 file changed, 104 insertions(+), 89 deletions(-) diff --git a/doc/src/Developer_org.rst b/doc/src/Developer_org.rst index c234cd11cc..6ecccf084d 100644 --- a/doc/src/Developer_org.rst +++ b/doc/src/Developer_org.rst @@ -1,68 +1,75 @@ Source files ------------ -The source files of the LAMMPS code are found in two -directories of the distribution: ``src`` and ``lib``. -Most of the code is C++ but there are small numbers of files -in several other languages. +The source files of the LAMMPS code are found in two directories of the +distribution: ``src`` and ``lib``. Most of the code is written in C++ +but there are small a number of files in several other languages like C, +Fortran, Shell script, or Python. -The core of the code is located in the -``src`` folder and its sub-directories. -A sizable number of these files are in the ``src`` directory -itself, but there are plenty of :doc:`packages `, which can be -included or excluded when LAMMPS is built. See the :doc:`Include -packages in build ` section of the manual for more -information about that part of the build process. LAMMPS currently -supports building with :doc:`conventional makefiles ` and -through :doc:`CMake ` which differ in how packages are -enabled or disabled for a LAMMPS binary. The source files for each +The core of the code is located in the ``src`` folder and its +sub-directories. A sizable number of these files are in the ``src`` +directory itself, but there are plenty of :doc:`packages `, +which can be included or excluded when LAMMPS is built. See the +:doc:`Include packages in build ` section of the manual +for more information about that part of the build process. LAMMPS +currently supports building with :doc:`conventional makefiles +` and through :doc:`CMake `. Those procedures +differ in how packages are enabled or disabled for inclusion into a +LAMMPS binary so they cannot be mixed. The source files for each package are in all-uppercase sub-directories of the ``src`` folder, for example ``src/MOLECULE`` or ``src/USER-MISC``. The ``src/STUBS`` sub-directory is not a package but contains a dummy MPI library, that is used when building a serial version of the code. The ``src/MAKE`` -directory contains makefiles with settings and flags for a variety of -configuration and machines for the build process with traditional -makefiles. +directory and its sub-directories contain makefiles with settings and +flags for a variety of configuration and machines for the build process +with traditional makefiles. The ``lib`` directory contains the source code for several supporting libraries or files with configuration settings to use globally installed -libraries, that are required by some of the optional packages. -Each sub-directory, like ``lib/poems`` or ``lib/gpu``, contains the -source files, some of which are in different languages such as Fortran -or CUDA. These libraries are linked to during a LAMMPS build, if the -corresponding package is installed. +libraries, that are required by some of the optional packages. They may +include python scripts that can transparently download additional source +code on request. Each sub-directory, like ``lib/poems`` or ``lib/gpu``, +contains the source files, some of which are in different languages such +as Fortran or CUDA. These libraries included in the LAMMPS build, +if the corresponding package is installed. LAMMPS C++ source files almost always come in pairs, such as ``src/run.cpp`` (implementation file) and ``src/run.h`` (header file). -Each pair of files defines a C++ -class, for example the :cpp:class:`LAMMPS_NS::Run` class which contains -the code invoked by the :doc:`run ` command in a LAMMPS input script. -As this example illustrates, source file and class names often have a -one-to-one correspondence with a command used in a LAMMPS input script. -Some source files and classes do not have a corresponding input script +Each pair of files defines a C++ class, for example the +:cpp:class:`LAMMPS_NS::Run` class which contains the code invoked by the +:doc:`run ` command in a LAMMPS input script. As this example +illustrates, source file and class names often have a one-to-one +correspondence with a command used in a LAMMPS input script. Some +source files and classes do not have a corresponding input script command, e.g. ``src/force.cpp`` and the :cpp:class:`LAMMPS_NS::Force` class. They are discussed in the next section. -A small number of C++ classes and utility functions are implemented with -only a ``.h`` file. Examples are the Pointer class or the MathVec functions. +The names of all source files are in lower case and may use the +underscore character '_' to separate words. Outside of bundled libraries +which may have different conventions, all C and C++ header files have a +``.h`` extension, all C++ files have a ``.cpp`` extension, and C files a +``.c`` extension. A small number of C++ classes and utility functions +are implemented with only a ``.h`` file. Examples are the Pointer class +or the MathVec functions. Class topology -------------- Though LAMMPS has a lot of source files and classes, its class topology -is relative flat, as outlined in the :ref:`class-topology` figure. Each -name refers to a class and has a pair of associated source files in the -``src`` folder, for example the class :cpp:class:`LAMMPS_NS::Memory` -corresponds to the files ``memory.cpp`` and ``memory.h``, or the class -:cpp:class:`LAMMPS_NS::AtomVec` corresponds to the files -``atom_vec.cpp`` and ``atom_vec.h``. Full lines in the figure represent -compositing: that is the class to the left holds a pointer to an -instance of the class to the right. Dashed lines instead represent -inheritance: the class to the right is derived from the class on the -left. Classes with a red boundary are not instantiated directly, but -they represent the base classes for "styles". Those "styles" make up -the bulk of the LAMMPS code and only a few typical examples are included -in the figure for demonstration purposes. +is not very deep, which can be seen from the :ref:`class-topology` +figure. In that figure, each name refers to a class and has a pair of +associated source files in the ``src`` folder, for example the class +:cpp:class:`LAMMPS_NS::Memory` corresponds to the files ``memory.cpp`` +and ``memory.h``, or the class :cpp:class:`LAMMPS_NS::AtomVec` +corresponds to the files ``atom_vec.cpp`` and ``atom_vec.h``. Full +lines in the figure represent compositing: that is the class at the base +of the arrow holds a pointer to an instance of the class at the tip. +Dashed lines instead represent inheritance: the class to the tip of the +arrow is derived from the class at the base. Classes with a red boundary +are not instantiated directly, but they represent the base classes for +"styles". Those "styles" make up the bulk of the LAMMPS code and only +a few representative examples are included in the figure so it remains +readable. .. _class-topology: .. figure:: JPG/lammps-classes.png @@ -82,69 +89,76 @@ in the figure for demonstration purposes. derived classes, which may also hold instances of other classes. The :cpp:class:`LAMMPS_NS::LAMMPS` class is the topmost class and -represents what is referred to an "instance" of LAMMPS. It is a -composite holding references to instances of other core classes +represents what is generally referred to an "instance" of LAMMPS. It is +a composite holding pointers to instances of other core classes providing the core functionality of the MD engine in LAMMPS and through them abstractions of the required operations. The constructor of the LAMMPS class will instantiate those instances, process the command line flags, initialize MPI (if not already done) and set up file pointers for -input and output. The destructor will shut everything down and free all +input and output. The destructor will shut everything down and free all associated memory. Thus code for the standalone LAMMPS executable in ``main.cpp`` simply initializes MPI, instantiates a single instance of -LAMMPS, and passes it the command line flags and input script. It +LAMMPS while passing it the command line flags and input script. It deletes the LAMMPS instance after the method reading the input returns and shuts down the MPI environment before it exits the executable. The :cpp:class:`LAMMPS_NS::Pointers` is not shown in the -:ref:`class-topology` figure, it holds references to members of the -`LAMMPS_NS::LAMMPS`, so that all classes derived from -:cpp:class:`LAMMPS_NS::Pointers` have direct access to those reference. -From the class topology all classes with blue boundary are referenced in -this class and all classes in the second and third columns, that are not -listed as derived classes are instead derived from -:cpp:class:`LAMMPS_NS::Pointers`. +:ref:`class-topology` figure for clarity. It holds references to many +of the members of the `LAMMPS_NS::LAMMPS`, so that all classes derived +from :cpp:class:`LAMMPS_NS::Pointers` have direct access to those +reference. From the class topology all classes with blue boundary are +referenced in the Pointers class and all classes in the second and third +columns, that are not listed as derived classes are instead derived from +:cpp:class:`LAMMPS_NS::Pointers`. To initialize the pointer references +in Pointers, a pointer to the LAMMPS class instance needs to be passed +to the constructor and thus all constructors for classes derived from it +must do so and pass this pointer to the constructor for Pointers. -Since all storage is encapsulated, the LAMMPS class can also be -instantiated multiple times by a calling code, and that can be either -simultaneously or consecutively. When running in parallel with MPI, -care has to be taken, that suitable communicators are used to not -create conflicts between different instances. +Since all storage is supposed to be encapsulated (there are a few +exceptions), the LAMMPS class can also be instantiated multiple times by +a calling code. Outside of the aforementioned exceptions, those LAMMPS +instances can be used alternately. As of the time of this writing +(early 2021) LAMMPS is not yet sufficiently thread-safe for concurrent +execution. When running in parallel with MPI, care has to be taken, +that suitable copies of communicators are used to not create conflicts +between different instances. -The LAMMPS class currently holds instances of 19 classes representing -different core functionalities There are a handful of virtual parent -classes in LAMMPS that define what LAMMPS calls ``styles``. They are -shaded red in the :ref:`class-topology` figure. Each of these are +The LAMMPS class currently (early 2021) holds instances of 19 classes +representing the core functionality. There are a handful of virtual +parent classes in LAMMPS that define what LAMMPS calls ``styles``. They +are shaded red in the :ref:`class-topology` figure. Each of these are parents of a number of child classes that implement the interface defined by the parent class. There are two main categories of these ``styles``: some may only have one instance active at a time (e.g. atom, pair, bond, angle, dihedral, improper, kspace, comm) and there is a -dedicated pointer variable in the composite class that manages them. +dedicated pointer variable for each of them in the composite class. Setups that require a mix of different such styles have to use a -*hybrid* class that manages and forwards calls to the corresponding -sub-styles for the designated subset of atoms or data. or the composite -class may have lists of class instances, e.g. Modify handles lists of -compute and fix styles, while Output handles dumps class instances. +*hybrid* class that takes the place of the one allowed instance and then +manages and forwards calls to the corresponding sub-styles for the +designated subset of atoms or data. The composite class may also have +lists of class instances, e.g. Modify handles lists of compute and fix +styles, while Output handles a list of dump class instances. -The exception to this scheme are the ``command`` style classes. These -implement specific commands that can be invoked before, after, or between -runs or are commands which launch a simulation. For these an instance -of the class is created, its command() method called and then, after -completion, the class instance deleted. Examples for this are the -create_box, create_atoms, minimize, run, or velocity command styles. +The exception to this scheme are the ``command`` style classes. These +implement specific commands that can be invoked before, after, or in +between runs. For these an instance of the class is created, its +command() method called and then, after completion, the class instance +deleted. Examples for this are the create_box, create_atoms, minimize, +run, or velocity command styles. For all those ``styles`` certain naming conventions are employed: for -the fix nve command the class is called FixNVE and the files are +the fix nve command the class is called FixNVE and the source files are ``fix_nve.h`` and ``fix_nve.cpp``. Similarly for fix ave/time we have -FixAveTime and ``fix_ave_time.h`` and ``fix_ave_time.cpp``. Style names +FixAveTime and ``fix_ave_time.h`` and ``fix_ave_time.cpp``. Style names are lower case and without spaces or special characters. A suffix or -multiple appended with a forward slash '/' denotes a variant of the -corresponding class without the suffix. To connect the style name and -the class name, LAMMPS uses macros like the following ATOM\_CLASS, -PAIR\_CLASS, BOND\_CLASS, REGION\_CLASS, FIX\_CLASS, COMPUTE\_CLASS, -or DUMP\_CLASS in the corresponding header file. During compilation -files with the pattern ``style_name.h`` are created that contain include -statements including all headers of all styles of a given type that -are currently active (or "installed). +words are appended with a forward slash '/' which denotes a variant of +the corresponding class without the suffix. To connect the style name +and the class name, LAMMPS uses macros like: ``AtomStyle()``, +``PairStyle()``, ``BondStyle()``, ``RegionStyle()``, and so on in the +corresponding header file. During configuration or compilation files +with the pattern ``style_.h`` are created that consist of a list +of include statements including all headers of all styles of a given +type that are currently active (or "installed). More details on individual classes in the :ref:`class-topology` are as @@ -152,11 +166,11 @@ follows: - The Memory class handles allocation of all large vectors and arrays. -- The Error class prints all error and warning messages. +- The Error class prints all (terminal) error and warning messages. -- The Universe class sets up partitions of processors so that multiple - simulations can be run, each on a subset of the processors allocated - for a run, e.g. by the mpirun command. +- The Universe class sets up one or more partitions of processors so + that one or multiple simulations can be run, on the processors + allocated for a run, e.g. by the mpirun command. - The Input class reads and processes input input strings and files, stores variables, and invokes :doc:`commands `. @@ -241,7 +255,8 @@ follows: .. TODO section on "Spatial decomposition and parallel operations" .. diagram of 3d processor grid, brick vs. tiled. local vs. ghost .. atoms, 6-way communication with pack/unpack functions, -.. PBC as part of the communication +.. PBC as part of the communication, forward and reverse communication +.. rendezvous communication, ring communication. .. TODO section on "Fixes, Computes, and Variables" .. how and when data is computed and provided and how it is From 9a419154fafcf57cc290aeab7962a1f89c02a12c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 1 Feb 2021 10:15:06 -0500 Subject: [PATCH 15/26] whitespace --- src/USER-MISC/pair_agni.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/USER-MISC/pair_agni.h b/src/USER-MISC/pair_agni.h index 4627d79804..58adc2002d 100644 --- a/src/USER-MISC/pair_agni.h +++ b/src/USER-MISC/pair_agni.h @@ -40,7 +40,7 @@ class PairAGNI : public Pair { double *eta,**xU,*alpha; double sigma,lambda,b,gwidth; int numeta,numtrain,ielement; - + }; protected: From 2b44d671283a0ed2b7211dd80c9fff83a8c1d431 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 1 Feb 2021 18:13:00 -0500 Subject: [PATCH 16/26] consistent dependencies for targes in "doc" folder makefile --- doc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 041c7a372a..aad20461ec 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -94,7 +94,7 @@ $(SPHINXCONFIG)/conf.py: $(SPHINXCONFIG)/conf.py.in -e 's,@LAMMPS_PYTHON_DIR@,$(BUILDDIR)/../python,g' \ -e 's,@LAMMPS_DOC_DIR@,$(BUILDDIR),g' $< > $@ -html: xmlgen $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) +html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) @if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi @$(MAKE) $(MFLAGS) -C graphviz all @(\ @@ -118,7 +118,7 @@ html: xmlgen $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) @rm -rf html/PDF/.[sg]* @echo "Build finished. The HTML pages are in doc/html." -spelling: xmlgen $(VENV) $(SPHINXCONFIG)/false_positives.txt +spelling: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(SPHINXCONFIG)/false_positives.txt @if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi @(\ . $(VENV)/bin/activate ; env PYTHONWARNINGS= \ From 2ee701f7191b7f84d18adf552fcd86393d279786 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 1 Feb 2021 18:43:42 -0500 Subject: [PATCH 17/26] also flush screen stdio buffer with thermo_modify flush yes --- src/thermo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/thermo.cpp b/src/thermo.cpp index 9197f88084..0e9defd165 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -381,6 +381,7 @@ void Thermo::compute(int flag) if (me == 0) { utils::logmesg(lmp,line); + if (screen && flushflag) fflush(screen); if (logfile && flushflag) fflush(logfile); } From 9ca0653c3ec6445c3a1473c366cc2e377e9b1a2d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 1 Oct 2020 11:26:30 -0400 Subject: [PATCH 18/26] add CodeQL static code analysis workflow --- .github/workflows/codeql-analysis.yml | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..5e0518e876 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,50 @@ +# GitHub action to run static code analysis on C++ and Python code +name: "CodeQL Code Analysis" + +on: + push: + branches: [master] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] + language: ['cpp', 'python'] + + steps: + - name: Checkout repository + if: ${{ github.repository == 'lammps/lammps' }} + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.repository == 'lammps/lammps' && github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + if: ${{ github.repository == 'lammps/lammps' }} + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Building LAMMPS via CMake + if: ${{ github.repository == 'lammps/lammps' }} + run: | + mkdir build + cd build + cmake -C ../cmake/presets/most.cmake ../cmake -DBUILD_SHARED_LIBS=on + make + + - name: Perform CodeQL Analysis + if: ${{ github.repository == 'lammps/lammps' }} + uses: github/codeql-action/analyze@v1 From c11bd658fc54df6f3c80962e363b1619efb5a381 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Thu, 1 Oct 2020 11:45:13 -0400 Subject: [PATCH 19/26] Add documentation and style check workflow --- .github/workflows/documentation.yml | 21 +++++++++++++++ .github/workflows/style.yml | 42 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/style.yml diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000000..430657bd85 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,21 @@ +name: documentation +on: + push: + branches: + - master + paths: + - 'doc/*' + +jobs: + build: + continue-on-error: true + runs-on: ubuntu-latest + container: "lammps/buildenv:fedora32_mingw" + steps: + - uses: actions/checkout@master + - name: Generate HTML + run: make -C doc -j 2 html + - name: Generate PDF + run: make -C doc -j 2 pdf + - name: Check Spelling + run: make -C doc -j 2 spelling diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml new file mode 100644 index 0000000000..8b9d55b22f --- /dev/null +++ b/.github/workflows/style.yml @@ -0,0 +1,42 @@ +name: style +on: + push: + branches: + - master + +jobs: + check_whitespace: + runs-on: ubuntu-latest + steps: + - name: Set up Python 3.6 + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade pyyaml + sudo apt install -y ninja-build + - uses: actions/checkout@master + - name: Configure + run: cmake -B build -G Ninja -D Python3_EXECUTABLE=$(which python) -S cmake + - name: Check for whitespace errors + run: cmake --build build --target check-whitespace + + check_permissions: + runs-on: ubuntu-latest + steps: + - name: Set up Python 3.6 + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade pyyaml + sudo apt install -y ninja-build + - uses: actions/checkout@master + - name: Configure + run: cmake -B build -G Ninja -D Python3_EXECUTABLE=$(which python) -S cmake + - name: Check file permissions + run: cmake --build build --target check-permissions From 60a11b9ea1278503988f90149ee29f51ab7b2e2f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 1 Oct 2020 12:21:09 -0400 Subject: [PATCH 20/26] do parallel compilation --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5e0518e876..e84483ff6c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: mkdir build cd build cmake -C ../cmake/presets/most.cmake ../cmake -DBUILD_SHARED_LIBS=on - make + make -j2 - name: Perform CodeQL Analysis if: ${{ github.repository == 'lammps/lammps' }} From 0be1a419c7538251db35f05bdb4567c1470885b5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 1 Oct 2020 12:52:23 -0400 Subject: [PATCH 21/26] split codeql workflow into two files as no compilation is needed for python --- .../{codeql-analysis.yml => codeql-cpp.yml} | 2 +- .github/workflows/codeql-python.yml | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) rename .github/workflows/{codeql-analysis.yml => codeql-cpp.yml} (97%) create mode 100644 .github/workflows/codeql-python.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-cpp.yml similarity index 97% rename from .github/workflows/codeql-analysis.yml rename to .github/workflows/codeql-cpp.yml index e84483ff6c..dcaab19d29 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-cpp.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['cpp', 'python'] + language: ['cpp'] steps: - name: Checkout repository diff --git a/.github/workflows/codeql-python.yml b/.github/workflows/codeql-python.yml new file mode 100644 index 0000000000..2d4a4992ed --- /dev/null +++ b/.github/workflows/codeql-python.yml @@ -0,0 +1,42 @@ +# GitHub action to run static code analysis on C++ and Python code +name: "CodeQL Code Analysis" + +on: + push: + branches: [master] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] + language: ['python'] + + steps: + - name: Checkout repository + if: ${{ github.repository == 'lammps/lammps' }} + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.repository == 'lammps/lammps' && github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + if: ${{ github.repository == 'lammps/lammps' }} + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Perform CodeQL Analysis + if: ${{ github.repository == 'lammps/lammps' }} + uses: github/codeql-action/analyze@v1 From b15555724d4c466f51565712a99e6073b17394e1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 1 Oct 2020 14:15:28 -0400 Subject: [PATCH 22/26] combine analysis and simplify --- ...{codeql-python.yml => codeql-analysis.yml} | 14 ++++-- .github/workflows/codeql-cpp.yml | 50 ------------------- 2 files changed, 9 insertions(+), 55 deletions(-) rename .github/workflows/{codeql-python.yml => codeql-analysis.yml} (74%) delete mode 100644 .github/workflows/codeql-cpp.yml diff --git a/.github/workflows/codeql-python.yml b/.github/workflows/codeql-analysis.yml similarity index 74% rename from .github/workflows/codeql-python.yml rename to .github/workflows/codeql-analysis.yml index 2d4a4992ed..a74f5fe12f 100644 --- a/.github/workflows/codeql-python.yml +++ b/.github/workflows/codeql-analysis.yml @@ -8,17 +8,17 @@ on: jobs: analyze: name: Analyze + if: ${{ github.repository == 'lammps/lammps' }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['python'] + language: ['cpp', 'python'] steps: - name: Checkout repository - if: ${{ github.repository == 'lammps/lammps' }} uses: actions/checkout@v2 with: # We must fetch at least the immediate parents so that if this is @@ -28,15 +28,19 @@ jobs: # If this run was triggered by a pull request event, then checkout # the head of the pull request instead of the merge commit. - run: git checkout HEAD^2 - if: ${{ github.repository == 'lammps/lammps' && github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' }} # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - if: ${{ github.repository == 'lammps/lammps' }} uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} + - name: Building LAMMPS via CMake + if: ${{ matrix.language == 'cpp' }} + run: | + cmake -B build -C cmake/presets/most.cmake cmake -DBUILD_SHARED_LIBS=on + make -C build -j2 + - name: Perform CodeQL Analysis - if: ${{ github.repository == 'lammps/lammps' }} uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/codeql-cpp.yml b/.github/workflows/codeql-cpp.yml deleted file mode 100644 index dcaab19d29..0000000000 --- a/.github/workflows/codeql-cpp.yml +++ /dev/null @@ -1,50 +0,0 @@ -# GitHub action to run static code analysis on C++ and Python code -name: "CodeQL Code Analysis" - -on: - push: - branches: [master] - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['cpp'] - - steps: - - name: Checkout repository - if: ${{ github.repository == 'lammps/lammps' }} - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.repository == 'lammps/lammps' && github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - if: ${{ github.repository == 'lammps/lammps' }} - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - - - name: Building LAMMPS via CMake - if: ${{ github.repository == 'lammps/lammps' }} - run: | - mkdir build - cd build - cmake -C ../cmake/presets/most.cmake ../cmake -DBUILD_SHARED_LIBS=on - make -j2 - - - name: Perform CodeQL Analysis - if: ${{ github.repository == 'lammps/lammps' }} - uses: github/codeql-action/analyze@v1 From 88e182da646ed62e1a71d800d380cf71ef71a2ef Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 1 Oct 2020 19:01:28 -0400 Subject: [PATCH 23/26] speed up compilation for static code analysis by switching to debug build type and turning off optimization --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a74f5fe12f..4bf207b49b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,7 +39,7 @@ jobs: - name: Building LAMMPS via CMake if: ${{ matrix.language == 'cpp' }} run: | - cmake -B build -C cmake/presets/most.cmake cmake -DBUILD_SHARED_LIBS=on + cmake -B build -C cmake/presets/most.cmake cmake -DCMAKE_BUILD_TYPE=Debug make -C build -j2 - name: Perform CodeQL Analysis From a83fe46860992a6e299c33e23588e73a10a5d7dc Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 1 Oct 2020 21:56:30 -0400 Subject: [PATCH 24/26] spelling target needs conf.py --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index aad20461ec..6032aff45f 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -118,7 +118,7 @@ html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) @rm -rf html/PDF/.[sg]* @echo "Build finished. The HTML pages are in doc/html." -spelling: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(SPHINXCONFIG)/false_positives.txt +spelling: xmlgen $(SPHINXCONFIG)/conf.py $(VENV) $(SPHINXCONFIG)/false_positives.txt @if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi @(\ . $(VENV)/bin/activate ; env PYTHONWARNINGS= \ From 6d836d8f302e9368a69474aabdc8dda3476b1e4c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 1 Oct 2020 21:56:53 -0400 Subject: [PATCH 25/26] run documentation actions in parallel --- .github/workflows/documentation.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 430657bd85..9a85f4897d 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -11,11 +11,10 @@ jobs: continue-on-error: true runs-on: ubuntu-latest container: "lammps/buildenv:fedora32_mingw" + strategy: + matrix: + target: ['html', 'pdf', 'spelling'] steps: - uses: actions/checkout@master - - name: Generate HTML - run: make -C doc -j 2 html - - name: Generate PDF - run: make -C doc -j 2 pdf - - name: Check Spelling - run: make -C doc -j 2 spelling + - name: Generate ${{ matrix.target }} + run: make -C doc ${{ matrix.target }} From bfe64629fd8ae61980bf6f08a21dc682b61f9009 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 1 Feb 2021 20:30:32 -0500 Subject: [PATCH 26/26] switch to do CodeQL analysis and Unittest on MacOS. currently for PRs and master --- .github/workflows/codeql-analysis.yml | 23 ++++++++------- .github/workflows/documentation.yml | 20 ------------- .github/workflows/style.yml | 42 --------------------------- .github/workflows/unittest-macos.yml | 36 +++++++++++++++++++++++ 4 files changed, 49 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/documentation.yml delete mode 100644 .github/workflows/style.yml create mode 100644 .github/workflows/unittest-macos.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4bf207b49b..7507db07ef 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -4,6 +4,8 @@ name: "CodeQL Code Analysis" on: push: branches: [master] + pull_request: + branches: [master] jobs: analyze: @@ -14,33 +16,34 @@ jobs: strategy: fail-fast: false matrix: - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] language: ['cpp', 'python'] steps: - name: Checkout repository uses: actions/checkout@v2 with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. fetch-depth: 2 - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} + - name: Create Build Environment + run: cmake -E make_directory ${{github.workspace}}/build + - name: Building LAMMPS via CMake if: ${{ matrix.language == 'cpp' }} + shell: bash + working-directory: ${{github.workspace}}/build run: | - cmake -B build -C cmake/presets/most.cmake cmake -DCMAKE_BUILD_TYPE=Debug - make -C build -j2 + cmake -C $GITHUB_WORKSPACE/cmake/presets/most.cmake $GITHUB_WORKSPACE/cmake + cmake --build . --parallel 2 - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml deleted file mode 100644 index 9a85f4897d..0000000000 --- a/.github/workflows/documentation.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: documentation -on: - push: - branches: - - master - paths: - - 'doc/*' - -jobs: - build: - continue-on-error: true - runs-on: ubuntu-latest - container: "lammps/buildenv:fedora32_mingw" - strategy: - matrix: - target: ['html', 'pdf', 'spelling'] - steps: - - uses: actions/checkout@master - - name: Generate ${{ matrix.target }} - run: make -C doc ${{ matrix.target }} diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml deleted file mode 100644 index 8b9d55b22f..0000000000 --- a/.github/workflows/style.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: style -on: - push: - branches: - - master - -jobs: - check_whitespace: - runs-on: ubuntu-latest - steps: - - name: Set up Python 3.6 - uses: actions/setup-python@v2 - with: - python-version: 3.6 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install --upgrade pyyaml - sudo apt install -y ninja-build - - uses: actions/checkout@master - - name: Configure - run: cmake -B build -G Ninja -D Python3_EXECUTABLE=$(which python) -S cmake - - name: Check for whitespace errors - run: cmake --build build --target check-whitespace - - check_permissions: - runs-on: ubuntu-latest - steps: - - name: Set up Python 3.6 - uses: actions/setup-python@v2 - with: - python-version: 3.6 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install --upgrade pyyaml - sudo apt install -y ninja-build - - uses: actions/checkout@master - - name: Configure - run: cmake -B build -G Ninja -D Python3_EXECUTABLE=$(which python) -S cmake - - name: Check file permissions - run: cmake --build build --target check-permissions diff --git a/.github/workflows/unittest-macos.yml b/.github/workflows/unittest-macos.yml new file mode 100644 index 0000000000..ed3b9562a5 --- /dev/null +++ b/.github/workflows/unittest-macos.yml @@ -0,0 +1,36 @@ +# GitHub action to build LAMMPS on MacOS and run unit tests +name: "Unittest for MacOS" + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + name: MacOS Unit Test + if: ${{ github.repository == 'lammps/lammps' }} + runs-on: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Create Build Environment + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Building LAMMPS via CMake + shell: bash + working-directory: ${{github.workspace}}/build + run: | + cmake -C $GITHUB_WORKSPACE/cmake/presets/most.cmake $GITHUB_WORKSPACE/cmake \ + -DENABLE_TESTING=ON -DBUILD_SHARED_LIBS=ON -DLAMMPS_EXCEPTIONS=ON + cmake --build . --parallel 2 + + - name: Run Tests + working-directory: ${{github.workspace}}/build + shell: bash + run: ctest -V