From 3306e94eebfee51fc582e474afd06a1bc8089d69 Mon Sep 17 00:00:00 2001 From: Luke Shingles Date: Mon, 28 Oct 2024 16:01:42 +0000 Subject: [PATCH] Initialise packets --- packet.cc | 6 +----- sn3d.cc | 5 ++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packet.cc b/packet.cc index 12d8a4768..822eb11c2 100644 --- a/packet.cc +++ b/packet.cc @@ -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 diff --git a/sn3d.cc b/sn3d.cc index e1738c21a..ea0945cfe 100644 --- a/sn3d.cc +++ b/sn3d.cc @@ -883,8 +883,7 @@ auto main(int argc, char *argv[]) -> int { } } - auto *const packets = static_cast(malloc(MPKTS * sizeof(Packet))); - std::fill_n(packets, MPKTS, Packet{}); + auto *const packets = static_cast(malloc(globals::npkts * sizeof(Packet))); assert_always(packets != nullptr); @@ -966,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");