Unverified Commit 6ed41033 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

synchronize flow of control and formatting between pair_style, bond_style and angle_style

parent 9fc6abb2
Loading
Loading
Loading
Loading
+129 −123
Original line number Diff line number Diff line
@@ -207,15 +207,12 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
    for (auto& angle_coeff : cfg.angle_coeff) {
        command("angle_coeff " + angle_coeff);
    }

    for (auto& post_command : cfg.post_commands) {
        command(post_command);
    }

    command("run 0 post no");
}


// re-generate yaml file with current settings.

void generate_yaml_file(const char *outfile, const TestConfig &config)
@@ -445,6 +442,9 @@ TEST(AngleStyle, plain) {
    lmp = init_lammps(argc,argv,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) {

        f=lmp->atom->f;
        tag=lmp->atom->tag;
        stats.reset();
@@ -506,6 +506,7 @@ TEST(AngleStyle, plain) {
        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);
@@ -588,6 +589,7 @@ TEST(AngleStyle, omp) {
    ::testing::internal::CaptureStdout();
    LAMMPS *lmp = init_lammps(argc,argv,test_config,true);
    std::string output = ::testing::internal::GetCapturedStdout();
    if (verbose) std::cout << output;

    if (!lmp) {
        std::cerr << "One or more prerequisite styles with /omp suffix\n"
@@ -683,6 +685,9 @@ TEST(AngleStyle, omp) {
    lmp = init_lammps(argc,argv,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) {

        f=lmp->atom->f;
        tag=lmp->atom->tag;
        stats.reset();
@@ -746,6 +751,7 @@ TEST(AngleStyle, omp) {
            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();
    cleanup_lammps(lmp,test_config);
+135 −128
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ LAMMPS *init_lammps(int argc, char **argv,
    // check if prerequisite styles are available
    Info *info = new Info(lmp);
    int nfail = 0;
    for (auto prerequisite : cfg.prerequisites) {
    for (auto& prerequisite : cfg.prerequisites) {
        std::string style = prerequisite.second;

        // this is a test for bond styles, so if the suffixed
@@ -207,11 +207,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
    for (auto& bond_coeff : cfg.bond_coeff) {
        command("bond_coeff " + bond_coeff);
    }

    for (auto& post_command : cfg.post_commands) {
        command(post_command);
    }

    command("run 0 post no");
}

@@ -227,7 +225,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 (auto& prerequisite : config.prerequisites) {
            std::cerr << prerequisite.first << "_style "
                      << prerequisite.second << "\n";
        }
@@ -255,21 +253,21 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)

    // prerequisites
    block.clear();
    for (auto prerequisite :  config.prerequisites) {
    for (auto& prerequisite :  config.prerequisites) {
        block += prerequisite.first + " " + prerequisite.second + "\n";
    }
    writer.emit_block("prerequisites", block);

    // pre_commands
    block.clear();
    for (auto command :  config.pre_commands) {
    for (auto& command :  config.pre_commands) {
        block += command + "\n";
    }
    writer.emit_block("pre_commands", block);

    // post_commands
    block.clear();
    for (auto command : config.post_commands) {
    for (auto& command : config.post_commands) {
        block += command + "\n";
    }
    writer.emit_block("post_commands", block);
@@ -282,7 +280,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)

    // bond_coeff
    block.clear();
    for (auto bond_coeff : config.bond_coeff) {
    for (auto& bond_coeff : config.bond_coeff) {
        block += bond_coeff + "\n";
    }
    writer.emit_block("bond_coeff", block);
@@ -290,7 +288,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
    // extract
    block.clear();
    std::stringstream outstr;
    for (auto data : config.extract) {
    for (auto& data : config.extract) {
        outstr << data.first << " " << data.second << std::endl;
    }
    writer.emit_block("extract", outstr.str());
@@ -357,7 +355,7 @@ TEST(BondStyle, plain) {
    if (!lmp) {
        std::cerr << "One or more prerequisite styles are not available "
            "in this LAMMPS configuration:\n";
        for (auto prerequisite : test_config.prerequisites) {
        for (auto& prerequisite : test_config.prerequisites) {
            std::cerr << prerequisite.first << "_style "
                      << prerequisite.second << "\n";
        }
@@ -444,6 +442,9 @@ TEST(BondStyle, plain) {
    lmp = init_lammps(argc,argv,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) {

        f=lmp->atom->f;
        tag=lmp->atom->tag;
        stats.reset();
@@ -505,6 +506,7 @@ TEST(BondStyle, plain) {
        EXPECT_FP_LE_WITH_EPS(bond->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);
@@ -587,11 +589,12 @@ TEST(BondStyle, omp) {
    ::testing::internal::CaptureStdout();
    LAMMPS *lmp = init_lammps(argc,argv,test_config,true);
    std::string output = ::testing::internal::GetCapturedStdout();
    if (verbose) std::cout << output;

    if (!lmp) {
        std::cerr << "One or more prerequisite styles with /omp suffix\n"
            "are not available in this LAMMPS configuration:\n";
        for (auto prerequisite : test_config.prerequisites) {
        for (auto& prerequisite : test_config.prerequisites) {
            std::cerr << prerequisite.first << "_style "
                      << prerequisite.second << "\n";
        }
@@ -622,7 +625,6 @@ TEST(BondStyle, omp) {

    Bond *bond = lmp->force->bond;
    double *stress = bond->virial;

    stats.reset();
    EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon);
    EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon);
@@ -682,6 +684,9 @@ TEST(BondStyle, omp) {
    lmp = init_lammps(argc,argv,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) {

        f=lmp->atom->f;
        tag=lmp->atom->tag;
        stats.reset();
@@ -745,6 +750,7 @@ TEST(BondStyle, omp) {
            EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon);
        if (print_stats)
            std::cerr << "run_energy  stats, newton off:" << stats << std::endl;
    }

    if (!verbose) ::testing::internal::CaptureStdout();
    cleanup_lammps(lmp,test_config);
@@ -760,6 +766,7 @@ TEST(BondStyle, single) {
    if (!verbose) ::testing::internal::CaptureStdout();
    LAMMPS *lmp = init_lammps(argc,argv,test_config);
    if (!verbose) ::testing::internal::GetCapturedStdout();

    if (!lmp) {
        std::cerr << "One or more prerequisite styles are not available "
            "in this LAMMPS configuration:\n";
+1 −1

File changed.

Contains only whitespace changes.