Skip to content

Commit 43f9eb9

Browse files
Update begrun.cpp
1 parent 1931b52 commit 43f9eb9

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

src/begrun.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include<fstream>
44
#include"floatdef.h"
55
#include"dt/adaptive.h"
6+
#include"io/vtk_save.h"
67

78
std::vector<Particle> LoadParticlesFromFile(const std::string& filename)
89
{
@@ -27,25 +28,41 @@ int main(int argc, char** argv) {
2728
<< "NN NN EEEEEEE XX XX TTT \n"
2829
<< "Newtonian EXact Trajectories\n";
2930

30-
if (argc != 3)
31+
if (argc != 4)
3132
{
32-
std::cerr << "Usage: next <initial.txt> <dt>\n";
33+
std::cerr << "No parameter file specified\n";
34+
std::cerr << "Usage: next <initial.txt> <dt> <dump_interval>\n";
3335
return 1;
3436
}
3537

3638
const char* filename = argv[1];
3739
real dt = std::stod(argv[2]);
40+
double cacheInterval = std::stod(argv[3]);
41+
real simTime = 0;
42+
real nextDump = 0;
3843

3944
std::vector<Particle> particles = LoadParticlesFromFile(filename);
4045

46+
int step = 0;
47+
4148
while (true)
4249
{
4350
real dtAdaptive = computeAdaptiveDt(particles, dt);
4451
Step(particles, dtAdaptive);
52+
simTime += dtAdaptive;
53+
54+
if (simTime >= nextDump)
55+
{
56+
std::string out = "dump_" + std::to_string(step) + ".vtk";
57+
SaveVTK(particles, out);
58+
std::cout << "Wrote: " << out << "\n";
59+
nextDump += cacheInterval;
60+
}
61+
62+
step++;
4563
}
4664

4765
return 0;
4866

4967

5068
}
51-

0 commit comments

Comments
 (0)