particles::pidt::mappings::MoveParticles::ParticleContainer particles::pidt::mappings::MoveParticles::extractAllParticlesFromDualCellBelongingToOneRank( int sourceHeapIndex, particles::pidt::Vertex& vertex, int rank, const tarch::la::Vector<DIMENSIONS,double>& x, const tarch::la::Vector<DIMENSIONS,double>& h ) { ParticleContainer destinationParticles; ParticleContainer& localVertexParticles = ParticleHeap::getInstance().getData(sourceHeapIndex); for ( ParticleContainer::iterator p = localVertexParticles.begin(); p!=localVertexParticles.end(); ) { const bool particleDoesNotTunnel = Vertex::isContainedInDualCell(x,h,p->_persistentRecords._x); const int whichAdjacentCellHoldsParticle = peano::utils::dLinearised(Vertex::getDualCellOfParticle(x,p->_persistentRecords._x),2); const bool particleBelongsToNeighbouringRank = vertex.getAdjacentRanks()(whichAdjacentCellHoldsParticle)==rank; if (particleDoesNotTunnel && particleBelongsToNeighbouringRank) { destinationParticles.push_back(*p); p = localVertexParticles.erase(p); } else { p++; } } return destinationParticles; }