aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar NeilZaim <49716072+NeilZaim@users.noreply.github.com> 2020-09-15 03:37:42 +0200
committerGravatar GitHub <noreply@github.com> 2020-09-14 18:37:42 -0700
commit9da12bfbb4add2b0c6d6661c1d66f612c4e01cdc (patch)
treed4f47b84e1ef20d4b1087156247b6ee8e6bfd564
parentfcfda04386ff11a4b5a42b1debd692621a2f9d99 (diff)
downloadWarpX-9da12bfbb4add2b0c6d6661c1d66f612c4e01cdc.tar.gz
WarpX-9da12bfbb4add2b0c6d6661c1d66f612c4e01cdc.tar.zst
WarpX-9da12bfbb4add2b0c6d6661c1d66f612c4e01cdc.zip
[mini] Add Warning/Assert for segfault in laser injection (#1315)
* Add Warning/Assert for segfault in laser injection * DPCPP Beta09: Package Broken (#1314) The Ubuntu packages seem to forget the `env/var.sh` activation scripts for the compiler packages for beta09. * Add Warning/Assert for segfault in laser injection Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
-rw-r--r--Source/Laser/LaserParticleContainer.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/Laser/LaserParticleContainer.cpp b/Source/Laser/LaserParticleContainer.cpp
index f18951443..12d0121dd 100644
--- a/Source/Laser/LaserParticleContainer.cpp
+++ b/Source/Laser/LaserParticleContainer.cpp
@@ -63,6 +63,11 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies,
m_up_laser_profile = laser_profiles_dictionary.at(laser_type_s)();
//__________
+#ifdef WARPX_DIM_XZ
+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE(nvec[1] == amrex::Real(0),
+ "Laser propagation direction must be 0 along y in 2D");
+#endif
+
// Plane normal
Real s = 1.0_rt / std::sqrt(nvec[0]*nvec[0] + nvec[1]*nvec[1] + nvec[2]*nvec[2]);
nvec = { nvec[0]*s, nvec[1]*s, nvec[2]*s };
@@ -566,6 +571,14 @@ LaserParticleContainer::ComputeWeightMobility (Real Sx, Real Sy)
// the amplitude of the field) are given in the lab-frame.
// Therefore, the mobility needs to be modified by a factor WarpX::gamma_boost.
mobility = mobility/WarpX::gamma_boost;
+
+ // If mobility is too high (caused by a small wavelength compared to the grid size),
+ // calculated antenna particle velocities may exceed c, which can cause a segfault.
+ constexpr Real warning_tol = 0.1_rt;
+ if (wavelength < std::min(Sx,Sy)*warning_tol){
+ amrex::Warning("WARNING: laser wavelength seems to be much smaller than the grid size."
+ " This may cause a segmentation fault");
+ }
}
void