Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force a single-value per element for elementwise reductions #195

Merged
merged 8 commits into from Jan 13, 2022

Conversation

thomasgibson
Copy link
Collaborator

This PR fixes #184

The logic here is that it's safe to force the elementwise reductions to have a shape of (nelem, 1) by definition of a reduction in this context; no need to broadcast to a full DOFArray

Copy link
Collaborator

@kaushikcfd kaushikcfd left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

grudge/reductions.py Outdated Show resolved Hide resolved
grudge/dt_utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@kaushikcfd kaushikcfd left a comment

Choose a reason for hiding this comment

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

Thanks!

@thomasgibson
Copy link
Collaborator Author

@inducer CI is now failing for some mysterious reason ever since #200. Here's a link to the log: https://github.com/inducer/grudge/runs/4638364194?check_suite_focus=true#step:3:606. It's not clear why this (and all other PRs) are experiencing problems related to this.

@inducer
Copy link
Owner

inducer commented Dec 27, 2021

There were a few legitimate CI failures yesterday (which I fixed), but these here look spurious. I've rerun the checks.

Copy link
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

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

Thanks! The main piece of this LGTM, however I have some questions about the area estimates in the time step estimation. If you'd rather deal with those separately (by filing an issue), I can live with that. I do think it's worth talking about this code briefly now, though.

grudge/dt_utils.py Show resolved Hide resolved
Comment on lines 298 to 299
1 if actx.supports_nonscalar_broadcasting
else afgrp.nunit_dofs
Copy link
Owner

Choose a reason for hiding this comment

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

This nodal averaging is super sketchy to me. Why not just use honest quadrature (using afgrp.weights or some such) to compute areas?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@inducer I agree this is a bit ugly, but let me explain why this was done.

You recall the issues with nonscalar broadcasting for array contexts right? Well when an array context can't support it, you get repeated values at each node, rather than the single DOFArray with one value per cell. This tried to address this difference.

Why not just use honest quadrature (using afgrp.weights or some such) to compute areas?

Um, that's what is happening if you look up a few more lines. In the definition of surface_areas:

surface_areas = abs(

Copy link
Owner

Choose a reason for hiding this comment

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

Ah. Missed that. Sorry! In this case, I would restate my comment here to maybe make two separate code paths: one for "capable" actxs, implementing just the sum over faces (and likely reshaping away the 1-long axis), and another for the "less capable" ones. That way, the math intent is easier to recognize from the (shorter, simpler, more sensible) code, but will still execute with the old and busted foundation. Does that sound reasonable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good! Yeah I like that, I'll update accordingly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated: 4f04de2

Copy link
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

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

Oops. I had a review comment pending here that I never submitted. My bad! At any rate, LGTM once that's resolved.

Comment on lines 298 to 299
1 if actx.supports_nonscalar_broadcasting
else afgrp.nunit_dofs
Copy link
Owner

Choose a reason for hiding this comment

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

Ah. Missed that. Sorry! In this case, I would restate my comment here to maybe make two separate code paths: one for "capable" actxs, implementing just the sum over faces (and likely reshaping away the 1-long axis), and another for the "less capable" ones. That way, the math intent is easier to recognize from the (shorter, simpler, more sensible) code, but will still execute with the old and busted foundation. Does that sound reasonable?

Copy link
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

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

Thanks! I've got one possible simplification to suggest. LGTM with or without that, let me know how you feel about it.

grudge/dt_utils.py Show resolved Hide resolved
@thomasgibson thomasgibson merged commit e94220e into main Jan 13, 2022
@thomasgibson thomasgibson deleted the thg/reductions-update branch January 13, 2022 22:04
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.

Elementwise reductions shouldn't return the same value in all DOFs of the element
3 participants