From cb79a956f70204b12ed37646ea1bb5a2eea307f4 Mon Sep 17 00:00:00 2001 From: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> Date: Wed, 16 Feb 2022 20:11:35 +0100 Subject: Gaussian particle beam: add error message when using y_rms = 0 in 2D (#2862) --- Source/Initialization/PlasmaInjector.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Source/Initialization/PlasmaInjector.cpp') diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index 1912f3679..6026f28a6 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -55,6 +55,8 @@ PlasmaInjector::PlasmaInjector () {} PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) : species_id(ispecies), species_name(name) { + using namespace amrex::literals; + amrex::ParmParse pp_species_name(species_name); #ifdef AMREX_USE_GPU @@ -211,6 +213,19 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) pp_species_name.query("do_symmetrize", do_symmetrize); gaussian_beam = true; parseMomentum(pp_species_name); +#if defined(WARPX_DIM_XZ) + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( y_rms > 0._rt, + "Error: Gaussian beam y_rms must be strictly greater than 0 in 2D " + "(it is used when computing the particles' weights from the total beam charge)"); +#elif defined(WARPX_DIM_1D_Z) + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( x_rms > 0._rt, + "Error: Gaussian beam x_rms must be strictly greater than 0 in 1D " + "(it is used when computing the particles' weights from the total beam charge)"); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( y_rms > 0._rt, + "Error: Gaussian beam y_rms must be strictly greater than 0 in 1D " + "(it is used when computing the particles' weights from the total beam charge)"); +#endif + } // Depending on injection type at runtime, initialize inj_pos // so that inj_pos->getPositionUnitBox calls -- cgit v1.2.3