-
Notifications
You must be signed in to change notification settings - Fork 35
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
[Breaking Change][WIP] Make Mesh-Level Boundary Conditions Usable without "User" flag #989
Conversation
…parthenon into jmm/global-boundaries
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 really like the new API. I am a bit confused by two things,
(1) Do you think this has to be a breaking change? You have already kept the user
flag functionality in place... it seems the only breaking change is the function signature for RegisterBoundaryCondition
. I wonder if there is a way to overload the function (or similar) so this doesn't need to be breaking.
(2) There are some changes to bvals*.cpp
and mesh.cpp
, etc. that don't seem to be related to the new user-defined BCs API, but rather a cleanup. Someone besides me should review these with a careful eye --- I worry that these changes could easily slip in some undesired behavior.
src/mesh/mesh.cpp
Outdated
@@ -1163,7 +1161,6 @@ bool Mesh::SetBlockSizeAndBoundaries(LogicalLocation loc, RegionSize &block_size | |||
|
|||
RegionSize Mesh::GetBlockSize(const LogicalLocation &loc) const { | |||
RegionSize block_size = GetBlockSize(); | |||
bool valid_region = true; |
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.
Oops this was not supposed to be deleted.
Hmm... I could do this I think. Is that really desirable? It would be a little bit of extra code for, IMO, not great justification. Sure, keeping full backwards compatibility is nice. But migrating to the new API should be very low effort for the downstream codes. I can add an overload though if you think it's important.
I think I only did cleanup related to the new BCs API. Basically, with the |
I definitely don't mind the breaking change. Although I felt some pressure from Parthenon syncs to try and limit this where possible. |
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 very good to me. I think this is a much cleaner approach (which also allows for cleaner downstream use).
Also I don't mind this being breaking change as downstream codes could implement this change in a non-breaking way (as far as I could tell).
The only thing I'd like to discuss before merge is about the default registration of reflecting boundary conditions (see separate comment).
@Yurlungur I missed bringing this PR up during the sync last week. If I haven't missed anything the open items are "remove the reflecting then and document how to register it." and checking what's going wrong with the Swarm boundaries on device. |
I'm sorry @pgrete I'm not sure I can get this done by the time I leave. I dug into the swarm failure some but I have no idea what's wrong with it. It might be best to merge this with a (eventual) refactor of swarm boundaries down the line. |
@Yurlungur where does this PR stand? |
Thanks to the cleanup to particles @brryan did I can probably revive this PR now. I haven't looked at it in some time, though. So I'd need a little bit of time to bring it up to develop. |
Superseded by #1177 |
API Breaking change
When registering user boundary functions, the mechanism changes from assigning the function pointer to an array. You now must call
ApplicationInput::RegisterBoundaryCondition
and give the custom boundary condition a name. This also eliminates the need for theuser
boundary flag in the input file, although that flag is implicitly still supported.PR Summary
A discussion on the new downstream code headed by @brryan @pdmullen indicated a desire to set mesh-level boundary conditions without using the
user
flag. Here I implement this feature. The changes I made are:ApplicationInput
now has a registration function where you register either a grid or particle boundary condition, with a function pointer (or a class in the case of swarm bounds) and a name.ApplicationInput
with the"reflecting"
name.BoundaryFlag
s are dramatically simplified, indicating (essentially) only whether or not boundaries are periodic.ApplicationInput
.The advantage of this is that you can now call (in your main function)
pman->app_input.RegisterBoundaryCondition(parthenon::BoundaryFace::inner_x1, "my_bc", &my_bc_func);
and then in the input file just use
I think the refactored code is also significantly cleaner and easier to read. Also I put a link to the parthenon paper in the readme.
PR Checklist