Skip to content
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

Adding support for pml in domain for multiple patches #4632

Conversation

RevathiJambunathan
Copy link
Member

@RevathiJambunathan RevathiJambunathan commented Jan 24, 2024

Thanks to @WeiqunZhang for the discussion and prototype!!!

The current implementation for pml_in_domain only works for a single patch
This PR adds capability to support 'pml_in_domain' for multiple distinct mesh-refinement patches

without the support for this feature : (PML in domain only on the left most edge of the left patch and right edge of the right patch) - i.e., the interiors edges dont apply PML correctly
Screenshot 2024-01-23 at 10 16 36 PM

With this PR :
Screenshot 2024-01-23 at 10 15 32 PM

}
if (do_pml_Hi[idim]){
domain0.growHi(idim, -ncell);
BoxList bl = grid_ba.boxList();
Copy link
Member

Choose a reason for hiding this comment

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

We could also use simplified_list() instead of boxList here. That way, it's less likely to hit the assert failure below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you Weiqun for the suggestions!
Done

// ncell is divided by refinement ratio to ensure that the
// physical width of the PML region is equal in fine and coarse patch
cdomain.growHi(idim, -ncell/ref_ratio[idim]);
BoxList bl = grid_cba.boxList();
Copy link
Member

Choose a reason for hiding this comment

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

Here we can use simplified_list as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member Author

Choose a reason for hiding this comment

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

discussed offline, switched back to boxList due to failing CI

@ax3l ax3l added the component: boundary PML, embedded boundaries, et al. label Jan 30, 2024
@@ -565,35 +565,43 @@ PML::PML (const int lev, const BoxArray& grid_ba, const DistributionMapping& gri
// In order to implement this, a reduced domain is created here (decreased by ncells in all direction)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the term "reduced domain" is not appropriate anymore in this comment, since it is not a single contiguous domain anymore.

for (auto& b : bl) {
for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
if (do_pml_Lo[idim]) {
Box const& bb = amrex::adjCellLo(b, idim);
Copy link
Member

@RemiLehe RemiLehe Feb 12, 2024

Choose a reason for hiding this comment

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

Could you add a comment to explains what this code (the call to adjCellLo and the subsequent intersects) does?

Copy link
Member Author

Choose a reason for hiding this comment

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

added comments to clarify

if (do_pml_Hi[idim]){
domain0.growHi(idim, -ncell);
BoxList bl = grid_ba.boxList();
for (auto& b : bl) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment to explain what this for loop does?
(In my understanding, it loops over the box at this level, and whenever a box touches a PML, it reduces the box by ncell, since this is where the surrounding "in-domain" PML will be created.)

Copy link
Member Author

Choose a reason for hiding this comment

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

added comments to clarify

Copy link
Member

@RemiLehe RemiLehe left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!
Could you add an automated test for this?

Also: could you confirm that this feature still work nicely with do_similar_dm_pml?

@@ -760,24 +768,28 @@ PML::PML (const int lev, const BoxArray& grid_ba, const DistributionMapping& gri
BoxArray grid_cba = grid_ba;
grid_cba.coarsen(ref_ratio);

// assuming that the bounding box around grid_cba is a single patch, and not disjoint patches, similar to fine patch.
amrex::Box cdomain = grid_cba.minimalBox();
BoxArray grid_cba_reduced = grid_cba;
Copy link
Member

Choose a reason for hiding this comment

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

The code below duplicates the above code.
Maybe it would be good, in a separate follow-up PR, to create a separate function for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. I ll do this in a separate PR

@RevathiJambunathan
Copy link
Member Author

Added a CI test by modifying existing 2D mr particles_in_pml test to include two patches
The dev branch shows spurious fields on the inner boundaries of the patch
Screenshot 2024-02-27 at 3 57 32 PM
The current PR applies the pml inside the domain correctly, fixing this spurious effect
Screenshot 2024-02-27 at 3 58 28 PM

@RemiLehe RemiLehe merged commit 6be87d6 into BLAST-WarpX:development Feb 28, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: boundary PML, embedded boundaries, et al. component: mesh refinement (A)MR enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants