Exemple #1
0
        public double[] CreateInternalGlobalForcesVector()
        {
            int nodesNumber = Properties.MasterSegmentPolynomialDegree + Properties.SlaveSegmentPolynomialDegree + 2;

            double[] internalGlobalForcesVector = new double[2 * nodesNumber];
            for (int i = 0; i < Properties.IntegrationPoints; i++)
            {
                double ksi2 = GaussPoints(i).Item1;
                double gW   = GaussPoints(i).Item2;
                double ksi1 = Project(0.0, ksi2);
                if (Math.Abs(ksi1) <= 1.05)
                {
                    Tuple <double[, ], double[, ], double[, ], double[, ], double[, ]> positionMatrices = CalculatePositionMatrix(ksi1, ksi2);
                    double[,] aMatrix   = positionMatrices.Item1;
                    double[,] daMatrix  = positionMatrices.Item2;
                    double[,] da2Matrix = positionMatrices.Item3;

                    Tuple <double[], double, double[], double[], double> surfaceCharacteristics = MasterSegmentGeometry(daMatrix, da2Matrix);
                    double[] n    = surfaceCharacteristics.Item3;
                    double   ksi3 = CalculatePenetration(aMatrix, n);
                    if (ksi3 <= 0)
                    {
                        double slaveMetricTensor = SlaveSegmentGeometry(positionMatrices.Item4, positionMatrices.Item5).Item2;
                        double scalar            = Math.Pow(slaveMetricTensor, 0.5) * gW;
                        double[,] AT = MatrixOperations.Transpose(aMatrix);
                        double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n);
                        double[] internalLocalForcesVector = VectorOperations.VectorScalarProductNew(VectorOperations.VectorScalarProductNew(AT_n, PenaltyFactor * ksi3), scalar);
                        internalGlobalForcesVector = VectorOperations.VectorVectorAddition(internalGlobalForcesVector, internalLocalForcesVector);
                    }
                }
            }
            return(internalGlobalForcesVector);
        }
Exemple #2
0
        public double[] CreateInternalGlobalForcesVector()
        {
            double[] F = new double[8];
            double[,] E = CalculateStressStrainMatrix(Properties.YoungMod, 0.30); //needs fixing in poisson v

            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;
                    Dictionary <int, double[]> globaldN = CalculateShapeFunctionsGlobalDerivatives(localdN, invJ);
                    double[,] B = CalculateBMatrix(globaldN);
                    double[] strainVector = CalculateStrainsVector(B);
                    double[] stressVector = CalculateStressVector(E, strainVector);
                    F = VectorOperations.VectorVectorAddition(F, VectorOperations.VectorScalarProductNew(
                                                                  VectorOperations.MatrixVectorProduct(MatrixOperations.Transpose(B), stressVector), detJ * gW[0] * gW[1] * Properties.Thickness));
                }
            }
            return(F);
        }
Exemple #3
0
        public double[] CreateInternalGlobalForcesVector()
        {
            double ksi1 = ClosestPointProjection();

            if (Math.Abs(ksi1) <= 1.05)
            {
                Tuple <double[, ], double[, ]> positionMatrices = CalculatePositionMatrix(ksi1);
                double[,] aMatrix  = positionMatrices.Item1;
                double[,] daMatrix = positionMatrices.Item2;

                Tuple <double[], double, double[]> surfaceCharacteristics = SurfaceGeometry(daMatrix);
                double   m11  = surfaceCharacteristics.Item2;
                double[] n    = surfaceCharacteristics.Item3;
                double   ksi3 = CalculateNormalGap(aMatrix, n);
                if (ksi3 <= 0)
                {
                    double[,] AT = MatrixOperations.Transpose(aMatrix);
                    double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n);
                    double[] internalGlobalForcesVector = VectorOperations.VectorScalarProductNew(AT_n, PenaltyFactor * ksi3);
                    return(internalGlobalForcesVector);
                }
                else
                {
                    double[] internalGlobalForcesVector = new double[6];
                    return(internalGlobalForcesVector);
                }
            }
            else
            {
                double[] internalGlobalForcesVector = new double[6];
                return(internalGlobalForcesVector);
            }
        }
        private Tuple <double[], double, double[], double[], double> MasterSegmentGeometry(double[,] daMatrix, double[,] da2Matrix)
        {
            double Xm1 = Nodes[1].XCoordinate + DisplacementVector[0];
            double Ym1 = Nodes[1].YCoordinate + DisplacementVector[1];
            double Xm2 = Nodes[2].XCoordinate + DisplacementVector[2];
            double Ym2 = Nodes[2].YCoordinate + DisplacementVector[3];
            double Xm3 = Nodes[3].XCoordinate + DisplacementVector[4];
            double Ym3 = Nodes[3].YCoordinate + DisplacementVector[5];
            double Xs  = Nodes[4].XCoordinate + DisplacementVector[6];
            double Ys  = Nodes[4].YCoordinate + DisplacementVector[7];

            double[] xupd                    = new double[] { -Xm1, -Ym1, -Xm2, -Ym2, -Xm3, -Ym3, -Xs, -Ys };
            double[] surfaceVector           = VectorOperations.MatrixVectorProduct(daMatrix, xupd);
            double[] surfaceVectorDerivative = VectorOperations.MatrixVectorProduct(da2Matrix, xupd);

            double detm = VectorOperations.VectorDotProduct(surfaceVector, surfaceVector);
            double m11  = 1.0 / detm;

            double[] vector     = new double[] { -surfaceVector[1], surfaceVector[0] };
            double   scalarCoef = 1.0 / (Math.Sqrt(detm));

            double[] normalUnitVec   = VectorOperations.VectorScalarProductNew(vector, scalarCoef);
            double[] tangentVector   = VectorOperations.VectorScalarProductNew(surfaceVector, scalarCoef);
            double   scalarCoef2     = Math.Pow(m11, 2.0);
            double   curvatureTensor = scalarCoef2 * VectorOperations.VectorDotProduct(surfaceVectorDerivative, normalUnitVec);

            return(new Tuple <double[], double, double[], double[], double>(surfaceVector, m11, normalUnitVec, tangentVector, curvatureTensor));
        }
Exemple #5
0
        public double[] CreateInternalGlobalForcesVector()
        {
            double[] ksiVector = Project(new double[2]);
            if (Math.Abs(ksiVector[0]) <= 1.05 && ksiVector[1] <= 1.05)
            {
                Tuple <double[, ], double[, ], double[, ]> aMatrices = CalculatePositionMatrix(ksiVector[0], ksiVector[1]);
                List <double[]> dRho = SurfaceVectors(ksiVector[0], ksiVector[1]);
                double[,] m = MetricTensor(dRho);
                double[] n        = NormalVector(m, dRho);
                double[] xUpdated = xUpdatedVector();
                double   ksi3     = CalculatePenetration(n, aMatrices.Item1, xUpdated);

                if (ksi3 <= 0)
                {
                    double[,] AT = MatrixOperations.Transpose(aMatrices.Item1);
                    double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n);
                    double[] internalGlobalForcesVector = VectorOperations.VectorScalarProductNew(AT_n, PenaltyFactor * ksi3);
                    return(internalGlobalForcesVector);
                }
                else
                {
                    return(new double[15]);
                }
            }
            else
            {
                return(new double[15]);
            }
        }
Exemple #6
0
        public double[] CreateInternalGlobalForcesVector()
        {
            double penetration = CalculateNormalGap();

            if (penetration <= 0)
            {
                double[,] A  = CalculatePositionMatrix();
                double[,] AT = MatrixOperations.Transpose(A);
                double[] n                    = CalculateNormalUnitVector();
                double[] t                    = CalculateTangentUnitVector();
                double[] AT_n                 = VectorOperations.MatrixVectorProduct(AT, n);
                double[] AT_t                 = VectorOperations.MatrixVectorProduct(AT, t);
                double   ksi                  = CalculateNormalGap();
                double   Tr                   = CalculateTangentialTraction();
                double[] ksi_AT_n             = VectorOperations.VectorScalarProductNew(AT_n, ksi);
                double[] e_ksi_AT_n           = VectorOperations.VectorScalarProductNew(ksi_AT_n, PenaltyFactor);
                double[] Tr_AT_t              = VectorOperations.VectorScalarProductNew(AT_t, Tr);
                double[] internalForcesvector = VectorOperations.VectorVectorAddition(e_ksi_AT_n, Tr_AT_t);
                return(internalForcesvector);
            }
            else
            {
                double[] internalGlobalForcesVector = new double[4];
                return(internalGlobalForcesVector);
            }
        }
Exemple #7
0
 private double[] PCG(double[,] stiffnessMatrix, double[] forceVector)
 {
     double[] solutionVector = new double[forceVector.Length];
     double[,] preconditioner = new double[stiffnessMatrix.GetLength(0), stiffnessMatrix.GetLength(1)];
     for (int i = 0; i < preconditioner.GetLength(0); i++)
     {
         preconditioner[i, i] = 1 / stiffnessMatrix[i, i];
     }
     double[] residual = VectorOperations.VectorVectorSubtraction(
         forceVector,
         VectorOperations.MatrixVectorProduct(stiffnessMatrix, solutionVector)
         );
     double[] preconVector = VectorOperations.MatrixVectorProduct(preconditioner, residual);
     for (int iter = 0; iter < maxIterations; iter++)
     {
         double[] u = VectorOperations.MatrixVectorProduct(stiffnessMatrix, preconVector);
         double   residualDotOld = VectorOperations.VectorDotProduct(residual, preconVector);
         double   alpha          = residualDotOld / VectorOperations.VectorDotProduct(preconVector, u);
         solutionVector = VectorOperations.VectorVectorAddition(solutionVector, VectorOperations.VectorScalarProductNew(preconVector, alpha));
         residual       = VectorOperations.VectorVectorSubtraction(residual, VectorOperations.VectorScalarProductNew(u, alpha));
         if (VectorOperations.VectorDotProduct(residual, residual) < tolerance)
         {
             break;
         }
         double residualDotNew = VectorOperations.VectorDotProduct(residual, VectorOperations.MatrixVectorProduct(preconditioner, residual));
         double beta           = residualDotNew / residualDotOld;
         preconVector = VectorOperations.VectorVectorAddition(
             VectorOperations.MatrixVectorProduct(preconditioner, residual),
             VectorOperations.VectorScalarProductNew(preconVector, beta)
             );
     }
     return(solutionVector);
 }
Exemple #8
0
        public void RunExample()
        {
            double[,] matrix1 = MatrixOperations.CreateRandomMatrix(2000, 2000);
            double[,] matrix2 = MatrixOperations.CreateRandomMatrix(2000, 2000);
            double[] vector1 = VectorOperations.CreateRandomVector(2000);
            double[,] result1, result2, result1b, result2b;
            double[] result1c, result2c;
            double   result1d, result2d;

            MatrixOperations.ParallelCalculations = false;
            Stopwatch watch1 = Stopwatch.StartNew();

            result1  = MatrixOperations.MatrixAddition(matrix1, matrix2);
            result1b = MatrixOperations.MatrixProduct(matrix1, matrix2);
            result1c = VectorOperations.MatrixVectorProduct(result1b, vector1);
            result1d = VectorOperations.VectorNorm2(result1c);
            long first = watch1.ElapsedMilliseconds;

            MatrixOperations.ParallelCalculations = true;
            Stopwatch watch2 = Stopwatch.StartNew();

            result2  = MatrixOperations.MatrixAddition(matrix1, matrix2);
            result2b = MatrixOperations.MatrixProduct(matrix1, matrix2);
            //result2 = MatrixOperations.TempVariable;
            result2c = VectorOperations.MatrixVectorProduct(result2b, vector1);
            result2d = VectorOperations.VectorNorm2(result2c);
            long second = watch2.ElapsedMilliseconds;

            string timeForCalculations = "Elapsed time for single threaded operation: " + first.ToString() + " -Result is:" + result1d + "\n" + "Elapsed time for multithreaded operation: " + second.ToString() + " -Result is:" + result2d;

            OnTimeElapsed(timeForCalculations);
        }
        private double Project(double ksi1Initial)
        {
            int    maxIterations = 1000;
            double tol           = Math.Pow(10.0, -6.0);
            double deltaKsi      = 0.0;
            double ksi           = ksi1Initial;

            double[] xUpdated = NodalXUpdated();
            for (int i = 1; i <= maxIterations; i++)
            {
                Tuple <double[, ], double[, ], double[, ]> aMatrices = CalculatePositionMatrix(ksi);
                //double[] slavePositionVector = new double[] { xUpdated[6], xUpdated[7] };
                double[] masterSlaveRelativeVector = VectorOperations.MatrixVectorProduct(aMatrices.Item1, xUpdated);
                double[] surfaceVector             = VectorOperations.VectorScalarProduct(VectorOperations.MatrixVectorProduct(aMatrices.Item2, xUpdated), -1);
                double[] surfaceVectorDerivative   = VectorOperations.VectorScalarProduct(VectorOperations.MatrixVectorProduct(aMatrices.Item3, xUpdated), -1);

                deltaKsi = CalculateDeltaKsi(masterSlaveRelativeVector, surfaceVector, surfaceVectorDerivative);
                ksi     += deltaKsi;
                if (Math.Abs(deltaKsi) <= tol)
                {
                    break;
                }
            }
            if (Math.Abs(deltaKsi) > tol)
            {
                throw new Exception("CPP not found in current iterations");
            }
            else
            {
                return(ksi);
            }
        }
Exemple #10
0
        public double[] CreateInternalGlobalForcesVector()
        {
            double[] fInt = new double[24];
            double[,] E = CalculateStressStrainMatrix(Properties.YoungMod, Properties.PoissonRatio);

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        double[] gP = GaussPoints(i, j, k).Item1;
                        double[] gW = GaussPoints(i, j, k).Item2;
                        Dictionary <string, double[]> localdN = CalculateShapeFunctionsLocalDerivatives(gP);
                        double[,] J    = CalculateJacobian(localdN);
                        double[,] invJ = CalculateInverseJacobian(J).Item1;
                        double detJ = CalculateInverseJacobian(J).Item2;
                        Dictionary <int, double[]> globaldN = CalculateShapeFunctionsGlobalDerivatives(localdN, invJ);
                        double[,] B = CalculateBMatrix(globaldN);
                        double[] strainVector = CalculateStrainsVector(B);
                        double[] stressVector = CalculateStressVector(E, strainVector);
                        fInt = VectorOperations.VectorVectorAddition(fInt, VectorOperations.VectorScalarProductNew(
                                                                         VectorOperations.MatrixVectorProduct(MatrixOperations.Transpose(B), stressVector), detJ * gW[0] * gW[1] * gW[2]));
                    }
                }
            }

            //double[,] Kstiff = CreateGlobalStiffnessMatrix();
            //double[] uDisp = DisplacementVector;
            //double[] fInt = VectorOperations.MatrixVectorProduct(Kstiff, uDisp);
            //fInt = VectorOperations.VectorScalarProductNew(fInt, 1.0);
            return(fInt);
        }
Exemple #11
0
        private double CalculatePenetration(double[] normalVector, double[,] aMatrix, double[] xUpdated)
        {
            double ksi3 = VectorOperations.VectorDotProduct(
                xUpdated, VectorOperations.MatrixVectorProduct(
                    MatrixOperations.Transpose(aMatrix), normalVector));

            return(ksi3);
        }
Exemple #12
0
        private double CalculatePenetration(double[,] aMatrix, double[] n)
        {
            double[,] AT = MatrixOperations.Transpose(aMatrix);
            double[] AT_n      = VectorOperations.MatrixVectorProduct(AT, n);
            double[] xupd      = NodalXUpdated();
            double   normalGap = VectorOperations.VectorDotProduct(xupd, AT_n);

            return(normalGap);
        }
Exemple #13
0
        public double[] CreateInternalGlobalForcesVector()
        {
            double[] intForces;
            double[,] stiff = CreateGlobalStiffnessMatrix();

            intForces = VectorOperations.MatrixVectorProduct(stiff, DisplacementVector);
            intForces = VectorOperations.VectorScalarProductNew(intForces, 1.0);
            return(intForces);
        }
Exemple #14
0
        private double[] BiCGSTAB(double[,] stiffnessMatrix, double[] forceVector)
        {
            double[] solutionVector = new double[forceVector.Length];

            double[] xVector = new double[forceVector.Length];
            double[] pVector = new double[forceVector.Length];
            double[] vVector = new double[forceVector.Length];

            double[,] K = stiffnessMatrix;

            double[] bVector     = forceVector;
            double[] rVector     = VectorOperations.VectorVectorSubtraction(bVector, VectorOperations.MatrixVectorProduct(K, xVector));
            double[] r0hatVector = rVector;

            double rho0 = 1.0;
            double w    = 1.0;
            double a    = 1.0;
            double rho1 = VectorOperations.VectorDotProduct(r0hatVector, rVector);
            double b;

            double[] sVector;
            double[] tVector;
            int      iters = 100;
            double   converged;

            for (int i = 0; i < iters; i++)
            {
                b       = (rho1 / rho0) * (a / w);
                pVector = VectorOperations.VectorVectorAddition(rVector,
                                                                VectorOperations.VectorScalarProductNew(
                                                                    VectorOperations.VectorVectorSubtraction(pVector,
                                                                                                             VectorOperations.VectorScalarProductNew(vVector, w)), b));
                vVector = VectorOperations.MatrixVectorProduct(K, pVector);
                a       = rho1 / VectorOperations.VectorDotProduct(r0hatVector, vVector);
                sVector = VectorOperations.VectorVectorSubtraction(rVector,
                                                                   VectorOperations.VectorScalarProductNew(vVector, a));
                tVector = VectorOperations.MatrixVectorProduct(K, sVector);
                w       = VectorOperations.VectorDotProduct(tVector, sVector) / VectorOperations.VectorDotProduct(tVector, tVector);
                rho0    = rho1;
                rho1    = -w *VectorOperations.VectorDotProduct(r0hatVector, tVector);

                xVector = VectorOperations.VectorVectorAddition(xVector,
                                                                VectorOperations.VectorScalarProductNew(pVector, a));
                xVector = VectorOperations.VectorVectorAddition(xVector,
                                                                VectorOperations.VectorScalarProductNew(sVector, w));
                rVector = VectorOperations.VectorVectorSubtraction(sVector,
                                                                   VectorOperations.VectorScalarProductNew(tVector, w));
                converged = VectorOperations.VectorNorm2(rVector);
                if (i == iters | converged < 0.00000001)
                {
                    break;
                }
            }
            solutionVector = xVector;
            return(solutionVector);
        }
Exemple #15
0
 private double[] Calculate_f(List <double[]> dRho, double[,] aMatrix, double[] xUpdated)
 {
     double[] f = new double[2];
     f[0] = VectorOperations.VectorDotProduct(
         dRho[0], VectorOperations.MatrixVectorProduct(
             aMatrix, xUpdated));
     f[1] = VectorOperations.VectorDotProduct(
         dRho[1], VectorOperations.MatrixVectorProduct(
             aMatrix, xUpdated));
     return(f);
 }
Exemple #16
0
        private double[] CalculateHatRVector(int i)
        {
            double[,] hatKMatrix = CalculateHatKMatrix();
            double[,] hatMMatrix = CalculateHatMMatrix();
            double[] hatCurrentU  = VectorOperations.MatrixVectorProduct(hatKMatrix, explicitSolution[i - 1]);
            double[] hatPreviousU = VectorOperations.MatrixVectorProduct(hatMMatrix, explicitSolution[i - 2]);

            double[] hatR = VectorOperations.VectorVectorSubtraction(ExternalForcesVector,
                                                                     VectorOperations.VectorVectorAddition(hatCurrentU, hatPreviousU));
            return(hatR);
        }
Exemple #17
0
        private double CalculateTangentialTraction()
        {
            double[,] A  = CalculatePositionMatrix();
            double[,] AT = MatrixOperations.Transpose(A);
            double[] displacementVector = DisplacementVector;
            double[] tangentUnitvector  = CalculateTangentUnitVector();
            double[] aT_t               = VectorOperations.MatrixVectorProduct(AT, tangentUnitvector);
            double   tangentGap         = VectorOperations.VectorDotProduct(displacementVector, aT_t);
            double   tangentialTraction = -PenaltyFactor * tangentGap;

            return(tangentialTraction);
        }
Exemple #18
0
        private Dictionary <int, double[]> CalculateShapeFunctionsGlobalDerivatives(Dictionary <string, double[]> dN, double[,] Jinv)
        {
            Dictionary <int, double[]> dNg = new Dictionary <int, double[]>();

            for (int i = 0; i < 8; i++)
            {
                double[] dNlocal  = new double[] { dN["ksi"][i], dN["ihta"][i], dN["mhi"][i] };
                double[] dNglobal = VectorOperations.MatrixVectorProduct(Jinv, dNlocal);
                dNg.Add(i, dNglobal);
            }
            return(dNg);
        }
Exemple #19
0
        private double Calculate_e(double[,] aMatrix, double[] xUpdated)
        {
            double[] dRho12 = new double[] {
                0.25 * (xUpdated[0] - xUpdated[3] + xUpdated[6] - xUpdated[9]),
                0.25 * (xUpdated[1] - xUpdated[4] + xUpdated[7] - xUpdated[10]),
                0.25 * (xUpdated[2] - xUpdated[5] + xUpdated[8] - xUpdated[11])
            };

            double e = VectorOperations.VectorDotProduct(
                dRho12, VectorOperations.MatrixVectorProduct(
                    aMatrix, xUpdated));

            return(e);
        }
Exemple #20
0
        private double CalculateNormalGap(double[,] aMatrix, double[] n)
        {
            double[,] AT = MatrixOperations.Transpose(aMatrix);
            double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n);
            double[] xupd = new double[] {
                Nodes[1].XCoordinate + DisplacementVector[0],
                Nodes[1].YCoordinate + DisplacementVector[1],
                Nodes[2].XCoordinate + DisplacementVector[2],
                Nodes[2].YCoordinate + DisplacementVector[3],
                Nodes[3].XCoordinate + DisplacementVector[4],
                Nodes[3].YCoordinate + DisplacementVector[5]
            };
            double normalGap = VectorOperations.VectorDotProduct(xupd, AT_n);

            return(normalGap);
        }
Exemple #21
0
        private double CalculateNormalGap()
        {
            double[,] A  = CalculatePositionMatrix();
            double[,] AT = MatrixOperations.Transpose(A);
            double[] n    = CalculateNormalUnitVector();
            double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n);
            double[] xupd = new double[] {
                Nodes[1].XCoordinate + DisplacementVector[0],
                Nodes[1].YCoordinate + DisplacementVector[1],
                Nodes[2].XCoordinate + DisplacementVector[2],
                Nodes[2].YCoordinate + DisplacementVector[3]
            };
            double normalGap = VectorOperations.VectorDotProduct(xupd, AT_n);

            return(normalGap);
        }
Exemple #22
0
        public List <double[]> GetGaussPointsInPhysicalSpace()
        {
            List <double[]> gaussPoints = new List <double[]>();

            double[] xUpdated = UpdateNodalCoordinates(DisplacementVector);
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    double[] gP         = GaussPoints(i, j).Item1;
                    double[] gaussPoint = VectorOperations.MatrixVectorProduct(CalculateShapeFunctionMatrix(gP[0], gP[1]), xUpdated);
                    gaussPoints.Add(gaussPoint);
                }
            }
            return(gaussPoints);
        }
Exemple #23
0
        private double[] CalculateDeltaKsi(double detm, double[,] mTensor, double[] fVector, double e)
        {
            double scalar = 1.0 / (detm - Math.Pow(e, 2) + 2.0 * e * mTensor[0, 1]);

            double[,] matrix = new double[, ]
            {
                { mTensor[1, 1], e - mTensor[0, 1] },
                { e - mTensor[1, 0], mTensor[0, 0] }
            };

            double[] deltaKsi = VectorOperations.VectorScalarProductNew(
                VectorOperations.MatrixVectorProduct(matrix, fVector),
                scalar);

            return(deltaKsi);
        }
Exemple #24
0
        private List <double[]> SurfaceVectors(double ksi1, double ksi2)
        {
            Tuple <double[, ], double[, ], double[, ]> positionsMatrices = CalculatePositionMatrix(ksi1, ksi2);

            double[,] da1 = positionsMatrices.Item2;
            double[,] da2 = positionsMatrices.Item3;
            double[] xUpdated = xUpdatedVector();

            List <double[]> dRho = new List <double[]>();

            dRho.Add(VectorOperations.VectorScalarProductNew(
                         VectorOperations.MatrixVectorProduct(da1, xUpdated), -1.0));
            dRho.Add(VectorOperations.VectorScalarProductNew(
                         VectorOperations.MatrixVectorProduct(da2, xUpdated), -1.0));
            return(dRho);
        }
Exemple #25
0
        private double CalculatePenetration(double ksi1, double ksi2)
        {
            double[]        xUpdated = xUpdatedVector();
            List <double[]> dRho     = SurfaceVectors(ksi1, ksi2);

            double[,] m = MetricTensor(dRho);
            double[] n = NormalVector(m, dRho);
            Tuple <double[, ], double[, ], double[, ]> aMatrices = CalculatePositionMatrix(ksi1, ksi2);

            double[,] a  = aMatrices.Item1;
            double[,] aT = MatrixOperations.Transpose(a);
            double ksi3 = VectorOperations.VectorDotProduct(
                xUpdated, VectorOperations.MatrixVectorProduct(
                    aT, n));

            return(ksi3);
        }
Exemple #26
0
        public double[] CreateInternalGlobalForcesVector()
        {
            double[,] globalStiffnessMatrix = new double[6, 6];
            double[,] lambda              = CreateLambdaMatrix();
            double[,] localStiff          = CreateLocalStiffnessMatrix();
            double[,] transposeLocalStiff = MatrixOperations.Transpose(lambda);
            double[,] KxL         = MatrixOperations.MatrixProduct(localStiff, lambda);
            globalStiffnessMatrix = MatrixOperations.MatrixProduct(transposeLocalStiff, KxL);
            double[] stiffPart = VectorOperations.MatrixVectorProduct(globalStiffnessMatrix, DisplacementVector);

            //if (AccelerationVector != null)
            //{
            //    double[,] globalMassMatrix = CreateMassMatrix();
            //    double[] massPart = VectorOperations.MatrixVectorProduct(globalMassMatrix, VectorOperations.VectorScalarProductNew(AccelerationVector, 1.0));
            //    stiffPart = VectorOperations.VectorVectorAddition(stiffPart, massPart);
            //}
            return(stiffPart);
        }
Exemple #27
0
        private double[] CalculateInternalLocalForcesVector()
        {
            double lengthInitial = CalculateElementLength();
            double E             = Properties.YoungMod;
            double A             = Properties.SectionArea;
            double I             = Properties.MomentOfInertia;

            double[,] Dmatrix = new[, ]
            {
                { E *A / lengthInitial, 0, 0 },
                { 0, 4 * E * I / lengthInitial, 2 * E * I / lengthInitial },
                { 0, 2 * E * I / lengthInitial, 4 * E * I / lengthInitial }
            };

            double[] localDisplacementVector   = CalculateLocalDisplacementVector();
            double[] internalLocalForcesVector = VectorOperations.MatrixVectorProduct(Dmatrix, localDisplacementVector);
            return(internalLocalForcesVector);
        }
Exemple #28
0
        private Tuple <double[], double, double[], double[], double> SlaveSegmentGeometry(double[,] daMatrix, double[,] da2Matrix)
        {
            double[] xupd                    = NodalXUpdated();
            double[] surfaceVector           = VectorOperations.MatrixVectorProduct(daMatrix, xupd);
            double[] surfaceVectorDerivative = VectorOperations.MatrixVectorProduct(da2Matrix, xupd);

            double detm = VectorOperations.VectorDotProduct(surfaceVector, surfaceVector);
            double m11  = 1.0 / detm;

            double[] vector     = new double[] { -surfaceVector[1], surfaceVector[0] };
            double   scalarCoef = 1.0 / (Math.Sqrt(detm));

            double[] normalUnitVec   = VectorOperations.VectorScalarProductNew(vector, scalarCoef);
            double[] tangentVector   = VectorOperations.VectorScalarProductNew(surfaceVector, scalarCoef);
            double   scalarCoef2     = Math.Pow(m11, 2.0);
            double   curvatureTensor = scalarCoef2 * VectorOperations.VectorDotProduct(surfaceVectorDerivative, normalUnitVec);

            return(new Tuple <double[], double, double[], double[], double>(surfaceVector, detm, normalUnitVec, tangentVector, curvatureTensor));
        }
Exemple #29
0
        private double[] CalculateInitialAccelerationsNewmark() //Bathe page 771
        {
            if (CustomStiffnessMatrix != null)
            {
                return(InitialValues.InitialAccelerationVector);
            }
            int step = explicitSolution.Count - 1;

            Assembler.UpdateDisplacements(explicitSolution[step]);
            double[,] stiffness = Assembler.CreateTotalStiffnessMatrix();
            double[,] mass      = Assembler.CreateTotalMassMatrix();

            double[] Ku  = VectorOperations.MatrixVectorProduct(stiffness, explicitSolution[step]);
            double[] RHS = VectorOperations.VectorVectorSubtraction(ExternalForcesVector, Ku);

            double[] acceleration = LinearSolver.Solve(mass, RHS);

            return(acceleration);
        }
Exemple #30
0
        private double[] CalculateHatRVectorNewmarkNL(int i, List <double> aConstants, double[] previousIterationSolution)
        {
            double[,] TotalMassMatrix;
            double[,] TotalDampingMatrix;
            double[,] TotalStiffnessMatrix;
            if (CustomMassMatrix != null)
            {
                TotalMassMatrix      = CustomMassMatrix;
                TotalDampingMatrix   = CustomDampingMatrix;
                TotalStiffnessMatrix = CustomStiffnessMatrix;
            }
            else
            {
                TotalMassMatrix      = Assembler.CreateTotalMassMatrix();
                TotalDampingMatrix   = Assembler.CreateTotalDampingMatrix();
                TotalStiffnessMatrix = Assembler.CreateTotalStiffnessMatrix();
            }

            double[] currentU   = explicitSolution[i - 1];
            double[] currentdU  = explicitVelocity[i - 1];
            double[] currentddU = explicitAcceleration[i - 1];

            double[] a0U = VectorOperations.VectorScalarProductNew(
                VectorOperations.VectorVectorSubtraction(currentU, previousIterationSolution), aConstants[0]);
            double[] a2dU  = VectorOperations.VectorScalarProductNew(currentdU, aConstants[2]);
            double[] a3ddU = VectorOperations.VectorScalarProductNew(currentddU, aConstants[3]);
            double[] a1U   = VectorOperations.VectorScalarProductNew(currentU, aConstants[1]);
            double[] a4dU  = VectorOperations.VectorScalarProductNew(currentdU, aConstants[4]);
            double[] a5ddU = VectorOperations.VectorScalarProductNew(currentddU, aConstants[5]);

            double[] vectorSum1 = VectorOperations.VectorVectorAddition(a0U,
                                                                        VectorOperations.VectorVectorAddition(a2dU, a3ddU));
            double[] vectorSum2 = VectorOperations.VectorVectorAddition(a1U,
                                                                        VectorOperations.VectorVectorAddition(a4dU, a5ddU));

            double[] part1 = VectorOperations.MatrixVectorProduct(TotalMassMatrix, vectorSum1);
            double[] part2 = VectorOperations.MatrixVectorProduct(TotalDampingMatrix, vectorSum2);

            double[] hatR = VectorOperations.VectorVectorAddition(ExternalForcesVector,
                                                                  VectorOperations.VectorVectorAddition(part1, part2));
            return(hatR);
        }