Пример #1
0
    private static void test06()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST06 tests TETRAHEDRON_NCC_RULE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    31 January 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int dim_num = 3;
        int       o;
        int       s;

        Console.WriteLine("");
        Console.WriteLine("TEST06");
        Console.WriteLine("  TETRAHEDRON_NCC_RULE returns the points and weights");
        Console.WriteLine("  of an NCC rule for the tetrahedron.");

        const int rule = 4;

        Console.WriteLine("");
        Console.WriteLine("  In this test, we simply print rule " + rule + "");

        int suborder_num = NewtonCotesClosed.tetrahedron_ncc_suborder_num(rule);

        int[] suborder = NewtonCotesClosed.tetrahedron_ncc_suborder(rule, suborder_num);

        double[] suborder_w   = new double[suborder_num];
        double[] suborder_xyz = new double[4 * suborder_num];

        NewtonCotesClosed.tetrahedron_ncc_subrule(rule, suborder_num, ref suborder_xyz, ref suborder_w);

        Console.WriteLine("");
        Console.WriteLine("  The compressed rule:");
        Console.WriteLine("");
        Console.WriteLine("  Number of suborders = " + suborder_num + "");
        Console.WriteLine("");
        Console.WriteLine("     S   Sub     Weight     Xsi1      Xsi2      Xsi3      Xsi4");
        Console.WriteLine("");

        for (s = 0; s < suborder_num; s++)
        {
            Console.WriteLine("  " + (s + 1).ToString(CultureInfo.InvariantCulture).PadLeft(4)
                              + "  " + suborder[s].ToString(CultureInfo.InvariantCulture).PadLeft(4)
                              + "  " + suborder_w[s].ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + suborder_xyz[0 + s * 4].ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + suborder_xyz[1 + s * 4].ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + suborder_xyz[2 + s * 4].ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + suborder_xyz[3 + s * 4].ToString("0.####").PadLeft(8) + "");
        }

        int order_num = NewtonCotesClosed.tetrahedron_ncc_order_num(rule);

        double[] xyz = new double[dim_num * order_num];
        double[] w   = new double[order_num];

        NewtonCotesClosed.tetrahedron_ncc_rule(rule, order_num, ref xyz, ref w);

        Console.WriteLine("");
        Console.WriteLine("  The full rule:");
        Console.WriteLine("");
        Console.WriteLine("  Order = " + order_num + "");
        Console.WriteLine("");
        Console.WriteLine("     O    Weight        X           Y           Z");
        Console.WriteLine("");

        for (o = 0; o < order_num; o++)
        {
            Console.WriteLine("  " + (o + 1).ToString(CultureInfo.InvariantCulture).PadLeft(4)
                              + "  " + w[o].ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + xyz[0 + o * 3].ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + xyz[1 + o * 3].ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + xyz[2 + o * 3].ToString("0.####").PadLeft(8) + "");
        }
    }
Пример #2
0
    private static void test03()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST03 tests TETRAHEDRON_NCC_RULE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    30 January 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int rule;

        Console.WriteLine("");
        Console.WriteLine("TEST03");
        Console.WriteLine("  TETRAHEDRON_NCC_RULE returns the points and weights");
        Console.WriteLine("  of an NCC rule for the tetrahedron.");
        Console.WriteLine("");
        Console.WriteLine("  In this test, we simply check that, for each");
        Console.WriteLine("  quadrature point, the barycentric coordinates");
        Console.WriteLine("  add up to 1.");

        int rule_num = NewtonCotesClosed.tetrahedron_ncc_rule_num();

        Console.WriteLine("");
        Console.WriteLine("      Rule    Suborder    Sum of coordinates");
        Console.WriteLine("");

        for (rule = 1; rule <= rule_num; rule++)
        {
            int suborder_num = NewtonCotesClosed.tetrahedron_ncc_suborder_num(rule);

            double[] suborder_xyz = new double[4 * suborder_num];
            double[] suborder_w   = new double[suborder_num];

            NewtonCotesClosed.tetrahedron_ncc_subrule(rule, suborder_num, ref suborder_xyz, ref suborder_w);

            Console.WriteLine("");
            Console.WriteLine("  " + rule.ToString(CultureInfo.InvariantCulture).PadLeft(8)
                              + "  " + suborder_num.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "");

            int suborder;
            for (suborder = 0; suborder < suborder_num; suborder++)
            {
                double xyz_sum = suborder_xyz[0 + suborder * 4]
                                 + suborder_xyz[1 + suborder * 4]
                                 + suborder_xyz[2 + suborder * 4]
                                 + suborder_xyz[3 + suborder * 4];
                Console.WriteLine("                    "
                                  + "  " + xyz_sum.ToString("0.################").PadLeft(25) + "");
            }
        }
    }