Beispiel #1
0
    private static void test02()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST02 checks the basis functions.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    07 July 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int    i;
        double xq;

        double[] xx =
        {
            2.0, 1.0, 0.0, 0.0, 0.0, 1.0, 2.0, 2.0
        }

        ;
        double yq;

        double[] yy =
        {
            5.0, 5.0, 5.0, 4.0, 3.0, 3.0, 3.0, 4.0
        }

        ;

        Console.WriteLine("");
        Console.WriteLine("TEST02");
        Console.WriteLine("  Basis function checks.");
        //
        //  Check that V is identity matrix at nodes.
        //
        Console.WriteLine("");
        Console.WriteLine("  The matrix Aij = V(j)(X(i),Y(i)) should be the identity.");
        Console.WriteLine("");

        double xw = 0.0;
        double ys = 3.0;
        double xe = 2.0;
        double yn = 5.0;

        for (i = 0; i < 8; i++)
        {
            xq = xx[i];
            yq = yy[i];
            FEM_2D_BVP_Serene.basis_serene(xq, yq, xw, ys, xe, yn, xx, yy);
            int j;
            for (j = 0; j < 8; j++)
            {
            }

            Console.WriteLine("");
        }

        //
        //  Check that VX and VY sum to zero anywhere.
        //
        Console.WriteLine("");
        Console.WriteLine("  The vectors dVdX(1:8)(X,Y) and dVdY(1:8)(X,Y)");
        Console.WriteLine("  should both sum to zero for any (X,Y).");

        int seed = 123456789;

        xq = 2.0 * UniformRNG.r8_uniform_01(ref seed);
        yq = 3.0 + 2.0 * UniformRNG.r8_uniform_01(ref seed);
        xw = 0.0;
        ys = 3.0;
        xe = 2.0;
        yn = 5.0;

        double[] vx = FEM_2D_BVP_Serene.basis_dx_serene(xq, yq, xw, ys, xe, yn, xx, yy);
        double[] vy = FEM_2D_BVP_Serene.basis_dy_serene(xq, yq, xw, ys, xe, yn, xx, yy);

        Console.WriteLine("");
        Console.WriteLine("  Random evaluation point is (" + xq + "," + yq + ")");
        Console.WriteLine("");
        Console.WriteLine("              dVdX        dVdY");
        Console.WriteLine("");
        for (i = 0; i < 8; i++)
        {
            Console.WriteLine(i.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                              + vx[i].ToString(CultureInfo.InvariantCulture).PadLeft(10) + "  "
                              + vy[i].ToString(CultureInfo.InvariantCulture).PadLeft(10) + "");
        }

        Console.WriteLine("");
        Console.WriteLine("  Sum:  "
                          + typeMethods.r8vec_sum(8, vx).ToString(CultureInfo.InvariantCulture).PadLeft(10) + "  "
                          + typeMethods.r8vec_sum(8, vy).ToString(CultureInfo.InvariantCulture).PadLeft(10) + "");
    }