diff options
author | 2021-12-20 18:39:08 -0800 | |
---|---|---|
committer | 2021-12-21 02:39:08 +0000 | |
commit | aafb6da2362374eb255eff450b846c4fec20ac5e (patch) | |
tree | 8a24908133d464a84aedd82d07ccc720808e8b6a /Source/Utils/WarpXUtil.cpp | |
parent | 634a2833a7a13cffde77c5d3229e0566c327f096 (diff) | |
download | WarpX-aafb6da2362374eb255eff450b846c4fec20ac5e.tar.gz WarpX-aafb6da2362374eb255eff450b846c4fec20ac5e.tar.zst WarpX-aafb6da2362374eb255eff450b846c4fec20ac5e.zip |
Inputs: `geometry.dims` option (#2685)
* Docs: `geometry.dims` option
Add a new, required option to specify the geometry of an
inputs file at runtime.
* Check & Report Runtime Dims Mismatch
* Examples: add `geometry.dims`
* Deprecation Warning: `geometry.coord_sys`
* PICMI: `geometry.dims`
* Improve error message
sounds a bit better
* Improve Doc Description
Co-authored-by: Revathi Jambunathan <41089244+RevathiJambunathan@users.noreply.github.com>
Co-authored-by: Revathi Jambunathan <41089244+RevathiJambunathan@users.noreply.github.com>
Diffstat (limited to 'Source/Utils/WarpXUtil.cpp')
-rw-r--r-- | Source/Utils/WarpXUtil.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/Source/Utils/WarpXUtil.cpp b/Source/Utils/WarpXUtil.cpp index b05935587..864fc3b10 100644 --- a/Source/Utils/WarpXUtil.cpp +++ b/Source/Utils/WarpXUtil.cpp @@ -53,6 +53,9 @@ void PreparseAMReXInputIntArray(amrex::ParmParse& a_pp, char const * const input void ParseGeometryInput() { + // Ensure that geometry.dims is set properly. + CheckDims(); + // Parse prob_lo and hi, evaluating any expressions since geometry does not // parse its input ParmParse pp_geometry("geometry"); @@ -516,25 +519,37 @@ void getArrWithParser (const amrex::ParmParse& a_pp, char const * const str, std } } -/** - * \brief Ensures that the blocks are setup correctly for the RZ spectral solver - * When using the RZ spectral solver, the Hankel transform cannot be - * divided among multiple blocks. Each block must extend over the - * entire radial extent. - * The grid can be divided up along z, but the number of blocks - * must be >= the number of processors. - */ +void CheckDims () +{ + // Ensure that geometry.dims is set properly. +#if defined(WARPX_DIM_3D) + std::string const dims_compiled = "3"; +#elif defined(WARPX_DIM_XZ) + std::string const dims_compiled = "2"; +#elif defined(WARPX_DIM_1D_Z) + std::string const dims_compiled = "1"; +#elif defined(WARPX_DIM_RZ) + std::string const dims_compiled = "RZ"; +#endif + ParmParse pp_geometry("geometry"); + std::string dims; + pp_geometry.get("dims", dims); + std::string dims_error = "ERROR: The selected WarpX executable was built as '"; + dims_error.append(dims_compiled).append("'-dimensional, but the "); + dims_error.append("inputs file declares 'geometry.dims = ").append(dims).append("'.\n"); + dims_error.append("Please re-compile with a different WarpX_DIMS option or select the right executable name."); + WarpXUtilMsg::AlwaysAssert(dims == dims_compiled, dims_error); +} + void CheckGriddingForRZSpectral () { -#ifndef WARPX_DIM_RZ - amrex::Abort("CheckGriddingForRZSpectral: WarpX was not built with RZ geometry."); -#else +#ifdef WARPX_DIM_RZ + // Ensure that geometry.dims is set properly. + CheckDims(); - // Ensure that geometry.coord_sys is set properly. - ParmParse pp_geometry("geometry"); + // Ensure that AMReX geometry.coord_sys is set properly int coord_sys = 1; - pp_geometry.query("coord_sys", coord_sys); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(coord_sys == 1, "geometry.coord_sys needs to be 1 when using cylindrical geometry"); + ParmParse pp_geometry("geometry"); pp_geometry.add("coord_sys", coord_sys); ParmParse pp_algo("algo"); |