public void Sort(SimulationStructure simulationStructure, int step) { neighbourPositionGetter.GetOldPositionsNeighbours(simulationStructure); neighbourSizeGetter.GetOldSizesNeighbours(simulationStructure); positionUpdater.UpdateSectionPositions(simulationStructure); foreach (KMeansSection section in simulationStructure.CoreGrid.GetCores().SelectMany(o => o.Sections)) { for (var i = 0; i < section.CurrentParticles.Count; i++) { var ownDistance = Vector3.DistanceSquared(section.CurrentParticles[i].Position, section.CurrentPosition); var minDistance = ownDistance; var bestDirection = -1; for (var j = 0; j < 6; j++) { var localDistance = Vector3.DistanceSquared(section.CurrentParticles[i].Position, section.NeighbourPositions[j]); if (!(localDistance < minDistance)) { continue; } bestDirection = j; minDistance = localDistance; } if (bestDirection == -1) { continue; } section.ToTransmit[bestDirection].Add(section.CurrentParticles[i]); section.CurrentParticles[i] = Particle.Null; } section.CurrentParticles = section.CurrentParticles.Where(o => !o.IsNull).ToList(); } nTransmitter.TransmitParticles(simulationStructure, step); }
public void Sort(SimulationStructure simulationStructure, int step) { sectionPositionUpdater.UpdateSectionPositions(simulationStructure); // puts right amount of particles for transmission calculates the total transmission space needed. bridgeTransmissionPreparer.PutParticlesForTransmission(simulationStructure); transmitter.TransmitParticles(simulationStructure, step); neighbourPositionGetter.GetOldPositionsNeighbours(simulationStructure); //Calculate new increase and send and give to neighbours. bridgeInterestGetter.GetOldNeighbourInterests(simulationStructure); }