Exemplo n.º 1
0
        private Matrix AddValuesToFilesAndGetResult(FEMSolver.FEMSolver fem, double[] squareTriangles, double[][] lengthSegments, Triangle[] triangles, int[][,] segments)
        {
            String InfoMatrices = MatricesAreaToString(fem.Me(), "M", squareTriangles, triangles);

            InfoMatrices += MatricesAreaToString(fem.Qe(), "Q", squareTriangles, triangles);
            InfoMatrices += MatricesAreaToString(fem.Ke(), "K", squareTriangles, triangles);
            InfoMatrices += MatricesBoundaryToString(fem.Re(), "R", lengthSegments, segments);
            InfoMatrices += MatricesBoundaryToString(fem.Pe(), "P", lengthSegments, segments);

            var A = fem.FEMContext.A;
            var b = fem.FEMContext.B;

            var result = fem.FEMContext.X;

            InfoMatrices += MatrixToString(A, "Matrix A");
            InfoMatrices += MatrixToString(b, "Vector B");



            InfoMatrices += MatrixToString(result, "Vector U");

            File.WriteAllText("Result.txt", InfoMatrices);

            return(result);
        }
Exemplo n.º 2
0
        private void FormationMatrix(TriangleNetHandler triangleNetHandler, List <Point> points, Canvas canvas, Equation equation)
        {
            ///////////FEM

            var dataInitializer = new DataInitializer(TriangleNetHandler, points, equation);

            var femContext = dataInitializer.GetInitialData();

            fem = new FEMSolver.FEMSolver(femContext);

            var errorSolver = new ErrorSolver(femContext, TriangleNetHandler, points, equation);

            var errorsContext = new ErrorContext
            {
                ErrorL2         = errorSolver.NormaErrorL2(Functions.U, femContext),
                ErrorW2         = errorSolver.NormaErrorW2(Functions.U, Functions.DU, femContext),
                NormL2          = errorSolver.NormaL2(femContext),
                NormW2          = errorSolver.NormaW2(femContext),
                pL2             = errorSolver.PL2(),
                pW2             = errorSolver.PW2(),
                pAitkenL2       = errorSolver.PAitkenL2(),
                pAitkenW2       = errorSolver.PAitkenW2(),
                TrianglesNumber = femContext.Data.NT.Length
            };

            errorContextForGrid.Add(errorsContext);

            ErrorGrid.ItemsSource = from v in errorContextForGrid
                                    select
                                    new
            {
                v.TrianglesNumber,
                v.NormL2,
                v.NormW2,
                v.ErrorL2,
                v.ErrorW2,
                v.pL2,
                v.pW2,
                v.pAitkenL2,
                v.pAitkenW2
            };

            // DrawInMatlab(x1, x2, z);
        }