diff options
author | 2019-09-26 09:00:22 -0700 | |
---|---|---|
committer | 2019-10-01 16:32:38 -0700 | |
commit | fac016f1173aacbf4500a28ef63ed683365e4d3f (patch) | |
tree | 5d73a178b35aa47c82cde169ad99a1a85a5c72ab /Source/Particles/Sorting/Partition.cpp | |
parent | 8575478f370f3db2525a8d5444e6949776e9da29 (diff) | |
download | WarpX-fac016f1173aacbf4500a28ef63ed683365e4d3f.tar.gz WarpX-fac016f1173aacbf4500a28ef63ed683365e4d3f.tar.zst WarpX-fac016f1173aacbf4500a28ef63ed683365e4d3f.zip |
Implemented iterator distance
Diffstat (limited to 'Source/Particles/Sorting/Partition.cpp')
-rw-r--r-- | Source/Particles/Sorting/Partition.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Source/Particles/Sorting/Partition.cpp b/Source/Particles/Sorting/Partition.cpp index 3ee49cafe..d64b9fa25 100644 --- a/Source/Particles/Sorting/Partition.cpp +++ b/Source/Particles/Sorting/Partition.cpp @@ -50,7 +50,7 @@ PhysicalParticleContainer::PartitionParticlesInBuffers( Gpu::ManagedDeviceVector<long> pid; pid.resize(np); - // First, partition particles in the larger buffer + // First, partition particles into the larger buffer // - Select the larger buffer iMultiFab const* bmasks = @@ -68,16 +68,22 @@ PhysicalParticleContainer::PartitionParticlesInBuffers( // separates the particles that deposit/gather on the fine patch (first part) // and the particles that deposit/gather in the buffers (last part) + // 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) { - nfine_current = nfine_gather = std::distance(pid.begin(), sep); - } else if (sep != pid.end()) { + // 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 = std::distance(pid.begin(), sep); + nfine_gather = iteratorDistance(pid.begin(), sep); bmasks = current_masks; n_buf = WarpX::n_current_deposition_buffer; } else { - nfine_current = std::distance(pid.begin(), sep); + nfine_current = iteratorDistance(pid.begin(), sep); bmasks = gather_masks; n_buf = WarpX::n_field_gather_buffer; } |