Skip to content

Conversation

@dewenyushu
Copy link
Contributor

Taking over #3094

fdkong and others added 4 commits January 25, 2023 09:39
Use case: moving boundary with AMR. Boundary needs to be defined on child elements
The motivaiton is that: "automatic" way might not work for cases.

For example, if the flag is on on a subset of processor cores, and
then we do reparitioning, and then we might hit trouble because
the flag is off on the other processors

I try to avoid having a global reduction to have everyone on the same page.
In fact, we know when we want to allow children on boundary in MOOSE.
In this case, we should set the flag to make the code more robust
@moosebuild
Copy link

Job Coverage on b6b8849 wanted to post the following:

Coverage

482ca3 #3470 b6b884
Total Total +/- New
Rate 59.96% 59.94% -0.01% 38.00%
Hits 48759 48770 +11 19
Misses 32563 32590 +27 31

Diff coverage report

Full coverage report

Warnings

  • New new line coverage rate 38.00% is less than the suggested 90.0%

This comment will be updated on new commits.

@dewenyushu
Copy link
Contributor Author

@roystgnr I just tried to address your concerns for the original PR (#3094 ) here. Please let me know your comments. Appreciate it so much!

@dewenyushu dewenyushu force-pushed the boundary_on_child_elements branch 4 times, most recently from 2668cf2 to b930170 Compare January 26, 2023 22:12
this->remove_side(parent, side, bnd_id);
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the function to transfer boundary to the parent before coarsening

// Make sure we transfer the element's boundary id(s)
// up to its parent when necessary before coarsening.
// This can be adding or removing the corresonding boundary info.
_mesh.get_boundary_info().transfer_boundary_ids_to_parent(elem);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is when I transfer the boundary info to the parent

@dewenyushu
Copy link
Contributor Author

dewenyushu commented Jan 26, 2023

I tried numerous times adding a unit test for this code change and it would not work.. Not sure if this is something related to the code change or related to the unit test (this is the first cpp unit test I am writing so..)

The change works for my MOOSE-based application and tests so I am not sure how to debug more...

@roystgnr Would you mind taking a quick look and letting me know where I made mistakes that is obvious to you? Thanks!!

…ing, if the child element has boundary info associated with itself
@dewenyushu dewenyushu force-pushed the boundary_on_child_elements branch from 5c28e1b to 18a8ea1 Compare January 26, 2023 23:32
@roystgnr
Copy link
Member

I tried numerous times adding a unit test for this code change and it would not work.

That's good! The best unit tests are the ones that prevent regressions of bugs that have already happened.

I can replicate this; looking at it today.

@roystgnr
Copy link
Member

Oh, or maybe I should have refreshed the page first. Looks like CI thinks you already fixed it. Reviewing today, then.

@dewenyushu
Copy link
Contributor Author

I tried numerous times adding a unit test for this code change and it would not work.

That's good! The best unit tests are the ones that prevent regressions of bugs that have already happened.

I can replicate this; looking at it today.

Great! Really appreciate it!! - I am not familiar with unit tests so please bare with me if there are some stupid mistakes

Copy link
Member

@roystgnr roystgnr left a comment

Choose a reason for hiding this comment

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

We're getting closer, at least?

Comment on lines +1674 to +1676
for (auto it = searched_elem_vec.begin(); it != searched_elem_vec.end(); ++it)
{
const Elem * searched_elem = *it;
Copy link
Member

Choose a reason for hiding this comment

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

This could be cleaned up as above.

searched_elem = elem->top_parent();
searched_elem_vec.push_back(elem->top_parent());
else if (!_children_on_boundary)
searched_elem_vec.push_back(elem);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not even sure what's going on here. We do need to check intermediate parents in the _children_on_boundary case, not just the queried element and its top_parent.

// If yes, we make sure that the corresponding parent side is added to the boundary.
// Otherwise, we remove the parent side from the boundary.
std::vector<const Elem *> family_on_side;
elem->family_tree_by_side(family_on_side, side);
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't check siblings of elem, it checks descendants.

Copy link
Member

Choose a reason for hiding this comment

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

And you shouldn't need a full family_tree method here, either, because we really do only care about siblings; if an element's really about to be coarsened then any descendants or niblings it has should be subactive and we can ignore them.

Copy link
Member

Choose a reason for hiding this comment

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

So you can just loop over the parent's children. Note that you also have to make sure to check which children are on side; if we coarsen a 4-pack of Quad4 then we only care about preserving the ids shared by each 2 of them on each side, never all 4 at once.

{
LOG_UNIT_TEST;

std::unique_ptr<Mesh> mesh;
Copy link
Member

Choose a reason for hiding this comment

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

Just put the Mesh on the stack here?

But that's a quibble; this looks like an excellent first unit test. Not yet sufficient, given the failure cases above, but a good start.

@dewenyushu
Copy link
Contributor Author

close this one due to #3477

@dewenyushu dewenyushu closed this Feb 21, 2023
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.

4 participants