-
Notifications
You must be signed in to change notification settings - Fork 19
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
Purge .join()
from mirgecom
#566
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just added a couple of questions/comments.
mirgecom/filter.py
Outdated
from arraycontext import map_array_container | ||
from functools import partial | ||
if not isinstance(field, DOFArray): | ||
return map_array_container( | ||
partial(filter_modally, dcoll, dd, cutoff, mode_resp_func), field | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the @obj_array_vectorize_n_args
be removed after this change? Also, the docstring should probably be updated to reflect that fields
and the return value can be object arrays now.
I think with inducer/arraycontext#128 it may be possible to implement this function as something along the lines of:
def filter_scalar(f):
dd_nodal = dof_desc.as_dofdesc(dd)
dd_modal = dof_desc.DD_VOLUME_MODAL
discr = dcoll.discr_from_dd(dd_nodal)
actx = f.array_context
modal_map = dcoll.connection_from_dds(dd_nodal, dd_modal)
nodal_map = dcoll.connection_from_dds(dd_modal, dd_nodal)
f = modal_map(f)
f = apply_spectral_filter(actx, f, discr, cutoff, mode_resp_func)
return nodal_map(f)
from arraycontext import rec_map_array_container
return rec_map_array_container(filter_scalar, field, leaf_class=DOFArray)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're totally right that @obj_array_vectorize_n_args
can be removed, thanks for pointing that out. I also updated the docs to reflect the changes: 74558fa
I think with inducer/arraycontext#128 it may be possible to implement this function as something along the lines of:
def filter_scalar(f): dd_nodal = dof_desc.as_dofdesc(dd) dd_modal = dof_desc.DD_VOLUME_MODAL discr = dcoll.discr_from_dd(dd_nodal) actx = f.array_context modal_map = dcoll.connection_from_dds(dd_nodal, dd_modal) nodal_map = dcoll.connection_from_dds(dd_modal, dd_nodal) f = modal_map(f) f = apply_spectral_filter(actx, f, discr, cutoff, mode_resp_func) return nodal_map(f) from arraycontext import rec_map_array_container return rec_map_array_container(filter_scalar, field, leaf_class=DOFArray)
I think it's certainly an option. However, I'd prefer not to tackle that in this PR.
Co-authored-by: Matt Smith <mjsmith6@illinois.edu>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 This is terrific! Thanks @thomasgibson!
This PR does exactly what the title suggests. It removes all
.join()
calls!Questions for the review: