Example #1
0
void MoleculeTest::testIsLessThan() {
	std::vector<Component> components;
	Component dummyComponent(0);
	dummyComponent.addLJcenter(0,0,0,0,0,0,0,false);
	components.push_back(dummyComponent);

	Molecule a(0, &components[0], 1.0, 1.0, 1.0,0,0,0,0,0,0,0,0,0,0);
	Molecule b(0, &components[0], 2.0, 2.0, 2.0,0,0,0,0,0,0,0,0,0,0);

	ASSERT_TRUE(a.isLessThan(b));
	ASSERT_TRUE(!b.isLessThan(a));

	a.setr(2, 3.0);

	ASSERT_TRUE(!a.isLessThan(b));
	ASSERT_TRUE(b.isLessThan(a));

	a.setr(2, 2.0);
	ASSERT_TRUE(a.isLessThan(b));
	ASSERT_TRUE(!b.isLessThan(a));

	a.setr(1, 3.0);

	ASSERT_TRUE(!a.isLessThan(b));
	ASSERT_TRUE(b.isLessThan(a));

	a.setr(1, 2.0);
	ASSERT_TRUE(a.isLessThan(b));
	ASSERT_TRUE(!b.isLessThan(a));

	a.setr(0, 3.0);

	ASSERT_TRUE(!a.isLessThan(b));
	ASSERT_TRUE(b.isLessThan(a));
}
void VTKMoleculeWriterImplementationTest::testWriteVTKFile() {
#ifdef ENABLE_MPI
	int rank = 0;
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	if (rank != 0) {
		return;
	}
#endif
	VTKMoleculeWriterImplementation writer(0);

	std::vector<Component> components;
	Component dummyComponent(0);
	dummyComponent.addLJcenter(0,0,0,0,0,0,0,false);
	components.push_back(dummyComponent);
	Molecule dummyMolecule(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, &components);

	std::vector<std::string> v;
	writer.initializeVTKFile();
	writer.initializeParallelVTKFile(v);

	writer.plotMolecule(dummyMolecule);
	writer.plotMolecule(dummyMolecule);
	ASSERT_EQUAL(writer.getNumMoleculesPlotted(), 2u);

	writer.writeVTKFile("VTKMoleculeWriter00.vtu");
	ASSERT_TRUE(fileExists("VTKMoleculeWriter00.vtu"));
	writer.writeParallelVTKFile("VTKMoleculeWriter00.pvtu");
	ASSERT_TRUE(fileExists("VTKMoleculeWriter00.pvtu"));

	removeFile("VTKMoleculeWriter00.vtu");
	removeFile("VTKMoleculeWriter00.pvtu");
}