コード例 #1
0
        public void applyBoundaryConditions(SymmetricMatrix <MatrixDimension3> globalMatrix, List <Vector3D> rightSide, int[] boundaryConditions)
        {
            int dimension     = globalMatrix.Dimension;
            int boundaryCount = boundaryConditions.Length;
            MatrixDimension3 neitralMatrix = new MatrixDimension3();
            Vector3D         defaultVector = new Vector3D();
            int boundaryInd;

            for (int boundary = 0; boundary < boundaryCount; boundary++)
            {
                for (int column = 0; column < dimension; column++)
                {
                    boundaryInd = boundaryConditions[boundary];
                    if (!boundaryInd.Equals(column))
                    {
                        globalMatrix.setElement(boundaryInd, column, neitralMatrix);
                    }
                    else
                    {
                        globalMatrix[boundaryInd, boundaryInd][0, 1] = 0;
                        globalMatrix[boundaryInd, boundaryInd][0, 2] = 0;
                        globalMatrix[boundaryInd, boundaryInd][1, 2] = 0;
                        globalMatrix[boundaryInd, boundaryInd][1, 0] = 0;
                        globalMatrix[boundaryInd, boundaryInd][2, 0] = 0;
                        globalMatrix[boundaryInd, boundaryInd][2, 1] = 0;
                    }
                    rightSide[boundaryInd] = defaultVector;
                }
            }
        }
コード例 #2
0
        //TODO удалить после тестирования, взято из CholeskySolver
        public static SymmetricMatrix <DoubleContainerElement> extractMatrix(SymmetricMatrix <MatrixDimension3> sourceMatrix)
        {
            int dimension = 3 * sourceMatrix.Dimension;
            SymmetricMatrix <DoubleContainerElement> result = new SymmetricMatrix <DoubleContainerElement>(dimension, new DoubleContainerElement());

            for (int sourceRowInd = 0; sourceRowInd < sourceMatrix.Dimension; sourceRowInd++)
            {
                int rightBound = sourceRowInd + sourceMatrix.getBandWidth() < sourceMatrix.Dimension ? sourceRowInd + sourceMatrix.getBandWidth() : sourceMatrix.Dimension;
                for (int sourceColInd = sourceRowInd; sourceColInd < rightBound; sourceColInd++)
                {
                    // Обрабатываем соответствующий блок
                    MatrixDimension3 block = sourceMatrix[sourceRowInd, sourceColInd];

                    for (int blockRowInd = 0; blockRowInd < 3; blockRowInd++)
                    {
                        for (int blockColInd = sourceRowInd == sourceColInd ? blockRowInd : 0; blockColInd < 3; blockColInd++)
                        {
                            result[sourceRowInd * 3 + blockRowInd, sourceColInd * 3 + blockColInd] = new DoubleContainerElement(block[blockRowInd, blockColInd]);
                        }
                    }
                }
            }

            return(result);
        }
コード例 #3
0
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (!obj.GetType().Equals(typeof(MatrixDimension3)))
            {
                return(false);
            }

            MatrixDimension3 matrix = obj as MatrixDimension3;

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (_elements[i, j] != matrix._elements[i, j])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #4
0
        public IContainerElement getTransposed()
        {
            MatrixDimension3 result = new MatrixDimension3();

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    result[i, j] = _elements[j, i];
                }
            }
            return(result);
        }
コード例 #5
0
        public static MatrixDimension3 operator*(MatrixDimension3 matrix, double value)
        {
            MatrixDimension3 result = new MatrixDimension3();

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    result[i, j] = matrix[i, j] * value;
                }
            }

            return(result);
        }
コード例 #6
0
        public static MatrixDimension3 getFromMatrix(Matrix matrix)
        {
            if ((matrix.RowsCount != 3) || (matrix.ColumnsCount != 3))
            {
                return(null);
            }
            MatrixDimension3 result = new MatrixDimension3();

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    result[i, j] = matrix[i, j];
                }
            }
            return(result);
        }
コード例 #7
0
        public MatrixDimension3 subtractionMatrix(MatrixDimension3 matrix)
        {
            if (matrix == null)
            {
                return(null);
            }

            MatrixDimension3 result = new MatrixDimension3();

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    result[i, j] = _elements[i, j] - matrix[i, j];
                }
            }
            return(result);
        }
コード例 #8
0
        private void createMatrKE(Element element, SymmetricMatrix <MatrixDimension3> matr, Matrix matrixD)
        {
            //----TODO: remove------
            Matrix bigMatrix = new Matrix(12, 12);

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

            double v = 1 / (36 * element.volume);

            for (int r = 0; r < 4; r++)
            {
                for (int s = r; s < 4; s++)
                {
                    Node   rNode  = getNodeByIndex(element, r);
                    Matrix matrBr = transpose(createMatrB(rNode));

                    Node   sNode  = getNodeByIndex(element, s);
                    Matrix matrBs = createMatrB(sNode);

                    //TODO: rename
                    var buf = MatrixDimension3.getFromMatrix(matrBr * matrixD * matrBs) * v;

                    for (int rowNum = 0; rowNum < 2; rowNum++)
                    {
                        for (int colNum = 0; colNum < 2; colNum++)
                        {
                            bigMatrix[3 * r + rowNum, 3 * s + colNum] = buf[rowNum, colNum];

                            if (r != s)
                            {
                                bigMatrix[3 * s + colNum, 3 * r + rowNum] = bigMatrix[3 * r + rowNum, 3 * s + colNum];
                            }
                        }
                    }

                    matr[rNode.id, sNode.id] = matr[rNode.id, sNode.id] + buf; //(rNode.id > sNode.id ? (MatrixDimension3) buf.getTransposed() : buf);
                }
            }
            //bigMatrix.printToFile("C:\\Data\\university\\master_1_year\\NM\\nm-lab-mag\\files\\resBlock.txt");
        }