示例#1
0
文件: Sph.cs 项目: hirekoke/FloWin
        private void Init()
        {
            _initialDensity = Kernel2D.Poly6.Func(0);

#if DEBUG
            // 流体粒子
            for (int i = 0; i < 64; i++)
            {
                Particle p = new Particle();
                p.Velocity = new Vector(0, 0);
                p.Type = ParticleType.Fluid;
                p.Mass = PARTICLE_MASS;
                p.Density = 0;

                double x = i % 8;
                double y = (i - x) / 8.0;
                p.Location = new Point(x * PARTICLE_PAD + 220, y * PARTICLE_PAD + 200);

                _particles.Add(p);
            }
#endif

            // 近傍粒子ペアを更新
            UpdateNeighborParticles();

            CalcDensity();
        }
示例#2
0
        private void Init()
        {
            Kernel2D.Kernel2D.H = H;

            // 流体粒子
            for (int i = 0; i < 16; i++)
            {
                Particle p = new Particle();
                p.Velocity = new Vector(0, 0);
                p.Type = ParticleType.Fluid;
                p.Mass = 1.0; // SPECIFIC_GRAVITY_WATER / 16.0;
                p.Density = 0;

                double x = i % 4;
                double y = (i - x) / 4.0;
                p.Location = new Vector(x * 5 + 30, y * 5 + 30);

                _particles.Add(p);
            }

            CalcDensity();
            _initialDensity = 0;
            foreach (Particle p in _particles)
            {
                if (_initialDensity < p.Density) _initialDensity = p.Density;
            }
            _initialDensity = 4.0 * Kernel2D.Poly6.Func(0);

            // 固定境界粒子
            for (int i = 0; i < 50; i++)
            {
                Particle particle = new Particle();
                particle.Velocity = new Vector(0, 0);
                particle.Type = ParticleType.Boundary;
                particle.Mass = 4;
                particle.Location = new Vector(i * 2, 100);
                _particles.Add(particle);
                if (i == 8) the_particle = particle;

                Particle pLeft1 = particle.Clone();
                pLeft1.Location = new Vector(0, i * 2);
                _particles.Add(pLeft1);

                Particle pRight1 = particle.Clone();
                pRight1.Location = new Vector(100, i * 2);
                _particles.Add(pRight1);
            }
        }
示例#3
0
文件: Sph.cs 项目: hirekoke/FloWin
        public void AddParticles(double x1, double y1, double x2, double y2)
        {
            Vector vec = new Vector(x2 - x1, y2 - y1);
            int num = (int)(vec.Length / (double)PARTICLE_PAD);
            if (num == 0) return;

            double dx = (x2 - x1) / (double)num;
            double dy = (y2 - y1) / (double)num;
            double px = x1; double py = y1;
            for (int i = 0; i < num; i++)
            {
                Particle p = new Particle();
                p.Velocity = new Vector(0, 1);
                p.Type = ParticleType.Fluid;
                p.Mass = PARTICLE_MASS;
                p.Density = 0;
                p.Location = new Point(px, py);
                _particles.Add(p);

                px += dx; py += dy;
            }
            CalcDensity();
        }