22// it under the terms of the GNU General Public License as published by
33// the Free Software Foundation, either version 3 of the License, or
44// (at your option) any later version.
5-
65// This program is distributed in the hope that it will be useful,
76// but WITHOUT ANY WARRANTY; without even the implied warranty of
87// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98// GNU General Public License for more details.
10-
119// You should have received a copy of the GNU General Public License
1210// along with this program. If not, see <http://www.gnu.org/licenses/>.
1311
14- #include " gravity/step.h"
15- #include " floatdef.h"
12+ #include " ../argparse/argparse.hpp"
1613#include " dt/adaptive.h"
14+ #include " floatdef.h"
15+ #include " gravity/step.h"
16+ #include " io/load_particle.hpp"
1717#include " io/vtk_save.h"
1818#include " io/vtu_save.h"
19- #include " io/load_particle.hpp"
20- #include " ../argparse/argparse.hpp"
21- #include < iostream>
2219#include < fstream>
20+ #include < iostream>
2321#include < omp.h>
24- #include < vector>
2522#include < string>
23+ #include < vector>
2624
27- int main (int argc, char ** argv)
28- {
29- auto args = next::parse_arguments (argc, argv);
25+ int main (int argc, char **argv) {
26+ auto args = next::parse_arguments (argc, argv);
3027
31- // ASCII banner (raw string literal preserves backslashes and spacing)
32- static constexpr const char * BANNER = R"NEXTBANNER(
28+ // ASCII banner (raw string literal preserves backslashes and spacing)
29+ static constexpr const char * BANNER = R"NEXTBANNER(
3330_ _ ________ _________
3431| \ | | ____\ \ / /__ __|
3532| \| | |__ \ V / | |
@@ -38,60 +35,56 @@ _ _ ________ _________
3835|_| \_|______/_/ \_\ |_|
3936)NEXTBANNER" ;
4037
41- // Print banner once at startup
42- std::cout << BANNER << ' \n ' ;
38+ // Print banner once at startup
39+ std::cout << BANNER << ' \n ' ;
4340
44- // Set threads and report
45- omp_set_num_threads (args.threads );
46-
47- std::cout << " Threads: " << args.threads << " \n " ;
41+ // Set threads and report
42+ omp_set_num_threads (args.threads );
4843
49- #ifdef NEXT_FP64
50- std::cout << " Precision: FP64\n " ;
51- #elif defined(NEXT_FP32)
52- std::cout << " Precision: FP32\n " ;
53- #endif
44+ std::cout << " Threads: " << args.threads << " \n " ;
5445
55- // Load particles
56- std::vector<Particle> particles = LoadParticlesFromFile (args.input_file );
46+ #ifdef NEXT_FP64
47+ std::cout << " Precision: FP64\n " ;
48+ #elif defined(NEXT_FP32)
49+ std::cout << " Precision: FP32\n " ;
50+ #endif
5751
58- real simTime = 0 ;
59- real nextDump = 0 ;
60- int step = 0 ;
61- char command;
52+ // Load particles
53+ std::vector<Particle> particles = LoadParticlesFromFile (args.input_file );
6254
63- while (true )
64- {
65- real dtAdaptive = computeAdaptiveDt (particles, args.dt );
66- Step (particles, dtAdaptive);
67- simTime += dtAdaptive;
55+ real simTime = 0 ;
56+ real nextDump = 0 ;
57+ int step = 0 ;
58+ char command;
6859
69- if (simTime >= nextDump)
70- {
71- std::string out = " dump_" + std::to_string (step) + (args.use_vtu ? " .vtu" : " .vtk" );
60+ while (true ) {
61+ real dtAdaptive = computeAdaptiveDt (particles, args.dt );
62+ Step (particles, dtAdaptive);
63+ simTime += dtAdaptive;
7264
73- if (args.use_vtu )
74- SaveVTU (particles, out);
75- else
76- SaveVTK (particles, out);
65+ if (simTime >= nextDump) {
66+ std::string out =
67+ " dump_" + std::to_string (step) + (args.use_vtu ? " .vtu" : " .vtk" );
7768
78- std::cout << " [Dump " << step << " ] "
79- << " t = " << simTime
80- << " , file: " << out << " \n " ;
69+ if (args.use_vtu )
70+ SaveVTU (particles, out);
71+ else
72+ SaveVTK (particles, out);
8173
82- nextDump += args.dump_interval ;
83- step++;
84- }
74+ std::cout << " [Dump " << step << " ] " << " t = " << simTime
75+ << " , file: " << out << " \n " ;
8576
86- if (std::cin.rdbuf ()->in_avail () > 0 ) {
87- std::cin >> command;
88- if (command == ' q' || command == ' Q' )
89- std::cout << " Exiting...\n " ;
90- break ;
77+ nextDump += args.dump_interval ;
78+ step++;
9179 }
92-
93-
80+
81+ if (std::cin.rdbuf ()->in_avail () > 0 ) {
82+ std::cin >> command;
83+ if (command == ' q' || command == ' Q' )
84+ std::cout << " Exiting...\n " ;
85+ break ;
9486 }
87+ }
9588
96- return 0 ;
89+ return 0 ;
9790}
0 commit comments