diff options
author | 2023-06-13 05:07:42 +0200 | |
---|---|---|
committer | 2023-06-13 03:07:42 +0000 | |
commit | 297dd2d31527acc9676d4eb0c3a9c54c2688abd6 (patch) | |
tree | 86e14ea3325872030f7fe3fb7b6e20013fa1d032 /Source/Utils/WarpXMovingWindow.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/Utils/WarpXMovingWindow.cpp')
-rw-r--r-- | Source/Utils/WarpXMovingWindow.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/Source/Utils/WarpXMovingWindow.cpp b/Source/Utils/WarpXMovingWindow.cpp index 90d7190fe..7e7985b98 100644 --- a/Source/Utils/WarpXMovingWindow.cpp +++ b/Source/Utils/WarpXMovingWindow.cpp @@ -55,7 +55,7 @@ using namespace amrex; void WarpX::UpdatePlasmaInjectionPosition (amrex::Real a_dt) { - int dir = moving_window_dir; + const int dir = moving_window_dir; // Continuously inject plasma in new cells (by default only on level 0) if (WarpX::warpx_do_continuous_injection and (WarpX::gamma_boost > 1)){ // In boosted-frame simulations, the plasma has moved since the last @@ -94,7 +94,7 @@ WarpX::MoveWindow (const int step, bool move_j) // Update the continuous position of the moving window, // and of the plasma injection moving_window_x += (moving_window_v - WarpX::beta_boost * PhysConst::c)/(1 - moving_window_v * WarpX::beta_boost / PhysConst::c) * dt[0]; - int dir = moving_window_dir; + const int dir = moving_window_dir; // Update warpx.current_injection_position // PhysicalParticleContainer uses this injection position @@ -112,7 +112,7 @@ WarpX::MoveWindow (const int step, bool move_j) const amrex::Real* current_lo = geom[0].ProbLo(); const amrex::Real* current_hi = geom[0].ProbHi(); const amrex::Real* cdx = geom[0].CellSize(); - int num_shift_base = static_cast<int>((moving_window_x - current_lo[dir]) / cdx[dir]); + const int num_shift_base = static_cast<int>((moving_window_x - current_lo[dir]) / cdx[dir]); if (num_shift_base == 0) return 0; @@ -139,7 +139,7 @@ WarpX::MoveWindow (const int step, bool move_j) new_slice_lo[i] = current_slice_lo[i]; new_slice_hi[i] = current_slice_hi[i]; } - int num_shift_base_slice = static_cast<int> ((moving_window_x - + const int num_shift_base_slice = static_cast<int> ((moving_window_x - current_slice_lo[dir]) / cdx[dir]); new_slice_lo[dir] = current_slice_lo[dir] + num_shift_base_slice*cdx[dir]; new_slice_hi[dir] = current_slice_hi[dir] + num_shift_base_slice*cdx[dir]; @@ -324,12 +324,12 @@ WarpX::MoveWindow (const int step, bool move_j) amrex::Real new_injection_position; if (moving_window_v >= 0){ // Forward-moving window - amrex::Real dx = geom[lev].CellSize(dir); + const amrex::Real dx = geom[lev].CellSize(dir); new_injection_position = current_injection_position + std::floor( (geom[lev].ProbHi(dir) - current_injection_position)/dx ) * dx; } else { // Backward-moving window - amrex::Real dx = geom[lev].CellSize(dir); + const amrex::Real dx = geom[lev].CellSize(dir); new_injection_position = current_injection_position - std::floor( (current_injection_position - geom[lev].ProbLo(dir))/dx) * dx; } @@ -410,7 +410,7 @@ WarpX::shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom, amrex::IntVect shiftiv(0); shiftiv[dir] = num_shift; - amrex::Dim3 shift = shiftiv.dim3(); + const amrex::Dim3 shift = shiftiv.dim3(); const amrex::RealBox& real_box = geom.ProbDomain(); const auto dx = geom.CellSizeArray(); @@ -452,23 +452,23 @@ WarpX::shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom, { // Compute x,y,z co-ordinates based on index type of mf #if defined(WARPX_DIM_1D_Z) - amrex::Real x = 0.0_rt; - amrex::Real y = 0.0_rt; - amrex::Real fac_z = (1.0_rt - mf_type[0]) * dx[0]*0.5_rt; - amrex::Real z = i*dx[0] + real_box.lo(0) + fac_z; + const amrex::Real x = 0.0_rt; + const amrex::Real y = 0.0_rt; + const amrex::Real fac_z = (1.0_rt - mf_type[0]) * dx[0]*0.5_rt; + const amrex::Real z = i*dx[0] + real_box.lo(0) + fac_z; #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) - amrex::Real fac_x = (1.0_rt - mf_type[0]) * dx[0]*0.5_rt; - amrex::Real x = i*dx[0] + real_box.lo(0) + fac_x; - amrex::Real y = 0.0; - amrex::Real fac_z = (1.0_rt - mf_type[1]) * dx[1]*0.5_rt; - amrex::Real z = j*dx[1] + real_box.lo(1) + fac_z; + const amrex::Real fac_x = (1.0_rt - mf_type[0]) * dx[0]*0.5_rt; + const amrex::Real x = i*dx[0] + real_box.lo(0) + fac_x; + const amrex::Real y = 0.0; + const amrex::Real fac_z = (1.0_rt - mf_type[1]) * dx[1]*0.5_rt; + const amrex::Real z = j*dx[1] + real_box.lo(1) + fac_z; #else - amrex::Real fac_x = (1.0_rt - mf_type[0]) * dx[0]*0.5_rt; - amrex::Real x = i*dx[0] + real_box.lo(0) + fac_x; - amrex::Real fac_y = (1.0_rt - mf_type[1]) * dx[1]*0.5_rt; - amrex::Real y = j*dx[1] + real_box.lo(1) + fac_y; - amrex::Real fac_z = (1.0_rt - mf_type[2]) * dx[2]*0.5_rt; - amrex::Real z = k*dx[2] + real_box.lo(2) + fac_z; + const amrex::Real fac_x = (1.0_rt - mf_type[0]) * dx[0]*0.5_rt; + const amrex::Real x = i*dx[0] + real_box.lo(0) + fac_x; + const amrex::Real fac_y = (1.0_rt - mf_type[1]) * dx[1]*0.5_rt; + const amrex::Real y = j*dx[1] + real_box.lo(1) + fac_y; + const amrex::Real fac_z = (1.0_rt - mf_type[2]) * dx[2]*0.5_rt; + const amrex::Real z = k*dx[2] + real_box.lo(2) + fac_z; #endif srcfab(i,j,k,n) = field_parser(x,y,z); }); @@ -512,7 +512,7 @@ WarpX::shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom, for (int i = 0, N=ba.size(); i < N; ++i) { bl.push_back(amrex::grow(ba[i], 0, mf.nGrowVect()[0])); } - amrex::BoxArray rba(std::move(bl)); + const amrex::BoxArray rba(std::move(bl)); amrex::MultiFab rmf(rba, dm, mf.nComp(), IntVect(0,mf.nGrowVect()[1]), MFInfo().SetAlloc(false)); for (amrex::MFIter mfi(mf); mfi.isValid(); ++mfi) { @@ -527,13 +527,13 @@ WarpX::shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom, void WarpX::ShiftGalileanBoundary () { - amrex::Real cur_time = t_new[0]; + const amrex::Real cur_time = t_new[0]; amrex::Real new_lo[AMREX_SPACEDIM]; amrex::Real new_hi[AMREX_SPACEDIM]; const amrex::Real* current_lo = geom[0].ProbLo(); const amrex::Real* current_hi = geom[0].ProbHi(); - amrex::Real time_shift = (cur_time - time_of_last_gal_shift); + const amrex::Real time_shift = (cur_time - time_of_last_gal_shift); #if defined(WARPX_DIM_3D) m_galilean_shift = { |