Exemplo n.º 1
0
        static void Main(string[] args)
        {
            InputModelArgs model = new InputModelArgs();

            model.Shape.L = 1;
            model.Shape.H = 0.1;
            model.Material.AutoiFillE(40000);
            model.Material.AutoFillV(0.3);
            model.Material.AutoFillG();
            model.Boundary = BoundaryConditions.FixedLeftSide;
            model.Load     = 2752.4039476340849;
            FEMSolver solver = new FEMSolver(model);

            int iter;

            Result result = solver.SolvePDE(30, 6, 0.001, out iter);

            AnaliticalOneSideFixed analitical = new AnaliticalOneSideFixed(model);

            using (StreamWriter sw = new StreamWriter("ResultU1.txt"))
            {
                foreach (Node node in solver.Mesh.MiddleNodes)
                {
                    Vector alfa = new Vector(3);
                    alfa[0] = node.X;
                    alfa[2] = node.Y;
                    sw.WriteLine(node.X.ToString() + " " + solver.U[2 * node.Index].ToString("0.00000") + "\t" + analitical.U(alfa)[0].ToString("0.00000"));
                }
                sw.Close();
            }



            using (StreamWriter sw = new StreamWriter("ResultU3.txt"))
            {
                foreach (Node node in solver.Mesh.MiddleNodes)
                {
                    Vector alfa = new Vector(3);
                    alfa[0] = node.X;
                    alfa[2] = node.Y;
                    sw.WriteLine(node.X.ToString() + "\t" + result.U[2 * node.Index + 1].ToString("0.00000") + "\t" + analitical.U(alfa)[2].ToString("0.00000"));
                }
                sw.Close();
            }
            Console.WriteLine("Ітерацій: " + iter.ToString());
            Console.WriteLine("Files Filed");
            Console.Read();
        }
        public void Solve()
        {
            IsSolved = false;
            Model.Material.AutoFillG();
            if (Model.Boundary == BoundaryConditions.FixedLeftSide)
            {
                analitical = new AnaliticalOneSideFixed(Model);
            }
            else
            {
                double sigma = Model.Load;

                analitical = new AnaliticalTwoSidesFixed(Model, sigma);
                Model.Load = (-1) * ((AnaliticalTwoSidesFixed)analitical).CountLoad();
            }

            FEMSolver solver = new FEMSolver(Model);

            int iter;

            Result result = solver.SolvePDE(LN, HN, Accuracy, out iter);

            Results.Clear();
            foreach (Node node in solver.Mesh.MiddleNodes)
            {
                Vector alfa = new Vector(3);
                alfa[0] = node.X;
                alfa[2] = node.Y;
                ResultItem resultItem = new ResultItem();
                resultItem.Alfa1        = node.X;
                resultItem.U1Numeric    = result.U[2 * node.Index];
                resultItem.U1Analitical = analitical.U(alfa)[0];

                resultItem.U3Numeric    = result.U[2 * node.Index + 1];
                resultItem.U3Analitical = analitical.U(alfa)[2];

                Results.Add(resultItem);
            }


            NonlinearResult = getNonlinearDrawREsult(result, solver);
            LinearResult    = getlinearDrawREsult(solver);
            AxesData        = getAxesData(Model);

            IsSolved = true;
        }