apply clang-format

This commit is contained in:
Axel Kohlmeyer
2024-09-25 18:15:49 -04:00
parent e44e462da6
commit e29e943ae6
6 changed files with 37 additions and 39 deletions

View File

@ -518,6 +518,4 @@ void FixEfield::update_efield_variables()
input->variable->compute_atom(evar, igroup, &efield[0][3], 4, 0); input->variable->compute_atom(evar, igroup, &efield[0][3], 4, 0);
modify->addstep_compute(update->ntimestep + 1); modify->addstep_compute(update->ntimestep + 1);
} }

View File

@ -364,7 +364,7 @@ TEST(DihedralStyle, plain)
stats.reset(); stats.reset();
auto *icompute = lmp->modify->get_compute_by_id("sum"); auto *icompute = lmp->modify->get_compute_by_id("sum");
double energy = 0.0; double energy = 0.0;
if (icompute) energy = icompute->compute_scalar(); if (icompute) energy = icompute->compute_scalar();
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon);
@ -486,7 +486,7 @@ TEST(DihedralStyle, omp)
stats.reset(); stats.reset();
auto *icompute = lmp->modify->get_compute_by_id("sum"); auto *icompute = lmp->modify->get_compute_by_id("sum");
double energy = 0.0; double energy = 0.0;
if (icompute) energy = icompute->compute_scalar(); if (icompute) energy = icompute->compute_scalar();
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
// TODO: this is currently broken for OPENMP with dihedral style hybrid // TODO: this is currently broken for OPENMP with dihedral style hybrid
@ -542,8 +542,9 @@ TEST(DihedralStyle, kokkos_omp)
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP(); if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP(); if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP();
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite", LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen",
"-k", "on", "t", "4", "-sf", "kk"}; "-nocite", "-k", "on", "t", "4",
"-sf", "kk"};
::testing::internal::CaptureStdout(); ::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(args, test_config, true); LAMMPS *lmp = init_lammps(args, test_config, true);
@ -595,9 +596,9 @@ TEST(DihedralStyle, kokkos_omp)
// FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid // FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid
// needs to be fixed in the main code somewhere. Not sure where, though. // needs to be fixed in the main code somewhere. Not sure where, though.
//if (test_config.dihedral_style.substr(0, 6) != "hybrid") // if (test_config.dihedral_style.substr(0, 6) != "hybrid")
// EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon); // EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon);
//if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl; // if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl;
if (!verbose) ::testing::internal::CaptureStdout(); if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config); cleanup_lammps(lmp, test_config);
@ -631,7 +632,7 @@ TEST(DihedralStyle, kokkos_omp)
// FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid // FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid
// needs to be fixed in the main code somewhere. Not sure where, though. // needs to be fixed in the main code somewhere. Not sure where, though.
//if (test_config.dihedral_style.substr(0, 6) != "hybrid") // if (test_config.dihedral_style.substr(0, 6) != "hybrid")
// EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon); // EXPECT_FP_LE_WITH_EPS(dihedral->energy, energy, epsilon);
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;

View File

@ -247,14 +247,15 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// run_torque // run_torque
if(lmp->atom->torque_flag) { if (lmp->atom->torque_flag) {
block.clear(); block.clear();
auto *t = lmp->atom->torque; auto *t = lmp->atom->torque;
for (int i = 1; i <= natoms; ++i) { for (int i = 1; i <= natoms; ++i) {
const int j = lmp->atom->map(i); const int j = lmp->atom->map(i);
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, t[j][0], t[j][1], t[j][2]); block +=
} fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, t[j][0], t[j][1], t[j][2]);
writer.emit_block("run_torque", block); }
writer.emit_block("run_torque", block);
} }
cleanup_lammps(lmp, config); cleanup_lammps(lmp, config);
@ -301,9 +302,9 @@ TEST(FixTimestep, plain)
EXPECT_POSITIONS("run_pos (normal run, verlet)", lmp->atom, test_config.run_pos, epsilon); EXPECT_POSITIONS("run_pos (normal run, verlet)", lmp->atom, test_config.run_pos, epsilon);
EXPECT_VELOCITIES("run_vel (normal run, verlet)", lmp->atom, test_config.run_vel, epsilon); EXPECT_VELOCITIES("run_vel (normal run, verlet)", lmp->atom, test_config.run_vel, epsilon);
if(lmp->atom->torque_flag) if (lmp->atom->torque_flag)
EXPECT_TORQUES("run_torques (normal run, verlet)", lmp->atom, test_config.run_torque, epsilon); EXPECT_TORQUES("run_torques (normal run, verlet)", lmp->atom, test_config.run_torque,
epsilon);
auto *ifix = lmp->modify->get_fix_by_id("test"); auto *ifix = lmp->modify->get_fix_by_id("test");
if (!ifix) { if (!ifix) {
@ -353,7 +354,7 @@ TEST(FixTimestep, plain)
EXPECT_POSITIONS("run_pos (restart, verlet)", lmp->atom, test_config.run_pos, epsilon); EXPECT_POSITIONS("run_pos (restart, verlet)", lmp->atom, test_config.run_pos, epsilon);
EXPECT_VELOCITIES("run_vel (restart, verlet)", lmp->atom, test_config.run_vel, epsilon); EXPECT_VELOCITIES("run_vel (restart, verlet)", lmp->atom, test_config.run_vel, epsilon);
if(lmp->atom->torque_flag) if (lmp->atom->torque_flag)
EXPECT_TORQUES("run_torque (restart, verlet)", lmp->atom, test_config.run_torque, epsilon); EXPECT_TORQUES("run_torque (restart, verlet)", lmp->atom, test_config.run_torque, epsilon);
ifix = lmp->modify->get_fix_by_id("test"); ifix = lmp->modify->get_fix_by_id("test");
@ -858,7 +859,7 @@ TEST(FixTimestep, kokkos_omp)
if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP(); if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP();
LAMMPS::argv args = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite", LAMMPS::argv args = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite",
"-k", "on", "t", "4", "-sf", "kk"}; "-k", "on", "t", "4", "-sf", "kk"};
::testing::internal::CaptureStdout(); ::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(args, test_config); LAMMPS *lmp = init_lammps(args, test_config);
@ -892,8 +893,9 @@ TEST(FixTimestep, kokkos_omp)
EXPECT_POSITIONS("run_pos (normal run, verlet)", lmp->atom, test_config.run_pos, epsilon); EXPECT_POSITIONS("run_pos (normal run, verlet)", lmp->atom, test_config.run_pos, epsilon);
EXPECT_VELOCITIES("run_vel (normal run, verlet)", lmp->atom, test_config.run_vel, epsilon); EXPECT_VELOCITIES("run_vel (normal run, verlet)", lmp->atom, test_config.run_vel, epsilon);
if(lmp->atom->torque_flag) if (lmp->atom->torque_flag)
EXPECT_TORQUES("run_torque (normal run, verlet)", lmp->atom, test_config.run_torque, epsilon); EXPECT_TORQUES("run_torque (normal run, verlet)", lmp->atom, test_config.run_torque,
epsilon);
auto *ifix = lmp->modify->get_fix_by_id("test"); auto *ifix = lmp->modify->get_fix_by_id("test");
@ -945,7 +947,7 @@ TEST(FixTimestep, kokkos_omp)
EXPECT_POSITIONS("run_pos (restart, verlet)", lmp->atom, test_config.run_pos, epsilon); EXPECT_POSITIONS("run_pos (restart, verlet)", lmp->atom, test_config.run_pos, epsilon);
EXPECT_VELOCITIES("run_vel (restart, verlet)", lmp->atom, test_config.run_vel, epsilon); EXPECT_VELOCITIES("run_vel (restart, verlet)", lmp->atom, test_config.run_vel, epsilon);
if(lmp->atom->torque_flag) if (lmp->atom->torque_flag)
EXPECT_TORQUES("run_torque (restart, verlet)", lmp->atom, test_config.run_torque, epsilon); EXPECT_TORQUES("run_torque (restart, verlet)", lmp->atom, test_config.run_torque, epsilon);
ifix = lmp->modify->get_fix_by_id("test"); ifix = lmp->modify->get_fix_by_id("test");
@ -1023,4 +1025,3 @@ TEST(FixTimestep, kokkos_omp)
cleanup_lammps(lmp, test_config); cleanup_lammps(lmp, test_config);
if (!verbose) ::testing::internal::GetCapturedStdout(); if (!verbose) ::testing::internal::GetCapturedStdout();
}; };

View File

@ -102,7 +102,7 @@ void EXPECT_VELOCITIES(const std::string &name, Atom *atom, const std::vector<co
} }
void EXPECT_TORQUES(const std::string &name, Atom *atom, const std::vector<coord_t> &t_ref, void EXPECT_TORQUES(const std::string &name, Atom *atom, const std::vector<coord_t> &t_ref,
double epsilon) double epsilon)
{ {
SCOPED_TRACE("EXPECT_TORQUES: " + name); SCOPED_TRACE("EXPECT_TORQUES: " + name);
double **t = atom->torque; double **t = atom->torque;

View File

@ -28,13 +28,13 @@ extern std::string INPUT_FOLDER;
// convenience method to write out common entries // convenience method to write out common entries
void write_yaml_header(class YamlWriter *writer, TestConfig *cfg, const char *version); void write_yaml_header(class YamlWriter *writer, TestConfig *cfg, const char *version);
#define EXPECT_FP_LE_WITH_EPS(val1, val2, eps) \ #define EXPECT_FP_LE_WITH_EPS(val1, val2, eps) \
do { \ do { \
const double diff = fabs(val1 - val2); \ const double diff = fabs(val1 - val2); \
const double div = std::min(fabs(val1), fabs(val2)); \ const double div = std::min(fabs(val1), fabs(val2)); \
const double err = (div==0.0) ? diff : diff/div; \ const double err = (div == 0.0) ? diff : diff / div; \
stats.add(err); \ stats.add(err); \
EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \ EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \
} while (0); } while (0);
void EXPECT_STRESS(const std::string &name, double *stress, const stress_t &expected_stress, void EXPECT_STRESS(const std::string &name, double *stress, const stress_t &expected_stress,
@ -46,6 +46,6 @@ void EXPECT_POSITIONS(const std::string &name, LAMMPS_NS::Atom *atom,
void EXPECT_VELOCITIES(const std::string &name, LAMMPS_NS::Atom *atom, void EXPECT_VELOCITIES(const std::string &name, LAMMPS_NS::Atom *atom,
const std::vector<coord_t> &v_ref, double epsilon); const std::vector<coord_t> &v_ref, double epsilon);
void EXPECT_TORQUES(const std::string &name, LAMMPS_NS::Atom *atom, void EXPECT_TORQUES(const std::string &name, LAMMPS_NS::Atom *atom,
const std::vector<coord_t> &t_ref, double epsilon); const std::vector<coord_t> &t_ref, double epsilon);
#endif #endif

View File

@ -126,13 +126,11 @@ TEST(FmtLib, insert_neg_double)
TEST(FmtLib, int_for_double) TEST(FmtLib, int_for_double)
{ {
const double val = -1.5; const double val = -1.5;
std::string text; ASSERT_THROW(auto text = fmt::format("word {:d}", val), std::exception);
ASSERT_THROW( text = fmt::format("word {:d}", val), std::exception);
} }
TEST(FmtLib, double_for_int) TEST(FmtLib, double_for_int)
{ {
const int val = 15; const int val = 15;
std::string text; ASSERT_THROW(auto text = fmt::format("word {:g}", val), std::exception);
ASSERT_THROW( text = fmt::format("word {:g}", val), std::exception);
} }