Skip to content
Snippets Groups Projects
Commit 6c10244c authored by Julian Adamek's avatar Julian Adamek
Browse files

unit tests can now write HDF5 output for further inspection

parent 920ad9e4
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ CXXFLAGS = -std=c++11 -O2 #-Wall -Wextra
INCLUDES = -I/usr/local/include -I. -I/usr/include/hdf5/openmpi
# defines (compilation flags -D)
DEFINES = -DHDF5 -DH5_HAVE_PARALLEL -DVELOCITY_DECAY=10
DEFINES = -DHDF5 -DH5_HAVE_PARALLEL -DVELOCITY_DECAY=0
# Libraries to link against
LIBS = -L/usr/lib/x86_64-linux-gnu/hdf5/openmpi -lhdf5 -lgsl -lgslcblas -lm
......@@ -41,6 +41,6 @@ clean:
# Run the unit tests
run: $(TARGET)
./$(TARGET)
mpirun -np 4 ./$(TARGET) -n 2 -m 2 -Ngrid 64 -Npcl 262144 -bench 64
.PHONY: all clean run
......@@ -78,6 +78,8 @@ int main(int argc, char **argv)
int Ngrid[3] = {32, 32, 32};
uint64_t Npcl = 32768;
int benchmark_iterations = 1;
// empty string
string ofilename = "";
for (int i = 0; i < argc; i++)
{
......@@ -101,6 +103,10 @@ int main(int argc, char **argv)
{
benchmark_iterations = atoi(argv[++i]);
}
if (strcmp(argv[i], "-o") == 0)
{
ofilename = argv[++i];
}
}
parallel.initialize(n, m);
......@@ -255,7 +261,7 @@ int main(int argc, char **argv)
start = std::chrono::high_resolution_clock::now();
for (int i = 0; i < benchmark_iterations; i++)
{
maxvel_old = particles_old.updateVel(kick_function, 0.01 - (i%2)*0.02, potentials, 1);
maxvel_old = particles_old.updateVel(kick_function, 0.005 - (i%2)*0.01, potentials, 1);
COUT << ", " << maxvel_old;
}
end = std::chrono::high_resolution_clock::now();
......@@ -268,7 +274,7 @@ int main(int argc, char **argv)
start = std::chrono::high_resolution_clock::now();
for (int i = 0; i < benchmark_iterations; i++)
{
maxvel_new = particles_new.updateVel(kick_function, 0.01 - (i%2)*0.02, potentials, 1);
maxvel_new = particles_new.updateVel(kick_function, 0.005 - (i%2)*0.01, potentials, 1);
COUT << ", " << maxvel_new;
}
end = std::chrono::high_resolution_clock::now();
......@@ -334,6 +340,14 @@ int main(int argc, char **argv)
COUT << "All tests successful" << endl;
// write the results to a file
if (ofilename != "")
{
density_old.saveHDF5(ofilename + "_density_old.h5");
density_new.saveHDF5(ofilename + "_density_new.h5");
potential.saveHDF5(ofilename + "_potential.h5");
}
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment