Ejemplo n.º 1
0
        private void SortInnerParticles(StrictBoundaryParticleSection coreParticleSection, int step, SimulationStructure simulationStructure)
        {
            for (var i = 0; i < coreParticleSection.CentralParticles.Count; i++)
            {
                var particle = coreParticleSection.CentralParticles[i];

                if (particle.Position.X < coreParticleSection.LowerBound.X)
                {
                    sortCostCalculator.AddComparisonCost(coreParticleSection.Core, 1, simulationStructure, step);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    coreParticleSection.OuterParticleGroups[0].Add(particle);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    continue;
                }

                if (particle.Position.X >= coreParticleSection.UpperBound.X)
                {
                    sortCostCalculator.AddComparisonCost(coreParticleSection.Core, 2, simulationStructure, step);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    coreParticleSection.OuterParticleGroups[1].Add(particle);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    continue;
                }
                if (particle.Position.Y < coreParticleSection.LowerBound.Y)
                {
                    sortCostCalculator.AddComparisonCost(coreParticleSection.Core, 3, simulationStructure, step);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    coreParticleSection.OuterParticleGroups[2].Add(particle);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    continue;
                }
                if (particle.Position.Y >= coreParticleSection.UpperBound.Y)
                {
                    sortCostCalculator.AddComparisonCost(coreParticleSection.Core, 4, simulationStructure, step);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    coreParticleSection.OuterParticleGroups[3].Add(particle);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    continue;
                }
                if (particle.Position.Z < coreParticleSection.LowerBound.Z)
                {
                    sortCostCalculator.AddComparisonCost(coreParticleSection.Core, 5, simulationStructure, step);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    coreParticleSection.OuterParticleGroups[4].Add(particle);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    continue;
                }
                sortCostCalculator.AddComparisonCost(coreParticleSection.Core, 6, simulationStructure, step);
                if (particle.Position.Z >= coreParticleSection.UpperBound.Z)
                {
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                    coreParticleSection.OuterParticleGroups[5].Add(particle);
                    coreParticleSection.CentralParticles[i] = Particle.Null;
                }
            }
            coreParticleSection.CentralParticles = coreParticleSection.CentralParticles.Where(o => !o.IsNull).ToList();
        }
        private void TransferParticles(StrictBoundaryParticleSection currentParticleSection, Point3 nextPosition, IEnumerable <Particle> particles, int step, SimulationStructure structure)
        {
            if (!particles.Any())
            {
                return;
            }
            IParticleSection otherParticleSection;

            currentParticleSection.Grid.SectionCoreMapping.TryGetKey(nextPosition, out otherParticleSection);

            if (otherParticleSection == null)
            {
                return;
            }
            var cloneParticles = particles.ToList();

            foreach (var particle in cloneParticles)
            {
                currentParticleSection.RemoveParticle(particle);
                otherParticleSection.AddParticle(particle);
            }

            costCalculator.AddTransmissionCost(currentParticleSection, (StrictBoundaryParticleSection)otherParticleSection, cloneParticles.Count, structure, step);
        }