コード例 #1
0
        public LineStatisticsMapper(VectorFieldUnsteady velocity, Plane plane) : base(plane, velocity.Size.ToInt2())
        {
            Velocity = velocity;
            Mapping  = ComputeStatistics;
            Plane    = plane;


            int time = velocity.Size.T;
        }
コード例 #2
0
        public LineStatisticsMapper(VectorFieldUnsteady velocity, Plane plane)
            : base(plane, velocity.Size.ToInt2())
        {
            Velocity = velocity;
            Mapping = ComputeStatistics;
            Plane = plane;

            int time = velocity.Size.T;
        }
コード例 #3
0
ファイル: CUDAMappers.cs プロジェクト: Leo-Rain/FlowSharp
 public FlowMapMapper(LoaderNCF.SliceRange[] uv, Plane plane, VectorFieldUnsteady velocity) : base(plane, velocity.Size.ToInt2())
 {
     _flowMap       = new FlowMapUncertain(_startPoint, uv, 0, 9);
     _algorithm     = _flowMap;
     Plane          = plane;
     _subrangePlane = Plane;
     Mapping        = GetCurrentMap;
     _velocity      = velocity;
     _maxPlane      = velocity.Size.ToInt2();
 }
コード例 #4
0
ファイル: CUDAMappers.cs プロジェクト: Leo-Rain/FlowSharp
 public LocalDiffusionMapper(VectorFieldUnsteady velocity, Plane plane) : base(plane, velocity.Size.ToInt2())
 {
     _diffusionMap = new LocalDiffusion(velocity, 0, 0.3f);
     _algorithm    = _diffusionMap;
     //           _ftleMap = new FTLE(velocity, 0, 0.3f);
     Plane          = plane;
     _subrangePlane = Plane;
     Mapping        = GetCurrentMap;
     _velocity      = velocity;
     _maxPlane      = velocity.Size.ToInt2();
 }
コード例 #5
0
ファイル: CUDAMappers.cs プロジェクト: Leo-Rain/FlowSharp
 public DiffusionMapper(VectorFieldUnsteady velocity, Plane plane) : base(plane, velocity.Size.ToInt2())
 {
     _diffusionMap  = new CutDiffusion(velocity, 0, 0.3f);
     _algorithm     = _diffusionMap;
     Plane          = plane;
     _subrangePlane = Plane;
     Mapping        = GetCurrentMap;
     _velocity      = velocity;
     _maxPlane      = velocity.Size.ToInt2();
     _scaledPlane   = new Plane(_subrangePlane.Origin, _subrangePlane.XAxis, _subrangePlane.YAxis, _subrangePlane.ZAxis, 1.0f / _cellToSeedRatio, _subrangePlane.PointSize);
 }
コード例 #6
0
ファイル: Unsteady.cs プロジェクト: Leo-Rain/FlowSharp
        public VectorFieldUnsteady(VectorFieldUnsteady field, VFJFunction function, int outputDim)
        {
            int       scalars  = outputDim;
            FieldGrid gridCopy = field._scalarsUnsteady[0].TimeSlices[0].Grid.Copy();

            _scalarsUnsteady = new ScalarFieldUnsteady[outputDim];

            // Reserve the space.
            for (int comp = 0; comp < outputDim; ++comp)
            {
                ScalarField[] fields = new ScalarField[field.Size.T]; //(field.Grid);

                for (int t = 0; t < field.Size.T; ++t)

                {
                    fields[t] = new ScalarField(gridCopy);
                }

                _scalarsUnsteady[comp]              = new ScalarFieldUnsteady(fields);
                _scalarsUnsteady[comp].TimeOrigin   = field[0].TimeOrigin ?? 0;
                _scalarsUnsteady[comp].InvalidValue = field.InvalidValue;
                _scalarsUnsteady[comp].DoNotScale();
            }

            this.InvalidValue = field.InvalidValue;
            this.TimeOrigin   = field.TimeOrigin;

            Grid = field.Grid.Copy();

            // Since the time component is in the grid size as well, we do not need to account for time specially.
            GridIndex indexIterator = new GridIndex(field.Size);

            foreach (GridIndex index in indexIterator)
            {
                Vector v = field.Sample((int)index);

                if (v[0] == InvalidValue)
                {
                    for (int dim = 0; dim < Scalars.Length; ++dim)
                    {
                        _scalarsUnsteady[dim][(int)index] = (float)InvalidValue;
                    }
                    continue;
                }

                SquareMatrix J         = field.SampleDerivative(index);
                Vector       funcValue = function(v, J);

                for (int dim = 0; dim < Scalars.Length; ++dim)
                {
                    Scalars[dim][(int)index] = funcValue[dim];
                }
            }
        }
コード例 #7
0
ファイル: DataMapper.cs プロジェクト: AnkeAnke/FlowSharp
 public CriticalPointTracking(CriticalPointSet2D[] cp, VectorFieldUnsteady velocity, Plane plane)
 {
     Debug.Assert(cp.Length == velocity.Size.T);
     CP = cp;
     Velocity = velocity;
     SlicesToRender = new VectorField[velocity.Size.T];
     for (int slice = 0; slice < velocity.Size.T; ++slice)
     {
         SlicesToRender[slice] = velocity.GetSlice(slice);
     }
     Mapping = TrackCP;
     Plane = plane;
 }
コード例 #8
0
ファイル: CUDAMappers.cs プロジェクト: Leo-Rain/FlowSharp
        public override void EndSelection(Vector2[] points)
        {
            base.EndSelection(points);

            _velocity = _flowMap.LoadMeanField();
            RefreshPlane();

            int   size = _velocity.Size.ToInt2().Product();
            float fill, mean, sd;

            _velocity.ScalarsAsSFU[0].GetTimeSlice(0).ComputeStatistics(out fill, out mean, out sd);
            Console.WriteLine("Region:\n\tRegion: " + size + "\n\tValid Part: " + fill + "\n\tValid Cells: " + fill * size);
        }
コード例 #9
0
ファイル: Tests.cs プロジェクト: AnkeAnke/FlowSharp
        public static VectorFieldUnsteady CreateBowl(Vec2 center, int numCells, Vec2 dir, int numSlices, float domainR = 2)
        {
            Vector origin = center - new Vec2(domainR);
            Vector cell = new Vec2(2 * domainR / numCells);
            Index size = new Index(numCells + 1, 2);

            ScalarField[] vX = new ScalarField[numSlices];
            ScalarField[] vY = new ScalarField[numSlices];

            for (int slice = 0; slice < numSlices; ++slice)
            {
                vX[slice] = ScalarField.FromAnalyticalField(BowlX, size, origin + dir * slice, cell);
                vY[slice] = ScalarField.FromAnalyticalField(BowlY, size, origin + dir * slice, cell);
            }

            VectorFieldUnsteady field = new VectorFieldUnsteady(new ScalarFieldUnsteady[] { new ScalarFieldUnsteady(vX), new ScalarFieldUnsteady(vY) });
            field.InvalidValue = float.MaxValue;
            field.DoNotScale();
            return field;
        }
コード例 #10
0
        public static VectorFieldUnsteady CreatePerfect(Vec2 center, int numCells, Vec2 dir, int numSlices, float domainR = 2)
        {
            Vector origin = center - new Vec2(domainR);
            Vector cell   = new Vec2(2 * domainR / numCells);
            Index  size   = new Index(numCells + 1, 2);

            ScalarField[] vX = new ScalarField[numSlices];
            ScalarField[] vY = new ScalarField[numSlices];

            for (int slice = 0; slice < numSlices; ++slice)
            {
                vX[slice] = ScalarField.FromAnalyticalField(PerfX, size, origin + dir * slice, cell);
                vY[slice] = ScalarField.FromAnalyticalField(PerfY, size, origin + dir * slice, cell);
            }

            VectorFieldUnsteady field = new VectorFieldUnsteady(new ScalarFieldUnsteady[] { new ScalarFieldUnsteady(vX), new ScalarFieldUnsteady(vY) });

            field.InvalidValue = float.MaxValue;
            field.DoNotScale();
            return(field);
        }
コード例 #11
0
        public PathlineLengthMapper(VectorFieldUnsteady velocity, Plane plane)
            : base(plane, velocity.Size.ToInt2())
        {
            Velocity = velocity;

            Mapping = ShowPaths;
            Plane = plane;

            int time = velocity.Size.T;
            _intersectTimeSlices = new PointSet<EndPoint>[time];
            _pathlineSegments = new LineSet[time - 1];
            _intersectTimeSlices[0] = FieldAnalysis.ValidDataPoints<EndPoint>(velocity.GetTimeSlice(0));//FieldAnalysis.SomePoints2D<EndPoint>(velocity, 100);//
            _points = new PointCloud[velocity.Size.T];
            _points[0] = new PointCloud(Plane, _intersectTimeSlices[0].ToBasicSet());
            _fieldPositionOfValidCell = new int[_intersectTimeSlices[0].Length];
            for(int i = 0; i < _fieldPositionOfValidCell.Length; ++i)
            {
                Vector3 pos = _intersectTimeSlices[0].Points[i].Position;
                _fieldPositionOfValidCell[i] = (int)(pos.X + 0.5) + (int)(pos.Y + 0.5) * Velocity.Size[0];
            }
        }
コード例 #12
0
        public PathlineLengthMapper(VectorFieldUnsteady velocity, Plane plane) : base(plane, velocity.Size.ToInt2())
        {
            Velocity = velocity;

            Mapping = ShowPaths;
            Plane   = plane;

            int time = velocity.Size.T;

            _intersectTimeSlices    = new PointSet <EndPoint> [time];
            _pathlineSegments       = new LineSet[time - 1];
            _intersectTimeSlices[0] = FieldAnalysis.ValidDataPoints <EndPoint>(velocity.GetTimeSlice(0));//FieldAnalysis.SomePoints2D<EndPoint>(velocity, 100);//
            _points    = new PointCloud[velocity.Size.T];
            _points[0] = new PointCloud(Plane, _intersectTimeSlices[0].ToBasicSet());
            _fieldPositionOfValidCell = new int[_intersectTimeSlices[0].Length];
            for (int i = 0; i < _fieldPositionOfValidCell.Length; ++i)
            {
                Vector3 pos = _intersectTimeSlices[0].Points[i].Position;
                _fieldPositionOfValidCell[i] = (int)(pos.X + 0.5) + (int)(pos.Y + 0.5) * Velocity.Size[0];
            }
        }
コード例 #13
0
        public PlaygroundMapper(Plane plane)
            : base(new Plane(plane, 1), new Int2(NUM_CELLS))
        {
            Mapping = Map;
            _velocity = Tests.CreateBowl(new Vec2(NUM_CELLS/2, 0), NUM_CELLS, new Vec2(-10, 0), 22, 200);
            _selections = new List<LineBall>(10);
            _selectionsAngle = new List<LineBall>(10);
            _steadySelection = new List<LineBall>(10);

            // Core.
            _core = new Line() { Positions = new Vector3[] { new Vector3(50, 100, 0), new Vector3(155, 100, _velocity.Size.T-1) } };
            LineSet set = new LineSet(new Line[] { _core }) { Color = new Vector3(0.2f) };
            set.Thickness *= 3;
            _coreBall = new LineBall(plane, set, LineBall.RenderEffect.DEFAULT);

            // Straight core.
            set = new LineSet(new Line[] { new Line() { Positions = new Vector3[] { _core[0], _core[0] + Vector3.UnitZ * (_velocity.Size.T - 1) } } }) { Color = new Vector3(0.2f) };
            set.Thickness *= 3;
            _straightCoreBall = new LineBall(Plane, set);

            var center = Tests.CreatePerfect(new Vec2(0, 0), NUM_CELLS, new Vec2(0), 1, 200);
            _steadyField = center.GetTimeSlice(0); //[0] as ScalarField;
        }
コード例 #14
0
        public PlaygroundMapper(Plane plane) : base(new Plane(plane, 1), new Int2(NUM_CELLS))
        {
            Mapping          = Map;
            _velocity        = Tests.CreateBowl(new Vec2(NUM_CELLS / 2, 0), NUM_CELLS, new Vec2(-10, 0), 22, 200);
            _selections      = new List <LineBall>(10);
            _selectionsAngle = new List <LineBall>(10);
            _steadySelection = new List <LineBall>(10);

            // Core.
            _core = new Line()
            {
                Positions = new Vector3[] { new Vector3(50, 100, 0), new Vector3(155, 100, _velocity.Size.T - 1) }
            };
            LineSet set = new LineSet(new Line[] { _core })
            {
                Color = new Vector3(0.2f)
            };

            set.Thickness *= 3;
            _coreBall      = new LineBall(plane, set, LineBall.RenderEffect.DEFAULT);

            // Straight core.
            set = new LineSet(new Line[] { new Line()
                                           {
                                               Positions = new Vector3[] { _core[0], _core[0] + Vector3.UnitZ * (_velocity.Size.T - 1) }
                                           } })
            {
                Color = new Vector3(0.2f)
            };
            set.Thickness    *= 3;
            _straightCoreBall = new LineBall(Plane, set);

            var center = Tests.CreatePerfect(new Vec2(0, 0), NUM_CELLS, new Vec2(0), 1, 200);

            _steadyField = center.GetTimeSlice(0); //[0] as ScalarField;
        }
コード例 #15
0
ファイル: CUDAMappers.cs プロジェクト: AnkeAnke/FlowSharp
        public override void EndSelection(Vector2[] points)
        {
            base.EndSelection(points);

            _velocity = _flowMap.LoadMeanField();
            RefreshPlane();

            int size = _velocity.Size.ToInt2().Product();
            float fill, mean, sd;
            _velocity.ScalarsAsSFU[0].GetTimeSlice(0).ComputeStatistics(out fill, out mean, out sd);
            Console.WriteLine("Region:\n\tRegion: " + size + "\n\tValid Part: " + fill + "\n\tValid Cells: " + fill * size);
        }
コード例 #16
0
        protected override void TraceCore(int member = 0, int startSubstep = 0)
        {
            int rad = NEIGHBOORHOOD_CP * (Core == CoreAlgorithm.ROUGH_STREAM_CONNECTION ? 4 : 1);
            string corename = RedSea.Singleton.CoreFileName + member + Core.ToString() + "cc.line";
            if (System.IO.File.Exists(corename))
            {
                GeometryWriter.ReadFromFile(corename, out _cores);
                LoadField(0, MemberMain, 1);
            }
            else
            {
                Vec3[] bases = new Vec3[] {
                    new Vec3(463.1f, 53.6f, 0),
                    new Vec3(366.4f, 34.4f, 0),
                    new Vec3(230.1f, 218.6f, 0)};

                if (Core == CoreAlgorithm.CLICK)
                {
                    Line[] lines = new Line[bases.Length];
                    for(int b = 0; b < bases.Length; ++b)
                        lines[b] = new Line() { Positions = new Vector3[] { (Vector3)bases[b], (Vector3)bases[b] + Vector3.UnitZ * (float)(RedSea.Singleton.NumSubstepsTotal / _everyNthTimestep) } };

                    _cores = new LineSet(lines);
                    LoadField(0, MemberMain, 1);
                    return;
                }

                int numSlices = RedSea.Singleton.NumSubstepsTotal / _everyNthTimestep;
                int stepSize = Core != CoreAlgorithm.ROUGH_STREAM_CONNECTION ? 1 : ROUGH_MULTIPLIER; // RedSea.Singleton.NumSubstepsTotal / _everyNthTimestep - 1;
                _cores = new LineSet(new Line[bases.Length]);
                for (int b = 0; b < _cores.Length; ++b)
                {
                    _cores[b] = new Line((int)Math.Ceiling((float)(numSlices -1)/ stepSize)+1);
                    //_cores[b][0] = (Vector3)bases[b];
                }

                int idx = 0;
                // Connect to other slices.
                for(int slice = 0; slice < numSlices; slice += stepSize)
                {
                    LoadField(Math.Min(slice, numSlices - 2), member, 2);

                    VectorField field = _velocity;
                    if (Core == CoreAlgorithm.PATHLINE)
                    {
                        var acc= new VectorFieldUnsteady(_velocity, FieldAnalysis.Acceleration, 2);
                        field = acc.GetTimeSlice(slice);
                    }
                    else
                    {
                        field = _velocity.GetTimeSlice(slice);
                    }

                    for (int b = 0; b < _cores.Length; ++b)
                    {
                        Vector3 lastCP = idx > 0? _cores[b][idx-1] : (Vector3)bases[b];
                        Int2 x = new Int2((int)lastCP.X - rad, (int)Math.Ceiling(lastCP.X) + rad);
                        Int2 y = new Int2((int)lastCP.Y - rad, (int)Math.Ceiling(lastCP.Y) + rad);
                        CriticalPointSet2D points = FieldAnalysis.ComputeCriticalPointsRegularSubdivision2DRange(field, x, y);

                        float minDist = float.MaxValue;
                        CriticalPoint2D nearest = null;

                        foreach(CriticalPoint2D point in points.Points)
                        {
                            float dist = (lastCP - point.Position).LengthSquared();
                            if(dist< minDist)
                            {
                                minDist = dist;
                                nearest = point;
                            }
                        }

                        _cores[b][idx] = nearest?.Position ?? lastCP;
                        _cores[b].Positions[idx].Z = slice;
                    }
                    idx++;

                    // Reverse-engineered: Always include the last possible slice.
                    if (slice + stepSize >= numSlices && slice + 1 < numSlices)
                        slice = numSlices - 1 - stepSize;
                }
                GeometryWriter.WriteToFile(corename, _cores);
            }
        }
コード例 #17
0
ファイル: CUDAMappers.cs プロジェクト: AnkeAnke/FlowSharp
 public DiffusionMapper(VectorFieldUnsteady velocity, Plane plane)
     : base(plane, velocity.Size.ToInt2())
 {
     _diffusionMap = new CutDiffusion(velocity, 0, 0.3f);
     _algorithm = _diffusionMap;
     Plane = plane;
     _subrangePlane = Plane;
     Mapping = GetCurrentMap;
     _velocity = velocity;
     _maxPlane = velocity.Size.ToInt2();
     _scaledPlane = new Plane(_subrangePlane.Origin, _subrangePlane.XAxis, _subrangePlane.YAxis, _subrangePlane.ZAxis, 1.0f/_cellToSeedRatio, _subrangePlane.PointSize);
 }
コード例 #18
0
ファイル: DataMapper.cs プロジェクト: AnkeAnke/FlowSharp
        // : base(plane, velocity.Size.ToInt2())
        public PathlineRadius(VectorFieldUnsteady velocity, Plane plane)
        {
            _velocity = velocity;
            Plane = plane;
            _intersectionPlane = new Plane(Plane, (velocity.TimeSlice ?? 0) * Plane.ZAxis);

            Mapping = AdvectLines;
        }
コード例 #19
0
ファイル: DataMapper.cs プロジェクト: AnkeAnke/FlowSharp
 public PathlineCoreTracking(VectorFieldUnsteady velocity, /*VectorField fffPos, VectorField fffNeg,*/ Plane plane)
 {
     Velocity = new VectorField(velocity, FieldAnalysis.PathlineCore, 3);
     CP = new CriticalPointSet2D[velocity.Size.T];
     for (int slice = 0; slice < velocity.Size.T; ++slice)
     {
         CP[slice] = FieldAnalysis.ComputeCriticalPointsRegularSubdivision2D(Velocity.GetSlicePlanarVelocity(slice), 5, 0.3f);
     }
     // Render original field.
     SlicesToRender = new VectorField[velocity.Size.T];
     for (int slice = 0; slice < velocity.Size.T; ++slice)
     {
         SlicesToRender[slice] = Velocity.GetSlice(slice);
     }
     Mapping = TrackCP;
     Plane = plane;
 }
コード例 #20
0
ファイル: DataMapper.cs プロジェクト: AnkeAnke/FlowSharp
        protected void Initialize()
        {
            _fieldOW = new VectorFieldUnsteady(_fieldOW, FieldAnalysis.OkuboWeiss, 1);

            float mean, fill;
            _fieldOW.ScalarsAsSFU[0].TimeSlices[0].ComputeStatistics(out fill, out mean, out _standardDeviation);
            Console.WriteLine("Mean: " + mean + ", SD: " + _standardDeviation + ", valid cells: " + fill);
        }
コード例 #21
0
ファイル: DataMapper.cs プロジェクト: AnkeAnke/FlowSharp
        public OkuboWeiss(VectorFieldUnsteady velocity, Plane plane)
        {
            Debug.Assert(velocity.NumVectorDimensions == 2 + 1);
            _fieldOW = velocity;

            Plane = plane;
            Mapping = GetTimeSlice;
        }
コード例 #22
0
ファイル: CUDAMappers.cs プロジェクト: AnkeAnke/FlowSharp
 public FlowMapMapper(LoaderNCF.SliceRange[] uv, Plane plane, VectorFieldUnsteady velocity)
     : base(plane, velocity.Size.ToInt2())
 {
     _flowMap = new FlowMapUncertain(_startPoint, uv, 0, 9);
     _algorithm = _flowMap;
     Plane = plane;
     _subrangePlane = Plane;
     Mapping = GetCurrentMap;
     _velocity = velocity;
     _maxPlane = velocity.Size.ToInt2();
 }
コード例 #23
0
ファイル: Unsteady.cs プロジェクト: AnkeAnke/FlowSharp
        public VectorFieldUnsteady(VectorFieldUnsteady field, VFJFunction function, int outputDim)
        {
            int scalars = outputDim;
            FieldGrid gridCopy = field._scalarsUnsteady[0].TimeSlices[0].Grid.Copy();
            _scalarsUnsteady = new ScalarFieldUnsteady[outputDim];

            // Reserve the space.
            for (int comp = 0; comp < outputDim; ++comp)
            {
                ScalarField[] fields = new ScalarField[field.Size.T]; //(field.Grid);

                for (int t = 0; t < field.Size.T; ++t)

                {
                    fields[t] = new ScalarField(gridCopy);
                }

                _scalarsUnsteady[comp] = new ScalarFieldUnsteady(fields);
                _scalarsUnsteady[comp].TimeOrigin = field[0].TimeOrigin ?? 0;
                _scalarsUnsteady[comp].InvalidValue = field.InvalidValue;
                _scalarsUnsteady[comp].DoNotScale();
            }

            this.InvalidValue = field.InvalidValue;
            this.TimeOrigin = field.TimeOrigin;

            Grid = field.Grid.Copy();

            // Since the time component is in the grid size as well, we do not need to account for time specially.
            GridIndex indexIterator = new GridIndex(field.Size);
            foreach (GridIndex index in indexIterator)
            {
                Vector v = field.Sample((int)index);

                if (v[0] == InvalidValue)
                {
                    for (int dim = 0; dim < Scalars.Length; ++dim)
                        _scalarsUnsteady[dim][(int)index] = (float)InvalidValue;
                    continue;
                }

                SquareMatrix J = field.SampleDerivative(index);
                Vector funcValue = function(v, J);

                for (int dim = 0; dim < Scalars.Length; ++dim)
                {
                    Scalars[dim][(int)index] = funcValue[dim];
                }
            }
        }
コード例 #24
0
ファイル: CUDAMappers.cs プロジェクト: AnkeAnke/FlowSharp
 public LocalDiffusionMapper(VectorFieldUnsteady velocity, Plane plane)
     : base(plane, velocity.Size.ToInt2())
 {
     _diffusionMap = new LocalDiffusion(velocity, 0, 0.3f);
     _algorithm = _diffusionMap;
      //           _ftleMap = new FTLE(velocity, 0, 0.3f);
     Plane = plane;
     _subrangePlane = Plane;
     Mapping = GetCurrentMap;
     _velocity = velocity;
     _maxPlane = velocity.Size.ToInt2();
 }