예제 #1
0
파일: Quad8.cs 프로젝트: kostas91m/GFEC
        public double[,] CreateMassMatrix()
        {
            double[,] M = new double[16, 16];
            double Mtot = new double();

            //double scalar = 28.24;
            //double[,] M = MatrixOperations.CreateDiagonalMatrix(8, scalar);

            double[,] consinstentMass = new double[16, 16];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    double[] gP = GaussPoints(i, j).Item1;
                    double[] gW = GaussPoints(i, j).Item2;
                    Dictionary <string, double[]> localdN = CalculateShapeFunctionsLocalDerivatives(gP);
                    double[,] J = CalculateJacobian(localdN);
                    double detJ = CalculateInverseJacobian(J).Item2;
                    double[,] Nmatrix = CalculateShapeFunctionMatrix(gP[0], gP[1]);
                    consinstentMass   = MatrixOperations.MatrixAddition(consinstentMass, MatrixOperations.ScalarMatrixProductNew(Properties.Density * Properties.Thickness * detJ * gW[0] * gW[1],
                                                                                                                                 MatrixOperations.MatrixProduct(MatrixOperations.Transpose(Nmatrix), Nmatrix)));
                    Mtot += Properties.Density * Properties.Thickness * detJ * gW[0] * gW[1];
                }
            }
            double c = Mtot / MatrixOperations.Trace(consinstentMass);

            //M = consinstentMass;
            for (int i = 0; i <= 15; i++)
            {
                M[i, i] = c * consinstentMass[i, i];
            }
            //for (int i = 0; i <= 15; i++)
            //{
            //    for (int j = 0; j <= 15; j++)
            //    {
            //        M[i, i] += Math.Abs(consinstentMass[i, j]);
            //    }
            //}
            //-------------------------------------------------------------------
            //double[,] tempM = MatrixOperations.CreateDiagonalMatrix(8, 1.0);
            //double length = 0.3;
            //double scalar = Properties.Density * Properties.Thickness * length * (length / 3.0) / 4.0;
            //double[,] M = MatrixOperations.ScalarMatrixProductNew(scalar, tempM);

            //double waveSpeed = Math.Sqrt(Properties.YoungMod / Properties.Density);
            //double deltatCritical = length * Math.Sqrt(1.0 - 0.33) / waveSpeed;


            //--------------------------------------------------------------
            //for (int i = 0; i < 2; i++)
            //{
            //    for (int j = 0; j < 2; j++)
            //    {
            //        double[] gP = GaussPoints(i, j).Item1;
            //        double[] gW = GaussPoints(i, j).Item2;
            //        Dictionary<string, double[]> localdN = CalculateShapeFunctionsLocalDerivatives(gP);
            //        double[,] J = CalculateJacobian(localdN);
            //        double[,] invJ = CalculateInverseJacobian(J).Item1;
            //        double detJ = CalculateInverseJacobian(J).Item2;
            //        double[,] Nmatrix = CalculateShapeFunctionMatrix(gP[i], gP[j]);
            //        M = MatrixOperations.MatrixAddition(M, MatrixOperations.ScalarMatrixProductNew(Properties.Density * Properties.Thickness * detJ * gW[i] * gW[j],
            //            MatrixOperations.MatrixProduct(MatrixOperations.Transpose(Nmatrix), Nmatrix)));
            //    }
            //}

            //--------------------------------------------------------

            //for (int i = 0; i < 8; i++)
            //{
            //    M[i, i] = 4.0;
            //}

            //for (int i = 0; i < 6; i++)
            //{
            //    M[i, i + 2] = 2.0;
            //    M[i + 2, i] = 2.0;
            //}

            //for (int i = 0; i < 4; i++)
            //{
            //    M[i, i + 4] = 1.0;
            //    M[i + 4, i] = 1.0;
            //}

            //for (int i = 0; i < 2; i++)
            //{
            //    M[i, i + 6] = 2.0;
            //    M[i + 6, i] = 2.0;
            //}

            //M = MatrixOperations.ScalarMatrixProductNew(0.67 * 0.8 * Properties.Density * Properties.Thickness / 32, M);
            //MatrixOperations.PrintMatrix(M);

            return(M);
        }