Skip to content

Breaking change: allow input decks to work for both 2D and 3D #113

Open
@RemiLehe

Description

@RemiLehe

From our Slack discussion:

It would be useful to be able to run the exact same input deck with 2D and 3D.
(In that case, when run with 2D, variables such as
geometry.prob_lo = -150.e-6 -150.e-6 -50.e-6
would be read in such a way that only the first and last values would be used.)

The motivation is that it would avoid a lot of copy-paste mistake: 2D input decks are usually obtained by copy-pasting 3D input decks, and modifying variables (such as prob_lo) by hand. However, it is easy to forget a variable, and this can have drastic consequences on the simulation.

For variables that are read by AMReX - not WarpX directly - (such as geometry.prob_lo), we should create a corresponding WarpX variable (e.g. warpx.prob_lo) and do something like this:

    amrex::Initialize(argc,argv);
   {
       ParmParse ppw("warpx");
       ParmParse ppg("geometry");
       if (ppw.countval("prob_lo") > 0) {
           Vector<Real> plo;
           ppw.getarr("prob_lo", plo);
#if (AMREX_SPACEDIM == 3)
           ppg.addarr("prob_lo", plo);
#else
           ppg.addarr("prob_lo", {plo[0],plo[2]});
#endif
       }
       // prob_hi, is_periodic, ...
   }

In order to implement the above change we should:

  • Change the way in which most vector variables are read, in 2D
  • Add the above mentioned warpx variables, for variables read by AMReX
  • Update the documentation, and clearly mention that only the first and last variable are read, in 2D (for each vector variable)
  • Remove all the 2D scripts, in the Example folder (they would no longer be needed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions