コード例 #1
0
        public Tuple <double[][], double[][]> Start()
        {
            KeyValuePair <double[, , ][], int> mainVert = VertexFill.fillMatrixWithMainVertexes(matrix, nqp, k, n, m, SCALE_X, SCALE_Y, SCALE_Z);

            matrix = mainVert.Key;
            nqp    = mainVert.Value;
            KeyValuePair <double[, , ][], int> interVert = VertexFill.fillMatrixWithIntermidiateVertexes(matrix, nqp, k, n, m, SCALE_X, SCALE_Y, SCALE_Z);

            matrix = interVert.Key;
            nqp    = interVert.Value;

            MG = new double[3 * nqp, 3 * nqp];
            F  = new double[3 * nqp];

            AKT = CreateAKT.createAKT(nqp, k, n, m, matrix, local_to_global);
            ZU  = CreateAKT.createZU(AKT);
            ZP  = CreateAKT.createZP(m, n, nel);
            createNT();
            MG    = createMG.getMG(nel, NT, AKT, DFIABG, lam, v, mu, c, nqp);
            MG    = createMG.improveMG(ZU, MG);
            PSIET = Presure.createPSI();
            F     = Presure.createF(nqp, nel, m, n, AKT, NT, PSIET, c);

            U = Gauss.Solve(MG, F);

            double[][] AKTres = new double[nqp][];
            for (int i = 0; i < nqp; i++)
            {
                double[] prev  = AKT[i];
                double[] point = U.Skip(i * 3).Take(3).ToArray();
                AKTres[i] = new double[3] {
                    Math.Round(prev[0] + point[0], 4), Math.Round(prev[1] + point[1], 4), Math.Round(prev[2] + point[2], 4)
                };
            }

            using (StreamWriter sw = new StreamWriter("C:\\FEM\\frontend\\FEMpoints.txt", false, System.Text.Encoding.Default))
            {
                sw.WriteLine(JsonConvert.SerializeObject((from a in AKTres select new { x = a[0], y = a[1], z = a[2], })));
            }

            using (StreamWriter sw = new StreamWriter("C:\\FEM\\frontend\\start.txt", false, System.Text.Encoding.Default))
            {
                sw.WriteLine(JsonConvert.SerializeObject((from a in AKT select new { x = a[0], y = a[1], z = a[2], })));
            }

            return(new Tuple <double[][], double[][]>(AKT, AKTres));
        }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Data d = new Data();

            d.a         = (Double.Parse(textBox7.Text)) / (Double.Parse(textBox5.Text)) / (Double.Parse(textBox6.Text));
            d.rmax      = Double.Parse(textBox1.Text);
            d.taumax    = Double.Parse(textBox8.Text);
            d.K         = Double.Parse(textBox7.Text);
            d.tempbegin = Double.Parse(textBox3.Text);
            d.tempair   = Double.Parse(textBox4.Text);
            d.alfaair   = Double.Parse(textBox2.Text);
            d.c         = Double.Parse(textBox5.Text);
            d.ro        = Double.Parse(textBox6.Text);
            d.rmin      = Double.Parse(textBox9.Text);
            Element[] el = new Element[ne];
            Node[]    n  = new Node[nh];
            for (int i = 0; i < ne; i++)
            {
                el[i] = new Element();
            }
            for (int i = 0; i < nh; i++)
            {
                n[i] = new Node();
            }
            double[,] globalH = new double[nh, nh];
            double[] globalP    = new double[nh];
            double[] globalT    = new double[nh];
            double[] globalPmin = new double[nh];

            double dr    = d.rmax / ne;
            double dtau  = (Math.Pow(dr, 2)) / (0.5 * d.a);
            double ntime = (d.taumax / dtau) + 1;

            dtau = d.taumax / ntime;


            initdata(d, el, n);

            for (double time = 0; time <= d.taumax; time += dtau)
            {
                initlocals(el, n, d);
                initglobals(el, n, globalH, globalP, d);

                for (int i = 0; i < nh; i++)
                {
                    globalPmin[i] = globalP[i] * (-1);
                }

                merge(matrix, globalH, globalPmin);
                Gauss.gauss(nh, matrix, globalT);

                for (int i = 0; i < nh; i++)
                {
                    n[i].temp = globalT[i];
                }
                richTextBox1.AppendText(time + "\t");
                richTextBox1.AppendText(globalT[0] + "\t");
                richTextBox1.AppendText(globalT[ne] + "\n");
                //textArea.append("\n");

                inputDataSet2(time, globalT[0]);
                inputDataSet1(time, globalT[ne]);
            }
        }
コード例 #3
0
        public static double[,] getMG(int nel, int[][] NT, double[][] AKT, double[,,] DFIABG, double lam, double v, double mu, double[] c, int nqp)
        {
            double[,,] dxyzabg = new double[3, 3, 27];
            double[] dj = new double[27];
            double[,,] dfixyz = new double[27, 20, 3];
            double[,] MG      = new double[3 * nqp, 3 * nqp];

            for (int number = 0; number < nel; number++)
            {
                int[] coordinates = NT[number];

                double globalCoordinate = 0;
                double diFi             = 0;
                double sum = 0;

                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        for (int k = 0; k < 27; k++)
                        {
                            sum = 0;
                            for (int l = 0; l < 20; l++)
                            {
                                globalCoordinate = AKT[coordinates[l]][i];
                                diFi             = DFIABG[k, j, l];
                                sum += globalCoordinate * diFi;
                            }
                            dxyzabg[i, j, k] = sum;
                        }
                    }
                }

                double[,] jak;
                for (int i = 0; i < 27; i++)
                {
                    jak = new double[3, 3] {
                        { dxyzabg[0, 0, i], dxyzabg[1, 0, i], dxyzabg[2, 0, i] },
                        { dxyzabg[0, 1, i], dxyzabg[1, 1, i], dxyzabg[2, 1, i] },
                        { dxyzabg[0, 2, i], dxyzabg[1, 2, i], dxyzabg[2, 2, i] }
                    };
                    dj[i] = (
                        jak[0, 0] * jak[1, 1] * jak[2, 2] +
                        jak[0, 1] * jak[1, 2] * jak[2, 0] +
                        jak[0, 2] * jak[1, 0] * jak[2, 1]
                        ) -
                            (
                        jak[0, 2] * jak[1, 1] * jak[2, 0] +
                        jak[0, 1] * jak[1, 0] * jak[2, 2] +
                        jak[0, 0] * jak[1, 2] * jak[2, 1]
                            );
                }


                double[] col = new double[3];

                for (int i = 0; i < 27; i++)
                {
                    for (int phi = 0; phi < 20; phi++)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            col[k] = DFIABG[i, k, phi];
                        }
                        double[,] matrix = new double[3, 3] {
                            { dxyzabg[0, 0, i], dxyzabg[1, 0, i], dxyzabg[2, 0, i] },
                            { dxyzabg[0, 1, i], dxyzabg[1, 1, i], dxyzabg[2, 1, i] },
                            { dxyzabg[0, 2, i], dxyzabg[1, 2, i], dxyzabg[2, 2, i] }
                        };
                        double[] gaussianSolve = Gauss.Solve(matrix, col);

                        for (int k = 0; k < 3; k++)
                        {
                            dfixyz[i, phi, k] = gaussianSolve[k];
                        }
                    }
                }

                double[, ][,] mge = new double[3, 3][, ];

                mge[0, 0] = one_one(dfixyz, dj, lam, v, mu, c);
                mge[1, 1] = two_two(dfixyz, dj, lam, v, mu, c);
                mge[2, 2] = three_three(dfixyz, dj, lam, v, mu, c);

                mge[0, 1] = one_two(dfixyz, dj, lam, v, mu, c);
                mge[0, 2] = one_three(dfixyz, dj, lam, v, mu, c);
                mge[1, 2] = two_three(dfixyz, dj, lam, v, mu, c);

                mge[1, 0] = rotate(mge[0, 1]);
                mge[2, 0] = rotate(mge[0, 2]);
                mge[2, 1] = rotate(mge[1, 2]);

                int x, y, localX, localY, globalX, globalY;

                for (int i = 0; i < 60; i++)
                {
                    for (int j = 0; j < 60; j++)
                    {
                        x = i / 20;
                        y = j / 20;

                        localX = i % 20;
                        localY = j % 20;

                        globalX = (NT[number][localX]) * 3 + x;
                        globalY = (NT[number][localY]) * 3 + y;

                        MG[globalX, globalY] += mge[x, y][localX, localY];
                    }
                }
            }
            return(MG);
        }