/** * Performs a multigrid cycle * * @param k * Level to cycle at. Start by calling <code>cycle(0)</code> */ private void cycle(int k) { if (k == m - 1) directSolve(); else { // Presmoothings preRelax(k); u[k + 1].assign(0); // Compute the residual A[k].zMult(u[k], r[k].assign(f[k]), -1, 1, false); // Restrict to the next coarser level I[k].zMult(r[k], f[k + 1], 1, 0, true); // Recurse to next level for (int i = 0; i < gamma; ++i) cycle(k + 1); // Add residual correction by prolongation I[k].zMult(u[k + 1], u[k], 1, 1, false); // Postsmoothings postRelax(k); } }
/** * Performs a multigrid cycle * * @param k * Level to cycle at. Start by calling <code>cycle(0)</code> */ private void cycle(int k) { if (k == m - 1) directSolve(); else { // Presmoothings preRelax(k); u[k + 1].assign(0); // Compute the residual A[k].zMult(u[k], r[k].assign(f[k]), -1, 1, false); // Restrict to the next coarser level I[k].zMult(r[k], f[k + 1], 1, 0, true); // Recurse to next level for (int i = 0; i < gamma; ++i) cycle(k + 1); // Add residual correction by prolongation I[k].zMult(u[k + 1], u[k], 1, 1, false); // Postsmoothings postRelax(k); } }
I.zMult(aiV, itaiV, 1, 0, true);
I.zMult(aiV, itaiV, 1, 0, true);