Пример #1
0
        public OneDemExample(double dx_gr = 0d) : base()
        {
            dx_granica = dx_gr;
            int n_pm = perc * scaler;


            var dx1 = boardL / n_pm;

            for (int i = 0; i < n_pm; i++)
            {
                Particles.Add(new Particle()
                {
                    Name = i.ToString(),
                    X    = -boardL + i * dx1,
                    Ro   = 1,
                    P    = 1,
                    E    = 2.5,
                    V    = 0
                });
            }
            var dx2 = boardL / (Np - n_pm);

            for (int i = n_pm; i < Np; i++)
            {
                Particles.Add(new Particle()
                {
                    Name = i.ToString(),
                    X    = (i - n_pm) * dx2 + dx_granica,
                    Ro   = 0.25,
                    P    = 0.1795,
                    E    = 1.795,
                    V    = 0
                });
            }

            for (int i = -1; i > -Np_wall - 1; i--)
            {
                Wall.Add(new Particle()
                {
                    Name   = (i).ToString(),
                    X      = -boardL + (i) * dx1,
                    Ro     = 1,
                    P      = 1,
                    E      = 2.5,
                    V      = 0,
                    IsWall = true
                });
            }
            for (int i = Np + 1; i <= Np + Np_wall; i++)
            {
                Wall.Add(new Particle()
                {
                    Name   = (i).ToString(),
                    X      = (i - n_pm - 1) * dx2 + dx_granica,
                    Ro     = 0.25,
                    P      = 0.1795,
                    E      = 1.795,
                    V      = 0,
                    IsWall = true
                });
            }

            var all = Particles.Concat(Wall).OrderBy(p => p.X);

            AllParticles.AddRange(all);

            AllParticles.ForEach(p => p.M = 0.6 / n_pm);

            for (int i = 0; i < AllParticles.Count; i++)
            {
                AllParticles[i].MInd = i;
            }

            var xs    = AllParticles.Select(p => p.X).ToArray();
            var walls = AllParticles.Select(p => p.IsWall).ToArray();

            SynchMeBefore += SynchMeAfterAct;

            foreach (var p in Particles)
            {
                AddChild(p);
            }
            Particles.ForEach(p => p.SetDts());



            var mhi  = Particles.Where(p => p.P > 0.3).Sum(p => p.M);
            var mlo  = Particles.Where(p => p.P < 0.3).Sum(p => p.M);
            var mall = Particles.Sum(p => p.M);

            foreach (var part in AllParticles)
            {
                part.Ro = AllParticles.Sum(p => p.M * KernelF.W(part.X - p.X, h));
            }
            foreach (var p in Particles)
            {
                p.P = GetP(p);
            }

            SynchMeAfter += SynchMeAfterAct;
            //SynchMeForNext += t => {
            //    foreach(var p in Particles) {
            //        p.P = GetP(p);
            //    }
            //};

            particles_par = Particles.AsParallel();
        }