-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix refinement next to refined blocks #928
Conversation
During re-meshing, track which meshblocks are newly created. After prolongating shared boundaries, but before prolongating internal boundaries, update elements on block faces to respect the ownership model. Still needs tweaks to the new-mesh priority!
@par-hermes format |
src/mesh/mesh.cpp
Outdated
|
||
// Output variables in use in this run | ||
if (Globals::my_rank == 0) { | ||
std::cout << "#Variables in use:\n" << *(resolved_packages) << std::endl; | ||
} |
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.
Isn't this included in another PR? Did that not get merged?
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.
No, that one's still in queue. I pinged some people, probably it will still go in before this one and I can avoid having to correct my mistake here.
return 2 * a.level(); | ||
}; | ||
|
||
auto ownership_less_than = [ownership_level](const LogicalLocation &a, |
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.
still cheeky IMO
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.
As in, I should collapse it? This seemed pretty easy to understand, if a little over-engineered
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.
no no---it's fine. Cheeky is not a bad thing.
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.
no no---it's fine. Cheeky is not a bad thing.
Check boxes needed :) Not for this PR, but we really need a regression test |
Yeah, we need to write a vector wave equation example I think. |
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.
Overall this looks good to me, but one potential bug and one potential performance enhancement below.
src/mesh/amr_loadbalance.cpp
Outdated
@@ -789,6 +789,7 @@ void Mesh::RedistributeAndRefineMeshBlocks(ParameterInput *pin, ApplicationInput | |||
RegionSize block_size = GetBlockSize(); | |||
|
|||
BlockList_t new_block_list(nbe - nbs + 1); | |||
std::set<LogicalLocation> newly_refined; |
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 we may want this to be a std::unordered_set
for performance reasons.
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.
Agreed, I think, the list could potentially be long and we're checking membership.
What's a good hash function for the unordered_set? Just morton number?
Speaking of that, I think I populate this list incorrectly, since I only pull from nbs
to nbe
of the global block list in populating newly_refined, meaning I need to collate the lists from all ranks. So, also going to fix 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.
A hash for LogicalLocation
is injected into the std::
namespace, so std::unordered_map<LogicalLocation>
should just work.
Good catch. Yeah, I think you need the locations on all ranks.
Okay, as updated the PR now gathers new refinements by comparing the global new & old lists of blocks (I think. The variable naming wasn't completely clear to me in an MPI context and there are no relevant comments). Testing with multiple MPI ranks now. Also switched to
Pretty sure this is the simple way to solve it, but maybe I'm missing something. |
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.
LGTM, thanks for switching over to std::unordered_set
. I think your solution is the right one.
Would love to just merge this in the next few days if there aren't objections |
I'm enabling auto merge |
PR Summary
Fixes #927
Not attached to the carry-around-the-list interface here, or the cheeky double-lambda.
Note that the issue this fixes is really two issues:
Most of the code is aimed at dealing with (2), which requires determining and then syncing according to a special priority order, namely:
That is, freshly-refined blocks should own any boundaries with coarser blocks, but none of their boundaries with previously-refined blocks (and should still choose by Morton number among themselves).
Still working on getting this entirely correct, (2) and (3) are muddy in the code as posted.
PR Checklist