1- #include " gravity/step.h"
2- #include < iostream>
3- #include < fstream>
4- #include " floatdef.h"
5- #include " dt/adaptive.h"
6- #include " io/vtk_save.h"
7-
8- std::vector<Particle> LoadParticlesFromFile (const std::string& filename)
9- {
10- std::vector<Particle> p;
11- std::ifstream in (filename);
12-
13- Particle temp;
14- while (in >> temp.x >> temp.y >> temp.z >> temp.vx >> temp.vy >> temp.vz >> temp.m )
15- {
16- p.push_back (temp);
17- }
18- return p;
19- }
20-
21- int main (int argc, char ** argv) {
22-
23- std::cout
24- << " NN NN EEEEEEE XX XX TTTTTTT\n "
25- << " NNN NN EE XX XX TTT \n "
26- << " NN N NN EEEEE XXX TTT \n "
27- << " NN NNN EE XX XX TTT \n "
28- << " NN NN EEEEEEE XX XX TTT \n "
29- << " Newtonian EXact Trajectories\n " ;
30- // Print the Splash
31-
32- if (argc != 4 ) // if there wasnt 3 of parameters set, throw a cerr
33- {
34- std::cerr << " No parameter file specified\n " ;
35- std::cerr << " Usage: next <initial.txt> <dt> <dump_interval>\n " ;
36- return 1 ;
37- }
38-
39- const char * filename = argv[1 ];
40- real dt = std::stod (argv[2 ]);
41- double cacheInterval = std::stod (argv[3 ]);
42- real simTime = 0 ;
43- real nextDump = 0 ;
44-
45- std::vector<Particle> particles = LoadParticlesFromFile (filename);
46-
47- int step = 0 ;
48-
49- while (true )
50- {
51- real dtAdaptive = computeAdaptiveDt (particles, dt);
52- Step (particles, dtAdaptive);
53- simTime += dtAdaptive;
54-
55- if (simTime >= nextDump)
56- {
57- std::string out = " dump_" + std::to_string (step) + " .vtk" ;
58- SaveVTK (particles, out); // save the file
59- std::cout << " Wrote: " << out << " \n " ; // say you wrote the file
60- nextDump += cacheInterval;
61- }
62-
63- step++; // increase counter by 1
64- }
65-
66- return 0 ; // end if succeeded, well probably not it never ends anyway.
67-
68-
69- }
1+ #include " gravity/step.h"
2+ #include < iostream>
3+ #include < fstream>
4+ #include " floatdef.h"
5+ #include " dt/adaptive.h"
6+ #include " io/vtk_save.h"
7+ #include " io/vtu_save.h"
8+
9+ std::vector<Particle> LoadParticlesFromFile (const std::string& filename)
10+ {
11+ std::vector<Particle> p;
12+ std::ifstream in (filename);
13+
14+ Particle temp;
15+ while (in >> temp.x >> temp.y >> temp.z >> temp.vx >> temp.vy >> temp.vz >> temp.m )
16+ p.push_back (temp);
17+
18+ return p;
19+ }
20+
21+ int main (int argc, char ** argv)
22+ {
23+ if (argc != 5 )
24+ {
25+ std::cerr << " Usage: next <initial.txt> <dt> <dump_interval> <vtk|vtu>\n " ;
26+ return 1 ;
27+ }
28+
29+ const char * filename = argv[1 ];
30+ real dt = std::stod (argv[2 ]);
31+ double cacheInterval = std::stod (argv[3 ]);
32+ std::string format = argv[4 ];
33+
34+ bool useVTU = (format == " vtu" );
35+
36+ real simTime = 0 ;
37+ real nextDump = 0 ;
38+
39+ std::vector<Particle> particles = LoadParticlesFromFile (filename);
40+
41+ int step = 0 ;
42+
43+ while (true )
44+ {
45+ real dtAdaptive = computeAdaptiveDt (particles, dt);
46+ Step (particles, dtAdaptive);
47+ simTime += dtAdaptive;
48+
49+ if (simTime >= nextDump)
50+ {
51+ std::string out;
52+
53+ if (useVTU)
54+ {
55+ out = " dump_" + std::to_string (step) + " .vtu" ;
56+ SaveVTU (particles, out);
57+ }
58+ else
59+ {
60+ out = " dump_" + std::to_string (step) + " .vtk" ;
61+ SaveVTK (particles, out);
62+ }
63+
64+ std::cout << " Wrote: " << out << " \n " ;
65+
66+ nextDump += cacheInterval;
67+ step++;
68+ }
69+ }
70+
71+ return 0 ;
72+ }
0 commit comments