Beispiel #1
0
        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;
        }
Beispiel #2
0
 public Vec3(float a, Vec2 b)
     : base(new float[] { a, b.X, b.Y })
 {
 }
Beispiel #3
0
 public Vec3(Vec2 a, float b)
     : base(new float[] { a.X, a.Y, b })
 {
 }
Beispiel #4
0
 public Vec2(Vec2 copy)
     : base(copy)
 {
 }
Beispiel #5
0
        public void Eigenanalysis(out SquareMatrix eigenvalues, out SquareMatrix eigenvectors)
        {
            Debug.Assert(Length == 2, "Only 2D eigenanalysis implemented so far.");
            eigenvectors = new SquareMatrix(2);
            eigenvalues = new SquareMatrix(2);

            float a = this[0][0]; float b = this[1][0]; float c = this[0][1]; float d = this[1][1];
            // Computing eigenvalues.
            float Th = (a + d) * 0.5f;
            float D = a * d - b * c;
            float root = Th * Th - D;

            float complex = 0;
            if (root < 0)
            {
                complex = -root;
                root = 0;
            }

            root = (float)Math.Sqrt(root);
            float l0 = Th + root;
            float l1 = Th - root;

            // Save directional information.
            eigenvalues[0] = new Vec2(l0, complex);
            eigenvalues[1] = new Vec2(l1, -complex);

            // Computing eigenvectors.
            if (c != 0)
            {
                eigenvectors[0] = new Vec2(l0 - d, c);
                eigenvectors[1] = new Vec2(l1 - d, c);
            }
            else if (b != 0)
            {
                eigenvectors[0] = new Vec2(b, l0 - a);
                eigenvectors[1] = new Vec2(b, l1 - a);
            }
            else
            {
                eigenvectors[0] = new Vec2(1, 0);
                eigenvectors[1] = new Vec2(0, 1);
            }
        }
Beispiel #6
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) });
        }