add multigrid module - #97
Closed
weiwongg wants to merge 2 commits into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new MultiGrid module to Bembel and an accompanying example demonstrating a multigrid solve for the Laplace–Beltrami problem on the sphere.
Changes:
- Introduces multigrid prolongation operators for (multi-patch) B-splines and a multiplicative multigrid solver implementation.
- Adds a public
Bembel/MultiGridmodule header wiring the new functionality into the library. - Adds an example (
LaplaceBeltramiMultiGrid.cpp) exercising the new module end-to-end.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/LaplaceBeltramiMultiGrid.cpp | New example using multigrid to solve a Laplace–Beltrami system and report iterations/error/timing. |
| Bembel/src/MultiGrid/ProlongationBsplines.hpp | Implements B-spline prolongation construction (Oslo algorithm + Kronecker products + multi-patch block structure). |
| Bembel/src/MultiGrid/Prolongation.hpp | Builds an ansatz-space prolongation matrix using glue/projector infrastructure. |
| Bembel/src/MultiGrid/MultiGridSolver.hpp | Adds Gauss–Seidel smoothing and a multiplicative multigrid V-cycle routine. |
| Bembel/MultiGrid | Public module header that exposes the new multigrid functionality. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+78
to
+87
| int d = 0; | ||
| for (int i = 0; i < num_fine_basis; ++i) { | ||
| for (int j = 0; j < polynomial_degree + 1; ++j) { | ||
| Eigen::MatrixXd non_zero_alpha; | ||
| std::tie(non_zero_alpha, d) = nonZerosInfoRow( | ||
| knots, uniform_refined_knots, polynomial_degree, i, d); | ||
| tripletList.push_back( | ||
| Triplet(i, d - polynomial_degree + j, non_zero_alpha(j))); | ||
| } | ||
| } |
Comment on lines
+18
to
+22
| #define MULTIGRID_minLvl 1 | ||
| #define MULTIGRID_cycleType 2 | ||
| #define MULTIGRID_preSmooth 3 | ||
| #define MULTIGRID_postSmooth 3 | ||
|
|
Comment on lines
+46
to
+55
| Eigen::VectorXd degree_vector = | ||
| fine_glue.get_glue_matrix().transpose() * | ||
| Eigen::VectorXd::Ones(fine_glue.get_glue_matrix().rows()); | ||
| // the reason we multiply 0.5 in the begining is because we use the scaled | ||
| // B-spline basis function in the Bembel | ||
| return 0.5 * degree_vector.cwiseInverse().asDiagonal() * | ||
| fine_glue.get_glue_matrix().transpose() * | ||
| MG::prolongateBsplinesMultiPatches2D(polynomial_degree, level, | ||
| num_patches, knot_repetition) * | ||
| coarse_glue.get_glue_matrix(); |
Comment on lines
+44
to
+55
| Eigen::VectorXd res; | ||
| do { | ||
| // repetitively call multiplicativeMultiGrid() | ||
| Bembel::MG::multiplicativeMultiGrid(Ss, f, &x, Ps, lvl); | ||
| // minus regularization terms such that the integral of function represented | ||
| // by x is 0. L.dot(x) is integral of x and L.dot(constant_one) is integral | ||
| // of constant one function. | ||
| x = x - L.dot(x) / L.dot(constant_one) * constant_one; | ||
| res = f - S * x; | ||
| ++iter; | ||
| } while (res.norm() > tol); | ||
| return iter; |
| #include "src/MultiGrid/Prolongation.hpp" | ||
| #include "src/MultiGrid/MultiGridSolver.hpp" | ||
|
|
||
| #endif |
Comment on lines
+22
to
+25
| template <typename Derived> | ||
| Eigen::SparseMatrix<double> prolongationMatrix( | ||
| const AnsatzSpace<Derived> &ansatz_space, unsigned int level) { | ||
| assert(level > 0 && |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Collaborator
|
I am closing this pull request as a modified version of this code was merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.