diff --git a/unittest/force-styles/test_angle_style.cpp b/unittest/force-styles/test_angle_style.cpp index e706cc11ac..e07ec3b689 100644 --- a/unittest/force-styles/test_angle_style.cpp +++ b/unittest/force-styles/test_angle_style.cpp @@ -362,8 +362,9 @@ TEST(AngleStyle, plain) EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + double energy = 0.0; + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl; @@ -393,8 +394,8 @@ TEST(AngleStyle, plain) EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl; @@ -480,8 +481,9 @@ TEST(AngleStyle, omp) EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, 10 * epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + double energy = 0.0; + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); // TODO: this is currently broken for OPENMP with angle style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. @@ -515,8 +517,8 @@ TEST(AngleStyle, omp) 10 * epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); // TODO: this is currently broken for OPENMP with angle style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. @@ -532,124 +534,124 @@ TEST(AngleStyle, omp) TEST(AngleStyle, kokkos_omp) { - if (!LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP(); - if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP(); - if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP(); + if (!LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP(); + if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP(); + if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP(); - LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite", - "-k", "on", "t", "4", "-sf", "kk"}; + LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite", + "-k", "on", "t", "4", "-sf", "kk"}; - ::testing::internal::CaptureStdout(); - LAMMPS *lmp = init_lammps(args, test_config, true); + ::testing::internal::CaptureStdout(); + LAMMPS *lmp = init_lammps(args, test_config, true); - std::string output = ::testing::internal::GetCapturedStdout(); - if (verbose) std::cout << output; + std::string output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; - if (!lmp) { - std::cerr << "One or more prerequisite styles with /kk suffix\n" - "are not available in this LAMMPS configuration:\n"; - for (auto &prerequisite : test_config.prerequisites) { - std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n"; + if (!lmp) { + std::cerr << "One or more prerequisite styles with /kk suffix\n" + "are not available in this LAMMPS configuration:\n"; + for (auto &prerequisite : test_config.prerequisites) { + std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n"; + } + GTEST_SKIP(); } - GTEST_SKIP(); - } - EXPECT_THAT(output, StartsWith("LAMMPS (")); - EXPECT_THAT(output, HasSubstr("Loop time")); + EXPECT_THAT(output, StartsWith("LAMMPS (")); + EXPECT_THAT(output, HasSubstr("Loop time")); - // abort if running in parallel and not all atoms are local - const int nlocal = lmp->atom->nlocal; - ASSERT_EQ(lmp->atom->natoms, nlocal); + // abort if running in parallel and not all atoms are local + const int nlocal = lmp->atom->nlocal; + ASSERT_EQ(lmp->atom->natoms, nlocal); - // relax error a bit for KOKKOS package - double epsilon = 5.0 * test_config.epsilon; + // relax error a bit for KOKKOS package + double epsilon = 5.0 * test_config.epsilon; - ErrorStats stats; - auto angle = lmp->force->angle; + ErrorStats stats; + auto angle = lmp->force->angle; - EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon); - EXPECT_STRESS("init_stress (newton on)", angle->virial, test_config.init_stress, epsilon); - - stats.reset(); - EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); - if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl; - - if (!verbose) ::testing::internal::CaptureStdout(); - run_lammps(lmp); - if (!verbose) ::testing::internal::GetCapturedStdout(); - - EXPECT_FORCES("run_forces (newton on)", lmp->atom, test_config.run_forces, 10 * epsilon); - EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, epsilon); - - stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); - EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); - EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon); - if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl; - - if (!verbose) ::testing::internal::CaptureStdout(); - cleanup_lammps(lmp, test_config); - lmp = init_lammps(args, test_config, false); - if (!verbose) ::testing::internal::GetCapturedStdout(); - - // skip over these tests if newton bond is forced to be on - if (lmp->force->newton_bond == 0) { - angle = lmp->force->angle; - - EXPECT_FORCES("init_forces (newton off)", lmp->atom, test_config.init_forces, epsilon); - EXPECT_STRESS("init_stress (newton off)", angle->virial, test_config.init_stress, - 2 * epsilon); + EXPECT_FORCES("init_forces (newton on)", lmp->atom, test_config.init_forces, epsilon); + EXPECT_STRESS("init_stress (newton on)", angle->virial, test_config.init_stress, epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); - if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl; + if (print_stats) std::cerr << "init_energy stats, newton on: " << stats << std::endl; if (!verbose) ::testing::internal::CaptureStdout(); run_lammps(lmp); if (!verbose) ::testing::internal::GetCapturedStdout(); - EXPECT_FORCES("run_forces (newton off)", lmp->atom, test_config.run_forces, 10 * epsilon); - EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, epsilon); + EXPECT_FORCES("run_forces (newton on)", lmp->atom, test_config.run_forces, 10 * epsilon); + EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + double energy = 0.0; + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->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 on: " << stats << std::endl; - if (!verbose) ::testing::internal::CaptureStdout(); - restart_lammps(lmp, test_config); - if (!verbose) ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + cleanup_lammps(lmp, test_config); + lmp = init_lammps(args, test_config, false); + if (!verbose) ::testing::internal::GetCapturedStdout(); - angle = lmp->force->angle; - EXPECT_FORCES("restart_forces", lmp->atom, test_config.init_forces, epsilon); - EXPECT_STRESS("restart_stress", angle->virial, test_config.init_stress, epsilon); + // skip over these tests if newton bond is forced to be on + if (lmp->force->newton_bond == 0) { + angle = lmp->force->angle; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); - if (print_stats) std::cerr << "restart_energy stats:" << stats << std::endl; + EXPECT_FORCES("init_forces (newton off)", lmp->atom, test_config.init_forces, epsilon); + EXPECT_STRESS("init_stress (newton off)", angle->virial, test_config.init_stress, + 2 * epsilon); - if (!verbose) ::testing::internal::CaptureStdout(); - data_lammps(lmp, test_config); - if (!verbose) ::testing::internal::GetCapturedStdout(); + stats.reset(); + EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); + if (print_stats) std::cerr << "init_energy stats, newton off:" << stats << std::endl; - angle = lmp->force->angle; - EXPECT_FORCES("data_forces", lmp->atom, test_config.init_forces, epsilon); - EXPECT_STRESS("data_stress", angle->virial, test_config.init_stress, epsilon); + if (!verbose) ::testing::internal::CaptureStdout(); + run_lammps(lmp); + if (!verbose) ::testing::internal::GetCapturedStdout(); - stats.reset(); - EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); - if (print_stats) std::cerr << "data_energy stats:" << stats << std::endl; + EXPECT_FORCES("run_forces (newton off)", lmp->atom, test_config.run_forces, 10 * epsilon); + EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, epsilon); - if (!verbose) ::testing::internal::CaptureStdout(); - cleanup_lammps(lmp, test_config); - if (!verbose) ::testing::internal::GetCapturedStdout(); + stats.reset(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) energy = icompute->compute_scalar(); + EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); + EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon); + if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl; + } + + if (!verbose) ::testing::internal::CaptureStdout(); + restart_lammps(lmp, test_config); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + angle = lmp->force->angle; + EXPECT_FORCES("restart_forces", lmp->atom, test_config.init_forces, epsilon); + EXPECT_STRESS("restart_stress", angle->virial, test_config.init_stress, epsilon); + + stats.reset(); + EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); + if (print_stats) std::cerr << "restart_energy stats:" << stats << std::endl; + + if (!verbose) ::testing::internal::CaptureStdout(); + data_lammps(lmp, test_config); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + angle = lmp->force->angle; + EXPECT_FORCES("data_forces", lmp->atom, test_config.init_forces, epsilon); + EXPECT_STRESS("data_stress", angle->virial, test_config.init_stress, epsilon); + + stats.reset(); + EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); + if (print_stats) std::cerr << "data_energy stats:" << stats << std::endl; + + if (!verbose) ::testing::internal::CaptureStdout(); + cleanup_lammps(lmp, test_config); + if (!verbose) ::testing::internal::GetCapturedStdout(); }; - TEST(AngleStyle, numdiff) { if (!LAMMPS::is_installed_pkg("EXTRA-FIX")) GTEST_SKIP(); @@ -766,11 +768,11 @@ TEST(AngleStyle, single) nangletypes)); if (utils::strmatch(test_config.angle_style, "^spica")) { - command("pair_style lj/spica 8.0"); - command("pair_coeff * * lj9_6 0.02 2.5"); + command("pair_style lj/spica 8.0"); + command("pair_coeff * * lj9_6 0.02 2.5"); } else { - command("pair_style zero 8.0"); - command("pair_coeff * *"); + command("pair_style zero 8.0"); + command("pair_coeff * *"); } command("angle_style " + test_config.angle_style); diff --git a/unittest/force-styles/test_bond_style.cpp b/unittest/force-styles/test_bond_style.cpp index 81b105259d..39316ec035 100644 --- a/unittest/force-styles/test_bond_style.cpp +++ b/unittest/force-styles/test_bond_style.cpp @@ -362,8 +362,9 @@ TEST(BondStyle, plain) EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + double energy = 0.0; + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl; @@ -393,8 +394,8 @@ TEST(BondStyle, plain) EXPECT_STRESS("run_stress (newton off)", bond->virial, test_config.run_stress, epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl; @@ -482,8 +483,9 @@ TEST(BondStyle, omp) EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, 10 * epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + double energy = 0.0; + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); // TODO: this is currently broken for OPENMP with bond style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. @@ -517,8 +519,8 @@ TEST(BondStyle, omp) 10 * epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); // TODO: this is currently broken for OPENMP with bond style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. @@ -584,13 +586,13 @@ TEST(BondStyle, kokkos_omp) EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, 10 * epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); // FIXME: this is currently broken ??? for KOKKOS with bond style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. - //if (test_config.bond_style.substr(0, 6) != "hybrid") + // if (test_config.bond_style.substr(0, 6) != "hybrid") // EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl; @@ -621,13 +623,13 @@ TEST(BondStyle, kokkos_omp) 10 * epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); // FIXME: this is currently broken ??? for KOKKOS with bond style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. - //if (test_config.bond_style.substr(0, 6) != "hybrid") + // if (test_config.bond_style.substr(0, 6) != "hybrid") // EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl; diff --git a/unittest/force-styles/test_dihedral_style.cpp b/unittest/force-styles/test_dihedral_style.cpp index 324745cc41..656a45861e 100644 --- a/unittest/force-styles/test_dihedral_style.cpp +++ b/unittest/force-styles/test_dihedral_style.cpp @@ -363,8 +363,9 @@ TEST(DihedralStyle, plain) EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + 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); if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl; @@ -394,8 +395,8 @@ TEST(DihedralStyle, plain) EXPECT_STRESS("run_stress (newton off)", dihedral->virial, test_config.run_stress, epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + 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); if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl; @@ -484,8 +485,9 @@ TEST(DihedralStyle, omp) EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, 10 * epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + 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 // needs to be fixed in the main code somewhere. Not sure where, though. @@ -519,8 +521,8 @@ TEST(DihedralStyle, omp) 10 * epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + 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 // needs to be fixed in the main code somewhere. Not sure where, though. @@ -587,8 +589,8 @@ TEST(DihedralStyle, kokkos_omp) EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, 10 * epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon); // FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid @@ -623,8 +625,8 @@ TEST(DihedralStyle, kokkos_omp) 10 * epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.run_energy, epsilon); // FIXME: this is currently broken ??? for KOKKOS with dihedral style hybrid diff --git a/unittest/force-styles/test_improper_style.cpp b/unittest/force-styles/test_improper_style.cpp index a65bf438df..bddb986d9c 100644 --- a/unittest/force-styles/test_improper_style.cpp +++ b/unittest/force-styles/test_improper_style.cpp @@ -356,8 +356,9 @@ TEST(ImproperStyle, plain) EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + double energy = 0.0; + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl; @@ -387,8 +388,8 @@ TEST(ImproperStyle, plain) EXPECT_STRESS("run_stress (newton off)", improper->virial, test_config.run_stress, epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon); EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl; @@ -477,8 +478,9 @@ TEST(ImproperStyle, omp) EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, 10 * epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + double energy = 0.0; + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon); // TODO: this is currently broken for OPENMP with improper style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. @@ -512,8 +514,8 @@ TEST(ImproperStyle, omp) 10 * epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) energy = icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon); // TODO: this is currently broken for OPENMP with improper style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. @@ -532,8 +534,9 @@ TEST(ImproperStyle, kokkos_omp) if (!LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP(); if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP(); - LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite", - "-k", "on", "t", "4", "-sf", "kk"}; + LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", + "-nocite", "-k", "on", "t", "4", + "-sf", "kk"}; ::testing::internal::CaptureStdout(); LAMMPS *lmp = init_lammps(args, test_config, true); @@ -579,12 +582,12 @@ TEST(ImproperStyle, kokkos_omp) EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, 10 * epsilon); stats.reset(); - int id = lmp->modify->find_compute("sum"); - double energy = lmp->modify->compute[id]->compute_scalar(); + auto *icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon); // FIXME: this is currently broken ??? for KOKKOS with improper style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. - //if (test_config.improper_style.substr(0, 6) != "hybrid") + // if (test_config.improper_style.substr(0, 6) != "hybrid") // EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton on: " << stats << std::endl; @@ -614,12 +617,12 @@ TEST(ImproperStyle, kokkos_omp) 10 * epsilon); stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); + icompute = lmp->modify->get_compute_by_id("sum"); + if (icompute) icompute->compute_scalar(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.run_energy, epsilon); // FIXME: this is currently broken ??? for KOKKOS with improper style hybrid // needs to be fixed in the main code somewhere. Not sure where, though. - //if (test_config.improper_style.substr(0, 6) != "hybrid") + // if (test_config.improper_style.substr(0, 6) != "hybrid") // EXPECT_FP_LE_WITH_EPS(improper->energy, energy, epsilon); if (print_stats) std::cerr << "run_energy stats, newton off:" << stats << std::endl; }