Skip to content

add multigrid module - #97

Closed
weiwongg wants to merge 2 commits into
temf:masterfrom
weiwongg:Multigrid
Closed

add multigrid module#97
weiwongg wants to merge 2 commits into
temf:masterfrom
weiwongg:Multigrid

Conversation

@weiwongg

Copy link
Copy Markdown
Collaborator

No description provided.

@jdoelz jdoelz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/MultiGrid module 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 thread Bembel/src/MultiGrid/ProlongationBsplines.hpp
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 thread Bembel/src/MultiGrid/ProlongationBsplines.hpp
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;
Comment thread Bembel/MultiGrid
#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>
@jdoelz

jdoelz commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

I am closing this pull request as a modified version of this code was merged.

@jdoelz jdoelz closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants