示例#1
0
        public Sparse_Straight_Solver(ref GlobalMatrix _GM)
        {
            F = new List <double>(new double[Size]);
            if (InsertedInfo.Sparse && InsertedInfo.Sparse_Straight)
            {
                Console.WriteLine(this.ToString() + " initiated");
                GM = _GM;
                gg = GM.gg;
                fe = GM.fe;
                lm = GM.lm;

                if (!InsertedInfo.Test_another_matrix)
                {
                    Size     = fe.Size;
                    al       = Shared_Field.CopyListCC(GM.al);
                    au       = Shared_Field.CopyListCC(GM.au);
                    F_sparse = Shared_Field.CopyVectorFrom(GM.F_sparse);
                }
                else
                {
                    al       = Shared_Field.CopyListCC(GM.Test_al);
                    au       = Shared_Field.CopyListCC(GM.Test_au);
                    Size     = GM.Test_Size;
                    F_sparse = Shared_Field.CopyVectorFrom(GM.F_test);
                }



                Solve();
            }
        }
示例#2
0
        public Sparse_MSG_Solver(ref GlobalMatrix _GM)
        {
            F_list = new List <double>(new double[Size]);
            if (InsertedInfo.Sparse && InsertedInfo.Sparse_MSG)
            {
                Console.WriteLine(this.ToString() + " initiated");

                GM = _GM;
                gg = GM.gg;
                fe = GM.fe;
                lm = GM.lm;

                if (!InsertedInfo.Test_another_matrix)
                {
                    Size     = fe.Size;
                    al       = Shared_Field.CopyListCC(GM.al);
                    au       = Shared_Field.CopyListCC(GM.au);
                    F_sparse = Shared_Field.CopyVectorFromToDouble(GM.F_sparse);
                }
                else
                {
                    Size     = GM.Test_Size;
                    al       = Shared_Field.CopyListCC(GM.Test_al);
                    au       = Shared_Field.CopyListCC(GM.Test_au);
                    F_sparse = Shared_Field.CopyVectorFromToDouble(GM.F_test);
                }

                Solve();

                Shared_Field.Save_vector(Answer, "dd84ai_RGR_output_X0_sparse_MSG.txt");
                Shared_Field.Show_three_elements_from_vector(Answer);
            }
        }
        public Dense_Straight_Solver(ref GlobalMatrix _GM)
        {
            F_list = new List <double>(new double[Size]);
            if (InsertedInfo.Dense)
            {
                Console.WriteLine(this.ToString() + " initiated");

                GM = _GM;
                gg = GM.gg;
                fe = GM.fe;
                lm = GM.lm;

                if (InsertedInfo.Test_another_matrix)
                {
                    Size    = GM.Test_Size;
                    A       = Shared_Field.CopyMatrixFrom(GM.Test_dense);
                    F_local = Shared_Field.CopyVectorFrom(GM.F_test);
                }
                else
                {
                    Size    = fe.Size;
                    A       = Shared_Field.CopyMatrixFrom(GM.A_dense);
                    F_local = Shared_Field.CopyVectorFrom(GM.F_dense);
                }

                Solve();

                Shared_Field.Save_vector(Answer, "dd84ai_RGR_output_X0_dense_Straight_LU.txt");
                Shared_Field.Show_three_elements_from_vector(Answer);
            }
        }
示例#4
0
        public New_FEM()
        {
            InsertedInfo II = new InsertedInfo();

            //for (int i = 0; i < DSS.Answer.Count() && i < 6; i++) Console.WriteLine($"F[{i}] = {DSS.Answer[i]}");
            //Console.WriteLine("----------");
            //for (int i = 0; i < SSS.Answer.Count() && i < 6; i++) Console.WriteLine($"F[{i}] = {SSS.Answer[i]}");

            if (!InsertedInfo.Test_another_matrix)
            {
                if (InsertedInfo.Dense)
                {
                    TBF_dense = new Trilinear_Basis_Functions(ref GM, new List <double>(DSS.Answer), II.Points, "dd84ai_DSS_precise_points.txt");
                }
                if (InsertedInfo.Sparse && InsertedInfo.Sparse_Straight)
                {
                    TBF_sparse_straight = new Trilinear_Basis_Functions(ref GM, new List <double>(SSS.Answer), II.Points, "dd84ai_SSS_precise_points.txt");
                    //if (InsertedInfo.Visualisation) TBF_sparse_straight.Visialize(SSS.Answer);
                }
                if (InsertedInfo.Sparse && InsertedInfo.Sparse_MSG)
                {
                    TBF_sparse_MSG = new Trilinear_Basis_Functions(ref GM, new List <double>(SMS.Answer), II.Points, "dd84ai_SMS_precise_points.txt");
                    //if (InsertedInfo.Visualisation) TBF_sparse_MSG.Visialize(SSS.Answer);
                }

                List <double> analitical_answer = new List <double>();
                foreach (var point in II.Points)
                {
                    analitical_answer.Add(InsertedInfo.U_analit(point.x, point.y, point.z));
                }
                Shared_Field.Save_vector(analitical_answer, "dd84ai_AAA.txt");
            }
            Console.Write("");
        }
示例#5
0
        public void ReadAxe(StreamReader inputFile, ref Axe TargetAxe)
        {
            string[] Splitted = Shared_Field.StringSplitter(inputFile);
            TargetAxe.StartPoint = System.Convert.ToDouble(Splitted[0]);
            TargetAxe.Quantity   = System.Convert.ToInt32(Splitted[1]);

            string[] SplittedX                = Shared_Field.StringSplitter(inputFile);
            string[] SplittedStep             = Shared_Field.StringSplitter(inputFile);
            string[] SplittedRazryadka        = Shared_Field.StringSplitter(inputFile);
            string[] SplittedForwardOrBacward = Shared_Field.StringSplitter(inputFile);
            for (int i = 0, end = TargetAxe.Quantity; i < end; i++)
            {
                TargetAxe.x.Add(System.Convert.ToDouble(SplittedX[i]));
                TargetAxe.step_init.Add(System.Convert.ToDouble(SplittedStep[i]));
                TargetAxe.koef_of_razryadka.Add(System.Convert.ToDouble(SplittedRazryadka[i]));

                if (SplittedForwardOrBacward[i] == "1")
                {
                    TargetAxe.ItsForwardOrBackward.Add(true);
                }
                else
                {
                    TargetAxe.ItsForwardOrBackward.Add(false);
                }
            }
        }
示例#6
0
        public void Save_and_Show(List <InsertedInfo.Point3D> Points, string name)
        {
            List <double> Answer = new List <double>();

            foreach (var point in Points)
            {
                Answer.Add(Calculate(point));
            }
            Console.WriteLine(name);
            foreach (var value in Answer)
            {
                Console.WriteLine($"Precise value = {value}");
            }
            Shared_Field.Save_vector(Answer, name);
        }
示例#7
0
        public void reading_sreda()
        {
            string Path = ProjectPath + "\\InsertedInfo\\Environment.txt";

            using (StreamReader inputFile = new StreamReader(Path))
            {
                string Trash = inputFile.ReadLine();
                //Настало время Осей.
                ReadAxe(inputFile, ref AxeX);
                ReadAxe(inputFile, ref AxeY);
                ReadAxe(inputFile, ref AxeZ);

                {
                    Trash = inputFile.ReadLine();
                    string[] Splitted = Shared_Field.StringSplitter(inputFile);
                    AxeX.DoubleToAxe = System.Convert.ToInt32(Splitted[0]);
                    AxeY.DoubleToAxe = System.Convert.ToInt32(Splitted[1]);
                    AxeZ.DoubleToAxe = System.Convert.ToInt32(Splitted[2]);
                }

                Console.WriteLine("Sreda has been read.");
            }
        }
示例#8
0
        /// <summary>
        /// The name is a good give away.
        /// </summary>
        void Constructing_Global_Matrix(ref List <double> X, ref List <double> Y, ref List <double> Z)
        {
            if (InsertedInfo.Dense)
            {
                //Инициализировали сразу нулями.
                A_dense = Shared_Field.Init_matrix(fe.Size);
                F_dense = Shared_Field.Init_vector(fe.Size);
            }
            if (InsertedInfo.Sparse)
            {
                al = new List <List <Shared_Field.coordinate_cell> >(); //Нижний треугольник
                au = new List <List <Shared_Field.coordinate_cell> >(); //Верхний треугольник.
                for (int i = 0; i < fe.Size; i++)
                {
                    al.Add(new List <Shared_Field.coordinate_cell>());
                    au.Add(new List <Shared_Field.coordinate_cell>());
                }
                F_sparse = Shared_Field.Init_vector(fe.Size);
            }
            /// <summary>
            /// Temporal Trash for Global Matrix Constructing
            /// </summary>
            List <List <double> > M   = new List <List <double> >();
            List <List <double> > G   = new List <List <double> >();
            List <double>         b   = new List <double>(new double[8]);
            List <int>            ind = new List <int>(new int[8]);

            for (int i = 0, element_counter = 0; i < X.Count() - 1; i++)
            {
                for (int j = 0; j < Y.Count() - 1; j++)
                {
                    for (int k = 0; k < Z.Count() - 1; k++, element_counter++)
                    {
                        lm.I_desire_to_recieve_M_and_G(ref M, ref G, ref b,
                                                       InsertedInfo.Gamma, InsertedInfo.Lyambda, i, j, k);

                        I_desire_to_recieve_my_indexes(ref ind, i, j, k);

                        if (InsertedInfo.Dense)
                        {
                            for (int h = 0; h < 8; h++)
                            {
                                for (int m = 0; m < 8; m++)
                                {
                                    A_dense[ind[h]][ind[m]] += G[h][m] + M[h][m];
                                }
                            }
                            //F
                            for (int l = 0; l < 8; l++)
                            {
                                F_dense[ind[l]] += b[l];
                            }
                        }
                        if (InsertedInfo.Sparse)
                        {
                            for (int h = 0; h < 8; h++)
                            {
                                for (int m = 0; m < 8; m++)
                                {
                                    if (ind[h] > ind[m])
                                    {
                                        int index = al[ind[h]].FindIndex(x => x.position == ind[m]);
                                        if (index == -1)
                                        {
                                            al[ind[h]].Add(new Shared_Field.coordinate_cell(G[h][m] + M[h][m], ind[m]));
                                        }
                                        else
                                        {
                                            al[ind[h]][index].value += G[h][m] + M[h][m];
                                        }
                                    }
                                    else
                                    {
                                        int index = au[ind[m]].FindIndex(x => x.position == ind[h]);
                                        if (index == -1)
                                        {
                                            au[ind[m]].Add(new Shared_Field.coordinate_cell(G[h][m] + M[h][m], ind[h]));
                                        }
                                        else
                                        {
                                            au[ind[m]][index].value += G[h][m] + M[h][m];
                                        }
                                    }
                                }
                            }

                            for (int l = 0; l < 8; l++)
                            {
                                F_sparse[ind[l]] += b[l];
                            }
                        }
                    }
                }
            }

            if (InsertedInfo.Dense)
            {
                Bounaries_activate_dense();
            }
            if (InsertedInfo.Sparse)
            {
                for (int i = 0; i < fe.Size; i++)
                {
                    al[i] = al[i].OrderBy(x => x.position).ToList();
                    au[i] = au[i].OrderBy(x => x.position).ToList();
                }
                Bounaries_activate_sparse();
            }
        }