From 297dd2d31527acc9676d4eb0c3a9c54c2688abd6 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Tue, 13 Jun 2023 05:07:42 +0200 Subject: 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 --- .../SpectralAlgorithms/PsatdAlgorithmComoving.cpp | 32 +++++++------- .../PsatdAlgorithmFirstOrder.cpp | 2 +- .../PsatdAlgorithmJConstantInTime.cpp | 50 +++++++++++----------- .../PsatdAlgorithmJLinearInTime.cpp | 30 ++++++------- .../SpectralAlgorithms/PsatdAlgorithmPml.cpp | 14 +++--- .../SpectralAlgorithms/SpectralBaseAlgorithm.cpp | 2 +- 6 files changed, 65 insertions(+), 65 deletions(-) (limited to 'Source/FieldSolver/SpectralSolver/SpectralAlgorithms') diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.cpp index eb7e1578e..37bbc2ca3 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.cpp @@ -75,15 +75,15 @@ PsatdAlgorithmComoving::pushSpectralFields (SpectralFieldData& f) const const amrex::Box& bx = f.fields[mfi].box(); // Extract arrays for the fields to be updated - amrex::Array4 fields = f.fields[mfi].array(); + const amrex::Array4 fields = f.fields[mfi].array(); // Extract arrays for the coefficients - amrex::Array4 C_arr = C_coef [mfi].array(); - amrex::Array4 S_ck_arr = S_ck_coef[mfi].array(); - amrex::Array4 X1_arr = X1_coef [mfi].array(); - amrex::Array4 X2_arr = X2_coef [mfi].array(); - amrex::Array4 X3_arr = X3_coef [mfi].array(); - amrex::Array4 X4_arr = X4_coef [mfi].array(); + const amrex::Array4 C_arr = C_coef [mfi].array(); + const amrex::Array4 S_ck_arr = S_ck_coef[mfi].array(); + const amrex::Array4 X1_arr = X1_coef [mfi].array(); + const amrex::Array4 X2_arr = X2_coef [mfi].array(); + const amrex::Array4 X3_arr = X3_coef [mfi].array(); + const amrex::Array4 X4_arr = X4_coef [mfi].array(); // Extract pointers for the k vectors const amrex::Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr(); @@ -178,13 +178,13 @@ void PsatdAlgorithmComoving::InitializeSpectralCoefficients (const SpectralKSpac const amrex::Real* kz = kz_vec[mfi].dataPtr(); // Extract arrays for the coefficients - amrex::Array4 C = C_coef [mfi].array(); - amrex::Array4 S_ck = S_ck_coef [mfi].array(); - amrex::Array4 X1 = X1_coef [mfi].array(); - amrex::Array4 X2 = X2_coef [mfi].array(); - amrex::Array4 X3 = X3_coef [mfi].array(); - amrex::Array4 X4 = X4_coef [mfi].array(); - amrex::Array4 T2 = Theta2_coef[mfi].array(); + const amrex::Array4 C = C_coef [mfi].array(); + const amrex::Array4 S_ck = S_ck_coef [mfi].array(); + const amrex::Array4 X1 = X1_coef [mfi].array(); + const amrex::Array4 X2 = X2_coef [mfi].array(); + const amrex::Array4 X3 = X3_coef [mfi].array(); + const amrex::Array4 X4 = X4_coef [mfi].array(); + const amrex::Array4 T2 = Theta2_coef[mfi].array(); // Store comoving velocity const amrex::Real vx = m_v_comoving[0]; @@ -254,7 +254,7 @@ void PsatdAlgorithmComoving::InitializeSpectralCoefficients (const SpectralKSpac if ( (nu != om_mod/om) && (nu != -om_mod/om) && (nu != 0.) ) { - Complex x1 = om2 / (om2_mod - nu * nu * om2) + const Complex x1 = om2 / (om2_mod - nu * nu * om2) * (theta_star - theta * C(i,j,k) + I * nu * om * theta * S_ck(i,j,k)); // X1 multiplies i*(k \times J) in the update equation for B @@ -424,7 +424,7 @@ void PsatdAlgorithmComoving::CurrentCorrection (SpectralFieldData& field_data) const amrex::Box& bx = field_data.fields[mfi].box(); // Extract arrays for the fields to be updated - amrex::Array4 fields = field_data.fields[mfi].array(); + const amrex::Array4 fields = field_data.fields[mfi].array(); // Extract pointers for the k vectors const amrex::Real* const modified_kx_arr = modified_kx_vec[mfi].dataPtr(); diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmFirstOrder.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmFirstOrder.cpp index 113f88fca..946d938c7 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmFirstOrder.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmFirstOrder.cpp @@ -69,7 +69,7 @@ PsatdAlgorithmFirstOrder::pushSpectralFields (SpectralFieldData& f) const const amrex::Box& bx = f.fields[mfi].box(); // Extract arrays for the fields to be updated - amrex::Array4 fields = f.fields[mfi].array(); + const amrex::Array4 fields = f.fields[mfi].array(); // Extract pointers for the k vectors const amrex::Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr(); diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp index 6aad1831e..72c2b7a28 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp @@ -129,14 +129,14 @@ PsatdAlgorithmJConstantInTime::pushSpectralFields (SpectralFieldData& f) const const amrex::Box& bx = f.fields[mfi].box(); // Extract arrays for the fields to be updated - amrex::Array4 fields = f.fields[mfi].array(); + const amrex::Array4 fields = f.fields[mfi].array(); // These coefficients are always allocated - amrex::Array4 C_arr = C_coef[mfi].array(); - amrex::Array4 S_ck_arr = S_ck_coef[mfi].array(); - amrex::Array4 X1_arr = X1_coef[mfi].array(); - amrex::Array4 X2_arr = X2_coef[mfi].array(); - amrex::Array4 X3_arr = X3_coef[mfi].array(); + const amrex::Array4 C_arr = C_coef[mfi].array(); + const amrex::Array4 S_ck_arr = S_ck_coef[mfi].array(); + const amrex::Array4 X1_arr = X1_coef[mfi].array(); + const amrex::Array4 X2_arr = X2_coef[mfi].array(); + const amrex::Array4 X3_arr = X3_coef[mfi].array(); amrex::Array4 X4_arr; amrex::Array4 T2_arr; @@ -379,11 +379,11 @@ void PsatdAlgorithmJConstantInTime::InitializeSpectralCoefficients ( const amrex::Real* kz_c = modified_kz_vec_centered[mfi].dataPtr(); // Coefficients always allocated - amrex::Array4 C = C_coef[mfi].array(); - amrex::Array4 S_ck = S_ck_coef[mfi].array(); - amrex::Array4 X1 = X1_coef[mfi].array(); - amrex::Array4 X2 = X2_coef[mfi].array(); - amrex::Array4 X3 = X3_coef[mfi].array(); + const amrex::Array4 C = C_coef[mfi].array(); + const amrex::Array4 S_ck = S_ck_coef[mfi].array(); + const amrex::Array4 X1 = X1_coef[mfi].array(); + const amrex::Array4 X2 = X2_coef[mfi].array(); + const amrex::Array4 X3 = X3_coef[mfi].array(); amrex::Array4 X4; amrex::Array4 T2; @@ -394,11 +394,11 @@ void PsatdAlgorithmJConstantInTime::InitializeSpectralCoefficients ( } // Extract Galilean velocity - amrex::Real vg_x = m_v_galilean[0]; + const amrex::Real vg_x = m_v_galilean[0]; #if defined(WARPX_DIM_3D) - amrex::Real vg_y = m_v_galilean[1]; + const amrex::Real vg_y = m_v_galilean[1]; #endif - amrex::Real vg_z = m_v_galilean[2]; + const amrex::Real vg_z = m_v_galilean[2]; // Loop over indices within one box ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept @@ -547,19 +547,19 @@ void PsatdAlgorithmJConstantInTime::InitializeSpectralCoefficientsAveraging ( const amrex::Real* kz_c = modified_kz_vec_centered[mfi].dataPtr(); // Coefficients allocated only with averaged Galilean PSATD - amrex::Array4 Psi1 = Psi1_coef[mfi].array(); - amrex::Array4 Psi2 = Psi2_coef[mfi].array(); - amrex::Array4 Y1 = Y1_coef[mfi].array(); - amrex::Array4 Y3 = Y3_coef[mfi].array(); - amrex::Array4 Y2 = Y2_coef[mfi].array(); - amrex::Array4 Y4 = Y4_coef[mfi].array(); + const amrex::Array4 Psi1 = Psi1_coef[mfi].array(); + const amrex::Array4 Psi2 = Psi2_coef[mfi].array(); + const amrex::Array4 Y1 = Y1_coef[mfi].array(); + const amrex::Array4 Y3 = Y3_coef[mfi].array(); + const amrex::Array4 Y2 = Y2_coef[mfi].array(); + const amrex::Array4 Y4 = Y4_coef[mfi].array(); // Extract Galilean velocity - amrex::Real vg_x = m_v_galilean[0]; + const amrex::Real vg_x = m_v_galilean[0]; #if defined(WARPX_DIM_3D) - amrex::Real vg_y = m_v_galilean[1]; + const amrex::Real vg_y = m_v_galilean[1]; #endif - amrex::Real vg_z = m_v_galilean[2]; + const amrex::Real vg_z = m_v_galilean[2]; // Loop over indices within one box ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept @@ -728,7 +728,7 @@ void PsatdAlgorithmJConstantInTime::CurrentCorrection (SpectralFieldData& field_ const amrex::Box& bx = field_data.fields[mfi].box(); // Extract arrays for the fields to be updated - amrex::Array4 fields = field_data.fields[mfi].array(); + const amrex::Array4 fields = field_data.fields[mfi].array(); // Extract pointers for the k vectors const amrex::Real* const modified_kx_arr = modified_kx_vec[mfi].dataPtr(); @@ -828,7 +828,7 @@ PsatdAlgorithmJConstantInTime::VayDeposition (SpectralFieldData& field_data) const amrex::Box& bx = field_data.fields[mfi].box(); // Extract arrays for the fields to be updated - amrex::Array4 fields = field_data.fields[mfi].array(); + const amrex::Array4 fields = field_data.fields[mfi].array(); // Extract pointers for the modified k vectors const amrex::Real* const modified_kx_arr = modified_kx_vec[mfi].dataPtr(); diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.cpp index c03ebcf69..30243e630 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.cpp @@ -84,14 +84,14 @@ PsatdAlgorithmJLinearInTime::pushSpectralFields (SpectralFieldData& f) const const amrex::Box& bx = f.fields[mfi].box(); // Extract arrays for the fields to be updated - amrex::Array4 fields = f.fields[mfi].array(); + const amrex::Array4 fields = f.fields[mfi].array(); // These coefficients are always allocated - amrex::Array4 C_arr = C_coef[mfi].array(); - amrex::Array4 S_ck_arr = S_ck_coef[mfi].array(); - amrex::Array4 X1_arr = X1_coef[mfi].array(); - amrex::Array4 X2_arr = X2_coef[mfi].array(); - amrex::Array4 X3_arr = X3_coef[mfi].array(); + const amrex::Array4 C_arr = C_coef[mfi].array(); + const amrex::Array4 S_ck_arr = S_ck_coef[mfi].array(); + const amrex::Array4 X1_arr = X1_coef[mfi].array(); + const amrex::Array4 X2_arr = X2_coef[mfi].array(); + const amrex::Array4 X3_arr = X3_coef[mfi].array(); amrex::Array4 X5_arr; amrex::Array4 X6_arr; @@ -280,11 +280,11 @@ void PsatdAlgorithmJLinearInTime::InitializeSpectralCoefficients ( const amrex::Real* kz_s = modified_kz_vec[mfi].dataPtr(); // Coefficients always allocated - amrex::Array4 C = C_coef[mfi].array(); - amrex::Array4 S_ck = S_ck_coef[mfi].array(); - amrex::Array4 X1 = X1_coef[mfi].array(); - amrex::Array4 X2 = X2_coef[mfi].array(); - amrex::Array4 X3 = X3_coef[mfi].array(); + const amrex::Array4 C = C_coef[mfi].array(); + const amrex::Array4 S_ck = S_ck_coef[mfi].array(); + const amrex::Array4 X1 = X1_coef[mfi].array(); + const amrex::Array4 X2 = X2_coef[mfi].array(); + const amrex::Array4 X3 = X3_coef[mfi].array(); // Loop over indices within one box amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept @@ -372,11 +372,11 @@ void PsatdAlgorithmJLinearInTime::InitializeSpectralCoefficientsAveraging ( #endif const amrex::Real* kz_s = modified_kz_vec[mfi].dataPtr(); - amrex::Array4 C = C_coef[mfi].array(); - amrex::Array4 S_ck = S_ck_coef[mfi].array(); + const amrex::Array4 C = C_coef[mfi].array(); + const amrex::Array4 S_ck = S_ck_coef[mfi].array(); - amrex::Array4 X5 = X5_coef[mfi].array(); - amrex::Array4 X6 = X6_coef[mfi].array(); + const amrex::Array4 X5 = X5_coef[mfi].array(); + const amrex::Array4 X6 = X6_coef[mfi].array(); // Loop over indices within one box amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp index 2b48bb99e..1a4039915 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp @@ -69,12 +69,12 @@ PsatdAlgorithmPml::pushSpectralFields(SpectralFieldData& f) const { const Box& bx = f.fields[mfi].box(); // Extract arrays for the fields to be updated - Array4 fields = f.fields[mfi].array(); + const Array4 fields = f.fields[mfi].array(); // Extract arrays for the coefficients - Array4 C_arr = C_coef[mfi].array(); - Array4 S_ck_arr = S_ck_coef[mfi].array(); - Array4 inv_k2_arr = inv_k2_coef[mfi].array(); + const Array4 C_arr = C_coef[mfi].array(); + const Array4 S_ck_arr = S_ck_coef[mfi].array(); + const Array4 inv_k2_arr = inv_k2_coef[mfi].array(); // Extract pointers for the k vectors const Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr(); @@ -368,9 +368,9 @@ void PsatdAlgorithmPml::InitializeSpectralCoefficients ( const Real* modified_kz = modified_kz_vec[mfi].dataPtr(); // Extract arrays for the coefficients - Array4 C = C_coef[mfi].array(); - Array4 S_ck = S_ck_coef[mfi].array(); - Array4 inv_k2 = inv_k2_coef[mfi].array(); + const Array4 C = C_coef[mfi].array(); + const Array4 S_ck = S_ck_coef[mfi].array(); + const Array4 inv_k2 = inv_k2_coef[mfi].array(); // Loop over indices within one box ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp index 099f6edf3..172715b98 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp @@ -70,7 +70,7 @@ SpectralBaseAlgorithm::ComputeSpectralDivE ( const Box& bx = field_data.fields[mfi].box(); // Extract arrays for the fields to be updated - Array4 fields = field_data.fields[mfi].array(); + const Array4 fields = field_data.fields[mfi].array(); // Extract pointers for the k vectors const Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr(); #if defined(WARPX_DIM_3D) -- cgit v1.2.3