modernize and reformat with clang-tidy and clang-format
This commit is contained in:
@ -63,12 +63,12 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
|
||||
LAMMPS *init_lammps(LAMMPS::argv &args, const TestConfig &cfg, const bool newton = true)
|
||||
{
|
||||
LAMMPS *lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
auto *lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
|
||||
// check if prerequisite styles are available
|
||||
Info *info = new Info(lmp);
|
||||
int nfail = 0;
|
||||
for (auto &prerequisite : cfg.prerequisites) {
|
||||
for (const auto &prerequisite : cfg.prerequisites) {
|
||||
std::string style = prerequisite.second;
|
||||
|
||||
// this is a test for dihedral styles, so if the suffixed
|
||||
@ -118,7 +118,7 @@ LAMMPS *init_lammps(LAMMPS::argv &args, const TestConfig &cfg, const bool newton
|
||||
|
||||
command("variable input_dir index " + INPUT_FOLDER);
|
||||
|
||||
for (auto &pre_command : cfg.pre_commands) {
|
||||
for (const auto &pre_command : cfg.pre_commands) {
|
||||
command(pre_command);
|
||||
}
|
||||
|
||||
@ -127,11 +127,11 @@ LAMMPS *init_lammps(LAMMPS::argv &args, const TestConfig &cfg, const bool newton
|
||||
|
||||
command("dihedral_style " + cfg.dihedral_style);
|
||||
|
||||
for (auto &dihedral_coeff : cfg.dihedral_coeff) {
|
||||
for (const auto &dihedral_coeff : cfg.dihedral_coeff) {
|
||||
command("dihedral_coeff " + dihedral_coeff);
|
||||
}
|
||||
|
||||
for (auto &post_command : cfg.post_commands) {
|
||||
for (const auto &post_command : cfg.post_commands) {
|
||||
command(post_command);
|
||||
}
|
||||
|
||||
@ -174,12 +174,12 @@ void restart_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
}
|
||||
|
||||
if ((cfg.dihedral_style.substr(0, 6) == "hybrid") || !lmp->force->dihedral->writedata) {
|
||||
for (auto &dihedral_coeff : cfg.dihedral_coeff) {
|
||||
for (const auto &dihedral_coeff : cfg.dihedral_coeff) {
|
||||
command("dihedral_coeff " + dihedral_coeff);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &post_command : cfg.post_commands) {
|
||||
for (const auto &post_command : cfg.post_commands) {
|
||||
command(post_command);
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
command("variable newton_bond delete");
|
||||
command("variable newton_bond index on");
|
||||
|
||||
for (auto &pre_command : cfg.pre_commands) {
|
||||
for (const auto &pre_command : cfg.pre_commands) {
|
||||
command(pre_command);
|
||||
}
|
||||
|
||||
@ -221,10 +221,10 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
|
||||
std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file);
|
||||
parse_input_script(input_file);
|
||||
|
||||
for (auto &dihedral_coeff : cfg.dihedral_coeff) {
|
||||
for (const auto &dihedral_coeff : cfg.dihedral_coeff) {
|
||||
command("dihedral_coeff " + dihedral_coeff);
|
||||
}
|
||||
for (auto &post_command : cfg.post_commands) {
|
||||
for (const auto &post_command : cfg.post_commands) {
|
||||
command(post_command);
|
||||
}
|
||||
command("run 0 post no");
|
||||
@ -241,7 +241,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : config.prerequisites) {
|
||||
for (const auto &prerequisite : config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
return;
|
||||
@ -260,7 +260,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// dihedral_coeff
|
||||
block.clear();
|
||||
for (auto &dihedral_coeff : config.dihedral_coeff) {
|
||||
for (const auto &dihedral_coeff : config.dihedral_coeff) {
|
||||
block += dihedral_coeff + "\n";
|
||||
}
|
||||
writer.emit_block("dihedral_coeff", block);
|
||||
@ -278,14 +278,14 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
writer.emit("init_energy", lmp->force->dihedral->energy);
|
||||
|
||||
// init_stress
|
||||
auto stress = lmp->force->dihedral->virial;
|
||||
auto *stress = lmp->force->dihedral->virial;
|
||||
block = fmt::format("{:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e}", stress[0],
|
||||
stress[1], stress[2], stress[3], stress[4], stress[5]);
|
||||
writer.emit_block("init_stress", block);
|
||||
|
||||
// init_forces
|
||||
block.clear();
|
||||
auto f = lmp->atom->f;
|
||||
auto *f = lmp->atom->f;
|
||||
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, f[j][0], f[j][1], f[j][2]);
|
||||
@ -346,7 +346,7 @@ TEST(DihedralStyle, plain)
|
||||
double epsilon = test_config.epsilon;
|
||||
|
||||
ErrorStats stats;
|
||||
auto dihedral = lmp->force->dihedral;
|
||||
auto *dihedral = lmp->force->dihedral;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton on)", dihedral->virial, test_config.init_stress, epsilon);
|
||||
@ -466,7 +466,7 @@ TEST(DihedralStyle, omp)
|
||||
double epsilon = 5.0 * test_config.epsilon;
|
||||
|
||||
ErrorStats stats;
|
||||
auto dihedral = lmp->force->dihedral;
|
||||
auto *dihedral = lmp->force->dihedral;
|
||||
|
||||
EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon);
|
||||
EXPECT_STRESS("init_stress (newton on)", dihedral->virial, test_config.init_stress,
|
||||
@ -534,7 +534,6 @@ TEST(DihedralStyle, omp)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
|
||||
TEST(DihedralStyle, numdiff)
|
||||
{
|
||||
if (!LAMMPS::is_installed_pkg("EXTRA-FIX")) GTEST_SKIP();
|
||||
|
||||
Reference in New Issue
Block a user