public void VelocityFriction(double a, double b, double c) { // The force of pressure affects velocity for (int iterate = 0; iterate < 1; iterate++) { // NOTE: We include the border cells in global friction for (int x = 0; x < t_width; x++) { for (int y = 0; y < t_height; y++) { int cell = CellOffset(x, y, t_width); Engine.Calc.Vector v = new Engine.Calc.Vector(mp_xv0[cell], mp_yv0[cell]); double len2 = v.MagnitudeSquared(); double len = System.Math.Sqrt(len2); if (len < 0.0f) { len = -len; } len -= m_dt * (a * len2 + b * len + c); if (len < 0.0d) { len = 0.0d; } if (len < 0.0f) { len = 0.0f; } v.Normalize(); v.SetMagnitude(len); mp_xv0[cell] = v.X; mp_yv0[cell] = v.Y; } } } }
private int Threaded_GetParticles(int start, int end, Threading.ParamList paramlist) { Engine.Effects.Code.Particles.AutonomousParticle[] particles = (Engine.Effects.Code.Particles.AutonomousParticle[])paramlist.Get("particles").Value; for (int x = start; x < end; x++) { for (int y = 0; y < t_cells.GetLength(1); y++) { int offset = Engine.Surface.Ops.GetGridOffset(x, y, t_cells.GetLength(0), t_cells.GetLength(1)); particles[offset] = new Effects.Code.Particles.AutonomousParticle(new Engine.Calc.Vector((x * t_gridCellWidth) + (t_gridCellWidth / 2), (y * t_gridCellHeight) + (t_gridCellHeight / 2))); Engine.Calc.Vector vel = t_cells[x, y].Pressure; vel.Normalize(); vel.SetMagnitude(2); particles[offset].Velocity = vel; //t_cells[x, y].CalculateAveragePressure(t_flowField, x * t_gridCellWidth, y * t_gridCellHeight); } } return(0); }