using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Azimuth; using Annulus; using Slipstream.StokesFlow; namespace Slipstream.Testbed.Demos { class UniformFlowStokesPanelSidways : Demo { StokesPanelGroup _panelGroup; Scalar panelLength = 10; public override void Start(FluidWorld world) { _panelGroup = new StokesPanelGroup( new[] { Vector.Zero }, new[] { Vector.UnitY }, panelLength); Random rand = new Random(1); for (int i = 0; i < 1000; ++i) { world.AddTracerParticle(new Vector(2 * rand.NextDouble() - 1, 2 * rand.NextDouble() - 1) * 100); } } Scalar cycleCount = 0; public override void Update(FluidWorld world) { cycleCount += 1.0 / 60.0; Scalar period = 10; Scalar angularVelocity = (1.0 / period) * (2 * Math.PI); var velocity = new Vector(0, 25 * angularVelocity * Math.Cos(angularVelocity * cycleCount)); world.FluidBaseVelocity = velocity; Scalar totalEnergyCount; _panelGroup.EnforceBoundaryConditions(world.FluidBaseVelocity); Action particles = (x, y, velx, vely) => { for (int i = 0; i < x.Count; ++i) { var velocityPanel = _panelGroup.VelocityAtPoint(new Vector(x[i], y[i])); velx[i] = velocityPanel.X; vely[i] = velocityPanel.Y; } }; world.IntegrateTracerParticles(particles, 1.0/60.0, out totalEnergyCount); } public override void Reset(FluidWorld world) { cycleCount = 0; } public override Blacklight.Core.Cel Draw(FluidWorld world) { var cel = new Blacklight.Core.Cel(); var collage = new Blacklight.Core.Drawables.Collage(); var panelCollage = new Blacklight.Core.Drawables.Collage(); var panel = new Blacklight.Core.Drawables.Rectangle { InsideColor = new Blacklight.Core.Color(0.84, 0.84, 0), ShellColor = new Blacklight.Core.Color(0.84, 0.25, 0), ShellPixelThickness = 0, ShellModelSpaceThickness = 0, SmoothBorder = false, }; panelCollage.AddDrawable(panel, new AffineMatrix( new Vector(panelLength * 0.5 * 0.66, 0), new Vector(0, 0.5), new Vector(0, 0))); foreach (var panelTransform in _panelGroup.PanelsModelToWorld) { collage.AddDrawable(panelCollage, panelTransform); } cel.AddEntity(new Blacklight.Core.Entity { drawable = collage, modelToWorld = AffineMatrix.Identity, }); return cel; } } }