add test for compute reduce/chunk

This commit is contained in:
Axel Kohlmeyer
2022-10-04 21:38:28 -04:00
parent 93841b939e
commit 874e1522e7

View File

@ -246,8 +246,8 @@ TEST_F(ComputeChunkTest, ChunkComputes)
command("compute trq all torque/chunk mols");
command("compute vcm all vcm/chunk mols");
command("fix hist1 all ave/time 1 1 1 c_ang[*] c_com[*] c_dip[*] c_gyr c_mom[*] c_omg[*] "
"c_trq[*] c_vcm[*] mode vector file all_chunk.dat format %15.8f");
command("fix hist2 all ave/time 1 1 1 c_tmp mode vector file vec_chunk.dat format %15.8f");
"c_trq[*] c_vcm[*] mode vector");
command("fix hist2 all ave/time 1 1 1 c_tmp mode vector");
command("run 0 post no");
END_HIDE_OUTPUT();
auto cang = get_array("ang");
@ -347,6 +347,31 @@ TEST_F(ComputeChunkTest, ChunkSpreadGlobal)
EXPECT_EQ(codd[i], cgyr[(((int)ctag[i] + 1) % 2)]);
}
}
TEST_F(ComputeChunkTest, ChunkReduce)
{
if (lammps_get_natoms(lmp) == 0.0) GTEST_SKIP();
BEGIN_HIDE_OUTPUT();
command("pair_style lj/cut/coul/cut 10.0");
command("pair_coeff * * 0.01 3.0");
command("bond_style harmonic");
command("bond_coeff * 100.0 1.5");
command("compute prp all property/chunk mols count");
command("variable one atom 1");
command("compute red all reduce/chunk mols sum v_one");
command("fix ave all ave/time 1 1 1 c_prp c_red mode vector");
command("run 0 post no");
END_HIDE_OUTPUT();
const int nchunks = get_scalar("mols");
auto cprp = get_vector("prp");
auto cred = get_vector("red");
for (int i = 0; i < nchunks; ++i)
EXPECT_EQ(cprp[i], cred[i]);
}
} // namespace LAMMPS_NS
int main(int argc, char **argv)