#include #include #include #include using namespace amrex; /* \brief Determine which particles deposit/gather in the buffer, and * and reorder the particle arrays accordingly * * More specifically: * - Modify `nfine_current` and `nfine_gather` (in place) * so that they correspond to the number of particles * that deposit/gather in the fine patch respectively. * - Reorder the particle arrays, * so that the `nfine_current`/`nfine_gather` first particles * deposit/gather in the fine patch * and (thus) the `np-nfine_current`/`np-nfine_gather` last particles * deposit/gather in the buffer * * \param nfine_current number of particles that deposit to the fine patch * (modified by this function) * \param nfine_gather number of particles that gather into the fine patch * (modified by this function) * \param np total number of particles in this tile * \param pti object that holds the particle information for this tile * \param lev current refinement level * \param current_masks indicates, for each cell, whether that cell is * in the deposition buffers or in the interior of the fine patch * \param gather_masks indicates, for each cell, whether that cell is * in the gather buffers or in the interior of the fine patch * \param uxp, uyp, uzp, wp references to the particle momenta and weight * (modified by this function) */ void PhysicalParticleContainer::PartitionParticlesInBuffers( long& nfine_current, long& nfine_gather, long const np, WarpXParIter& pti, int const lev, iMultiFab const* current_masks, iMultiFab const* gather_masks, RealVector& uxp, RealVector& uyp, RealVector& uzp, RealVector& wp) { BL_PROFILE("PPC::Evolve::partition"); // Initialize temporary arrays Gpu::DeviceVector inexflag; inexflag.resize(np); Gpu::DeviceVector pid; pid.resize(np); // First, partition particles into the larger buffer // - Select the larger buffer iMultiFab const* bmasks = (WarpX::n_field_gather_buffer >= WarpX::n_current_deposition_buffer) ? gather_masks : current_masks; // - For each particle, find whether it is in the larger buffer, // by looking up the mask. Store the answer in `inexflag`. amrex::ParallelFor( np, fillBufferFlag(pti, bmasks, inexflag, Geom(lev), 0) ); // - Find the indices that reorder particles so that the last particles // are in the larger buffer fillWithConsecutiveIntegers( pid ); auto const sep = stablePartition( pid.begin(), pid.end(), inexflag ); // At the end of this step, `pid` contains the indices that should be used to // reorder the particles, and `sep` is the position in the array that // separates the particles that deposit/gather on the fine patch (first part) // and the particles that deposit/gather in the buffers (last part) long const n_fine = iteratorDistance(pid.begin(), sep); // Number of particles on fine patch, i.e. outside of the larger buffer // Second, among particles that are in the larger buffer, partition // particles into the smaller buffer if (WarpX::n_current_deposition_buffer == WarpX::n_field_gather_buffer) { // No need to do anything if the buffers have the same size nfine_current = nfine_gather = iteratorDistance(pid.begin(), sep); } else if (sep == pid.end()) { // No need to do anything if there are no particles in the larger buffer nfine_current = nfine_gather = np; } else { int n_buf; if (bmasks == gather_masks) { nfine_gather = n_fine; bmasks = current_masks; n_buf = WarpX::n_current_deposition_buffer; } else { nfine_current = n_fine; bmasks = gather_masks; n_buf = WarpX::n_field_gather_buffer; } if (n_buf > 0) { // - For each particle in the large buffer, find whether it is in // the smaller buffer, by looking up the mask. Store the answer in `inexflag`. amrex::ParallelFor( np - n_fine, fillBufferFlag(pti, bmasks, inexflag, Geom(lev), n_fine) ); auto const sep2 = stablePartition( sep, pid.end(), inexflag ); if (bmasks == gather_masks) { nfine_gather = iteratorDistance(pid.begin(), sep2); } else { nfine_current = iteratorDistance(pid.begin(), sep2); } } } // only deposit / gather to coarsest grid if (m_deposit_on_main_grid && lev > 0) { nfine_current = 0; } if (m_gather_from_main_grid && lev > 0) { nfine_gather = 0; } // Reorder the actual particle array, using the `pid` indices if (nfine_current != np || nfine_gather != np) { // Temporary array for particle AoS ParticleVector particle_tmp; particle_tmp.resize(np); // Copy particle AoS auto& aos = pti.GetArrayOfStructs(); amrex::ParallelFor( np, copyAndReorder( aos(), particle_tmp, pid ) ); std::swap(aos(), particle_tmp); // Temporary array for particle individual attributes RealVector tmp; tmp.resize(np); // Copy individual attributes amrex::ParallelFor( np, copyAndReorder( wp, tmp, pid ) ); std::swap(wp, tmp); amrex::ParallelFor( np, copyAndReorder( uxp, tmp, pid ) ); std::swap(uxp, tmp); amrex::ParallelFor( np, copyAndReorder( uyp, tmp, pid ) ); std::swap(uyp, tmp); amrex::ParallelFor( np, copyAndReorder( uzp, tmp, pid ) ); std::swap(uzp, tmp); // Make sure that the temporary arrays are not destroyed before // the GPU kernels finish running Gpu::streamSynchronize(); } // Make sure that the temporary arrays are not destroyed before // the GPU kernels finish running Gpu::streamSynchronize(); } ion value='jarred/canvas'>jarred/canvas Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2023-10-18Adds macOS Keychain certs to default CA storeGravatar Anshul Gupta 2-2/+175
2023-10-18fix(node:buffer): fix the behavior of `totalLength` in `Buffer.concat` (#6574)Gravatar Ai Hoshino 2-3/+23
2023-10-18fix: change `--no-scripts` to `--ignore-scripts` (#6587)Gravatar Dawid Sowa 1-2/+2
2023-10-18fix: online docs moved (#6579)Gravatar Mountain/\Ash 1-1/+1
2023-10-18Fix minimum kernel version in docs (#6153)Gravatar Kevin Latka 1-1/+1
2023-10-18build-id++Gravatar Dylan Conway 1-1/+1
2023-10-18fix(web): stub `performance.getEntriesByName` (#6542)Gravatar Liz 1-0/+18
2023-10-17update root package variableGravatar Dylan Conway 1-8/+3
2023-10-17Fix missing `{port: 0}` causing flaky testGravatar Ashcon Partovi 1-0/+2
2023-10-17test changes in usockets in ciGravatar Dylan Conway 5-0/+9
2023-10-17fix #4766 (#6563)Gravatar Pierre CM 1-4/+4
2023-10-17Update ZigGeneratedClasses.cppGravatar Dylan Conway 1-2/+0
2023-10-17use npm alias in dependencies (#6545)Gravatar Dylan Conway 7-29/+271
2023-10-17fix(node:http): fix `server.address()` (#6442)Gravatar Ai Hoshino 12-12/+453
2023-10-17docs: fix ws.publish (#6558)Gravatar Aral Roca Gomez 1-1/+1
2023-10-17perf(bun-types): remove needless some call (#6550)Gravatar Mikhail 1-1/+1
2023-10-16fix(runtime): make some things more stable (partial jsc debug build) (#5881)Gravatar dave caruso 116-1446/+1830
2023-10-16fix(runtime): improve IPC reliability + organization pass on that code (#6475)Gravatar dave caruso 15-98/+266
2023-10-16Simplify getting Set of extentions (#4975)Gravatar Mikhail 1-3/+3
2023-10-16Fix formattingGravatar Ashcon Partovi 1-3/+1
2023-10-16fix(test): when tests run with --only the nested describe blocks `.on… (#5616)Gravatar Igor Shapiro 2-13/+45
2023-10-16perf(node:events): optimize `emit(...)` function (#5485)Gravatar Yannik Schröder 3-11/+132
2023-10-16fix: don't remove content-encoding header from header table (#5743)Gravatar Liz 2-2/+25
2023-10-16fix(sqlite) Insert .all() does not return an array #5872 (#5946)Gravatar Hugo Galan 2-7/+11
2023-10-16Fix formattingGravatar Ashcon Partovi 2-5/+4
2023-10-16Fix `Response.statusText` (#6151)Gravatar Chris Toshok 10-238/+269
2023-10-16fix-subprocess-argument-missing (#6407)Gravatar Nicolae-Rares Ailincai 4-2/+40
2023-10-16Add type parameter to `expect` (#6128)Gravatar Voldemat 1-3/+3
2023-10-16fix(node:worker_threads): ensure threadId property is exposed on worker_threa...Gravatar Jérôme Benoit 6-15/+75
2023-10-16Fix use before define bug in sqliteGravatar Ashcon Partovi 2-5/+5
2023-10-16fix(jest): fix toStrictEqual on same URLs (#6528)Gravatar João Alisson 2-13/+16
2023-10-16Fix `toHaveBeenCalled` having wrong error signatureGravatar Ashcon Partovi 1-2/+2
2023-10-16Fix formattingGravatar Ashcon Partovi 1-2/+1
2023-10-16Add `reusePort` to `Bun.serve` typesGravatar Ashcon Partovi 1-0/+9
2023-10-16Fix `request.url` having incorrect portGravatar Ashcon Partovi 4-1/+92
2023-10-16Remove uWebSockets header from Bun.serve responsesGravatar Ashcon Partovi 1-6/+6
2023-10-16Rename some testsGravatar Ashcon Partovi 3-0/+0
2023-10-16Fix #6467Gravatar Ashcon Partovi 2-3/+10
2023-10-16Update InternalModuleRegistryConstants.hGravatar Dylan Conway 1-3/+3
2023-10-16Development -> Contributing (#6538)Gravatar Colin McDonnell 2-1/+1
2023-10-14fix(net/tls) fix pg hang on end + hanging on query (#6487)Gravatar Ciro Spaciari 3-8/+36
2023-10-13fix installing dependencies that match workspace versions (#6494)Gravatar Dylan Conway 4-2/+64
2023-10-13fix lockfile struct padding (#6495)Gravatar Dylan Conway 3-3/+18