From 2d863d655ec1e1f684f55ea745021b9c97a03c60 Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Fri, 9 Feb 2024 15:07:46 -0500 Subject: [PATCH] fix clang-tidy warnings (#468) ### Description This fixes many `clang-tidy` warnings thoughout the code. Most of them had to do with unnecessary header includes or const issues. No outputs should change at the bitwise level. ### Related issues N/A ### Checklist _Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an `x` inside the square brackets `[ ]` in the Markdown source below:_ - [x] I have added a description (see above). - [x] I have added a link to any related issues see (see above). - [x] I have read the [Contributing Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md). - [x] I have added tests for any new physics that this PR adds to the code. - [x] I have tested this PR on my local computer and all tests pass. - [x] I have manually triggered the GPU tests with the magic comment `/azp run`. - [x] I have requested a reviewer for this PR. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- extern/Microphysics | 2 +- src/AdvectionSimulation.hpp | 11 +----- src/Chemistry.hpp | 5 +-- src/CloudyCooling.cpp | 1 - src/CloudyCooling.hpp | 24 ++++++------ src/EOS.hpp | 18 ++++----- src/FCQuantities/test_fc_quantities.cpp | 10 ++--- src/GrackleDataReader.cpp | 14 ++++--- src/GrackleDataReader.hpp | 11 +----- src/LLF.hpp | 2 - src/NSCBC/channel.cpp | 20 +++++----- src/NSCBC/vortex.cpp | 16 ++++---- src/NSCBC_inflow.hpp | 1 - src/NSCBC_outflow.hpp | 2 - src/ODEIntegrate.hpp | 13 +------ src/RadhydroSimulation.hpp | 52 +++++++++++-------------- src/ShockCloud/test_cloudy.cpp | 2 +- src/fextract.cpp | 5 +-- src/fextract.hpp | 6 +-- src/grid.hpp | 2 - src/hydro_system.hpp | 20 ++-------- src/hyperbolic_system.hpp | 9 +---- src/interpolate.cpp | 7 +++- src/interpolate.hpp | 6 +-- src/linear_advection.hpp | 36 ++++------------- src/mhd_system.hpp | 12 +----- src/planck_integral.hpp | 9 ++--- src/radiation_system.hpp | 13 +++---- src/simulation.hpp | 48 ++++++++++------------- src/valarray.hpp | 1 - 30 files changed, 133 insertions(+), 245 deletions(-) diff --git a/extern/Microphysics b/extern/Microphysics index fbeddb367..348ca2f58 160000 --- a/extern/Microphysics +++ b/extern/Microphysics @@ -1 +1 @@ -Subproject commit fbeddb367c6ef7d71052e23c20deda164243e643 +Subproject commit 348ca2f5801c8cf80fa5910efe5f036bf4f737fe diff --git a/src/AdvectionSimulation.hpp b/src/AdvectionSimulation.hpp index 9c5014bbd..905849cbc 100644 --- a/src/AdvectionSimulation.hpp +++ b/src/AdvectionSimulation.hpp @@ -11,22 +11,15 @@ #include -#include "AMReX.H" -#include "AMReX_Arena.H" #include "AMReX_Array.H" -#include "AMReX_Array4.H" #include "AMReX_BLassert.H" #include "AMReX_Box.H" -#include "AMReX_Config.H" #include "AMReX_DistributionMapping.H" -#include "AMReX_FArrayBox.H" -#include "AMReX_FabArrayUtility.H" #include "AMReX_IntVect.H" #include "AMReX_MultiFab.H" #include "AMReX_REAL.H" #include "AMReX_SPACE.H" #include "AMReX_TagBox.H" -#include "AMReX_Utility.H" #include "AMReX_YAFluxRegister.H" #include @@ -98,7 +91,7 @@ template class AdvectionSimulation : public AMRSimulation

void fluxFunction(amrex::MultiFab const &consState, amrex::MultiFab &primVar, amrex::MultiFab &x1Flux, amrex::MultiFab &x1LeftState, - amrex::MultiFab &x1RightState, const int ng_reconstruct, const int nvars); + amrex::MultiFab &x1RightState, int ng_reconstruct, int nvars); double advectionVx_ = 1.0; // default double advectionVy_ = 0.0; // default @@ -131,7 +124,7 @@ template void AdvectionSimulation::applyPoissonG // deliberately empty } -template auto AdvectionSimulation::computeExtraPhysicsTimestep(int const level) -> amrex::Real +template auto AdvectionSimulation::computeExtraPhysicsTimestep(int const /*level*/) -> amrex::Real { // user can override this return std::numeric_limits::max(); diff --git a/src/Chemistry.hpp b/src/Chemistry.hpp index 31a4248aa..38bf4ab0b 100644 --- a/src/Chemistry.hpp +++ b/src/Chemistry.hpp @@ -10,11 +10,8 @@ /// #include -#include #include "AMReX.H" -#include "AMReX_BLassert.H" -#include "AMReX_Extension.H" #include "AMReX_GpuQualifiers.H" #include "hydro_system.hpp" @@ -29,7 +26,7 @@ namespace quokka::chemistry { -AMREX_GPU_DEVICE void chemburner(burn_t &chemstate, const Real dt); +AMREX_GPU_DEVICE void chemburner(burn_t &chemstate, Real dt); template void computeChemistry(amrex::MultiFab &mf, const Real dt, const Real max_density_allowed, const Real min_density_allowed) { diff --git a/src/CloudyCooling.cpp b/src/CloudyCooling.cpp index 1b734616e..0a9526bfe 100644 --- a/src/CloudyCooling.cpp +++ b/src/CloudyCooling.cpp @@ -9,7 +9,6 @@ /// #include "CloudyCooling.hpp" -#include "ODEIntegrate.hpp" namespace quokka::cooling { diff --git a/src/CloudyCooling.hpp b/src/CloudyCooling.hpp index 62dd51495..dd6ee60f9 100644 --- a/src/CloudyCooling.hpp +++ b/src/CloudyCooling.hpp @@ -9,17 +9,16 @@ /// \brief Defines methods for interpolating cooling rates from Cloudy tables. /// -#include - #include "AMReX.H" -#include "AMReX_BLassert.H" #include "AMReX_Extension.H" #include "AMReX_GpuQualifiers.H" +#include "AMReX_iMultiFab.H" #include "FastMath.hpp" #include "GrackleDataReader.hpp" #include "Interpolate2D.hpp" #include "ODEIntegrate.hpp" +#include "fmt/core.h" #include "fundamental_constants.H" #include "hydro_system.hpp" #include "radiation_system.hpp" @@ -47,14 +46,14 @@ constexpr double E_cmb = radiation_constant_cgs_ * (T_cmb * T_cmb * T_cmb * T_cm struct cloudyGpuConstTables { // these are non-owning, so can make a copy of the whole struct - amrex::Table1D const log_nH; - amrex::Table1D const log_Tgas; - - amrex::Table2D const primCool; - amrex::Table2D const primHeat; - amrex::Table2D const metalCool; - amrex::Table2D const metalHeat; - amrex::Table2D const meanMolWeight; + amrex::Table1D log_nH; + amrex::Table1D log_Tgas; + + amrex::Table2D primCool; + amrex::Table2D primHeat; + amrex::Table2D metalCool; + amrex::Table2D metalHeat; + amrex::Table2D meanMolWeight; }; class cloudy_tables @@ -152,7 +151,8 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto ComputeTgasFromEgas(double rho, do if (Egas <= Eint_min) { return Tmin_table; - } else if (Egas >= Eint_max) { + } + if (Egas >= Eint_max) { return Tmax_table; } diff --git a/src/EOS.hpp b/src/EOS.hpp index 2a518b894..644af4f77 100644 --- a/src/EOS.hpp +++ b/src/EOS.hpp @@ -17,9 +17,7 @@ #include "physics_info.hpp" #include -#include "burn_type.H" #include "eos.H" -#include "extern_parameters.H" #ifdef PRIMORDIAL_CHEM #include "actual_eos_data.H" @@ -43,27 +41,25 @@ template class EOS public: static constexpr int nmscalars_ = Physics_Traits::numMassScalars; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeTgasFromEint(amrex::Real rho, amrex::Real Eint, const std::optional> massScalars = {}) -> amrex::Real; + ComputeTgasFromEint(amrex::Real rho, amrex::Real Eint, std::optional> massScalars = {}) -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeEintFromTgas(amrex::Real rho, amrex::Real Tgas, const std::optional> massScalars = {}) -> amrex::Real; + ComputeEintFromTgas(amrex::Real rho, amrex::Real Tgas, std::optional> massScalars = {}) -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeEintFromPres(amrex::Real rho, amrex::Real Pressure, const std::optional> massScalars = {}) - -> amrex::Real; + ComputeEintFromPres(amrex::Real rho, amrex::Real Pressure, std::optional> massScalars = {}) -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeEintTempDerivative(amrex::Real rho, amrex::Real Tgas, const std::optional> massScalars = {}) - -> amrex::Real; + ComputeEintTempDerivative(amrex::Real rho, amrex::Real Tgas, std::optional> massScalars = {}) -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeOtherDerivatives(amrex::Real rho, amrex::Real P, const std::optional> massScalars = {}); + ComputeOtherDerivatives(amrex::Real rho, amrex::Real P, std::optional> massScalars = {}); [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputePressure(amrex::Real rho, amrex::Real Eint, const std::optional> massScalars = {}) -> amrex::Real; + ComputePressure(amrex::Real rho, amrex::Real Eint, std::optional> massScalars = {}) -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeSoundSpeed(amrex::Real rho, amrex::Real Pressure, const std::optional> massScalars = {}) -> amrex::Real; + ComputeSoundSpeed(amrex::Real rho, amrex::Real Pressure, std::optional> massScalars = {}) -> amrex::Real; private: static constexpr amrex::Real gamma_ = EOS_Traits::gamma; diff --git a/src/FCQuantities/test_fc_quantities.cpp b/src/FCQuantities/test_fc_quantities.cpp index f7f53abfd..8c21661c2 100644 --- a/src/FCQuantities/test_fc_quantities.cpp +++ b/src/FCQuantities/test_fc_quantities.cpp @@ -115,14 +115,14 @@ void checkMFs(amrex::Vector> const for (int level = 0; level < state1.size(); ++level) { for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { // initialise MF - const BoxArray &ba = state1[level][idim].boxArray(); - const DistributionMapping &dm = state1[level][idim].DistributionMap(); + const amrex::BoxArray &ba = state1[level][idim].boxArray(); + const amrex::DistributionMapping &dm = state1[level][idim].DistributionMap(); int ncomp = state1[level][idim].nComp(); int ngrow = state1[level][idim].nGrow(); - MultiFab mf_diff(ba, dm, ncomp, ngrow); + amrex::MultiFab mf_diff(ba, dm, ncomp, ngrow); // compute difference between two MFs (at level) - MultiFab::Copy(mf_diff, state1[level][idim], 0, 0, ncomp, ngrow); - MultiFab::Subtract(mf_diff, state2[level][idim], 0, 0, ncomp, ngrow); + amrex::MultiFab::Copy(mf_diff, state1[level][idim], 0, 0, ncomp, ngrow); + amrex::MultiFab::Subtract(mf_diff, state2[level][idim], 0, 0, ncomp, ngrow); // compute error (summed over each component) for (int icomp = 0; icomp < Physics_Indices::nvarPerDim_fc; ++icomp) { err += mf_diff.norm1(icomp); diff --git a/src/GrackleDataReader.cpp b/src/GrackleDataReader.cpp index 4590eab3a..eb0645bd9 100644 --- a/src/GrackleDataReader.cpp +++ b/src/GrackleDataReader.cpp @@ -24,6 +24,7 @@ #include "AMReX_Print.H" #include "AMReX_TableData.H" #include "FastMath.hpp" +#include "fmt/core.h" static const bool grackle_verbose = true; @@ -109,7 +110,7 @@ void initialize_cloudy_data(cloudy_data &my_cloudy, char const *group_name, std: parameter_name = "Temperature"; } - double *temp_data = new double[my_cloudy.grid_dimension[q]]; + auto *temp_data = new double[my_cloudy.grid_dimension[q]]; // NOLINT(cppcoreguidelines-owning-memory) attr_id = H5Aopen_name(dset_id, parameter_name.c_str()); @@ -117,7 +118,7 @@ void initialize_cloudy_data(cloudy_data &my_cloudy, char const *group_name, std: my_cloudy.grid_parameters[q] = amrex::Table1D(temp_data, 0, static_cast(my_cloudy.grid_dimension[q])); - for (int64_t w = 0; w < my_cloudy.grid_dimension[q]; w++) { + for (int w = 0; w < my_cloudy.grid_dimension[q]; w++) { if (q < my_cloudy.grid_rank - 1) { my_cloudy.grid_parameters[q](w) = temp_data[w]; } else { @@ -128,7 +129,8 @@ void initialize_cloudy_data(cloudy_data &my_cloudy, char const *group_name, std: if (grackle_verbose) { amrex::Print() << fmt::format("\t{}: {} to {} ({} steps).\n", parameter_name, my_cloudy.grid_parameters[q](0), - my_cloudy.grid_parameters[q](my_cloudy.grid_dimension[q] - 1), my_cloudy.grid_dimension[q]); + my_cloudy.grid_parameters[q](static_cast(my_cloudy.grid_dimension[q]) - 1), + my_cloudy.grid_dimension[q]); } status = H5Aclose(attr_id); @@ -142,7 +144,7 @@ void initialize_cloudy_data(cloudy_data &my_cloudy, char const *group_name, std: { // Read Cooling data - double *temp_data = new double[my_cloudy.data_size]; + auto *temp_data = new double[my_cloudy.data_size]; // NOLINT(cppcoreguidelines-owning-memory) status = H5Dread(dset_id, HDF5_R8, H5S_ALL, H5S_ALL, H5P_DEFAULT, temp_data); @@ -168,7 +170,7 @@ void initialize_cloudy_data(cloudy_data &my_cloudy, char const *group_name, std: { // Read Heating data - double *temp_data = new double[my_cloudy.data_size]; + auto *temp_data = new double[my_cloudy.data_size]; // NOLINT(cppcoreguidelines-owning-memory) parameter_name = fmt::format("/CoolingRates/{}/Heating", group_name); @@ -199,7 +201,7 @@ void initialize_cloudy_data(cloudy_data &my_cloudy, char const *group_name, std: if (std::string(group_name) == "Primordial") { // Read mean molecular weight table - double *temp_data = new double[my_cloudy.data_size]; + auto *temp_data = new double[my_cloudy.data_size]; // NOLINT(cppcoreguidelines-owning-memory) amrex::GpuArray lo{0, 0, 0}; amrex::GpuArray hi{static_cast(my_cloudy.grid_dimension[2]), static_cast(my_cloudy.grid_dimension[1]), diff --git a/src/GrackleDataReader.hpp b/src/GrackleDataReader.hpp index b0e696dbb..765a35f45 100644 --- a/src/GrackleDataReader.hpp +++ b/src/GrackleDataReader.hpp @@ -9,26 +9,19 @@ /// \brief Defines methods for reading the cooling rate tables used by Grackle. /// -#include #include -#include -#include #include -#include "fmt/core.h" #include #include #include -#include "AMReX.H" -#include "AMReX_Array.H" -#include "AMReX_BLassert.H" #include "AMReX_TableData.H" using Real = amrex::Real; -#define SMALL_LOG_VALUE -99.0 -#define CLOUDY_MAX_DIMENSION 3 // we are using amrex::Table3D +constexpr double SMALL_LOG_VALUE = -99.0; +constexpr int CLOUDY_MAX_DIMENSION = 3; // we are using amrex::Table3D /* HDF5 definitions */ diff --git a/src/LLF.hpp b/src/LLF.hpp index 92804b316..5bf6a745f 100644 --- a/src/LLF.hpp +++ b/src/LLF.hpp @@ -6,8 +6,6 @@ #include #include -#include "ArrayView.hpp" -#include "EOS.hpp" #include "HydroState.hpp" #include "valarray.hpp" diff --git a/src/NSCBC/channel.cpp b/src/NSCBC/channel.cpp index 98763f765..2d4145d02 100644 --- a/src/NSCBC/channel.cpp +++ b/src/NSCBC/channel.cpp @@ -68,16 +68,16 @@ template <> struct Physics_Traits { namespace { #endif -Real rho0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -Real u0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -Real s0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real Tgas0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real P_outflow = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real u_inflow = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real v_inflow = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real w_inflow = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED GpuArray::numPassiveScalars> s_inflow{}; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -#if 0 // workaround AMDGPU compiler bug +Real rho0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +Real u0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +Real s0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real Tgas0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real P_outflow = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real u_inflow = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real v_inflow = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real w_inflow = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::GpuArray::numPassiveScalars> s_inflow{}; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +#if 0 // workaround AMDGPU compiler bug }; // namespace #endif diff --git a/src/NSCBC/vortex.cpp b/src/NSCBC/vortex.cpp index 6ef755777..77e9186d3 100644 --- a/src/NSCBC/vortex.cpp +++ b/src/NSCBC/vortex.cpp @@ -64,14 +64,14 @@ template <> struct Physics_Traits { namespace { const bool outflow_boundary_along_x_axis = true; -Real G_vortex = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real T_ref = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real P_ref = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real u0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real v0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED Real w0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -AMREX_GPU_MANAGED GpuArray::nscalars_> s0{}; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -}; // namespace +amrex::Real G_vortex = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real T_ref = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real P_ref = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real u0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real v0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::Real w0 = NAN; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +AMREX_GPU_MANAGED amrex::GpuArray::nscalars_> s0{}; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +}; // namespace template <> void RadhydroSimulation::setInitialConditionsOnGrid(quokka::grid grid_elem) { diff --git a/src/NSCBC_inflow.hpp b/src/NSCBC_inflow.hpp index e8055b9e8..72e145014 100644 --- a/src/NSCBC_inflow.hpp +++ b/src/NSCBC_inflow.hpp @@ -14,7 +14,6 @@ #include "AMReX_REAL.H" #include "EOS.hpp" #include "hydro_system.hpp" -#include "physics_numVars.hpp" #include "valarray.hpp" namespace NSCBC diff --git a/src/NSCBC_outflow.hpp b/src/NSCBC_outflow.hpp index 92a98e148..35f3f1b14 100644 --- a/src/NSCBC_outflow.hpp +++ b/src/NSCBC_outflow.hpp @@ -11,10 +11,8 @@ #include "AMReX_GpuQualifiers.H" #include "AMReX_REAL.H" -#include "ArrayView.hpp" #include "EOS.hpp" #include "hydro_system.hpp" -#include "physics_numVars.hpp" #include "valarray.hpp" namespace NSCBC diff --git a/src/ODEIntegrate.hpp b/src/ODEIntegrate.hpp index 5624239a7..2a7c7a007 100644 --- a/src/ODEIntegrate.hpp +++ b/src/ODEIntegrate.hpp @@ -13,7 +13,6 @@ #include #include -#include "AMReX.H" #include "AMReX_BLassert.H" #include "AMReX_Extension.H" #include "AMReX_GpuQualifiers.H" @@ -126,7 +125,7 @@ constexpr int maxStepsODEIntegrate = 2000; template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void rk_adaptive_integrate(F &&rhs, Real t0, quokka::valarray &y0, Real t1, void *user_data, Real reltol, - quokka::valarray const &abstol, int &steps_taken, bool debug = false) + quokka::valarray const &abstol, int &steps_taken) { // Integrate dy/dt = rhs(y, t) from t0 to t1, // with local truncation error bounded by relative tolerance 'reltol' @@ -162,10 +161,6 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void rk_adaptive_integrate(F &&rhs, Rea dt = t1 - time; } - if (debug) { - printf("Step i = %d t = %e dt = %e\n", i, time, dt); - } - bool step_success = false; for (int k = 0; k < maxRetries; ++k) { // compute single step of chosen RK method @@ -196,9 +191,6 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void rk_adaptive_integrate(F &&rhs, Rea } dt *= eta; // use new timestep step_success = true; - if (debug) { - printf("\tsuccess k = %d epsilon = %e eta = %e\n", k, epsilon, eta); - } break; } } @@ -212,9 +204,6 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void rk_adaptive_integrate(F &&rhs, Rea } dt *= eta; // use new timestep AMREX_ASSERT(!std::isnan(dt)); - if (debug) { - printf("\tfailed step k = %d eta = %e\n", k, eta); - } } if (!step_success) { diff --git a/src/RadhydroSimulation.hpp b/src/RadhydroSimulation.hpp index 2793efd38..80160c9de 100644 --- a/src/RadhydroSimulation.hpp +++ b/src/RadhydroSimulation.hpp @@ -10,7 +10,6 @@ /// timestepping, solving, and I/O of a simulation for radiation moments. #include -#include #include #include #include @@ -31,25 +30,19 @@ #include "AMReX_Box.H" #include "AMReX_FArrayBox.H" #include "AMReX_FabArray.H" -#include "AMReX_FabArrayUtility.H" #include "AMReX_FabFactory.H" #include "AMReX_Geometry.H" #include "AMReX_GpuControl.H" #include "AMReX_GpuDevice.H" #include "AMReX_GpuQualifiers.H" -#include "AMReX_IArrayBox.H" -#include "AMReX_IndexType.H" #include "AMReX_IntVect.H" #include "AMReX_MultiFab.H" #include "AMReX_MultiFabUtil.H" #include "AMReX_ParallelDescriptor.H" #include "AMReX_ParmParse.H" -#include "AMReX_Periodicity.H" -#include "AMReX_PhysBCFunct.H" #include "AMReX_PlotFileUtil.H" #include "AMReX_Print.H" #include "AMReX_REAL.H" -#include "AMReX_Utility.H" #include "AMReX_YAFluxRegister.H" #include "physics_numVars.hpp" @@ -61,7 +54,6 @@ #include "Chemistry.hpp" #include "CloudyCooling.hpp" -#include "HLLC.hpp" #include "SimulationData.hpp" #include "hydro_system.hpp" #include "hyperbolic_system.hpp" @@ -224,8 +216,8 @@ template class RadhydroSimulation : public AMRSimulation &dstfluxes, std::array &srcfluxes, const int srccomp, - const int dstcomp); + void addFluxArrays(std::array &dstfluxes, std::array &srcfluxes, int srccomp, + int dstcomp); auto expandFluxArrays(std::array &fluxes, int nstartNew, int ncompNew) -> std::array; @@ -235,7 +227,7 @@ template class RadhydroSimulation : public AMRSimulation bool; void addStrangSplitSources(amrex::MultiFab &state, int lev, amrex::Real time, amrex::Real dt_lev); @@ -264,10 +256,10 @@ template class RadhydroSimulation : public AMRSimulation dx) -> std::tuple, std::array>; - auto computeHydroFluxes(amrex::MultiFab const &consVar, const int nvars, const int lev) + auto computeHydroFluxes(amrex::MultiFab const &consVar, int nvars, int lev) -> std::pair, std::array>; - auto computeFOHydroFluxes(amrex::MultiFab const &consVar, const int nvars, const int lev) + auto computeFOHydroFluxes(amrex::MultiFab const &consVar, int nvars, int lev) -> std::pair, std::array>; template @@ -435,7 +427,7 @@ template void RadhydroSimulation::computeMaxSign } } -template auto RadhydroSimulation::computeExtraPhysicsTimestep(int const level) -> amrex::Real +template auto RadhydroSimulation::computeExtraPhysicsTimestep(int const /*level*/) -> amrex::Real { BL_PROFILE("RadhydroSimulation::computeExtraPhysicsTimestep()"); // users can override this to enforce additional timestep constraints @@ -458,7 +450,7 @@ template void RadhydroSimulation::checkHydroStat if (!validStates) { amrex::Print() << "Hydro states invalid (" + std::string(file) + ":" + std::to_string(line) + ")\n"; amrex::Print() << "Writing checkpoint for debugging...\n"; - amrex::MFIter::allowMultipleMFIters(true); + amrex::MFIter::allowMultipleMFIters(1); WriteCheckpointFile(); amrex::Abort("Hydro states invalid (" + std::string(file) + ":" + std::to_string(line) + ")"); } @@ -587,11 +579,11 @@ template void RadhydroSimulation::computeAfterEv amrex::Real const abs_err = (Etot - Etot0); amrex::Real const rel_err = abs_err / Etot0; - amrex::Print() << "\nInitial gas+radiation energy = " << Etot0 << std::endl; - amrex::Print() << "Final gas+radiation energy = " << Etot << std::endl; - amrex::Print() << "\tabsolute conservation error = " << abs_err << std::endl; - amrex::Print() << "\trelative conservation error = " << rel_err << std::endl; - amrex::Print() << std::endl; + amrex::Print() << "\nInitial gas+radiation energy = " << Etot0 << '\n'; + amrex::Print() << "Final gas+radiation energy = " << Etot << '\n'; + amrex::Print() << "\tabsolute conservation error = " << abs_err << '\n'; + amrex::Print() << "\trelative conservation error = " << rel_err << '\n'; + amrex::Print() << '\n'; if (computeReferenceSolution_) { // compute reference solution @@ -617,14 +609,14 @@ template void RadhydroSimulation::computeAfterEv const double rel_error = err_norm / sol_norm; errorNorm_ = rel_error; - amrex::Print() << "Relative rms L1 error norm = " << rel_error << std::endl; + amrex::Print() << "Relative rms L1 error norm = " << rel_error << '\n'; } - amrex::Print() << std::endl; + amrex::Print() << '\n'; // compute average number of radiation subcycles per timestep double const avg_rad_subcycles = static_cast(radiationCellUpdates_) / static_cast(cellUpdates_); - amrex::Print() << "avg. num. of radiation subcycles = " << avg_rad_subcycles << std::endl; - amrex::Print() << std::endl; + amrex::Print() << "avg. num. of radiation subcycles = " << avg_rad_subcycles << '\n'; + amrex::Print() << '\n'; } template void RadhydroSimulation::advanceSingleTimestepAtLevel(int lev, amrex::Real time, amrex::Real dt_lev, int ncycle) @@ -778,7 +770,7 @@ void RadhydroSimulation::FillPatch(int lev, amrex::Real time, amrex:: } } -template void RadhydroSimulation::PreInterpState(amrex::MultiFab &mf, int scomp, int ncomp) +template void RadhydroSimulation::PreInterpState(amrex::MultiFab &mf, int /*scomp*/, int /*ncomp*/) { BL_PROFILE("RadhydroSimulation::PreInterpState()"); @@ -797,7 +789,7 @@ template void RadhydroSimulation::PreInterpState }); } -template void RadhydroSimulation::PostInterpState(amrex::MultiFab &mf, int scomp, int ncomp) +template void RadhydroSimulation::PostInterpState(amrex::MultiFab &mf, int /*scomp*/, int /*ncomp*/) { BL_PROFILE("RadhydroSimulation::PostInterpState()"); @@ -886,7 +878,7 @@ void RadhydroSimulation::advanceHydroAtLevelWithRetries(int lev, amre for (int retry_count = 0; retry_count <= max_retries; ++retry_count) { // reduce timestep by a factor of 2^retry_count - const int nsubsteps = std::pow(2, retry_count); + const int nsubsteps = static_cast(std::pow(2, retry_count)); const amrex::Real dt_step = dt_lev / nsubsteps; if (retry_count > 0 && Verbose()) { @@ -943,7 +935,7 @@ void RadhydroSimulation::advanceHydroAtLevelWithRetries(int lev, amre // crash, we have exceeded max_retries amrex::Print() << "\nQUOKKA FATAL ERROR\n" << "Hydro update exceeded max_retries on level " << lev << ". Cannot continue, crashing...\n" - << std::endl; + << std::endl; // NOLINT(performance-avoid-endl) // write plotfile or Ascent Blueprint file amrex::ParallelDescriptor::Barrier(); @@ -965,7 +957,7 @@ void RadhydroSimulation::advanceHydroAtLevelWithRetries(int lev, amre } } -template auto RadhydroSimulation::isCflViolated(int lev, amrex::Real time, amrex::Real dt_actual) -> bool +template auto RadhydroSimulation::isCflViolated(int lev, amrex::Real /*time*/, amrex::Real dt_actual) -> bool { // check whether dt_actual would violate CFL condition using the post-update hydro state @@ -1631,7 +1623,7 @@ void RadhydroSimulation::advanceRadiationSubstepAtLevel(int lev, amre amrex::YAFluxRegister *fr_as_fine) { if (Verbose()) { - amrex::Print() << "\tsubstep " << iter_count << " t = " << time << std::endl; + amrex::Print() << "\tsubstep " << iter_count << " t = " << time << '\n'; } // get cell sizes diff --git a/src/ShockCloud/test_cloudy.cpp b/src/ShockCloud/test_cloudy.cpp index 336f8f095..abde42a63 100644 --- a/src/ShockCloud/test_cloudy.cpp +++ b/src/ShockCloud/test_cloudy.cpp @@ -73,7 +73,7 @@ auto problem_main() -> int // do integration with RK2 (Heun's method) int nsteps = 0; - rk_adaptive_integrate(user_rhs, 0, y, dt, &user_data, rtol, abstol, nsteps, true); + rk_adaptive_integrate(user_rhs, 0, y, dt, &user_data, rtol, abstol, nsteps); // check if integration failed if (nsteps >= maxStepsODEIntegrate) { diff --git a/src/fextract.cpp b/src/fextract.cpp index 6da0dc3ba..a36c805fb 100644 --- a/src/fextract.cpp +++ b/src/fextract.cpp @@ -1,9 +1,6 @@ -#include -#include #include #include -#include "AMReX_Config.H" #include "AMReX_Geometry.H" #include "AMReX_MultiFab.H" #include "AMReX_SPACE.H" @@ -115,7 +112,7 @@ auto fextract(MultiFab &mf, Geometry &geom, const int idir, const Real slice_coo ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) { GpuArray idx_vec({i - lo0.x, j - lo0.y, k - lo0.z}); int idx = idx_vec[idir]; - dataptr[idx] = fab(i, j, k, ivar); + dataptr[idx] = fab(i, j, k, ivar); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) }); } } diff --git a/src/fextract.hpp b/src/fextract.hpp index 80fe2953a..2343732a8 100644 --- a/src/fextract.hpp +++ b/src/fextract.hpp @@ -1,7 +1,6 @@ #ifndef FEXTRACT_HPP_ #define FEXTRACT_HPP_ -#include "AMReX_Config.H" #include "AMReX_Geometry.H" #include "AMReX_MultiFab.H" #include @@ -10,8 +9,7 @@ #include #include -using namespace amrex; - -auto fextract(MultiFab &mf, Geometry &geom, int idir, Real slice_coord, bool center = false) -> std::tuple, Vector>>; +auto fextract(amrex::MultiFab &mf, amrex::Geometry &geom, int idir, amrex::Real slice_coord, bool center = false) + -> std::tuple, amrex::Vector>>; #endif // FEXTRACT_HPP_ \ No newline at end of file diff --git a/src/grid.hpp b/src/grid.hpp index 67d2eeba5..22f469343 100644 --- a/src/grid.hpp +++ b/src/grid.hpp @@ -1,8 +1,6 @@ #ifndef GRID_HPP_ // NOLINT #define GRID_HPP_ -#include "AMReX_MFParallelFor.H" -#include "AMReX_MultiFab.H" #include #include #include diff --git a/src/hydro_system.hpp b/src/hydro_system.hpp index d5a6351c0..0198ff7c9 100644 --- a/src/hydro_system.hpp +++ b/src/hydro_system.hpp @@ -14,12 +14,10 @@ // library headers #include "AMReX.H" -#include "AMReX_Arena.H" #include "AMReX_Array4.H" #include "AMReX_BLassert.H" -#include "AMReX_FArrayBox.H" -#include "AMReX_Loop.H" #include "AMReX_REAL.H" +#include "AMReX_iMultiFab.H" // internal headers #include "ArrayView.hpp" @@ -108,8 +106,8 @@ template class HydroSystem : public HyperbolicSystem posvec) -> amrex::GpuArray; - static void EnforceLimits(amrex::Real densityFloor, amrex::Real pressureFloor, amrex::Real speedCeiling, amrex::Real tempCeiling, - amrex::Real const tempFloor, amrex::MultiFab &state_mf); + static void EnforceLimits(amrex::Real densityFloor, amrex::Real pressureFloor, amrex::Real speedCeiling, amrex::Real tempCeiling, amrex::Real tempFloor, + amrex::MultiFab &state_mf); static void AddInternalEnergyPdV(amrex::MultiFab &rhs_mf, amrex::MultiFab const &consVar_mf, amrex::GpuArray dx, std::array const &faceVelArray, amrex::iMultiFab const &redoFlag_mf); @@ -444,16 +442,6 @@ AMREX_GPU_DEVICE AMREX_FORCE_INLINE auto HydroSystem::isStateValid(am // when the dual energy method is used, we *cannot* reset on pressure // failures. on the other hand, we don't need to -- the auxiliary internal // energy is used instead! -#if 0 - bool isPressurePositive = false; - if constexpr (!is_eos_isothermal()) { - const amrex::Real P = ComputePressure(cons, i, j, k); - isPressurePositive = (P > 0.); - } else { - isPressurePositive = true; - } -#endif - // return (isDensityPositive && isPressurePositive); return isDensityPositive && isMassScalarPositive; } @@ -746,7 +734,7 @@ void HydroSystem::EnforceLimits(amrex::Real const densityFloor, amrex amrex::Real sp_sum = 0.0; for (int idx = 0; idx < nmscalars_; ++idx) { if (state[bx](i, j, k, scalar0_index + idx) < 0.0) { - state[bx](i, j, k, scalar0_index + idx) = small_x * rho; + state[bx](i, j, k, scalar0_index + idx) = network_rp::small_x * rho; } // get sum to renormalize diff --git a/src/hyperbolic_system.hpp b/src/hyperbolic_system.hpp index 2ee15eb7c..73163a7b9 100644 --- a/src/hyperbolic_system.hpp +++ b/src/hyperbolic_system.hpp @@ -14,25 +14,18 @@ /// // c++ headers -#include #include // library headers #include "AMReX_Array4.H" -#include "AMReX_Dim3.H" -#include "AMReX_ErrorList.H" #include "AMReX_Extension.H" -#include "AMReX_FArrayBox.H" -#include "AMReX_FabArrayUtility.H" #include "AMReX_IntVect.H" -#include "AMReX_Math.H" #include "AMReX_MultiFab.H" #include "AMReX_SPACE.H" // internal headers -#include "AMReX_TagBox.H" #include "ArrayView.hpp" -#include "simulation.hpp" +#include "math_impl.hpp" // #define MULTIDIM_EXTREMA_CHECK diff --git a/src/interpolate.cpp b/src/interpolate.cpp index b7e5043ac..6de4f0be3 100644 --- a/src/interpolate.cpp +++ b/src/interpolate.cpp @@ -1,3 +1,6 @@ +#include +#include + #include "interpolate.hpp" #define LIKELY_IN_CACHE_SIZE 8 @@ -121,7 +124,7 @@ void interpolate_arrays(double *x, double *y, int len, double *arr_x, double *ar const double slope = (arr_y[j + 1] - arr_y[j]) / (arr_x[j + 1] - arr_x[j]); y[i] = slope * (x[i] - arr_x[j]) + arr_y[j]; } - assert(!isnan(y[i])); + assert(!std::isnan(y[i])); } } @@ -147,6 +150,6 @@ double interpolate_value(double x, double const *arr_x, double const *arr_y, int const double slope = (arr_y[j + 1] - arr_y[j]) / (arr_x[j + 1] - arr_x[j]); y = slope * (x - arr_x[j]) + arr_y[j]; } - assert(!isnan(y)); + assert(!std::isnan(y)); return y; } diff --git a/src/interpolate.hpp b/src/interpolate.hpp index 733d809f6..2efd772eb 100644 --- a/src/interpolate.hpp +++ b/src/interpolate.hpp @@ -1,11 +1,9 @@ #ifndef INTERPOLATE_H_ // NOLINT #define INTERPOLATE_H_ -#include -#include -#include +#include -#include "AMReX.H" +#include "AMReX_GpuQualifiers.H" AMREX_GPU_HOST_DEVICE int64_t binary_search_with_guess(double key, const double *arr, int64_t len, int64_t guess); diff --git a/src/linear_advection.hpp b/src/linear_advection.hpp index edc717799..a7046e539 100644 --- a/src/linear_advection.hpp +++ b/src/linear_advection.hpp @@ -10,16 +10,11 @@ /// // c++ headers -#include #include -#include // library headers // internal headers -#include "AMReX_BLassert.H" -#include "AMReX_FArrayBox.H" -#include "AMReX_FabArrayUtility.H" #include "hyperbolic_system.hpp" /// Class for a linear, scalar advection equation @@ -31,7 +26,7 @@ template class LinearAdvectionSystem : public HyperbolicSys // static member functions - static void ConservedToPrimitive(amrex::MultiFab const &cons_mf, amrex::MultiFab &primVar_mf, const int nghost, const int nvars); + static void ConservedToPrimitive(amrex::MultiFab const &cons_mf, amrex::MultiFab &primVar_mf, int nghost, int nvars); static void ComputeMaxSignalSpeed(amrex::Array4 const & /*cons*/, amrex::Array4 const &maxSignal, double advectionVx, double advectionVy, double advectionVz, amrex::Box const &indexRange); @@ -40,16 +35,16 @@ template class LinearAdvectionSystem : public HyperbolicSys static auto isStateValid(amrex::Array4 const &cons, int i, int j, int k) -> bool; static void PredictStep(amrex::MultiFab const &consVarOld_mf, amrex::MultiFab &consVarNew_mf, - std::array const &fluxArray, const double dt, - amrex::GpuArray dx_in, const int nvars); + std::array const &fluxArray, double dt, amrex::GpuArray dx_in, + int nvars); static void AddFluxesRK2(amrex::MultiFab &U_new_mf, amrex::MultiFab const &U0_mf, amrex::MultiFab const &U1_mf, - std::array const &fluxArray, const double dt, - amrex::GpuArray dx_in, const int nvars); + std::array const &fluxArray, double dt, amrex::GpuArray dx_in, + int nvars); template - static void ComputeFluxes(amrex::MultiFab &x1Flux_mf, amrex::MultiFab const &x1LeftState_mf, amrex::MultiFab const &x1RightState_mf, - const double advectionVx, const int nvars); + static void ComputeFluxes(amrex::MultiFab &x1Flux_mf, amrex::MultiFab const &x1LeftState_mf, amrex::MultiFab const &x1RightState_mf, double advectionVx, + int nvars); }; template @@ -118,14 +113,6 @@ void LinearAdvectionSystem::PredictStep(amrex::MultiFab const &consVa +(dt / dy) * (x2Flux[bx](i, j, k, n) - x2Flux[bx](i, j + 1, k, n)), +(dt / dz) * (x3Flux[bx](i, j, k, n) - x3Flux[bx](i, j, k + 1, n)))); } -#if 0 - // check if state is valid -- flag for re-do if not - if (!isStateValid(consVarNew, i, j, k)) { - redoFlag(i, j, k) = quokka::redoFlag::redo; - } else { - redoFlag(i, j, k) = quokka::redoFlag::none; - } -#endif }); } @@ -172,15 +159,6 @@ void LinearAdvectionSystem::AddFluxesRK2(amrex::MultiFab &U_new_mf, a // save results in U_new U_new[bx](i, j, k, n) = (0.5 * U_0 + 0.5 * U_1) + (AMREX_D_TERM(0.5 * FxU_1, +0.5 * FyU_1, +0.5 * FzU_1)); } - -#if 0 - // check if state is valid -- flag for re-do if not - if (!isStateValid(U_new, i, j, k)) { - redoFlag(i, j, k) = quokka::redoFlag::redo; - } else { - redoFlag(i, j, k) = quokka::redoFlag::none; - } -#endif }); } diff --git a/src/mhd_system.hpp b/src/mhd_system.hpp index 5c47313ef..4a320ece9 100644 --- a/src/mhd_system.hpp +++ b/src/mhd_system.hpp @@ -11,18 +11,10 @@ // c++ headers // library headers -#include "AMReX_Arena.H" -#include "AMReX_Array4.H" -#include "AMReX_BLassert.H" -#include "AMReX_FArrayBox.H" -#include "AMReX_Loop.H" -#include "AMReX_REAL.H" -#include "AMReX_TagBox.H" // internal headers -#include "ArrayView.hpp" -#include "simulation.hpp" -#include "valarray.hpp" +#include "physics_info.hpp" +#include "physics_numVars.hpp" /// Class for a MHD system of conservation laws template class MHDSystem diff --git a/src/planck_integral.hpp b/src/planck_integral.hpp index 56d53a337..fa84fce90 100644 --- a/src/planck_integral.hpp +++ b/src/planck_integral.hpp @@ -7,18 +7,15 @@ #ifndef PLANCKINTEGRAL_HPP_ // NOLINT #define PLANCKINTEGRAL_HPP_ -#include +#include #include -#include "AMReX.H" #include "AMReX_Array.H" #include "AMReX_BLassert.H" #include "AMReX_Extension.H" #include "AMReX_GpuQualifiers.H" #include "AMReX_REAL.H" -#include "valarray.hpp" - using Real = amrex::Real; static constexpr bool USE_SECOND_ORDER = false; @@ -256,9 +253,9 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto integrate_planck_from_0_to_x(const } else { y = interpolate_planck_integral(logx); } - assert(!isnan(y)); + assert(!std::isnan(y)); assert(y <= 1.); return y; } -#endif // PLANCKINTEGRAL_HPP_ \ No newline at end of file +#endif // PLANCKINTEGRAL_HPP_ diff --git a/src/radiation_system.hpp b/src/radiation_system.hpp index 4c6ce87b9..1bf061124 100644 --- a/src/radiation_system.hpp +++ b/src/radiation_system.hpp @@ -13,8 +13,6 @@ #include #include -#include -#include // library headers #include "AMReX.H" @@ -24,12 +22,11 @@ #include "AMReX_REAL.H" // internal headers -#include "ArrayView.hpp" #include "EOS.hpp" #include "hyperbolic_system.hpp" +#include "math_impl.hpp" #include "physics_info.hpp" #include "planck_integral.hpp" -#include "simulation.hpp" #include "valarray.hpp" // Hyper parameters of the radiation solver @@ -650,10 +647,10 @@ template AMREX_GPU_HOST_DEVICE auto RadSystem::C const double f_fac = std::sqrt(4.0 - 3.0 * (f * f)); const double chi = (3.0 + 4.0 * (f * f)) / (5.0 + 2.0 * f_fac); -#if 0 - // compute Minerbo (1978) closure [piecewise approximation] - // (For unknown reasons, this closure tends to work better - // than the Levermore/Lorentz closure on the Su & Olson 1997 test.) +#if 0 // NOLINT + // compute Minerbo (1978) closure [piecewise approximation] + // (For unknown reasons, this closure tends to work better + // than the Levermore/Lorentz closure on the Su & Olson 1997 test.) const double chi = (f < 1. / 3.) ? (1. / 3.) : (0.5 - f + 1.5 * f*f); #endif diff --git a/src/simulation.hpp b/src/simulation.hpp index 231576243..0e4e61d6b 100644 --- a/src/simulation.hpp +++ b/src/simulation.hpp @@ -10,7 +10,6 @@ /// timestepping, solving, and I/O of a simulation. // c++ headers -#include "AMReX_Interpolater.H" #include #include #include @@ -33,7 +32,6 @@ namespace filesystem = experimental::filesystem; #include #include #include -#include #include // library headers @@ -43,30 +41,24 @@ namespace filesystem = experimental::filesystem; #include "AMReX_Array4.H" #include "AMReX_AsyncOut.H" #include "AMReX_BCRec.H" -#include "AMReX_BC_TYPES.H" #include "AMReX_BLassert.H" -#include "AMReX_Config.H" #include "AMReX_DistributionMapping.H" #include "AMReX_Extension.H" #include "AMReX_FArrayBox.H" #include "AMReX_FillPatchUtil.H" #include "AMReX_FillPatcher.H" -#include "AMReX_FluxRegister.H" #include "AMReX_GpuQualifiers.H" #include "AMReX_INT.H" #include "AMReX_IndexType.H" #include "AMReX_IntVect.H" -#include "AMReX_LayoutData.H" +#include "AMReX_Interpolater.H" #include "AMReX_MultiFabUtil.H" -#include "AMReX_ParallelContext.H" #include "AMReX_ParallelDescriptor.H" #include "AMReX_REAL.H" #include "AMReX_SPACE.H" #include "AMReX_Vector.H" #include "AMReX_VisMF.H" #include "AMReX_YAFluxRegister.H" -#include "fundamental_constants.H" -#include "physics_numVars.hpp" #include #include #include @@ -92,10 +84,10 @@ namespace filesystem = experimental::filesystem; #endif // internal headers -#include "CheckNaN.hpp" +#include "fundamental_constants.H" #include "grid.hpp" -#include "math_impl.hpp" #include "physics_info.hpp" +#include "physics_numVars.hpp" #ifdef QUOKKA_USE_OPENPMD #include "openPMD.hpp" @@ -462,7 +454,7 @@ template void AMRSimulation::initialize() // check that grids will be properly nested on each level // (this is necessary since FillPatch only fills from non-ghost cells on // lev-1) - auto checkIsProperlyNested = [=](int const lev, amrex::IntVect const &blockingFactor) { + auto checkIsProperlyNested = [this](int const lev, amrex::IntVect const &blockingFactor) { return amrex::ProperlyNested(refRatio(lev - 1), blockingFactor, nghost_cc_, amrex::IndexType::TheCellType(), &amrex::cell_cons_interp); }; @@ -471,7 +463,7 @@ template void AMRSimulation::initialize() // level lev is not properly nested amrex::Print() << "Blocking factor is too small for proper grid nesting! " "Increase blocking factor to >= ceil(nghost,ref_ratio)*ref_ratio." - << std::endl; + << std::endl; // NOLINT(performance-avoid-endl) amrex::Abort("Grids not properly nested!"); } } @@ -623,7 +615,7 @@ template void AMRSimulation::readParameters() int hours = 0; int minutes = 0; int seconds = 0; - int nargs = std::sscanf(maxWalltimeInput.c_str(), "%d:%d:%d", &hours, &minutes, &seconds); + int nargs = std::sscanf(maxWalltimeInput.c_str(), "%d:%d:%d", &hours, &minutes, &seconds); // NOLINT if (nargs == 3) { maxWalltime_ = 3600 * hours + 60 * minutes + seconds; amrex::Print() << fmt::format("Setting walltime limit to {} hours, {} minutes, {} seconds.\n", hours, minutes, seconds); @@ -670,7 +662,7 @@ template void AMRSimulation::setInitialCondition amrex::Print() << "[ERROR] [FATAL] AsyncOut is currently broken! If you want to " "run with AsyncOut anyway (THIS MAY CAUSE DATA CORRUPTION), comment " "out this line in src/simulation.hpp. Aborting." - << std::endl; + << std::endl; // NOLINT(performance-avoid-endl) amrex::Abort(); } @@ -746,7 +738,7 @@ template void AMRSimulation::computeTimestep() for (int level = 0; level <= finest_level; ++level) { n_factor *= nsubsteps[level]; - dt_0 = std::min(dt_0, n_factor * dt_tmp[level]); + dt_0 = std::min(dt_0, static_cast(n_factor) * dt_tmp[level]); dt_0 = std::min(dt_0, maxDt_); // limit to maxDt_ if (tNew_[level] == 0.0) { // first timestep @@ -787,10 +779,10 @@ template void AMRSimulation::computeTimestep() } const amrex::Real work_nonsubcycling = static_cast(total_cells) * (dt_0 / dt_global); - if (work_nonsubcycling <= work_subcycling) { + if (work_nonsubcycling <= static_cast(work_subcycling)) { // use global timestep on this coarse step if (verbose) { - const amrex::Real ratio = work_nonsubcycling / work_subcycling; + const amrex::Real ratio = work_nonsubcycling / static_cast(work_subcycling); amrex::Print() << "\t>> Using global timestep on this coarse step (estimated work ratio: " << ratio << ").\n"; } for (int lev = 1; lev <= max_level; ++lev) { @@ -853,7 +845,7 @@ template void AMRSimulation::evolve() if (suppress_output == 0) { amrex::Print() << "\nCoarse STEP " << step + 1 << " at t = " << cur_time << " (" << (cur_time / stopTime_) * 100. << "%) starts ..." - << std::endl; + << '\n'; } amrex::ParallelDescriptor::Barrier(); // synchronize all MPI ranks @@ -946,13 +938,13 @@ template void AMRSimulation::evolve() for (int n = 0; n < ncomp_cc; ++n) { amrex::Real const final_sum = state_new_cc_[0].sum(n) * vol; amrex::Real const abs_err = (final_sum - init_sum_cons[n]); - amrex::Print() << "Initial " << componentNames_cc_[n] << " = " << init_sum_cons[n] << std::endl; - amrex::Print() << "\tabsolute conservation error = " << abs_err << std::endl; + amrex::Print() << "Initial " << componentNames_cc_[n] << " = " << init_sum_cons[n] << '\n'; + amrex::Print() << "\tabsolute conservation error = " << abs_err << '\n'; if (init_sum_cons[n] != 0.0) { amrex::Real const rel_err = abs_err / init_sum_cons[n]; - amrex::Print() << "\trelative conservation error = " << rel_err << std::endl; + amrex::Print() << "\trelative conservation error = " << rel_err << '\n'; } - amrex::Print() << std::endl; + amrex::Print() << '\n'; } // compute zone-cycles/sec @@ -964,7 +956,7 @@ template void AMRSimulation::evolve() for (int lev = 0; lev <= max_level; ++lev) { amrex::Print() << "Zone-updates on level " << lev << ": " << cellUpdatesEachLevel_[lev] << "\n"; } - amrex::Print() << std::endl; + amrex::Print() << '\n'; // write final checkpoint if (checkpointInterval_ > 0 && istep[0] > last_chk_file_step) { @@ -1255,7 +1247,7 @@ template void AMRSimulation::timeStepWithSubcycl if (Verbose()) { amrex::Print() << "[Level " << lev << " step " << istep[lev] + 1 << "] "; - amrex::Print() << "ADVANCE with time = " << tNew_[lev] << " dt = " << dt_[lev] << std::endl; + amrex::Print() << "ADVANCE with time = " << tNew_[lev] << " dt = " << dt_[lev] << '\n'; } // Advance a single level for a single time step, and update flux registers @@ -1335,13 +1327,15 @@ void AMRSimulation::incrementFluxRegisters(amrex::MFIter &mfi, amrex: if (fr_as_crse != nullptr) { AMREX_ASSERT(lev < finestLevel()); AMREX_ASSERT(fr_as_crse == flux_reg_[lev + 1].get()); - fr_as_crse->CrseAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, geom[lev].CellSize(), dt_lev, amrex::RunOn::Gpu); + fr_as_crse->CrseAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, // NOLINT(readability-container-data-pointer) + geom[lev].CellSize(), dt_lev, amrex::RunOn::Gpu); } if (fr_as_fine != nullptr) { AMREX_ASSERT(lev > 0); AMREX_ASSERT(fr_as_fine == flux_reg_[lev].get()); - fr_as_fine->FineAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, geom[lev].CellSize(), dt_lev, amrex::RunOn::Gpu); + fr_as_fine->FineAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, // NOLINT(readability-container-data-pointer) + geom[lev].CellSize(), dt_lev, amrex::RunOn::Gpu); } } diff --git a/src/valarray.hpp b/src/valarray.hpp index 06869db9d..96cab0730 100644 --- a/src/valarray.hpp +++ b/src/valarray.hpp @@ -13,7 +13,6 @@ #include #include #include -#include // library headers #include "AMReX_Extension.H"