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

Fixing bug with the ES solver and MR: E_aux[lev] = E_fp[lev] in the UpdateAuxilaryData #4922

Open
wants to merge 39 commits into
base: development
Choose a base branch
from

Conversation

oshapoval
Copy link
Member

@oshapoval oshapoval commented May 10, 2024

This PR fixes a bug with the ES solver and MR. This issues was initially observed by @aeriforme. Worked on the issue with @RemiLehe.

Problem: observed doubling of the E field for lev>0.

Solution: when ES solver is used we have E_cp[levl] =0 and we should update the auxiliary data as E_aux[lev] = E_fp[lev] (inside WarpX::UpdateAuxilaryDataStagToNodal() and WarpX::UpdateAuxilaryDataSameType() rather than E_aux[lev] = E_fp[lev] - E_cp[lev] + E_aux[lev-1] in contrast to the EM solver. Otherwise it would result in doubling of E field we observed.

To do:

  • do the same in WarpX::UpdateAuxilaryDataStagToNodal ()
  • add CI test with amr.max_level = 1 (reused CI test electrostatic_sphere_eb_mr)
  • fix scraping tests

Results after the fix:

  • With MR patch occupying the whole simulation box:
    Figure 32-4
  • With MR patch smaller than the simulation box:
    Figure 31-6

@oshapoval oshapoval requested a review from RemiLehe May 10, 2024 01:12
@ax3l ax3l added bug Something isn't working component: electrostatic electrostatic solver bug: affects latest release Bug also exists in latest release version component: mesh refinement (A)MR labels May 12, 2024
@RemiLehe RemiLehe self-assigned this May 20, 2024
@EZoni EZoni self-requested a review July 3, 2024 01:32
Copy link
Member

@EZoni EZoni left a comment

Choose a reason for hiding this comment

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

I found three small issues, detailed below, that were causing the failure of two CI tests. I will push a commit to fix those and see if this is enough to make all CI tests pass successfully.

Update: bug fixes pushed in e5f0de6.

Comment on lines 676 to 716
if (do_pml && pml[lev]->ok())
{
WARPX_ABORT_WITH_MESSAGE("Averaged Galilean PSATD with PML is not yet implemented");
}

Copy link
Member

Choose a reason for hiding this comment

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

Just double checking, are this and the following similar changes (I counted four of them) related to this PR? The PR is a bug fix for the electrostatic solver with mesh refinement, while these changes are removing abort statements related to averaged Galilean PSATD with PMLs. Were they maybe left over from a different branch and/or should they be implemented in a dedicated PR?

Examples/Tests/electrostatic_sphere_eb/inputs_rz_mr Outdated Show resolved Hide resolved
Comment on lines 305 to 306
amrex::IntVect(0),
amrex::IntVect(1),
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that resetting the first argument (corresponding to src_nghost in the definition of ParallelCopy) to amrex::IntVect(1), as it was before, fixes the "erroneous arithmetic operation" error that was occurring in the tests ElectrostaticSphereLabFrame_MR_emass_10 and ElectrostaticSphereEB_RZ_MR.

What was the reason for deciding to change the code here and pass 0 ghost cells for the source MultiFab, as opposed to 1 ghost cell for the destination MultiFab?

Suggested change
amrex::IntVect(0),
amrex::IntVect(1),
amrex::IntVect(1),
amrex::IntVect(1),

@EZoni EZoni self-requested a review July 12, 2024 18:08
@EZoni
Copy link
Member

EZoni commented Jul 13, 2024

I'm investigating the failure of the scraping CI tests (which appears as "erroneous arithmetic operation") and what I can report so far is that it probably due to uninitialized values in the MultiFabs Efield_cax and Bfield_cax.

It's not clear to me yet why we are leaving some of those values untouched, hence uninitialized, with the code changes here.

Regardless of this, we might want to think whether we would like to initialize those MultiFabs to 0.0 as we do for the corresponding MultiFabs on level 0.

Merged the code changes in #5049 to verify that they are sufficient to fix the issue. Will rebase once more after #5049 is merged.

@EZoni EZoni force-pushed the mr_fix_auxilary_update_es_solver branch from 5c7f7dc to 9407bf9 Compare July 15, 2024 17:44
@EZoni
Copy link
Member

EZoni commented Jul 15, 2024

@oshapoval @RemiLehe
The scraping tests seem fixed now, thanks to #5049, which is a separate bug fix that we should merge first.
This said, before merging this PR, I will do another round of review and possibly clean up some code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: affects latest release Bug also exists in latest release version bug Something isn't working component: electrostatic electrostatic solver component: mesh refinement (A)MR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants