Skip to content

Add ZernikeB1 interpolation matrix#7232

Merged
nilsdeppe merged 2 commits into
sxs-collaboration:developfrom
michaeldmurphy1:zernikeb1_interp_mat
May 31, 2026
Merged

Add ZernikeB1 interpolation matrix#7232
nilsdeppe merged 2 commits into
sxs-collaboration:developfrom
michaeldmurphy1:zernikeb1_interp_mat

Conversation

@michaeldmurphy1

Copy link
Copy Markdown
Contributor

Proposed changes

To go between DG and Subcell grids, we need to project which requires an interpolation matrix for ZernikeB1.

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.
  • If a coding agent is used, have one of
    "Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com",
    "Co-Authored-by: Codex noreply@openai.com", or
    "Co-Authored-By: GitHub Copilot CLI noreply@microsoft.com"
    as the last line of the commit, depending on the agent.

Further comments

Comment thread src/NumericalAlgorithms/Spectral/BasisFunctions/Zernike.cpp Outdated
Comment thread src/NumericalAlgorithms/Spectral/InterpolationMatrix.cpp
Comment thread src/NumericalAlgorithms/Spectral/InterpolationMatrix.cpp Outdated
Comment thread src/NumericalAlgorithms/Spectral/InterpolationMatrix.cpp
Comment on lines +227 to +232
const DataVector collocation_pts =
Zernike<Dim>::compute_collocation_points_and_weights(num_points).first +
1.0;
// Build shifted target points in the same [0,2] coordinate system
const T shifted_target = target_points + 1.0;
DataVector extended_collocation_pts(2 * num_points, 0.0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it possible to combine the 3 DataVector-ish things into 1 allocation? The matrix here is also temp/internal, but I don't know if we can do non-owning Matrix.

Comment thread src/NumericalAlgorithms/Spectral/BasisFunctions/Zernike.cpp Outdated
sign * extended_diff_matrix(i, j + num_points);
}
}
extended_diff_matrix.resize(num_points, num_points, true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does another allocation and copy. Can you restructure the loop on line 213 to do the "evaluate and fold" all at once?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just make the matrix num_points X num_points to start now?

@nilsdeppe nilsdeppe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can squash.

sign * extended_diff_matrix(i, j + num_points);
}
}
extended_diff_matrix.resize(num_points, num_points, true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just make the matrix num_points X num_points to start now?

// Mirror xi around the symmetry point xi=-1 (r=0): xi' = -xi - 2.
DataVector extended_collocation_pts(2 * num_points);
{
const DataVector pts =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

DataVector&

Comment on lines +241 to +249
Matrix result =
fornberg_interpolation_matrix(target_points, extended_collocation_pts);
const size_t num_target = result.rows();
for (size_t i = 0; i < num_points; ++i) {
for (size_t k = 0; k < num_target; ++k) {
result(k, i) += sign * result(k, i + num_points);
}
}
result.resize(num_target, num_points, true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same fold question as for the diff matrix. Can this also elide the resize?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think I can avoid the extra allocation...

michaeldmurphy1 and others added 2 commits May 31, 2026 14:22
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nilsdeppe nilsdeppe merged commit b1e7968 into sxs-collaboration:develop May 31, 2026
24 checks passed
@michaeldmurphy1 michaeldmurphy1 deleted the zernikeb1_interp_mat branch June 1, 2026 13:11
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.

2 participants