public void CalculateMatrix(ISolverSubdomain subdomain) { if (ks == null) { BuildKs(); } subdomain.Matrix = this.ks[subdomain.ID]; }
public void DampingMatrixVectorProduct(ISolverSubdomain subdomain, IVector <double> vIn, double[] vOut) { this.Cs[subdomain.ID].Multiply(vIn, vOut); double[] vQ = new double[vOut.Length]; qs[subdomain.ID].Multiply(vIn, vQ); for (int i = 0; i < vOut.Length; i++) { vOut[i] -= vQ[i]; } }
private void CalculateEffectiveMatrixInternal(ISolverSubdomain subdomain, ImplicitIntegrationCoefficients coefficients) { subdomain.Matrix = this.Ks[subdomain.ID]; subdomain.Matrix.LinearCombination( new double[] { coefficients.Stiffness, coefficients.Mass, coefficients.Damping }, new IMatrix2D <double>[] { this.Ks[subdomain.ID], this.Ms[subdomain.ID], this.Cs[subdomain.ID] }); }
public void ProcessInternalRHS(ISolverSubdomain subdomain, double[] rhs, double[] solution) { //ScaleSubdomainSolidVector(subdomain, new Vector<double>(rhs)); //return; double[] vQ = new double[rhs.Length]; qs[subdomain.ID].Multiply(new Vector <double>(solution), vQ); for (int i = 0; i < rhs.Length; i++) { rhs[i] += vQ[i]; } ScaleSubdomainSolidVector(subdomain, new Vector <double>(rhs)); }
private void CalculateRHSImplicit(ISolverSubdomain subdomain, double[] rhsResult, bool addRHS) { int id = subdomain.ID; for (int i = 0; i < subdomain.RHS.Length; i++) { //uu[id].Data[i] = v[id].Data[i] + a2a0 * v1[id].Data[i] + a3a0 * v2[id].Data[i]; uu[id].Data[i] = a0 * v[id].Data[i] + a2 * v1[id].Data[i] + a3 * v2[id].Data[i]; uc[id].Data[i] = a1 * v[id].Data[i] + a4 * v1[id].Data[i] + a5 * v2[id].Data[i]; } //provider.Ms[id].Multiply(uu[id], uum[id].Data); provider.MassMatrixVectorProduct(subdomain, uu[id], uum[id].Data); provider.DampingMatrixVectorProduct(subdomain, uc[id], ucc[id].Data); if (addRHS) { for (int i = 0; i < subdomain.RHS.Length; i++) { rhsResult[i] = rhs[id].Data[i] + uum[id].Data[i] + ucc[id].Data[i]; } } else { for (int i = 0; i < subdomain.RHS.Length; i++) { rhsResult[i] = uum[id].Data[i] + ucc[id].Data[i]; } } #region Old Fortran code //If (ptAnal.tDynamic.bHasDamping) Then // atDynUU(iMesh).afValues = atDynV(iMesh).afValues + fA2A0 * atDynV1(iMesh).afValues + fA3A0 * atDynV2(iMesh).afValues // atDynUC(iMesh).afValues = atDynV(iMesh).afValues + fA4A1 * atDynV1(iMesh).afValues + fA5A1 * atDynV2(iMesh).afValues //Else // atDynUU(iMesh).afValues = atDynV(iMesh).afValues + fA2A0 * atDynV1(iMesh).afValues + fA3A0 * atDynV2(iMesh).afValues //End If //If (Present(ProcessVel)) Then // Call ProcessVel(iMesh, Size(atDynUU(iMesh).afValues), atDynUU(iMesh).afValues, atDynUUM(iMesh).afValues) //Else // Call MatrixVectorMultiplication(iMesh, Size(atRHS(iMesh).afValues), 2, atDynUU(iMesh).afValues, atDynUUM(iMesh).afValues) //End If //If (ptAnal.tDynamic.bHasDamping) Then // If (Present(ProcessAcc)) Then // Call ProcessAcc(iMesh, Size(atDynUU(iMesh).afValues), atDynUC(iMesh).afValues, atDynUCC(iMesh).afValues) // Else // Call MatrixVectorMultiplication(iMesh, Size(atRHS(iMesh).afValues), 3, atDynUC(iMesh).afValues, atDynUCC(iMesh).afValues) // End If // atRHS(iMesh).afValues = atRHS(iMesh).afValues + atDynUUM(iMesh).afValues + atDynUCC(iMesh).afValues //Else // atRHS(iMesh).afValues = atRHS(iMesh).afValues + atDynUUM(iMesh).afValues //End If #endregion }
private void DestroyAccuracy(ISolverSubdomain subdomain) { if (AccuracyDigits < 1) { return; } for (int i = 0; i < subdomain.RHS.Length; i++) { //ScientificDouble s = ScientificDouble.GetScientificDouble(subdomain.RHS[i]); //s.ReduceAccuracy(AccuracyDigits); //subdomain.RHS[i] = ScientificDouble.GetDouble(s); subdomain.RHS[i] = Double.Parse(String.Format("{0:" + stringFormat + "}", subdomain.RHS[i])); } }
private void ScaleSubdomainSolidVector(ISolverSubdomain subdomain, IVector <double> vector) { foreach (int nodeID in model.SubdomainsDictionary[subdomain.ID].NodalDOFsDictionary.Keys) { foreach (DOFType dofType in model.SubdomainsDictionary[subdomain.ID].NodalDOFsDictionary[nodeID].Keys) { if (dofType != DOFType.Pore) { int dof = model.SubdomainsDictionary[subdomain.ID].NodalDOFsDictionary[nodeID][dofType]; if (dof > -1) { vector[dof] *= this.scalingCoefficient; } } } } }
public double InitializeAndGetResidual(IList <ISolverSubdomain> subdomains, double[] r, double[] x) { if (subdomains.Count != 1) { throw new InvalidOperationException("Skyline PCG solver operates on one subdomain only."); } double detf = 0; double temp = 0; ISolverSubdomain subdomain = subdomains[0]; for (int i = 0; i < subdomain.RHS.Length; i++) { temp = subdomain.RHS[i]; detf += temp * temp; r[i] = temp; } return(Math.Sqrt(detf)); }
public void CalculateEffectiveMatrix(ISolverSubdomain subdomain, ImplicitIntegrationCoefficients coefficients) { subdomain.Matrix = this.Ks[subdomain.ID]; //// REMOVE //subdomain.CloneMatrix(); if (((SkylineMatrix2D <double>)subdomain.Matrix).IsFactorized) { BuildKs(); } subdomain.Matrix.LinearCombination( new double[] { coefficients.Stiffness, coefficients.Mass, coefficients.Damping }, new IMatrix2D <double>[] { this.Ks[subdomain.ID], this.Ms[subdomain.ID], this.Cs[subdomain.ID] }); }
public NEUWriter(Model model, ISolverSubdomain subdomain) { this.model = model; this.subdomain = subdomain; }
public void CalculateMatrix(ISolverSubdomain subdomain) { throw new NotImplementedException(); }
public double[] GetOtherRHSComponents(ISolverSubdomain subdomain, IVector <double> currentSolution) { return(new double[subdomain.RHS.Length]); }
public void MassMatrixVectorProduct(ISolverSubdomain subdomain, IVector <double> vIn, double[] vOut) { this.Ms[subdomain.ID].Multiply(vIn, vOut); }
public void ProcessRHS(ISolverSubdomain subdomain, ImplicitIntegrationCoefficients coefficients) { scalingCoefficient = coefficients.Damping; ScaleSubdomainSolidVector(subdomain, subdomain.RHS); }
public void CalculateEffectiveMatrix(ISolverSubdomain subdomain, ImplicitIntegrationCoefficients coefficients) { InitializeProvidersAndBuildQs(coefficients); scalingCoefficient = coefficients.Damping; CalculateEffectiveMatrixInternal(subdomain, coefficients); }
public double[] GetOtherRHSComponents(ISolverSubdomain subdomain, IVector <double> currentSolution) { //// u[id]: old solution //// v[id]: current solution //// vv: old acceleration //// v2: current acceleration //// v1: current velocity ////double vv = v2[id].Data[j]; ////v2[id].Data[j] = a0 * (v[id].Data[j] - u[id].Data[j]) - a2 * v1[id].Data[j] - a3 * vv; ////v1[id].Data[j] += a6 * vv + a7 * v2[id].Data[j]; //int id = subdomain.ID; //Vector<double> currentAcceleration = new Vector<double>(subdomain.Solution.Length); //Vector<double> currentVelocity = new Vector<double>(subdomain.Solution.Length); //Vector<double> uu = new Vector<double>(subdomain.Solution.Length); //Vector<double> uc = new Vector<double>(subdomain.Solution.Length); //for (int j = 0; j < subdomain.RHS.Length; j++) //{ // currentAcceleration.Data[j] = a0 * (currentSolution[j] - v[id].Data[j]) - a2 * v1[id].Data[j] - a3 * v2[id].Data[j]; // currentVelocity.Data[j] = v1[id].Data[j] + a6 * v2[id].Data[j] + a7 * currentAcceleration.Data[j]; // uu.Data[j] = a0 * currentSolution[j] + a2 * currentVelocity.Data[j] + a3 * currentAcceleration.Data[j]; // uc.Data[j] = a1 * currentSolution[j] + a4 * currentVelocity.Data[j] + a5 * currentAcceleration.Data[j]; //} //Vector<double> tempResult = new Vector<double>(subdomain.Solution.Length); //Vector<double> result = new Vector<double>(subdomain.Solution.Length); //provider.MassMatrixVectorProduct(subdomain, uu, tempResult.Data); //result.Add(tempResult); //provider.DampingMatrixVectorProduct(subdomain, uc, tempResult.Data); //result.Add(tempResult); //return result.Data; Vector <double> result = new Vector <double>(subdomain.Solution.Length); Vector <double> temp = new Vector <double>(subdomain.Solution.Length); Vector <double> tempResult = new Vector <double>(subdomain.Solution.Length); //Vector<double> uu = new Vector<double>(subdomain.Solution.Length); //Vector<double> uc = new Vector<double>(subdomain.Solution.Length); //int id = subdomain.ID; //for (int j = 0; j < subdomain.RHS.Length; j++) //{ // uu.Data[j] = -a0 * (v[id].Data[j] - currentSolution[j]) - a2 * v1[id].Data[j] - a3 * v2[id].Data[j]; // uc.Data[j] = -a1 * (v[id].Data[j] - currentSolution[j]) - a4 * v1[id].Data[j] - a5 * v2[id].Data[j]; //} //provider.MassMatrixVectorProduct(subdomain, uu, tempResult.Data); //result.Add(tempResult); //provider.DampingMatrixVectorProduct(subdomain, uc, tempResult.Data); //result.Add(tempResult); ////CalculateRHSImplicit(subdomain, result.Data, false); ////result.Scale(-1d); currentSolution.CopyTo(temp.Data, 0); temp.Scale(a0); provider.MassMatrixVectorProduct(subdomain, temp, tempResult.Data); result.Add(tempResult); currentSolution.CopyTo(temp.Data, 0); temp.Scale(a1); provider.DampingMatrixVectorProduct(subdomain, temp, tempResult.Data); result.Add(tempResult); return(result.Data); }
public void ProcessRHS(ISolverSubdomain subdomain, ImplicitIntegrationCoefficients coefficients) { }
public void ProcessInternalRHS(ISolverSubdomain subdomain, double[] rhs, double[] solution) { }