From aa8d3b2a3bd762ac53a24e25768a4aef3a8b44fa Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Wed, 27 Mar 2024 08:30:04 -0400 Subject: [PATCH 1/4] a few more clang-tidy fixes (#2804) --- Source/driver/Castro_advance_ctu.cpp | 5 ++++- Source/driver/Castro_advance_sdc.cpp | 3 +++ Source/hydro/Castro_ctu_hydro.cpp | 5 ++++- Source/hydro/Castro_mol_hydro.cpp | 4 ++++ Source/hydro/advection_util.H | 3 +++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/driver/Castro_advance_ctu.cpp b/Source/driver/Castro_advance_ctu.cpp index 911a2780e9..44b5cc57a8 100644 --- a/Source/driver/Castro_advance_ctu.cpp +++ b/Source/driver/Castro_advance_ctu.cpp @@ -12,13 +12,16 @@ using namespace amrex; advance_status -Castro::do_advance_ctu (Real time, Real dt) +Castro::do_advance_ctu (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static) { // this routine will advance the old state data (called Sborder here) // to the new time, for a single level. The new data is called // S_new here. The update includes reactions (if we are not doing // SDC), hydro, and the source terms. + amrex::ignore_unused(time); + amrex::ignore_unused(dt); + BL_PROFILE("Castro::do_advance_ctu()"); advance_status status {}; diff --git a/Source/driver/Castro_advance_sdc.cpp b/Source/driver/Castro_advance_sdc.cpp index 83b226c7bc..01c5f653be 100644 --- a/Source/driver/Castro_advance_sdc.cpp +++ b/Source/driver/Castro_advance_sdc.cpp @@ -30,6 +30,9 @@ Castro::do_advance_sdc (Real time, // this is the new "formal" SDC integration routine. + amrex::ignore_unused(amr_iteration); + amrex::ignore_unused(amr_ncycle); + // this does the entire update in time for 1 SDC iteration. BL_PROFILE("Castro::do_advance_sdc()"); diff --git a/Source/hydro/Castro_ctu_hydro.cpp b/Source/hydro/Castro_ctu_hydro.cpp index c1a29ae0c2..0ad62f029b 100644 --- a/Source/hydro/Castro_ctu_hydro.cpp +++ b/Source/hydro/Castro_ctu_hydro.cpp @@ -14,8 +14,11 @@ using namespace amrex; advance_status -Castro::construct_ctu_hydro_source(Real time, Real dt) +Castro::construct_ctu_hydro_source(Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static) { + amrex::ignore_unused(time); + amrex::ignore_unused(dt); + advance_status status {}; if (!do_hydro) { diff --git a/Source/hydro/Castro_mol_hydro.cpp b/Source/hydro/Castro_mol_hydro.cpp index 4d7e0f32db..fbcc8c6171 100644 --- a/Source/hydro/Castro_mol_hydro.cpp +++ b/Source/hydro/Castro_mol_hydro.cpp @@ -21,6 +21,8 @@ void Castro::construct_mol_hydro_source(Real time, Real dt, MultiFab& A_update) { + amrex::ignore_unused(time); + #ifdef RADIATION amrex::Abort("Error: radiation not supported for the MOL hydro source term"); #else @@ -648,6 +650,8 @@ Castro::construct_mol_hydro_source(Real time, Real dt, MultiFab& A_update) } Array4 pradial_fab = pradial.array(); +#endif +#if AMREX_SPACEDIM == 1 Array4 const qex_arr = qe[0].array(); #endif diff --git a/Source/hydro/advection_util.H b/Source/hydro/advection_util.H index 1669869dc4..cde9eaaba6 100644 --- a/Source/hydro/advection_util.H +++ b/Source/hydro/advection_util.H @@ -23,6 +23,9 @@ void src_to_prim(int i, int j, int k, const Real dt, #endif Array4 const& srcQ) { + + amrex::ignore_unused(dt); + for (int n = 0; n < NQSRC; ++n) { srcQ(i,j,k,n) = 0.0_rt; } From 07c4e95b2469eef846210bcfa835ebeb1ffbf602 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Wed, 27 Mar 2024 16:44:52 -0400 Subject: [PATCH 2/4] address some clang-tidy warnings in gravity (#2801) --- Source/gravity/Castro_gravity.cpp | 2 +- Source/gravity/Gravity.H | 32 +++++++++++++++---------------- Source/gravity/Gravity.cpp | 25 ++++++++++++------------ Source/reactions/Castro_react.cpp | 4 ++-- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Source/gravity/Castro_gravity.cpp b/Source/gravity/Castro_gravity.cpp index ed8a2406e0..bf9dc4f6b7 100644 --- a/Source/gravity/Castro_gravity.cpp +++ b/Source/gravity/Castro_gravity.cpp @@ -388,7 +388,7 @@ void Castro::construct_old_gravity_source(MultiFab& source, MultiFab& state_in, Real SrE{}; - if (castro::grav_source_type == 1 || castro::grav_source_type == 2) { + if (castro::grav_source_type == 1 || castro::grav_source_type == 2) { // NOLINT(bugprone-branch-clone) // Src = rho u dot g, evaluated with all quantities at t^n diff --git a/Source/gravity/Gravity.H b/Source/gravity/Gravity.H index af7ff177fa..0f6aba88ac 100644 --- a/Source/gravity/Gravity.H +++ b/Source/gravity/Gravity.H @@ -127,7 +127,7 @@ public: /// @param time Current time /// @param multi_level boolean, do we iterate over all levels or mask off fine grids? /// - void set_mass_offset(amrex::Real time, bool multi_level=true); + void set_mass_offset(amrex::Real time, bool multi_level=true) const; /// /// Return ``grad_phi_prev`` at given level @@ -242,17 +242,17 @@ public: /// /// Compute the difference between level and composite solves /// -/// @param level level index -/// @param comp_phi MultiFab containing computed phi -/// @param comp_gphi Vector of MultiFabs containing computed grad phi -/// @param cml_phi MultiFab, computed minus level phi -/// @param cml_gphi Vector of MultiFabs, computed minus level grad phi +/// @param level level index +/// @param comp_phi MultiFab containing computed phi +/// @param comp_gphi Vector of MultiFabs containing computed grad phi +/// @param comp_minus_level_phi MultiFab, computed minus level phi +/// @param comp_minus_level_grad_phi Vector of MultiFabs, computed minus level grad phi /// void create_comp_minus_level_grad_phi(int level, amrex::MultiFab& comp_phi, const amrex::Vector& comp_gphi, - amrex::MultiFab& cml_phi, - amrex::Vector >& cml_gphi); + amrex::MultiFab& comp_minus_level_phi, + amrex::Vector >& comp_minus_level_grad_phi); /// @@ -348,7 +348,7 @@ public: /// @param radial_grav Radial gravity /// @param grav_vector Gravity vector /// - void interpolate_monopole_grav(int level, RealVector& radial_grav, amrex::MultiFab& grav_vector); + void interpolate_monopole_grav(int level, RealVector& radial_grav, amrex::MultiFab& grav_vector) const; /// /// Integrate radially outward to find radial mass distribution @@ -368,7 +368,7 @@ public: #ifdef GR_GRAV RealVector& radial_pres, #endif - int n1d, int level); + int n1d, int level) const; /// /// Implement multipole boundary conditions @@ -383,7 +383,7 @@ public: /// /// Initialize multipole gravity /// - void init_multipole_grav(); + void init_multipole_grav() const; #if (AMREX_SPACEDIM == 3) @@ -480,7 +480,7 @@ public: /// @param Rhs MultiFab /// @param coeffs Vector of MultiFabs /// - void applyMetricTerms(int level,amrex::MultiFab& Rhs, const amrex::Vector& coeffs); + void applyMetricTerms(int level,amrex::MultiFab& Rhs, const amrex::Vector& coeffs) const; /// /// @@ -488,7 +488,7 @@ public: /// @param level Index of level /// @param cc Cell-centered data /// - void unweight_cc(int level,amrex::MultiFab& cc); + void unweight_cc(int level,amrex::MultiFab& cc) const; /// /// @@ -496,7 +496,7 @@ public: /// @param level Index of level /// @param edges Edge-based data /// - void unweight_edges(int level, const amrex::Vector& edges); + void unweight_edges(int level, const amrex::Vector& edges) const; #endif /// @@ -504,7 +504,7 @@ public: /// @param phi Gravitational potential /// @param grav_vector Gravity vector /// - void add_pointmass_to_gravity (int level, amrex::MultiFab& phi, amrex::MultiFab& grav_vector); + void add_pointmass_to_gravity (int level, amrex::MultiFab& phi, amrex::MultiFab& grav_vector) const; /// /// Get the rhs @@ -546,7 +546,7 @@ public: const amrex::Vector >& grad_phi, const amrex::Vector& res, const amrex::MultiFab* const crse_bcdata, - amrex::Real rel_eps, amrex::Real abs_eps); + amrex::Real rel_eps, amrex::Real abs_eps) const; /// diff --git a/Source/gravity/Gravity.cpp b/Source/gravity/Gravity.cpp index 606562c843..02c02c0ea0 100644 --- a/Source/gravity/Gravity.cpp +++ b/Source/gravity/Gravity.cpp @@ -1318,7 +1318,7 @@ Gravity::test_composite_phi (int crse_level) } void -Gravity::interpolate_monopole_grav(int level, RealVector& radial_grav, MultiFab& grav_vector) +Gravity::interpolate_monopole_grav(int level, RealVector& radial_grav, MultiFab& grav_vector) const { BL_PROFILE("Gravity::interpolate_monopole_grav()"); @@ -1434,7 +1434,7 @@ Gravity::compute_radial_mass(const Box& bx, #ifdef GR_GRAV RealVector& radial_pres_local, #endif - int n1d, int level) + int n1d, int level) const { const Geometry& geom = parent->Geom(level); @@ -1599,7 +1599,7 @@ Gravity::compute_radial_mass(const Box& bx, } void -Gravity::init_multipole_grav() +Gravity::init_multipole_grav() const { if (gravity::lnum < 0) { amrex::Abort("lnum negative"); @@ -1691,7 +1691,7 @@ Gravity::init_multipole_grav() multipole::parity_q0(l) = 1.0_rt; if (l % 2 != 0) { - if (AMREX_SPACEDIM == 3 && (multipole::doReflectionLo(2) || multipole::doReflectionHi(2))) { + if (AMREX_SPACEDIM == 3 && (multipole::doReflectionLo(2) || multipole::doReflectionHi(2))) { // NOLINT(bugprone-branch-clone) multipole::parity_q0(l) = 0.0_rt; } else if (AMREX_SPACEDIM == 2 && parent->Geom(0).Coord() == 1) { @@ -1725,7 +1725,7 @@ Gravity::init_multipole_grav() if (AMREX_SPACEDIM == 3) { multipole::parity_qC_qS(l,m) = 1.0_rt; } - else if (AMREX_SPACEDIM == 2 && parent->Geom(0).Coord() == 1) { + else if (AMREX_SPACEDIM == 2 && parent->Geom(0).Coord() == 1) { // NOLINT(bugprone-branch-clone) multipole::parity_qC_qS(l,m) = 0.0_rt; } else if (AMREX_SPACEDIM == 1 && parent->Geom(0).Coord() == 2) { @@ -2847,7 +2847,7 @@ Gravity::fill_direct_sum_BCs(int crse_level, int fine_level, const Vector& coeffs) +Gravity::applyMetricTerms(int level, MultiFab& Rhs, const Vector& coeffs) const { BL_PROFILE("Gravity::applyMetricTerms()"); @@ -2877,7 +2877,7 @@ Gravity::applyMetricTerms(int level, MultiFab& Rhs, const Vector& coe } void -Gravity::unweight_cc(int level, MultiFab& cc) +Gravity::unweight_cc(int level, MultiFab& cc) const { BL_PROFILE("Gravity::unweight_cc()"); @@ -2896,7 +2896,7 @@ Gravity::unweight_cc(int level, MultiFab& cc) } void -Gravity::unweight_edges(int level, const Vector& edges) +Gravity::unweight_edges(int level, const Vector& edges) const { BL_PROFILE("Gravity::unweight_edges()"); @@ -2949,7 +2949,7 @@ Gravity::make_mg_bc () } void -Gravity::set_mass_offset (Real time, bool multi_level) +Gravity::set_mass_offset (Real time, bool multi_level) const { BL_PROFILE("Gravity::set_mass_offset()"); @@ -2999,7 +2999,7 @@ Gravity::set_mass_offset (Real time, bool multi_level) } void -Gravity::add_pointmass_to_gravity (int level, MultiFab& phi, MultiFab& grav_vector) +Gravity::add_pointmass_to_gravity (int level, MultiFab& phi, MultiFab& grav_vector) const { BL_PROFILE("Gravity::add_pointmass_to_gravity()"); @@ -3094,8 +3094,7 @@ Gravity::make_radial_gravity(int level, Real time, RealVector& radial_grav) // Create MultiFab with NUM_STATE components and no ghost cells MultiFab S(grids[lev],dmap[lev],NUM_STATE,0); - if ( eps == 0.0 ) - { + if ( eps == 0.0 ) { // NOLINT(bugprone-branch-clone,-warnings-as-errors) // Old and new time are identical; this should only happen if // dt is smaller than roundoff compared to the current time, // in which case we're probably in trouble anyway, @@ -3713,7 +3712,7 @@ Gravity::actual_solve_with_mlmg (int crse_level, int fine_level, const amrex::Vector >& grad_phi, const amrex::Vector& res, const amrex::MultiFab* const crse_bcdata, - amrex::Real rel_eps, amrex::Real abs_eps) + amrex::Real rel_eps, amrex::Real abs_eps) const { BL_PROFILE("Gravity::actual_solve_with_mlmg()"); diff --git a/Source/reactions/Castro_react.cpp b/Source/reactions/Castro_react.cpp index bc070c7359..3e6ff3949b 100644 --- a/Source/reactions/Castro_react.cpp +++ b/Source/reactions/Castro_react.cpp @@ -12,8 +12,8 @@ using namespace amrex; #ifndef TRUE_SDC advance_status -Castro::do_old_reactions (Real time, Real dt) -{ +Castro::do_old_reactions (Real time, Real dt) { // NOLINT(readability-convert-member-functions-to-static) + amrex::ignore_unused(time); amrex::ignore_unused(dt); From 21c2bc578acb482cc89988cb5f72e0c3cc3e0c9f Mon Sep 17 00:00:00 2001 From: "Eric T. Johnson" Date: Wed, 27 Mar 2024 16:45:31 -0400 Subject: [PATCH 3/4] Fix initial He4 mass fraction in Detonation (#2806) There were two separate issues with the helium mass fraction calculation: If any of cfrac, nfrac, or ofrac were zero, the corresponding mass fractions would be clamped to smallx, but the helium mass fraction didn't account for this. The number of remaining species was one too high, as it should also exclude He4. --- .../sdc_det_plt00040_extrema.out | 138 +++++++++--------- Exec/science/Detonation/problem_initialize.H | 9 +- 2 files changed, 76 insertions(+), 71 deletions(-) diff --git a/Exec/science/Detonation/ci-benchmarks/sdc_det_plt00040_extrema.out b/Exec/science/Detonation/ci-benchmarks/sdc_det_plt00040_extrema.out index b23a288448..5d48f26c1b 100644 --- a/Exec/science/Detonation/ci-benchmarks/sdc_det_plt00040_extrema.out +++ b/Exec/science/Detonation/ci-benchmarks/sdc_det_plt00040_extrema.out @@ -1,79 +1,79 @@ plotfile = det_x_plt00040 - time = 5.1558159133685604e-06 + time = 5.1558159140336702e-06 variables minimum value maximum value - density 185259613.21 216639295.98 - xmom -76364812859 2.9487648003e+16 + density 185259659.3 216625503.34 + xmom -13760057465 2.9527146771e+16 ymom 0 0 zmom 0 0 - rho_E 1.3062473824e+26 2.7890630574e+26 - rho_e 1.3062473824e+26 2.7748033958e+26 - Temp 50000004.458 7845854782 - rho_H1 2.1207015241e-22 0.020000144873 - rho_He3 0.0017224909604 0.021023115362 - rho_He4 94365290.111 200001891.25 - rho_C12 0.020000000212 21243051.967 - rho_N14 1.9999977239e-22 0.020000190213 - rho_O16 0.019999999996 19209.485639 - rho_Ne20 0.019999999996 9734.6358293 - rho_Mg24 0.019999999996 23306.635461 - rho_Si28 0.019999999996 2013766.0467 - rho_S32 0.019999999996 1654854.387 - rho_Ar36 0.019999999996 821077.40202 - rho_Ca40 0.019999999996 724428.55057 - rho_Ti44 0.019999999996 34137.672926 - rho_Cr48 0.019999999996 78094.207516 - rho_Fe52 0.019999999996 277975.05929 - rho_Fe54 0.019999999996 94999519.274 - rho_Ni56 0.019999999996 2236723.6985 - rho_n 2.1207015241e-22 234580.251 - rho_p 0.019999995434 3609846.1745 - rho_enuc -4.6916352344e+29 3.5793978339e+32 - pressure 5.5236728673e+25 1.1610546577e+26 - kineng 0 2.0430835425e+24 - soundspeed 612864631.35 895226082.4 - Gamma_1 1.359975607 1.3820247131 - MachNumber 0 0.16100811998 - uplusc 612864631.35 999536286.21 - uminusc -895226453.03 -612859846.92 - entropy 98214771.47 336273518.24 + rho_E 1.3062473821e+26 2.7889438781e+26 + rho_e 1.3062473821e+26 2.7747059271e+26 + Temp 50000000.026 7845854559 + rho_H1 2.1203665799e-22 0.020000114043 + rho_He3 0.0017224849005 0.021021778892 + rho_He4 94384549.451 200001582.65 + rho_C12 0.020000000216 21181006.118 + rho_N14 1.9999997268e-22 0.020000159166 + rho_O16 0.02 19209.472033 + rho_Ne20 0.02 3403.302453 + rho_Mg24 0.02 23330.215568 + rho_Si28 0.02 2016074.1508 + rho_S32 0.02 1656865.76 + rho_Ar36 0.02 822126.88981 + rho_Ca40 0.02 725125.60248 + rho_Ti44 0.02 34184.806642 + rho_Cr48 0.02 78126.082381 + rho_Fe52 0.02 278040.09021 + rho_Fe54 0.02 94986843.638 + rho_Ni56 0.02 2239055.987 + rho_n 0.020000004562 234580.08802 + rho_p 0.019999995438 3609282.9073 + rho_enuc -4.6902991452e+29 3.5778382148e+32 + pressure 5.5236728651e+25 1.1610543806e+26 + kineng 0 2.047804488e+24 + soundspeed 612864631.21 895226062.8 + Gamma_1 1.3599756296 1.3819790602 + MachNumber 0 0.16114515958 + uplusc 612864631.21 999634014.46 + uminusc -895226128.14 -612860627.32 + entropy 98214767.758 336273492.62 magvort 0 0 - divu -97902.982158 33744.686211 - eint_E 6.5312369121e+17 1.3804344246e+18 - eint_e 6.5312369121e+17 1.3804344246e+18 - logden 8.267780753 8.3357372357 - StateErr_0 185259613.21 216639295.98 - StateErr_1 50000004.458 7845854782 - StateErr_2 1e-30 9.9999779304e-11 - X(H1) 1e-30 9.9999779304e-11 - X(He3) 8.9859771063e-12 9.9999601234e-11 - X(He4) 0.48406305162 0.9999999982 - X(C12) 1.0000000106e-10 0.10016992833 - X(N14) 1e-30 1.0000000525e-10 - X(O16) 9.999999998e-11 9.6047401986e-05 - X(Ne20) 9.999999998e-11 4.5902903915e-05 - X(Mg24) 9.999999998e-11 0.00011109993006 - X(Si28) 9.999999998e-11 0.010051430746 - X(S32) 9.999999998e-11 0.0083423100958 - X(Ar36) 9.999999998e-11 0.004162785426 - X(Ca40) 9.999999998e-11 0.0037083550771 - X(Ti44) 9.999999998e-11 0.00017290662768 - X(Cr48) 9.999999998e-11 0.00040059772358 - X(Fe52) 9.999999998e-11 0.001337522714 - X(Fe54) 9.999999998e-11 0.46488979858 - X(Ni56) 9.999999998e-11 0.010324644421 - X(n) 1e-30 0.0011729007238 - X(p) 9.9999977087e-11 0.017592929732 - abar 4.000000001 6.7312458561 - Ye 0.49998677577 0.50001556472 - x_velocity -381.82392939 138572160.27 + divu -97879.954761 33763.419428 + eint_E 6.5312369103e+17 1.3804343698e+18 + eint_e 6.5312369103e+17 1.3804343698e+18 + logden 8.267780861 8.3357095848 + StateErr_0 185259659.3 216625503.34 + StateErr_1 50000000.026 7845854559 + StateErr_2 1e-30 9.9999779324e-11 + X(H1) 1e-30 9.9999779324e-11 + X(He3) 8.9862145938e-12 9.9999601254e-11 + X(He4) 0.48407561714 0.9999999982 + X(C12) 1.0000000108e-10 0.099893133188 + X(N14) 1e-30 1.0000000432e-10 + X(O16) 1e-10 9.6047335509e-05 + X(Ne20) 1e-10 1.6050538078e-05 + X(Mg24) 1e-10 0.00011120690546 + X(Si28) 1e-10 0.010059247336 + X(S32) 1e-10 0.0083490446432 + X(Ar36) 1e-10 0.0041662673673 + X(Ca40) 1e-10 0.0037091533301 + X(Ti44) 1e-10 0.00017295101573 + X(Cr48) 1e-10 0.00040068985616 + X(Fe52) 1e-10 0.0013377863567 + X(Fe54) 1e-10 0.46486808681 + X(Ni56) 1e-10 0.010336068249 + X(n) 1.0000002281e-10 0.001172900139 + X(p) 9.9999977027e-11 0.017594951746 + abar 4.000000001 6.7310197958 + Ye 0.49998669648 0.50001557929 + x_velocity -68.800275809 138706560.7 y_velocity 0 0 z_velocity 0 0 - t_sound_t_enuc 3.4412406672e-13 0.97497430527 - enuc -2.4944881551e+21 1.6522384906e+24 - magvel 0 138572160.27 - radvel -381.82392939 138572160.27 - circvel 0 2 - magmom 0 2.9487648003e+16 + t_sound_t_enuc 3.4412406685e-13 0.97470686938 + enuc -2.4937801624e+21 1.6516237283e+24 + magvel 0 138706560.7 + radvel -68.800275809 138706560.7 + circvel 0 2.8284271247 + magmom 0 2.9527146771e+16 angular_momentum_x 0 0 angular_momentum_y 0 0 angular_momentum_z 0 0 diff --git a/Exec/science/Detonation/problem_initialize.H b/Exec/science/Detonation/problem_initialize.H index 58205bbf24..c625a16440 100644 --- a/Exec/science/Detonation/problem_initialize.H +++ b/Exec/science/Detonation/problem_initialize.H @@ -55,10 +55,15 @@ void problem_initialize () if (problem::in14 >= 0) { problem::xn[problem::in14] = amrex::max(problem::nfrac, problem::smallx); - problem::xn[problem::ihe4] = 1.0_rt - problem::cfrac - problem::nfrac - problem::ofrac - (NumSpec - 3) * problem::smallx; + problem::xn[problem::ihe4] = 1.0_rt - problem::xn[problem::ic12] + - problem::xn[problem::in14] + - problem::xn[problem::io16] + - (NumSpec - 4) * problem::smallx; } else { - problem::xn[problem::ihe4] = 1.0_rt - problem::cfrac - problem::ofrac - (NumSpec - 2) * problem::smallx; + problem::xn[problem::ihe4] = 1.0_rt - problem::xn[problem::ic12] + - problem::xn[problem::io16] + - (NumSpec - 3) * problem::smallx; } // Set the ambient material From 931e173a32f097fd63e0b3c89844fca9bb7f3317 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Wed, 27 Mar 2024 17:16:18 -0400 Subject: [PATCH 4/4] Enforce clang-tidy via CI (#2802) --- .github/workflows/clang-tidy.yml | 31 +++++++++++++++++++ .../dependencies_clang-tidy-apt-llvm.sh | 22 +++++++++++++ Exec/hydro_tests/Sedov/problem_initialize.H | 12 +++---- Source/hydro/Castro_mol.cpp | 2 +- Source/hydro/trans.cpp | 4 +-- Source/sources/Castro_sources.cpp | 12 +++---- 6 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/clang-tidy.yml create mode 100755 .github/workflows/dependencies_clang-tidy-apt-llvm.sh diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml new file mode 100644 index 0000000000..1a4435a650 --- /dev/null +++ b/.github/workflows/clang-tidy.yml @@ -0,0 +1,31 @@ +name: "clang-tidy" + +on: [pull_request] +jobs: + clang_tidy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get submodules + run: | + git submodule update --init + cd external/Microphysics + git fetch; git checkout development + echo "MICROPHYSICS_HOME=$(pwd)" >> $GITHUB_ENV + cd ../amrex + git fetch; git checkout development + echo "AMREX_HOME=$(pwd)" >> $GITHUB_ENV + cd ../.. + + - name: Install dependencies + run: | + .github/workflows/dependencies_clang-tidy-apt-llvm.sh 17 + + - name: Compile flame_wave + run: | + echo $AMREX_HOME + echo $MICROPHYSICS_HOME + cd Exec/science/subchandra + make USE_MPI=FALSE USE_CLANG_TIDY=TRUE CLANG_TIDY=clang-tidy-17 CLANG_TIDY_WARN_ERROR=TRUE -j 4 + diff --git a/.github/workflows/dependencies_clang-tidy-apt-llvm.sh b/.github/workflows/dependencies_clang-tidy-apt-llvm.sh new file mode 100755 index 0000000000..b64cd619eb --- /dev/null +++ b/.github/workflows/dependencies_clang-tidy-apt-llvm.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +# `man apt.conf`: +# Number of retries to perform. If this is non-zero APT will retry +# failed files the given number of times. +echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries + +if [[ ! -f /etc/apt/trusted.gpg.d/apt.llvm.org.asc ]]; then + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc +fi + +source /etc/os-release # set UBUNTU_CODENAME + +sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME} main" +sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-$1 main" + +sudo apt-get update + +sudo apt-get install -y --no-install-recommends \ + clang-tidy-$1 libomp-$1-dev diff --git a/Exec/hydro_tests/Sedov/problem_initialize.H b/Exec/hydro_tests/Sedov/problem_initialize.H index b056e41349..fb0eb76814 100644 --- a/Exec/hydro_tests/Sedov/problem_initialize.H +++ b/Exec/hydro_tests/Sedov/problem_initialize.H @@ -22,10 +22,7 @@ void problem_initialize () } } - Real xn_zone[NumSpec]; - for (int n = 0; n < NumSpec; ++n) { - xn_zone[n] = 0.0_rt; - } + Real xn_zone[NumSpec] = {0.0}; xn_zone[0] = 1.0_rt; eos_t eos_state; @@ -96,17 +93,20 @@ void problem_initialize () vctr = (4.0_rt / 3.0_rt) * M_PI * problem::r_init * problem::r_init * problem::r_init; #else - amrex::Abort("Sedov problem unsupported in 3D axisymmetric geometry."); - #endif } else if (coord_type == 2) { + +#if AMREX_SPACEDIM == 1 // Must have AMREX_SPACEDIM == 1 for this coord_type. vctr = (4.0_rt / 3.0_rt) * M_PI * problem::r_init * problem::r_init * problem::r_init; +#else + amrex::Abort("Sedov problem unsupported in 2-D or 3-D spherical geometry."); +#endif } diff --git a/Source/hydro/Castro_mol.cpp b/Source/hydro/Castro_mol.cpp index 23a004c719..eb6314769c 100644 --- a/Source/hydro/Castro_mol.cpp +++ b/Source/hydro/Castro_mol.cpp @@ -199,7 +199,7 @@ Castro::mol_ppm_reconstruct(const Box& bx, void -Castro::mol_consup(const Box& bx, +Castro::mol_consup(const Box& bx, // NOLINT(readability-convert-member-functions-to-static) #ifdef SHOCK_VAR Array4 const& shk, #endif diff --git a/Source/hydro/trans.cpp b/Source/hydro/trans.cpp index 9c85de9df1..acbc4947df 100644 --- a/Source/hydro/trans.cpp +++ b/Source/hydro/trans.cpp @@ -64,7 +64,7 @@ Castro::trans_single(const Box& bx, void -Castro::actual_trans_single(const Box& bx, +Castro::actual_trans_single(const Box& bx, // NOLINT(readability-convert-member-functions-to-static) int idir_t, int idir_n, int d, Array4 const& q_arr, Array4 const& qo_arr, @@ -521,7 +521,7 @@ Castro::trans_final(const Box& bx, void -Castro::actual_trans_final(const Box& bx, +Castro::actual_trans_final(const Box& bx, // NOLINT(readability-convert-member-functions-to-static) int idir_n, int idir_t1, int idir_t2, int d, Array4 const& q_arr, Array4 const& qo_arr, diff --git a/Source/sources/Castro_sources.cpp b/Source/sources/Castro_sources.cpp index fc5dddce4f..67d736a6d7 100644 --- a/Source/sources/Castro_sources.cpp +++ b/Source/sources/Castro_sources.cpp @@ -522,7 +522,7 @@ Castro::print_all_source_changes(Real dt, bool is_new) // and the hydro advance. advance_status -Castro::pre_advance_operators (Real time, Real dt) +Castro::pre_advance_operators (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static) { amrex::ignore_unused(time); amrex::ignore_unused(dt); @@ -560,7 +560,7 @@ Castro::pre_advance_operators (Real time, Real dt) // but before the hydro advance. advance_status -Castro::pre_hydro_operators (Real time, Real dt) +Castro::pre_hydro_operators (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static) { amrex::ignore_unused(time); amrex::ignore_unused(dt); @@ -585,7 +585,7 @@ Castro::pre_hydro_operators (Real time, Real dt) // but before the corrector sources. advance_status -Castro::post_hydro_operators (Real time, Real dt) +Castro::post_hydro_operators (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static) { amrex::ignore_unused(time); amrex::ignore_unused(dt); @@ -602,13 +602,13 @@ Castro::post_hydro_operators (Real time, Real dt) // Perform all operations that occur after the corrector sources. advance_status -Castro::post_advance_operators (Real time, Real dt) +Castro::post_advance_operators (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static) { - advance_status status {}; - amrex::ignore_unused(time); amrex::ignore_unused(dt); + advance_status status {}; + #ifndef TRUE_SDC #ifdef REACTIONS status = do_new_reactions(time, dt);