diff --git a/src/EXTRA-FIX/fix_ttm.cpp b/src/EXTRA-FIX/fix_ttm.cpp index 13fbd4aff4..4c0d2e9cd5 100644 --- a/src/EXTRA-FIX/fix_ttm.cpp +++ b/src/EXTRA-FIX/fix_ttm.cpp @@ -46,6 +46,18 @@ using namespace FixConst; static constexpr int OFFSET = 16384; static constexpr double SHIFT = 0.0; +// helper class + +namespace { + class parser_error : public std::exception { + std::string message; + + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; +} + /* ---------------------------------------------------------------------- */ FixTTM::FixTTM(LAMMPS *lmp, int narg, char **arg) : diff --git a/src/EXTRA-FIX/fix_ttm.h b/src/EXTRA-FIX/fix_ttm.h index 1a2e9fb24a..da782b1f5a 100644 --- a/src/EXTRA-FIX/fix_ttm.h +++ b/src/EXTRA-FIX/fix_ttm.h @@ -77,14 +77,6 @@ class FixTTM : public Fix { virtual void deallocate_grid(); virtual void read_electron_temperatures(const std::string &); virtual void write_electron_temperatures(const std::string &); - - class parser_error : public std::exception { - std::string message; - - public: - parser_error(const std::string &mesg) { message = mesg; } - const char *what() const noexcept { return message.c_str(); } - }; }; } // namespace LAMMPS_NS diff --git a/src/EXTRA-FIX/fix_ttm_grid.cpp b/src/EXTRA-FIX/fix_ttm_grid.cpp index 7b3f434907..b42b876a3b 100644 --- a/src/EXTRA-FIX/fix_ttm_grid.cpp +++ b/src/EXTRA-FIX/fix_ttm_grid.cpp @@ -41,6 +41,18 @@ static constexpr int MAXLINE = 256; static constexpr int CHUNK = 1024; static constexpr int OFFSET = 16384; +// helper class + +namespace { + class parser_error : public std::exception { + std::string message; + + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; +} + /* ---------------------------------------------------------------------- */ FixTTMGrid::FixTTMGrid(LAMMPS *lmp, int narg, char **arg) : diff --git a/src/EXTRA-FIX/fix_ttm_mod.cpp b/src/EXTRA-FIX/fix_ttm_mod.cpp index 0aef2ec4ff..d39d50c9e5 100644 --- a/src/EXTRA-FIX/fix_ttm_mod.cpp +++ b/src/EXTRA-FIX/fix_ttm_mod.cpp @@ -41,6 +41,18 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; +// helper class + +namespace { + class parser_error : public std::exception { + std::string message; + + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; +} + // OFFSET avoids outside-of-box atoms being rounded to grid pts incorrectly // SHIFT = 0.0 assigns atoms to lower-left grid pt // SHIFT = 0.5 assigns atoms to nearest grid pt diff --git a/src/EXTRA-FIX/fix_ttm_mod.h b/src/EXTRA-FIX/fix_ttm_mod.h index f26f270e7a..21eb0efcaa 100644 --- a/src/EXTRA-FIX/fix_ttm_mod.h +++ b/src/EXTRA-FIX/fix_ttm_mod.h @@ -87,14 +87,6 @@ class FixTTMMod : public Fix { void read_parameters(const std::string &); void read_electron_temperatures(const std::string &); void write_electron_temperatures(const std::string &); - - class parser_error : public std::exception { - std::string message; - - public: - parser_error(const std::string &mesg) { message = mesg; } - const char *what() const noexcept { return message.c_str(); } - }; }; } // namespace LAMMPS_NS diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 79205f7c81..b43afb00d6 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -42,12 +42,14 @@ using namespace FixConst; #define MAXLINE 1024 -class parser_error : public std::exception { - std::string message; -public: - parser_error(const std::string &mesg) { message = mesg; } - const char *what() const noexcept { return message.c_str(); } -}; +namespace { + class parser_error : public std::exception { + std::string message; + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; +} /* ---------------------------------------------------------------------- */ diff --git a/src/REAXFF/fix_acks2_reaxff.cpp b/src/REAXFF/fix_acks2_reaxff.cpp index f19b31f9ed..ec14ed72b2 100644 --- a/src/REAXFF/fix_acks2_reaxff.cpp +++ b/src/REAXFF/fix_acks2_reaxff.cpp @@ -43,12 +43,14 @@ using namespace LAMMPS_NS; using namespace FixConst; -class parser_error : public std::exception { - std::string message; -public: - parser_error(const std::string &mesg) { message = mesg; } - const char *what() const noexcept { return message.c_str(); } -}; +namespace { + class parser_error : public std::exception { + std::string message; + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; +} static const char cite_fix_acks2_reax[] = "fix acks2/reaxff command:\n\n" diff --git a/src/REAXFF/fix_qeq_reaxff.cpp b/src/REAXFF/fix_qeq_reaxff.cpp index f0ba651a26..89ee3f338f 100644 --- a/src/REAXFF/fix_qeq_reaxff.cpp +++ b/src/REAXFF/fix_qeq_reaxff.cpp @@ -49,12 +49,14 @@ using namespace LAMMPS_NS; using namespace FixConst; -class parser_error : public std::exception { - std::string message; -public: - parser_error(const std::string &mesg) { message = mesg; } - const char *what() const noexcept { return message.c_str(); } -}; +namespace { + class parser_error : public std::exception { + std::string message; + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; +} static constexpr double EV_TO_KCAL_PER_MOL = 14.4; static constexpr double SMALL = 1.0e-14; diff --git a/src/REAXFF/reaxff_control.cpp b/src/REAXFF/reaxff_control.cpp index 2020e8a5c3..90f12b2031 100644 --- a/src/REAXFF/reaxff_control.cpp +++ b/src/REAXFF/reaxff_control.cpp @@ -40,6 +40,15 @@ using LAMMPS_NS::utils::sfgets; using LAMMPS_NS::utils::logmesg; using LAMMPS_NS::ValueTokenizer; +namespace { + class parser_error : public std::exception { + std::string message; + public: + parser_error(const std::string &mesg) { message = mesg; } + const char *what() const noexcept { return message.c_str(); } + }; +} + namespace ReaxFF { static std::unordered_set inactive_keywords = { "ensemble_type", "nsteps", "dt", "proc_by_dim", "random_vel", @@ -54,13 +63,6 @@ namespace ReaxFF { "energy_update_freq", "atom_info", "atom_velocities", "atom_forces", "bond_info", "angle_info" }; - class parser_error : public std::exception { - std::string message; - public: - parser_error(const std::string &mesg) { message = mesg; } - const char *what() const noexcept { return message.c_str(); } - }; - // NOTE: this function is run on MPI rank 0 only void Read_Control_File(const char *control_file, control_params *control) diff --git a/src/REAXFF/reaxff_ffield.cpp b/src/REAXFF/reaxff_ffield.cpp index 605e077724..db4a63972e 100644 --- a/src/REAXFF/reaxff_ffield.cpp +++ b/src/REAXFF/reaxff_ffield.cpp @@ -41,14 +41,16 @@ using LAMMPS_NS::utils::open_potential; using LAMMPS_NS::utils::getsyserror; using LAMMPS_NS::utils::uppercase; -namespace ReaxFF { - +namespace { class parser_error : public std::exception { std::string message; public: parser_error(const std::string &mesg) { message = mesg; } const char *what() const noexcept { return message.c_str(); } }; +} + +namespace ReaxFF { void Read_Force_Field(const char *filename, reax_interaction *reax, control_params *control, MPI_Comm world)