Skip to content

Commit

Permalink
Initialise packets
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Oct 28, 2024
1 parent 995b118 commit 6b61eeb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions packet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,10 @@ void packet_init(Packet *pkt)

// Now place the pellets in the ejecta and decide at what time they will decay.

if (globals::npkts > MPKTS) {
printout("Too many packets. Abort.\n");
std::abort();
}

printout("Placing pellets...\n");
auto allpkts = std::ranges::iota_view{0, globals::npkts};
std::ranges::for_each(allpkts, [&, norm, e0](const int n) {
pkt[n] = Packet{};
const double targetval = rng_uniform() * norm;

// first i such that en_cumulative[i] > targetval
Expand Down
4 changes: 2 additions & 2 deletions sn3d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ auto main(int argc, char *argv[]) -> int {
}
}

auto *const packets = static_cast<Packet *>(malloc(MPKTS * sizeof(Packet)));
auto *const packets = static_cast<Packet *>(malloc(globals::npkts * sizeof(Packet)));

assert_always(packets != nullptr);

Expand Down Expand Up @@ -965,7 +965,7 @@ auto main(int argc, char *argv[]) -> int {
printout("Simulation propagates %g packets per process (total %g with nprocs %d)\n", 1. * globals::npkts,
1. * globals::npkts * globals::nprocs, globals::nprocs);

printout("[info] mem_usage: packets occupy %.3f MB\n", MPKTS * sizeof(Packet) / 1024. / 1024.);
printout("[info] mem_usage: packets occupy %.3f MB\n", globals::npkts * sizeof(Packet) / 1024. / 1024.);

if (!globals::simulation_continued_from_saved) {
std::remove("deposition.out");
Expand Down

0 comments on commit 6b61eeb

Please sign in to comment.