apply clang-format
This commit is contained in:
@ -364,7 +364,7 @@ TEST(DihedralStyle, plain)
|
||||
|
||||
stats.reset();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
double energy = 0.0;
|
||||
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, energy, epsilon);
|
||||
@ -486,7 +486,7 @@ TEST(DihedralStyle, omp)
|
||||
|
||||
stats.reset();
|
||||
auto *icompute = lmp->modify->get_compute_by_id("sum");
|
||||
double energy = 0.0;
|
||||
double energy = 0.0;
|
||||
if (icompute) energy = icompute->compute_scalar();
|
||||
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon);
|
||||
// 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 (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP();
|
||||
|
||||
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen",
|
||||
"-nocite", "-k", "on", "t", "4",
|
||||
"-sf", "kk"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
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
|
||||
// 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);
|
||||
//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();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
@ -631,7 +632,7 @@ TEST(DihedralStyle, kokkos_omp)
|
||||
|
||||
// FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid
|
||||
// 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);
|
||||
|
||||
if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl;
|
||||
|
||||
@ -247,14 +247,15 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// run_torque
|
||||
|
||||
if(lmp->atom->torque_flag) {
|
||||
block.clear();
|
||||
auto *t = lmp->atom->torque;
|
||||
for (int i = 1; i <= natoms; ++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]);
|
||||
}
|
||||
writer.emit_block("run_torque", block);
|
||||
if (lmp->atom->torque_flag) {
|
||||
block.clear();
|
||||
auto *t = lmp->atom->torque;
|
||||
for (int i = 1; i <= natoms; ++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]);
|
||||
}
|
||||
writer.emit_block("run_torque", block);
|
||||
}
|
||||
|
||||
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_VELOCITIES("run_vel (normal run, verlet)", lmp->atom, test_config.run_vel, epsilon);
|
||||
if(lmp->atom->torque_flag)
|
||||
EXPECT_TORQUES("run_torques (normal run, verlet)", lmp->atom, test_config.run_torque, epsilon);
|
||||
|
||||
if (lmp->atom->torque_flag)
|
||||
EXPECT_TORQUES("run_torques (normal run, verlet)", lmp->atom, test_config.run_torque,
|
||||
epsilon);
|
||||
|
||||
auto *ifix = lmp->modify->get_fix_by_id("test");
|
||||
if (!ifix) {
|
||||
@ -353,7 +354,7 @@ TEST(FixTimestep, plain)
|
||||
|
||||
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);
|
||||
if(lmp->atom->torque_flag)
|
||||
if (lmp->atom->torque_flag)
|
||||
EXPECT_TORQUES("run_torque (restart, verlet)", lmp->atom, test_config.run_torque, epsilon);
|
||||
|
||||
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();
|
||||
|
||||
LAMMPS::argv args = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
"-k", "on", "t", "4", "-sf", "kk"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
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_VELOCITIES("run_vel (normal run, verlet)", lmp->atom, test_config.run_vel, epsilon);
|
||||
if(lmp->atom->torque_flag)
|
||||
EXPECT_TORQUES("run_torque (normal run, verlet)", lmp->atom, test_config.run_torque, epsilon);
|
||||
if (lmp->atom->torque_flag)
|
||||
EXPECT_TORQUES("run_torque (normal run, verlet)", lmp->atom, test_config.run_torque,
|
||||
epsilon);
|
||||
|
||||
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_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);
|
||||
|
||||
ifix = lmp->modify->get_fix_by_id("test");
|
||||
@ -1023,4 +1025,3 @@ TEST(FixTimestep, kokkos_omp)
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
|
||||
@ -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,
|
||||
double epsilon)
|
||||
double epsilon)
|
||||
{
|
||||
SCOPED_TRACE("EXPECT_TORQUES: " + name);
|
||||
double **t = atom->torque;
|
||||
|
||||
@ -28,13 +28,13 @@ extern std::string INPUT_FOLDER;
|
||||
// convenience method to write out common entries
|
||||
void write_yaml_header(class YamlWriter *writer, TestConfig *cfg, const char *version);
|
||||
|
||||
#define EXPECT_FP_LE_WITH_EPS(val1, val2, eps) \
|
||||
do { \
|
||||
const double diff = fabs(val1 - val2); \
|
||||
const double div = std::min(fabs(val1), fabs(val2)); \
|
||||
const double err = (div==0.0) ? diff : diff/div; \
|
||||
stats.add(err); \
|
||||
EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \
|
||||
#define EXPECT_FP_LE_WITH_EPS(val1, val2, eps) \
|
||||
do { \
|
||||
const double diff = fabs(val1 - val2); \
|
||||
const double div = std::min(fabs(val1), fabs(val2)); \
|
||||
const double err = (div == 0.0) ? diff : diff / div; \
|
||||
stats.add(err); \
|
||||
EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \
|
||||
} while (0);
|
||||
|
||||
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,
|
||||
const std::vector<coord_t> &v_ref, double epsilon);
|
||||
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
|
||||
|
||||
@ -126,13 +126,11 @@ TEST(FmtLib, insert_neg_double)
|
||||
TEST(FmtLib, int_for_double)
|
||||
{
|
||||
const double val = -1.5;
|
||||
std::string text;
|
||||
ASSERT_THROW( text = fmt::format("word {:d}", val), std::exception);
|
||||
ASSERT_THROW(auto text = fmt::format("word {:d}", val), std::exception);
|
||||
}
|
||||
|
||||
TEST(FmtLib, double_for_int)
|
||||
{
|
||||
const int val = 15;
|
||||
std::string text;
|
||||
ASSERT_THROW( text = fmt::format("word {:g}", val), std::exception);
|
||||
ASSERT_THROW(auto text = fmt::format("word {:g}", val), std::exception);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user