Skip to content

Commit 2702cb8

Browse files
Update begrun.cpp
1 parent e35cda1 commit 2702cb8

1 file changed

Lines changed: 36 additions & 32 deletions

File tree

src/begrun.cpp

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,76 +28,80 @@ using next::OutputFormat;
2828
int main(int argc, char **argv) {
2929
auto args = next::parse_arguments(argc, argv);
3030

31-
// ASCII banner (raw string literal preserves backslashes and spacing)
3231
static constexpr const char *BANNER = R"NEXTBANNER(
33-
_ _ ________ _________
32+
_ _ ________ _________
3433
| \ | | ____\ \ / /__ __|
3534
| \| | |__ \ V / | |
3635
| . ` | __| > < | |
3736
| |\ | |____ / . \ | |
38-
|_| \_|______/_/ \_\ |_|
37+
|_| \_|______/_/ \_\ |_|
3938
)NEXTBANNER";
4039

41-
// Print banner once at startup
4240
std::cout << BANNER << '\n';
4341

4442
// Set threads and report
4543
omp_set_num_threads(args.threads);
46-
47-
std::cout << " Threads: " << args.threads << "\n";
44+
std::cout << " Threads: " << args.threads << "\n";
4845

4946
#ifdef NEXT_FP64
5047
std::cout << " Precision: FP64\n";
5148
#elif defined(NEXT_FP32)
5249
std::cout << " Precision: FP32\n";
5350
#endif
5451

55-
// Load particles
56-
std::vector<Particle> particles = LoadParticlesFromFile(args.input_file);
52+
// --- SoA UPDATE ---
53+
// LoadParticlesFromFile now returns a single 'Particle' struct
54+
// which internally contains all the parallel vectors.
55+
Particle particles = LoadParticlesFromFile(args.input_file);
56+
57+
std::cout << " Particles: " << particles.size() << "\n";
5758

5859
real simTime = 0;
5960
real nextDump = 0;
6061
int step = 0;
6162
char command;
6263

6364
while (true) {
65+
// Both computeAdaptiveDt and Step now take the SoA object by reference
6466
real dtAdaptive = computeAdaptiveDt(particles, args.dt);
6567
Step(particles, dtAdaptive);
68+
6669
simTime += dtAdaptive;
6770

68-
if (simTime >= nextDump) {
69-
std::string out = "dump_" + std::to_string(step);
71+
if (simTime >= nextDump) {
72+
std::string out = "dump_" + std::to_string(step);
7073

71-
switch (args.format) {
72-
case OutputFormat::VTK:
73-
out += ".vtk";
74-
SaveVTK(particles, out);
75-
break;
74+
switch (args.format) {
75+
case OutputFormat::VTK:
76+
out += ".vtk";
77+
SaveVTK(particles, out);
78+
break;
7679

77-
case OutputFormat::VTU:
78-
out += ".vtu";
79-
SaveVTU(particles, out);
80-
break;
80+
case OutputFormat::VTU:
81+
out += ".vtu";
82+
SaveVTU(particles, out);
83+
break;
8184

82-
case OutputFormat::HDF5:
83-
out += ".hdf5";
84-
SaveHDF5(particles, out);
85-
break;
86-
}
85+
case OutputFormat::HDF5:
86+
out += ".hdf5";
87+
SaveHDF5(particles, out);
88+
break;
89+
}
8790

88-
std::cout << "[Dump " << step << "] t = " << simTime
89-
<< ", file: " << out << "\n";
90-
91-
nextDump += args.dump_interval;
92-
step++;
93-
}
91+
std::cout << "[Dump " << step << "] t = " << simTime
92+
<< ", file: " << out << "\n";
9493

94+
nextDump += args.dump_interval;
95+
step++;
96+
}
9597

98+
// Non-blocking exit check
9699
if (std::cin.rdbuf()->in_avail() > 0) {
97100
std::cin >> command;
98-
if (command == 'q' || command == 'Q')
101+
if (command == 'q' || command == 'Q') {
99102
std::cout << "Exiting...\n";
100-
break;
103+
break;
104+
}
101105
}
102106
}
103107

0 commit comments

Comments
 (0)