-
Notifications
You must be signed in to change notification settings - Fork 17
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
Refactor DiscretizationCollection constructor #122
Conversation
735eb77
to
1b8153d
Compare
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.
Thanks for starting to think about this. Some thoughts from a quick scroll.
e6de687
to
ac5e7bf
Compare
96d06fa
to
a71f6e8
Compare
eaf89ad
to
0f4a6e5
Compare
Is this ready for review from your end? (I ask because of the ambiguous state: no review requested, work still ongoing, but also not marked as draft) |
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.
Thanks! A few comments below.
grudge/discretization.py
Outdated
from a :class:`grudge.dof_desc.DOFDesc` | ||
to a :class:`meshmode.discretization.Discretization`. | ||
At minimum, this should include a base discretization given by | ||
the dof descriptor :class:`grudge.dof_desc.DD_VOLUME`. |
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.
I think the documentation of what this is needs to be expanded a bit, to avoid some misunderstandings that I had when first reading this, mainly on how this relates to the discr_from_dd
method. (Maybe a different name would also help... vol_discr_from_dd
?)
- The
discr_from_dd
method can be used to retrieve all sorts of stuff (boundary discretizations and whatnot). Thisdiscr_from_dd
dictionary cannot be used to supply "pre-made" versions of those. (It might be attractive to allow that? not sure) Said another way, this should set an expectation for what can and cannot be part of this mapping. - This is treated as read-only, i.e. additional discretizations made by
discr_from_dd
aren't added to this.
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.
I decided to do away with the redundant discretizations altogether and streamline them through to discr_from_dd
where possible: ae3a105.
I personally like this a lot more
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.
I haven’t been following this PR closely, so I’m way out of the loop on what exactly is being changed… But I just wanted to ask: what will happen here when we add multiple volume discretizations? Is the _base_discr
change going to be compatible with that?
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.
The _base_discr
is specifying the "base"/interpolatory element group on the mesh
. So one question I have: If you have multiple volume discretizations, will they have different meshes? If so, then _base_discr should probably be a set of "base"/interpolator discretization objects defined on their appropriate volume meshes.
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.
@majosm When you are at a point where you are trying to couple different discretizations (I think that's going to be MIRGECom + MIRGEHeat right?), I would appreciate being involved at some point in the discussion so I can see what's needed in grudge.
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.
The
_base_discr
is specifying the "base"/interpolatory element group on themesh
. So one question I have: If you have multiple volume discretizations, will they have different meshes? If so, then _base_discr should probably be a set of "base"/interpolator discretization objects defined on their appropriate volume meshes.
I think there will need to be a global mesh (so we have connectivity between the different volumes), but it will get split into sub-meshes for each volume in order to construct the discretizations for each.
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.
Ah okay! This makes sense. Then it sounds like what we want to make sure is that we pass in some mapping to make_discretization_collection
(I proposed doing this as some kwarg for metadata) that associates sub-meshes with "base" (often referred to as the volume discretization) discretizations. I would be curious to know your opinion on the matter discussed here: #122 (comment)
discr_tag_to_group_factory, | ||
discr_from_dd, | ||
dist_boundary_connections, | ||
mpi_communicator=None): | ||
""" |
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 version is definitely no longer compatible with code that calls the DiscretizationCollection
constructor directly. That's OK for grudge because you've fixed all the call sites, and it's OK for mirgecom because it only uses EagerDiscretization
to which you've added the backward compatibility code. But I'm not sure it's OK for all other users? (cc @alexfikl)
Alternatively, the compat code could live here.
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.
I have some grudge code sitting around, but it needs a lot of changes to move away from the deprecated symbolic stuff, so I'm fine with making a more breaking change here.
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.
Afraid I don't really know a way around this without resorting to some hacky python. I'd prefer not to make this overly complicated if possible. How about once this PR is merged, we pin an issue describing how the interface has changed?
:arg discr_context: A :class:`~meshmode.mesh.Mesh` object to define | ||
the discretization collection over. |
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.
Not sure I love the name. In pytential, @alexfikl used "places": https://documen.tician.de/pytential/symbolic.html in a similar role.
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.
In particular, the GeometryCollection class in there. (The name was used in the code before introducing the GeometryCollection, so I just named it like that to stay consistent)
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.
To be honest, I'm starting to like this placeholder business less and less the more I think about it. make_discretization_collection
is intended to be the primary user-facing way to create the DiscretizationCollection
And I can already imagine having an ambiguous placeholder argument causing confusion later on down the line.
I am not a fan, and I think we should avoid them if we can. I would rather just rename discr_context
back to mesh
, document it as such, and add an optional kwarg for discretization-related metadata that can be leveraged in the future. Thoughts @inducer @alexfikl ?
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.
@majosm This is probably a relevant discussion.
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.
I'm starting to like this placeholder business less and less the more I think about it.
Not sure I understand what you're objecting to. Having symbolic names for parts of the domain? Something else? Sorry if I'm being dense.
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.
Sorry if I wasn't very clear. I was referring to using placeholder arguments in make_discretization_collection
like places
or discr_context
(determined by position alone) which can be pretty much anything (mesh, discretizations, dicts of discretizations). I don't feel comfortable doing that.
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.
I would rather try to use something along the lines of **kwargs
, which is a bit more controlled from my perspective.
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.
Personally, I feel like I've had OK experiences with those types of arguments, if used judiciously. Examples:
loopy
functions will often take objects or string representations that parse to them. (e.g. domains, statements)pyopencl.Array
's constructor can take a context or an array as first argument.
The type of an object can be unambiguously determined, so I don't see a big risk in taking e.g. mesh
as a shorthand for {DEFAULT_VOLUME: mesh}
.
On the other hand, I find **kwargs
parsing kind of unattractive:
- Forget to check for extra arguments
- Assuming you mean we would use
mesh=
orgeometries=
as alternatives to each other, we'd need to add logic to reject calls that have both. **kwargs
have to be the last argument. If that makes the interface kwargs-only, then all calls become kind of wordy, which isn't amazing for high-profile API real estate like the effective discretization collection constructor.
the discretization collection over. | ||
:arg discr_tag_to_group_factory: A mapping from discretization tags | ||
(typically one of: :class:`grudge.dof_desc.DISCR_TAG_BASE`, | ||
:class:`grudge.dof_desc.DISCR_TAG_MODAL`, or |
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.
Is overriding the meaning of "modal" allowed?
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.
I think this is addressed in 23dfa75. A default modal factory is provided whenever it is not explicitly provided by the user (in a similar way to how there is a default simplex group factor)
grudge/discretization.py
Outdated
# Modal discr should always comes from the base discretization | ||
discr_tag_to_group_factory[DISCR_TAG_MODAL] = \ | ||
_generate_modal_group_factory( | ||
discr_tag_to_group_factory[DISCR_TAG_BASE] | ||
) |
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 should error if DISCR_TAG_MODAL
was supplied, instead of silently overwriting. The docs specifically allow supplying modal.
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.
I've updated this in 23dfa75; I've opted to only provide the group factor when it's not provided by the user
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
22fdd11
to
6bdc25c
Compare
fa9a8b9
to
23dfa75
Compare
81b52e7
to
ae3a105
Compare
Superseded by #236. |
This PR removes all the work that the current constructor for
DiscretizationCollection
is doing for setup. The proposed interface for creating these discretization collections is provided by the functionmake_discretization_collection
.