示例#1
0
        public static VectorField GetRingField(int numCells)
        {
            ScalarField[] fields = new ScalarField[2];
            Index         size   = new Index(numCells + 1, 2);
            Vector        origin = new Vector(-2, 2);
            Vector        cell   = new Vector(4.0f / numCells, 2);

            fields[0] = ScalarField.FromAnalyticalField(RingFieldX, size, origin, cell);
            fields[1] = ScalarField.FromAnalyticalField(RingFieldY, size, origin, cell);

            return(new VectorField(fields));
        }
示例#2
0
        public static VectorFieldUnsteady CreatePathlineSpiral(int numCells, int numSlices, float domainR = 2)
        {
            Vector origin = 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(x => (float)Math.Cos((float)slice / 3) * 4, size, origin, cell);
                vY[slice] = ScalarField.FromAnalyticalField(x => (float)Math.Sin((float)slice / 3) * 4, size, origin, cell);
            }

            return(new VectorFieldUnsteady(new ScalarFieldUnsteady[] { new ScalarFieldUnsteady(vX), new ScalarFieldUnsteady(vY) }));
        }
示例#3
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);
        }