diff options
author | 2023-06-13 05:07:42 +0200 | |
---|---|---|
committer | 2023-06-13 03:07:42 +0000 | |
commit | 297dd2d31527acc9676d4eb0c3a9c54c2688abd6 (patch) | |
tree | 86e14ea3325872030f7fe3fb7b6e20013fa1d032 /Source/Particles/LaserParticleContainer.cpp | |
parent | d1a2d04521691a9489f53cc003142e91d98571ee (diff) | |
download | WarpX-297dd2d31527acc9676d4eb0c3a9c54c2688abd6.tar.gz WarpX-297dd2d31527acc9676d4eb0c3a9c54c2688abd6.tar.zst WarpX-297dd2d31527acc9676d4eb0c3a9c54c2688abd6.zip |
Enforce const correctness using clang-tidy CI test (#3921)
* add clang-tidy workflow
* fix missing newline
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* make clang.14.sh executable
* remove non explicitly selected checks
* complete list of dependencies
* fix bug
* specify path of clang-tidy file
* fix bug
* add new check
* remove one check
* add magic numbers check
* removed one check
* keep only one check
* Docs: Conda Dev w/ Boost (#3911)
Add the `boost` package to the conda developer environment.
Used for QED table generation.
* Fix typo in Adastra cluster documentation (#3918)
* add back three checks
* prepare clang-tidy wrapper
* actually use clang-tidy in the script
* test
* fix bug
* actually use clang-tidy
* fixed bug
* fixed bug
* fixed bug
* fixed bug
* remove all checks except the selected 3
* fixed bug
* fixed bug
* fixed bug
* enforce const correctness using clang-tidy
* remove one check
* Fix Concurrency Issue
* BLAS++/LAPACK++ for RZ+PSATD
* Build all 4 WarpX DIMS
* add few echo for test purposes
* try to debug mysterious error
* don't test RZ with clang-tidy
* add back RZ test
* add some const
* fix bug
* check also header files
* remove header filter since it does not work as expected
* fixed bug
* check also WarpX headers
* fix bugs
* continue enforcing const correctness
* continue enforcing const correctness
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fixed bug
* fix bugs and add new const
* clean .clang-tidy
* make regex more precise according to Weiqun's suggestion
* add more const
* fix bugs
* fix bug
* silence warning on float comparison
* fixed bug
* fixed bugs
* fix bug and add const
* fixed bugs
* fix bug
* fix bug
* fix bug
* fixed bug
* fix bug
Diffstat (limited to 'Source/Particles/LaserParticleContainer.cpp')
-rw-r--r-- | Source/Particles/LaserParticleContainer.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/Source/Particles/LaserParticleContainer.cpp b/Source/Particles/LaserParticleContainer.cpp index 8221683c1..73e27b3c5 100644 --- a/Source/Particles/LaserParticleContainer.cpp +++ b/Source/Particles/LaserParticleContainer.cpp @@ -86,7 +86,7 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, charge = 1.0; mass = std::numeric_limits<Real>::max(); - ParmParse pp_laser_name(m_laser_name); + const ParmParse pp_laser_name(m_laser_name); // Parse the type of laser profile and set the corresponding flag `profile` std::string laser_type_s; @@ -114,7 +114,7 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, const bool a0_is_specified = utils::parser::queryWithParser(pp_laser_name, "a0", a0); if (a0_is_specified){ - Real omega = 2._rt*MathConst::pi*PhysConst::c/m_wavelength; + const Real omega = 2._rt*MathConst::pi*PhysConst::c/m_wavelength; m_e_max = PhysConst::m_e * omega * PhysConst::c * a0 / PhysConst::q_e; } AMREX_ALWAYS_ASSERT_WITH_MESSAGE( @@ -138,10 +138,10 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, //Check if someone uses the obsolete syntax std::vector<std::string> backward_laser_names; - ParmParse pp_lasers("lasers"); + const ParmParse pp_lasers("lasers"); pp_lasers.queryarr("names", backward_laser_names); - for(std::string lasersiter : backward_laser_names){ - ParmParse pp_name(lasersiter); + for(const std::string& lasersiter : backward_laser_names){ + const ParmParse pp_name(lasersiter); std::string backward_profile; std::stringstream lasers; pp_name.query("profile", backward_profile); @@ -187,7 +187,7 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, // Get the position of the plane, along the boost direction, in the lab frame // and convert the position of the antenna to the boosted frame m_Z0_lab = m_nvec[0]*m_position[0] + m_nvec[1]*m_position[1] + m_nvec[2]*m_position[2]; - Real Z0_boost = m_Z0_lab/WarpX::gamma_boost; + const Real Z0_boost = m_Z0_lab/WarpX::gamma_boost; m_position[0] += (Z0_boost-m_Z0_lab)*m_nvec[0]; m_position[1] += (Z0_boost-m_Z0_lab)*m_nvec[1]; m_position[2] += (Z0_boost-m_Z0_lab)*m_nvec[2]; @@ -234,7 +234,7 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, m_updated_position = m_position; // Sanity checks - int dir = WarpX::moving_window_dir; + const int dir = WarpX::moving_window_dir; std::vector<Real> windir(3, 0.0); #if defined(WARPX_DIM_1D_Z) windir[2] = 1.0; @@ -328,7 +328,7 @@ LaserParticleContainer::UpdateContinuousInjectionPosition (Real dt) { if (!m_enabled) return; - int dir = WarpX::moving_window_dir; + const int dir = WarpX::moving_window_dir; if (do_continuous_injection and (WarpX::gamma_boost > 1)){ // In boosted-frame simulations, the antenna has moved since the last // call to this function, and injection position needs to be updated @@ -482,9 +482,9 @@ LaserParticleContainer::InitData (int lev) } } #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) - BoxArray plane_ba { Box {IntVect(plane_lo[0],0), IntVect(plane_hi[0],0)} }; + const BoxArray plane_ba { Box {IntVect(plane_lo[0],0), IntVect(plane_hi[0],0)} }; #else - BoxArray plane_ba { Box {IntVect(0), IntVect(0)} }; + const BoxArray plane_ba { Box {IntVect(0), IntVect(0)} }; #endif amrex::Vector<amrex::ParticleReal> particle_x, particle_y, particle_z, particle_w; @@ -658,7 +658,7 @@ LaserParticleContainer::Evolve (int lev, if (skip_deposition == false) { // Deposit at t_{n+1/2} - amrex::Real relative_time = -0.5_rt * dt; + const amrex::Real relative_time = -0.5_rt * dt; int* ion_lev = nullptr; // Deposit inside domains @@ -792,16 +792,16 @@ LaserParticleContainer::calculate_laser_plane_coordinates (const WarpXParIter& p const auto GetPosition = GetParticlePosition(pti); #if (AMREX_SPACEDIM >= 2) - Real tmp_u_X_0 = m_u_X[0]; - Real tmp_u_X_2 = m_u_X[2]; - Real tmp_position_0 = m_position[0]; - Real tmp_position_2 = m_position[2]; + const Real tmp_u_X_0 = m_u_X[0]; + const Real tmp_u_X_2 = m_u_X[2]; + const Real tmp_position_0 = m_position[0]; + const Real tmp_position_2 = m_position[2]; #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ) - Real tmp_u_X_1 = m_u_X[1]; - Real tmp_u_Y_0 = m_u_Y[0]; - Real tmp_u_Y_1 = m_u_Y[1]; - Real tmp_u_Y_2 = m_u_Y[2]; - Real tmp_position_1 = m_position[1]; + const Real tmp_u_X_1 = m_u_X[1]; + const Real tmp_u_Y_0 = m_u_Y[0]; + const Real tmp_u_Y_1 = m_u_Y[1]; + const Real tmp_u_Y_2 = m_u_Y[2]; + const Real tmp_position_1 = m_position[1]; #endif #endif @@ -854,17 +854,17 @@ LaserParticleContainer::update_laser_particle (WarpXParIter& pti, const auto GetPosition = GetParticlePosition(pti); auto SetPosition = SetParticlePosition(pti); - Real tmp_p_X_0 = m_p_X[0]; - Real tmp_p_X_1 = m_p_X[1]; - Real tmp_p_X_2 = m_p_X[2]; - Real tmp_nvec_0 = m_nvec[0]; - Real tmp_nvec_1 = m_nvec[1]; - Real tmp_nvec_2 = m_nvec[2]; + const Real tmp_p_X_0 = m_p_X[0]; + const Real tmp_p_X_1 = m_p_X[1]; + const Real tmp_p_X_2 = m_p_X[2]; + const Real tmp_nvec_0 = m_nvec[0]; + const Real tmp_nvec_1 = m_nvec[1]; + const Real tmp_nvec_2 = m_nvec[2]; // Copy member variables to tmp copies for GPU runs. - Real tmp_mobility = m_mobility; - Real gamma_boost = WarpX::gamma_boost; - Real beta_boost = WarpX::beta_boost; + const Real tmp_mobility = m_mobility; + const Real gamma_boost = WarpX::gamma_boost; + const Real beta_boost = WarpX::beta_boost; amrex::ParallelFor( np, [=] AMREX_GPU_DEVICE (int i) { |