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); }
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); } }
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); } }
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); }
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]); } }
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); }
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)); }
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); }
private double[] LoadControlledNR(double[] forceVector) { lambda = 1.0 / numberOfLoadSteps; double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = new double[forceVector.Length]; double[] incrementalExternalForcesVector = new double[forceVector.Length]; double[] tempSolutionVector = new double[solutionVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] dU; double[] residual; double residualNorm; //Assembler.UpdateAccelerations(CalculateAccelerations(InitialValues.InitialAccelerationVector)); for (int i = 0; i < numberOfLoadSteps; i++) { incrementalExternalForcesVector = VectorOperations.VectorVectorAddition(incrementalExternalForcesVector, incrementDf); Assembler.UpdateDisplacements(solutionVector); Assembler.UpdateAccelerations(explicitAcceleration.Values.Last()); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); double[,] tangentMatrix = CalculateHatMMatrix(); dU = LinearSolver.Solve(tangentMatrix, incrementDf); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, dU); Assembler.UpdateDisplacements(solutionVector); tangentMatrix = CalculateHatMMatrix(); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); while (residualNorm > tolerance && iteration < maxIterations) { tangentMatrix = CalculateHatMMatrix(); deltaU = VectorOperations.VectorVectorSubtraction(deltaU, LinearSolver.Solve(tangentMatrix, residual)); tempSolutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); Assembler.UpdateDisplacements(tempSolutionVector); //Assembler.UpdateAccelerations(CalculateAccelerations(solutionVector)); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); iteration = iteration + 1; } solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); if (iteration >= maxIterations) { Console.WriteLine("Newton-Raphson: Solution not converged at current iterations"); } } return(solutionVector); }
private double[] LoadControlledNR(double[] forceVector) { double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = localSolutionVector; double[] incrementalExternalForcesVector = new double[forceVector.Length]; double[] tempSolutionVector = new double[solutionVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] dU; double[] residual; double residualNorm; for (int i = 0; i < numberOfLoadSteps; i++) { incrementalExternalForcesVector = VectorOperations.VectorVectorAddition(incrementalExternalForcesVector, incrementDf); discretization.UpdateDisplacements(solutionVector); internalForcesTotalVector = discretization.CreateTotalInternalForcesVector(); double[,] stiffnessMatrix = discretization.CreateTotalStiffnessMatrix(); //OnConvergenceResult("Newton-Raphson: Solution not converged at load step" + i); dU = linearSolver.Solve(stiffnessMatrix, incrementDf); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, dU); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); while (residualNorm > Tolerance && iteration < MaxIterations) { stiffnessMatrix = discretization.CreateTotalStiffnessMatrix(); deltaU = VectorOperations.VectorVectorSubtraction(deltaU, linearSolver.Solve(stiffnessMatrix, residual)); tempSolutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); discretization.UpdateDisplacements(tempSolutionVector); internalForcesTotalVector = discretization.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); if (residualNorm <= Tolerance) { OnConvergenceResult("Newton-Raphson: Load Step " + i + " - Solution converged at iteration " + iteration + " - Residual Norm = " + residualNorm); } else { OnConvergenceResult("Newton-Raphson: Load Step " + i + " - Solution not converged at iteration " + iteration + " - Residual Norm = " + residualNorm); } iteration = iteration + 1; //(Application.Current.Windows[0] as MainWindow).LogTool.Text = "ok"; //OnConvergenceResult("Newton-Raphson: Solution not converged at load step" + iteration); } InternalForces.Add(i + 1, internalForcesTotalVector); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); Solutions.Add(i + 1, solutionVector); if (iteration >= MaxIterations) { OnConvergenceResult("Newton-Raphson did not converge at Load Step " + i + ". Exiting solution."); LoadStepConvergence.Add("Solution not converged."); break; } LoadStepConvergence.Add("Solution converged."); } return(solutionVector); }
private double[] NormalVector(double[,] m, List <double[]> dRho) { double detm = MetricTensorDet(m); double[] drhoBydrho = VectorOperations.VectorCrossProduct(dRho[0], dRho[1]); double[] n = VectorOperations.VectorScalarProductNew(drhoBydrho, 1.0 / (Math.Sqrt(detm))); return(n); }
private double[] CalculatePreviousDisplacementVector() { double[] previousDisp = VectorOperations.VectorVectorAddition( VectorOperations.VectorVectorSubtraction(InitialValues.InitialDisplacementVector, VectorOperations.VectorScalarProductNew(InitialValues.InitialVelocityVector, timeStep)), VectorOperations.VectorScalarProductNew(InitialValues.InitialAccelerationVector, a3)); return(previousDisp); }
public double[] CreateInternalGlobalForcesVector() { double[] intForces; double[,] stiff = CreateGlobalStiffnessMatrix(); intForces = VectorOperations.MatrixVectorProduct(stiff, DisplacementVector); intForces = VectorOperations.VectorScalarProductNew(intForces, 1.0); return(intForces); }
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); }
//private double[] UpdatedF(double[] forceVector) //{ // lambda = 1.0 / numberOfLoadSteps; // double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); // double[] solutionVector = new double[forceVector.Length]; // double[] incrementalExternalForcesVector = new double[forceVector.Length]; // double[] tempSolutionVector = new double[solutionVector.Length]; // double[] deltaU = new double[solutionVector.Length]; // double[] internalForcesTotalVector; // double[] dU; // double[] currentU = explicitSolution.Values.Last(); // Assembler.UpdateDisplacements(currentU); // internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); // double[,] TotalMassMatrix = Assembler.CreateTotalMassMatrix(); // double[] a2_M_ut = VectorOperations.MatrixVectorProduct( // MatrixOperations.ScalarMatrixProductNew(a2, TotalMassMatrix), currentU); // double[] a0_M_ut = VectorOperations.MatrixVectorProduct( // MatrixOperations.ScalarMatrixProductNew(a0, TotalMassMatrix), currentU); // double[,] hatMMatrix = CalculateHatMMatrix(); // double[] hatM_utprevious = VectorOperations.MatrixVectorProduct(hatMMatrix, ) //double[,] hatK = MatrixOperations.MatrixSubtraction(TotalStiffnessMatrix, // MatrixOperations.ScalarMatrixProductNew(a2, TotalMassMatrix)); //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)); // double[,] tangentMatrix = CalculateHatMMatrix(); // dU = LinearSolver.Solve(tangentMatrix, incrementDf); // solutionVector = VectorOperations.VectorVectorAddition(solutionVector, dU); // Assembler.UpdateDisplacements(solutionVector); // tangentMatrix = CalculateHatMMatrix(); // internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); // residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); // residualNorm = VectorOperations.VectorNorm2(residual); // int iteration = 0; // Array.Clear(deltaU, 0, deltaU.Length); // return solutionVector; //} /// <summary> /// Calculates accelerations for time t /// </summary> /// <returns></returns> private double[] CalculateAccelerations() //Bathe page 771 { int steps = explicitSolution.Count; double[] aCurrent = VectorOperations.VectorScalarProductNew( VectorOperations.VectorVectorAddition(explicitSolution[steps - 4], VectorOperations.VectorVectorAddition( VectorOperations.VectorScalarProductNew(explicitSolution[steps - 3], -2.0), explicitSolution[steps - 2])), a0); return(aCurrent); }
private double[] CalculateVelocityNewmark(int step, List <double> aConstants) { double[] dUt = explicitVelocity[step - 1]; double[] ddUt = explicitAcceleration[step - 1]; double[] ddUtplusDt = explicitAcceleration[step]; double[] part1 = VectorOperations.VectorScalarProductNew(ddUt, aConstants[6]); double[] part2 = VectorOperations.VectorScalarProductNew(ddUtplusDt, aConstants[7]); double[] dUtplusDt = VectorOperations.VectorVectorAddition(dUt, VectorOperations.VectorVectorAddition(part1, part2)); return(dUtplusDt); }
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); }
private double[] CalculateAccelerationNewmark(int step, List <double> aConstants) { double[] dUt = explicitVelocity[step - 1]; double[] ut = explicitSolution[step - 1]; double[] utplusDt = explicitSolution[step]; double[] ddUt = explicitAcceleration[step - 1]; double[] part1 = VectorOperations.VectorScalarProductNew( VectorOperations.VectorVectorSubtraction(utplusDt, ut), aConstants[0]); double[] part2 = VectorOperations.VectorScalarProductNew(dUt, aConstants[2]); double[] part3 = VectorOperations.VectorScalarProductNew(ddUt, aConstants[3]); double[] ddUtplusDt = VectorOperations.VectorVectorSubtraction(part1, VectorOperations.VectorVectorAddition(part2, part3)); return(ddUtplusDt); }
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); }
private double[] NewtonIterations(double[] forceVector) { lambda = 1.0 / numberOfLoadSteps; double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = new double[forceVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] dU; double[] residual; double residualNorm; solutionVector = explicitSolution.Values.Last(); Assembler.UpdateDisplacements(solutionVector); Assembler.UpdateAccelerations(explicitAcceleration.Values.Last()); residual = VectorOperations.VectorVectorSubtraction(forceVector, Assembler.CreateTotalInternalForcesVector()); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); for (int i = 0; i < maxIterations; i++) { double[,] tangentMatrix = CalculateHatMMatrix(); deltaU = LinearSolver.Solve(tangentMatrix, residual); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); Assembler.UpdateDisplacements(solutionVector); //Assembler.UpdateAccelerations(CalculateAccelerations()); internalForcesTotalVector = Assembler.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(forceVector, internalForcesTotalVector); residualNorm = VectorOperations.VectorNorm2(residual); if (residualNorm < tolerance) { break; } iteration = iteration + 1; } Console.WriteLine(iteration); if (iteration >= maxIterations) { Console.WriteLine("Newton-Raphson: Solution not converged at current iterations"); } return(solutionVector); }
private double[] LoadControlledNR(double[] forceVector) { double[] incrementDf = VectorOperations.VectorScalarProductNew(forceVector, lambda); double[] solutionVector = new double[forceVector.Length]; double[] incrementalExternalForcesVector = new double[forceVector.Length]; double[] tempSolutionVector = new double[solutionVector.Length]; double[] deltaU = new double[solutionVector.Length]; double[] internalForcesTotalVector; double[] dU; double[] residual; double residualNorm; for (int i = 0; i < numberOfLoadSteps; i++) { incrementalExternalForcesVector = VectorOperations.VectorVectorAddition(incrementalExternalForcesVector, incrementDf); base.UpdateDisplacements(solutionVector); internalForcesTotalVector = base.CreateTotalInternalForcesVector(); double[,] stiffnessMatrix = base.CreateTotalStiffnessMatrix(); dU = linearSolver.Solve(stiffnessMatrix, incrementDf); solutionVector = VectorOperations.VectorVectorAddition(solutionVector, dU); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); int iteration = 0; Array.Clear(deltaU, 0, deltaU.Length); while (residualNorm > tolerance && iteration < maxIterations) { stiffnessMatrix = base.CreateTotalStiffnessMatrix(); deltaU = VectorOperations.VectorVectorSubtraction(deltaU, linearSolver.Solve(stiffnessMatrix, residual)); tempSolutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); base.UpdateDisplacements(tempSolutionVector); internalForcesTotalVector = base.CreateTotalInternalForcesVector(); residual = VectorOperations.VectorVectorSubtraction(internalForcesTotalVector, incrementalExternalForcesVector); residualNorm = VectorOperations.VectorNorm2(residual); iteration = iteration + 1; } solutionVector = VectorOperations.VectorVectorAddition(solutionVector, deltaU); if (iteration >= maxIterations) { Console.WriteLine("Newton-Raphson: Solution not converged at current iterations"); } } return(solutionVector); }
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)); }
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); }
private Tuple <double[], double, double[]> SurfaceGeometry(double[,] daMatrix) { 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 Xs = Nodes[3].XCoordinate + DisplacementVector[4]; double Ys = Nodes[3].YCoordinate + DisplacementVector[5]; double[] xupd = new double[] { -Xm1, -Ym1, -Xm2, -Ym2, -Xs, -Ys }; double[] surfaceVector = VectorOperations.MatrixVectorProduct(daMatrix, xupd); double detm = VectorOperations.VectorDotProduct(surfaceVector, surfaceVector); double m11 = 1.0 / detm; double[] vector = new double[] { Ym2 - Ym1, Xm1 - Xm2 }; double scalarCoef = -1.0 / (2.0 * Math.Sqrt(detm)); double[] normalUnitVec = VectorOperations.VectorScalarProductNew(vector, scalarCoef); return(new Tuple <double[], double, double[]>(surfaceVector, m11, normalUnitVec)); }
private Tuple <double[], double, double[], double[], double> MasterSegmentGeometry(double[,] daMatrix, double[,] da2Matrix) { double[] xupd = VectorOperations.VectorScalarProduct(NodalXUpdated(), -1); 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[2]; double scalarCoef = new double(); double scalarCoef2 = Math.Pow(m11, 2.0); double[] tangentVector = new double[2]; double curvatureTensor = new double(); if (Properties.MasterSegmentPolynomialDegree == 1) { 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]; vector[0] = Ym2 - Ym1; vector[1] = Xm1 - Xm2; scalarCoef = -1.0 / (2.0 * Math.Sqrt(detm)); } else { vector[0] = -surfaceVector[1]; vector[1] = surfaceVector[0]; scalarCoef = 1.0 / (Math.Sqrt(detm)); tangentVector = VectorOperations.VectorScalarProductNew(surfaceVector, scalarCoef); } double[] normalUnitVec = VectorOperations.VectorScalarProductNew(vector, scalarCoef); curvatureTensor = scalarCoef2 * VectorOperations.VectorDotProduct(surfaceVectorDerivative, normalUnitVec); return(new Tuple <double[], double, double[], double[], double>(surfaceVector, m11, normalUnitVec, tangentVector, curvatureTensor)); }
public double[] CreateInternalGlobalForcesVector() { //double ksi1 = ClosestPointProjection(); Ksi1Current = ClosestPointProjection(); if (counter == 1) { Ksi1Initial = Ksi1Current; } counter = counter + 1; if (Math.Abs(Ksi1Current) <= 1.05) { Tuple <double[, ], double[, ]> positionMatrices = CalculatePositionMatrix(Ksi1Current); double[,] aMatrix = positionMatrices.Item1; double[,] daMatrix = positionMatrices.Item2; Tuple <double[], double, double[], double[], double> surfaceCharacteristics = SurfaceGeometry(daMatrix); double m11 = surfaceCharacteristics.Item2; double[] n = surfaceCharacteristics.Item3; double[] tVector = surfaceCharacteristics.Item4; double detM = surfaceCharacteristics.Item5; double ksi3 = CalculateNormalGap(aMatrix, n); if (ksi3 <= 0) { double[,] AT = MatrixOperations.Transpose(aMatrix); double[] AT_n = VectorOperations.MatrixVectorProduct(AT, n); double[] AT_t = VectorOperations.MatrixVectorProduct(AT, tVector); double deltaKsi = CalculateTangentialVelocity(Ksi1Current, Ksi1Initial); //Console.WriteLine(Ksi1Initial); double Tr1 = CalculateTangentialTraction(deltaKsi, detM); double phi = Math.Sqrt(Tr1 * Tr1 * m11) - FrictionCoef * PenaltyFactor * Math.Abs(ksi3); if (phi <= 0.0) { double T1 = Tr1; double[] internalGlobalForcesVector = VectorOperations.VectorVectorAddition( VectorOperations.VectorScalarProductNew(AT_n, PenaltyFactor * ksi3), VectorOperations.VectorScalarProductNew(AT_t, T1 * Math.Sqrt(m11))); return(internalGlobalForcesVector); } else { double T1 = (Tr1 / Math.Abs(Tr1)) * mhid * PenaltyFactor * Math.Abs(ksi3) * Math.Sqrt(detM); double[] internalGlobalForcesVector = VectorOperations.VectorVectorAddition( VectorOperations.VectorScalarProductNew(AT_n, PenaltyFactor * ksi3), VectorOperations.VectorScalarProductNew(AT_t, T1 * Math.Sqrt(m11))); return(internalGlobalForcesVector); } } else { double[] internalGlobalForcesVector = new double[6]; return(internalGlobalForcesVector); } } else { double[] internalGlobalForcesVector = new double[6]; return(internalGlobalForcesVector); } }