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

[WIP] Add ability to load external particle fields from file #4981

Closed
wants to merge 11 commits into from

Conversation

RemiLehe
Copy link
Member

@RemiLehe RemiLehe commented Jun 10, 2024

We currently have the ability to load an external grid field from a file (thanks to #3584).

This PR provide a similar ability for the external particle fields.

The external grid and particle fields differ e.g. in the case of the EM solver:

  • the external grid fields are applied to the grid at t=0 and serve as initial condition to the Maxwell solver.
  • by contrast, the external particle fields are applied to the particles directly and are not affected by the Maxwell solver.

TODO:

  • Add explanation of how we are doing this: we add fields to aux. This means that this will automatically work with all other modules that gather the fields: particle push, ionization routine, etc.
  • Make it work with momentum conserving (in follow-up PR?)
  • Check MR
  • Make the data structures for external grid fields and external particle fields more similar.

@RemiLehe RemiLehe changed the title [WIP] Add ability to load particle external fields from file [WIP] Add ability to load external particle fields from file Jun 10, 2024
@RemiLehe RemiLehe marked this pull request as ready for review June 11, 2024 23:18
// TODO reuse WarpX::AddExternalFields
// TODO replace fp_external with simply external
for (int lev = 0; lev <= finest_level; ++lev) {
// FIXME: RZ multimode has more than one component for all these

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: RZ multimode has more than one component for all these
const amrex::IntVect& ng_src = guard_cells.ng_FieldGather;

// Level 0: Copy from fine to aux
// TODO Check if aux and fp are aliases of each other. If so, we can skip the copy.
Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed anymore after this PR is merged:
AMReX-Codes/amrex#3986

MultiFab::Copy(*Efield_aux[0][2], *Efield_fp[0][2], 0, 0, Efield_aux[0][2]->nComp(), ng_src);
MultiFab::Copy(*Bfield_aux[0][0], *Bfield_fp[0][0], 0, 0, Bfield_aux[0][0]->nComp(), ng_src);
MultiFab::Copy(*Bfield_aux[0][1], *Bfield_fp[0][1], 0, 0, Bfield_aux[0][1]->nComp(), ng_src);
MultiFab::Copy(*Bfield_aux[0][2], *Bfield_fp[0][2], 0, 0, Bfield_aux[0][2]->nComp(), ng_src);
Copy link
Member Author

Choose a reason for hiding this comment

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

Here, we need to check whether WarpX::fft_do_time_averaging is true. If yes,

MultiFab::Copy(*Bfield_aux[0][0], *Bfield_avg_fp[0][0], 0, 0, Bfield_aux[0][0]->nComp(), ng_src);

and otherwise, keep this code

@RemiLehe
Copy link
Member Author

Super-seeded by #4997

@RemiLehe RemiLehe closed this Jun 25, 2024
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.

None yet

1 participant