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

Refactor ReadBCParams #5767

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

Conversation

lucafedeli88
Copy link
Member

@lucafedeli88 lucafedeli88 commented Mar 14, 2025

I would like to propose to refactor the ReadBCParams function (now defined in WarpXUtil), with the aim of:

  • avoid manipulating directly the static variables of the WarpX class
  • re-organize what the function does into smaller functions that only do one thing

Specifically, the changes are:

  • create a new /FieldBoundaries.H/cpp file in BoundaryConditions, that for the moment contains only one pure function to parse the field boundary types from the inputfile (the idea is to extend this file later):
std::pair<
        amrex::Array<FieldBoundaryType, AMREX_SPACEDIM>,
        amrex::Array<FieldBoundaryType, AMREX_SPACEDIM>
    >
    warpx::boundary_conditions::parse_field_boundaries ()
  • move the part of ReadBCParams that sets pp_geometry.addarr("is_periodic", geom_periodicity); according to boundary conditions to set_periodicity_according_to_boundary_types in Initialization/WarpXAMReXInit.cpp (we usually place here methods that change AMReX default parameters during the initialization).

  • move the part of ReadBCParams that parses the particle boundary conditions to a new pure function parse_particle_boundaries in Particles/ParticleBoundaries.H/cpp (note that field boundary conditions are passed as arguments for consistency checks and for assigning default values):

    std::pair<
        amrex::Array<ParticleBoundaryType, AMREX_SPACEDIM>,
        amrex::Array<ParticleBoundaryType, AMREX_SPACEDIM>
    >
    warpx::particles::parse_particle_boundaries (
        const amrex::Array<FieldBoundaryType, AMREX_SPACEDIM>& field_boundary_lo,
        const amrex::Array<FieldBoundaryType, AMREX_SPACEDIM>& field_boundary_hi);
  • initialize field_boundary_lo, field_boundary_hi, particle_boundary_lo, particle_boundary_hi inside WarpX::MakeWarpX

  • Move consistency checks involving field solver to WarpX::ReadParameters (a further improvement would be to break ReadParameters into smaller pieces, but this will require several dedicated PRs).

  • remove void ReadBCParams () from WarpXUtil.H/cpp

@lucafedeli88 lucafedeli88 changed the title [WIP] Refactor ReadBCParams Refactor ReadBCParams Mar 17, 2025
@lucafedeli88 lucafedeli88 added cleaning Clean code, improve readability component: boundary PML, embedded boundaries, et al. labels Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleaning Clean code, improve readability component: boundary PML, embedded boundaries, et al.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants