public void Solve() { mb = new MeshBuilder(Info.Points.Length); NodeCount = mb.Build(Info.Mesh); mb.BuildBoundary(Info.FB); mb.BuildBoundary(Info.SB); pb = new PortraitBuilder(NodeCount, Info.Mesh); MatrixPortrait mp = new MatrixPortrait(); pb.Build(mp); IMatrix A = new SymmetricSparseMatrix(NodeCount, mp); double[] B = new double[NodeCount]; SLAEInfo slaeinfo = new SLAEInfo(); slaeinfo.Points = Info.Points; slaeinfo.Mesh = Info.Mesh; slaeinfo.F = Info.F; sb = new SLAEBuilder(slaeinfo); sb.Build(A, B); sb.AddBoundary(A, B, Info.FB); sb.AddBoundary(A, B, Info.SB); Weights = Solver.Solve(A, B); }
public void Solve() { mb = new MeshBuilder(Info.Points.Length); NodeCount = mb.Build(Info.Mesh); mb.BuildBoundary(Info.FB); pb = new PortraitBuilder(NodeCount, Info.Mesh); MatrixPortrait mp = new MatrixPortrait(); pb.Build(mp); IMatrix A = new SymmetricSparseMatrix(NodeCount, mp); double[] B = new double[NodeCount]; SLAEInfoDelta slaeinfo = new SLAEInfoDelta(); slaeinfo.Points = Info.Points; slaeinfo.Mesh = Info.Mesh; slaeinfo.R0 = Info.R0; slaeinfo.Z0 = Info.Z0; slaeinfo.DeltaCoefficient = Info.DeltaCoefficient; sb = new SLAEBuilderDelta(slaeinfo); sb.Build(A, B); sb.AddBoundary(A, B, Info.FB); Console.WriteLine("Start Solving SLAE"); Weights = Solver.Solve(A, B); }
public void Solve() { Problem problem = new Problem(new ProblemInfo { Mesh = LinearMesh, SolverType = Solver.SolverType }); problem.Solve(); Q = problem.Q; MatrixPortrait MP = new MatrixPortrait(); PB.Build(MP); IMatrix A = new SymmetricSparseMatrix(Mesh.NodeCount, MP); double[] B = new double[Mesh.NodeCount]; CurrentIter = 0; Diff = 1.0; QDiff = 1.0; while (CurrentIter < MaxIters && Diff >= Eps && QDiff >= Delta) { // SLAE Solution NSB.Build(A, B, Q); prevQ = Q; Q = Solver.Solve(A, B); QDiff = VectorUtils.RelativeError(prevQ, Q); A.Clear(); Array.Fill(B, 0.0); if (DoOptimization) { // Optimization double w = OptimizeQ(A, B); // Calculating new Q for (int i = 0; i < Q.Length; i++) { Q[i] = Q[i] * w + prevQ[i] * (1.0 - w); } } // Calculate diff NSB.Build(A, B, Q); A.Multiply(Q, Aq); Diff = VectorUtils.RelativeError(Aq, B); CurrentIter++; Console.WriteLine($"Iter: {CurrentIter}, Diff: {Diff}, QDiff: {QDiff}"); A.Clear(); Array.Fill(B, 0.0); Array.Fill(Aq, 0.0); } }
public void Solve() { MatrixPortrait MP = new MatrixPortrait(); PB.Build(MP); IMatrix A = new SymmetricSparseMatrix(Mesh.NodeCount, MP); double[] B = new double[Mesh.NodeCount]; SB.Build(A, B); Q = Solver.Solve(A, B); }
public void Build(MatrixPortrait MP) { MP.IA = new int[NodeCount + 1]; MP.IA[0] = MP.IA[1] = 0; for (int i = 2; i <= NodeCount; i++) { int col = MP.IA[i - 1]; MP.IA[i] = col + connections[i - 1].Count; } MP.JA = new int[MP.IA[NodeCount]]; for (int i = 1, k = 0; i < NodeCount; i++) { foreach (int j in connections[i]) { MP.JA[k] = j; k++; } } }