From cd324d41dfad70c6374205324b06309e8ac90110 Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Sat, 9 Dec 2023 21:20:05 -0500 Subject: [PATCH 01/18] fix clang-tidy warnings --- src/hyperbolic_system.hpp | 1 + src/radiation_system.hpp | 1 + src/simulation.hpp | 104 +++++++------------------------------- src/valarray.hpp | 1 - 4 files changed, 19 insertions(+), 88 deletions(-) diff --git a/src/hyperbolic_system.hpp b/src/hyperbolic_system.hpp index 2ee15eb7c..3e3e7f7f2 100644 --- a/src/hyperbolic_system.hpp +++ b/src/hyperbolic_system.hpp @@ -33,6 +33,7 @@ #include "AMReX_TagBox.H" #include "ArrayView.hpp" #include "simulation.hpp" +#include "math_impl.hpp" // #define MULTIDIM_EXTREMA_CHECK diff --git a/src/radiation_system.hpp b/src/radiation_system.hpp index 157c5103e..b4fcfa670 100644 --- a/src/radiation_system.hpp +++ b/src/radiation_system.hpp @@ -27,6 +27,7 @@ #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" diff --git a/src/simulation.hpp b/src/simulation.hpp index b5503f9f6..c61dadf6c 100644 --- a/src/simulation.hpp +++ b/src/simulation.hpp @@ -10,8 +10,6 @@ /// timestepping, solving, and I/O of a simulation. // c++ headers -#include -#include #include #if __has_include() #include @@ -30,7 +28,6 @@ namespace filesystem = experimental::filesystem; #include #include #include -#include #include // library headers @@ -40,29 +37,23 @@ 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_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 "physics_numVars.hpp" #include #include #include @@ -82,9 +73,7 @@ namespace filesystem = experimental::filesystem; #endif // internal headers -#include "CheckNaN.hpp" #include "grid.hpp" -#include "math_impl.hpp" #include "physics_info.hpp" #define USE_YAFLUXREGISTER @@ -392,7 +381,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); }; @@ -401,7 +390,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!"); } } @@ -539,7 +528,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); @@ -569,7 +558,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(); } @@ -645,7 +634,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 @@ -686,10 +675,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) { @@ -752,7 +741,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 @@ -835,13 +824,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 @@ -853,7 +842,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) { @@ -930,7 +919,7 @@ template void AMRSimulation::ellipticSolveAllLev // N.B.: This function actually works for subcycled or not subcycled, as long as // nsubsteps[lev] is set correctly. -template auto AMRSimulation::timeStepWithSubcycling(int lev, amrex::Real time, bool coarseTimeBoundary, int stepsLeft) -> int +template auto AMRSimulation::timeStepWithSubcycling(int lev, amrex::Real time, bool /*coarseTimeBoundary*/, int stepsLeft) -> int { BL_PROFILE("AMRSimulation::timeStepWithSubcycling()"); @@ -972,70 +961,11 @@ template auto AMRSimulation::timeStepWithSubcycl } } - /// "additional AMR subcycling" code borrowed from Chombo: stepsLeft--; -#if 0 - // If this wasn't just done by the next coarser level, check to see if - // it is necessary to do additional subcycling in time. - if ((!coarseTimeBoundary) && (constantDt_ <= 0)) { - - // The factor by which the current time step at the current level - // has been divided (so far) for subcycling. - int maxFactorSublevels = reductionFactor_[lev]; - - // Compute the new subcycling factor for this level and all finer - // levels and find the maximum - for (int i = lev; i <= finest_level; i++) { - amrex::Real dtCFL = computeTimestepAtLevel(i); - amrex::Real dtCur = dt_[i]; - - // The current factor for level "i" - int factor = reductionFactor_[i]; - - // While the current dt exceeds the CFL-limited dt by a tolerance, - // double the subcycling factor and halve the current dt - while (dtCur > dtToleranceFactor_ * dtCFL) { - factor *= 2; - dtCur *= 0.5; - } - - if (factor > maxFactorSublevels) { - maxFactorSublevels = factor; - } - } - - // More subcycling is necessary - if (maxFactorSublevels > reductionFactor_[lev]) { - if (verbose) { - amrex::Print() << "\tSubcycling --- maxFactorSublevels: " - << maxFactorSublevels << std::endl; - } - - // Adjust the number of time steps left for the current level - stepsLeft = - (stepsLeft + 1) * maxFactorSublevels / reductionFactor_[lev] - 1; - - // Adjust the dt's on this and all finer levels - for (int i = lev; i <= finest_level; i++) { - const int divisor = maxFactorSublevels / reductionFactor_[i]; - dt_[i] /= static_cast(divisor); - - if (verbose) { - amrex::Print() << "\t\tLevel " << i << ": factor: " << divisor << " (" - << reductionFactor_[i] << "), " - << "dt: " << dt_[i] << std::endl; - } - - reductionFactor_[i] = maxFactorSublevels; - } - } - } -#endif - 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 @@ -1097,13 +1027,13 @@ 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])}, geom[lev].CellSize(), dt_lev, amrex::RunOn::Gpu); // NOLINT } 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])}, geom[lev].CellSize(), dt_lev, amrex::RunOn::Gpu); // NOLINT } } 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" From 8fc5f7f90e7307e90f64cf3b10d4fb9583ea3cff Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Sat, 9 Dec 2023 21:52:19 -0500 Subject: [PATCH 02/18] fix clang-tidy problems --- src/AdvectionSimulation.hpp | 11 ++------ src/Chemistry.hpp | 5 +--- src/CloudyCooling.cpp | 1 - src/CloudyCooling.hpp | 23 ++++++++-------- src/EOS.hpp | 16 +++++------ src/FastMath.hpp | 4 +-- src/GrackleDataReader.cpp | 13 ++++----- src/GrackleDataReader.hpp | 11 ++------ src/LLF.hpp | 2 -- src/NSCBC_inflow.hpp | 1 - src/NSCBC_outflow.hpp | 2 -- src/ODEIntegrate.hpp | 13 +-------- src/RadhydroSimulation.hpp | 53 +++++++++++++++---------------------- src/fextract.cpp | 5 +--- src/fextract.hpp | 5 +--- src/grid.hpp | 2 -- src/hydro_system.hpp | 18 +++---------- src/hyperbolic_system.hpp | 8 ------ src/interpolate.cpp | 36 +++++++++++++------------ src/interpolate.hpp | 6 ++--- src/linear_advection.hpp | 34 +++++------------------- src/mhd_system.hpp | 12 ++------- src/planck_integral.hpp | 4 +-- src/radiation_system.hpp | 6 +---- src/root_finding.hpp | 25 ++++++++++++----- 25 files changed, 111 insertions(+), 205 deletions(-) diff --git a/src/AdvectionSimulation.hpp b/src/AdvectionSimulation.hpp index b8bf211b9..7c0e34372 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 @@ -96,7 +89,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 @@ -129,7 +122,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 1a30a0c99..977bf549e 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) { 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..b1d93a8e4 100644 --- a/src/CloudyCooling.hpp +++ b/src/CloudyCooling.hpp @@ -9,17 +9,17 @@ /// \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 +47,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 +152,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..e77cd3ef1 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,27 @@ 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 = {}) + 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 = {}) + 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/FastMath.hpp b/src/FastMath.hpp index caf9dee62..d8ba7fd3a 100644 --- a/src/FastMath.hpp +++ b/src/FastMath.hpp @@ -17,10 +17,10 @@ // Code taken from singularity-eos // https://github.com/lanl/singularity-eos +#include + #include "AMReX_Extension.H" #include "AMReX_GpuQualifiers.H" -#include -#include // this speeds up the *total walltime* for problems with cooling by ~30% on a // single V100 diff --git a/src/GrackleDataReader.cpp b/src/GrackleDataReader.cpp index 4590eab3a..fe67798d6 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,7 @@ 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 +143,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 +169,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 +200,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_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 d83201075..8cf99c54f 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 7d5443aad..9bf015b70 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 @@ -19,7 +18,6 @@ #include #include "AMReX.H" -#include "AMReX_Algorithm.H" #include "AMReX_Arena.H" #include "AMReX_Array.H" #include "AMReX_Array4.H" @@ -28,24 +26,18 @@ #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_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" #ifdef AMREX_USE_ASCENT @@ -56,7 +48,6 @@ #include "Chemistry.hpp" #include "CloudyCooling.hpp" -#include "HLLC.hpp" #include "SimulationData.hpp" #include "hydro_system.hpp" #include "hyperbolic_system.hpp" @@ -223,8 +214,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; @@ -234,7 +225,7 @@ template class RadhydroSimulation : public AMRSimulation bool; void addStrangSplitSources(amrex::MultiFab &state, int lev, amrex::Real time, amrex::Real dt_lev); @@ -263,10 +254,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 @@ -434,7 +425,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 @@ -457,7 +448,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) + ")"); } @@ -572,11 +563,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 @@ -602,14 +593,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) @@ -759,7 +750,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()"); @@ -778,7 +769,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()"); @@ -859,7 +850,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()) { @@ -909,7 +900,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(); @@ -931,7 +922,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 @@ -1562,7 +1553,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/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..19447cace 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,6 @@ #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..63e0966f4 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" @@ -109,7 +107,7 @@ 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); + 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 3e3e7f7f2..73163a7b9 100644 --- a/src/hyperbolic_system.hpp +++ b/src/hyperbolic_system.hpp @@ -14,25 +14,17 @@ /// // 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..f041e3c0d 100644 --- a/src/interpolate.cpp +++ b/src/interpolate.cpp @@ -1,3 +1,6 @@ +#include +#include + #include "interpolate.hpp" #define LIKELY_IN_CACHE_SIZE 8 @@ -30,7 +33,8 @@ int64_t binary_search_with_guess(const double key, const double *arr, int64_t le /* Handle keys outside of the arr range first */ if (key > arr[len - 1]) { return len; - } else if (key < arr[0]) { + } + if (key < arr[0]) { return -1; } @@ -39,10 +43,11 @@ int64_t binary_search_with_guess(const double key, const double *arr, int64_t le * From above we know key >= arr[0] when we start. */ if (len <= 4) { - int64_t i; + int64_t i = 0; - for (i = 1; i < len && key >= arr[i]; ++i) + for (i = 1; i < len && key >= arr[i]; ++i) { ; + } return i - 1; } @@ -69,25 +74,22 @@ int64_t binary_search_with_guess(const double key, const double *arr, int64_t le /* key >= arr[guess] */ if (key < arr[guess + 1]) { return guess; - } else { - /* key >= arr[guess + 1] */ - if (key < arr[guess + 2]) { - return guess + 1; - } else { - /* key >= arr[guess + 2] */ - imin = guess + 2; - /* last attempt to restrict search to items in - * cache */ - if (guess < len - LIKELY_IN_CACHE_SIZE - 1 && key < arr[guess + LIKELY_IN_CACHE_SIZE]) { - imax = guess + LIKELY_IN_CACHE_SIZE; - } - } + } + /* key >= arr[guess + 1] */ + if (key < arr[guess + 2]) { + return guess + 1; + } /* key >= arr[guess + 2] */ + imin = guess + 2; + /* last attempt to restrict search to items in + * cache */ + if (guess < len - LIKELY_IN_CACHE_SIZE - 1 && key < arr[guess + LIKELY_IN_CACHE_SIZE]) { + imax = guess + LIKELY_IN_CACHE_SIZE; } } /* finally, find index by bisection */ while (imin < imax) { - const int64_t imid = imin + ((imax - imin) >> 1); + const int64_t imid = imin + ((imax - imin) >> 1); // NOLINT(hicpp-signed-bitwise) if (key >= arr[imid]) { imin = imid + 1; } else { 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..bc2f34783 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); + 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 e01dc587d..e0031899d 100644 --- a/src/planck_integral.hpp +++ b/src/planck_integral.hpp @@ -7,17 +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; diff --git a/src/radiation_system.hpp b/src/radiation_system.hpp index b4fcfa670..41bbf1c0a 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,13 +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" // physical constants in CGS units @@ -608,7 +604,7 @@ 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 +#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.) diff --git a/src/root_finding.hpp b/src/root_finding.hpp index 329550549..5ae86f572 100644 --- a/src/root_finding.hpp +++ b/src/root_finding.hpp @@ -71,14 +71,14 @@ namespace quokka::math template class eps_tolerance { public: - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE eps_tolerance() { eps = 4 * std::numeric_limits::epsilon(); } + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE eps_tolerance() : eps(4 * std::numeric_limits::epsilon()) { } AMREX_GPU_HOST_DEVICE - AMREX_FORCE_INLINE explicit eps_tolerance(amrex::Real eps_) { eps = eps_; } + AMREX_FORCE_INLINE explicit eps_tolerance(amrex::Real eps_) : eps(eps_) { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE explicit eps_tolerance(unsigned bits) { BOOST_MATH_STD_USING - eps = (std::max)(T(ldexp(1.0F, 1 - bits)), T(4 * std::numeric_limits::epsilon())); + eps = (std::max)(T(ldexp(1.0F, 1 - bits)), T(4 * std::numeric_limits::epsilon())); // NOLINT(cppcoreguidelines-prefer-member-initializer) } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator()(const T &a, const T &b) { @@ -285,7 +285,19 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::pair toms748_solve(F f, cons BOOST_MATH_STD_USING // For ADL of std math functions int count = max_iter; - T a, b, fa, fb, c, u, fu, a0, b0, d, fd, e, fe; + T a; + T b; + T fa; + T fb; + T c; + T u; + T fu; + T a0; + T b0; + T d; + T fd; + T e; + T fe; static const T mu = 0.5F; // initialise a, b and fa, fb: @@ -299,10 +311,11 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::pair toms748_solve(F f, cons if (tol(a, b) || (fa == 0) || (fb == 0)) { max_iter = 0; - if (fa == 0) + if (fa == 0) { b = a; - else if (fb == 0) + } else if (fb == 0) { a = b; +} return std::make_pair(a, b); } From 7a64fdd2b6f5949d16db3faf739072c1e0df96c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 10 Dec 2023 02:55:38 +0000 Subject: [PATCH 03/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/AdvectionSimulation.hpp | 4 ++-- src/Chemistry.hpp | 2 +- src/CloudyCooling.hpp | 1 - src/EOS.hpp | 16 +++++++--------- src/GrackleDataReader.cpp | 9 +++++---- src/RadhydroSimulation.hpp | 16 ++++++++-------- src/fextract.hpp | 3 ++- src/hydro_system.hpp | 4 ++-- src/linear_advection.hpp | 14 +++++++------- src/planck_integral.hpp | 1 - src/radiation_system.hpp | 6 +++--- src/root_finding.hpp | 6 +++--- src/simulation.hpp | 9 ++++++--- 13 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/AdvectionSimulation.hpp b/src/AdvectionSimulation.hpp index 7c0e34372..263d41c8d 100644 --- a/src/AdvectionSimulation.hpp +++ b/src/AdvectionSimulation.hpp @@ -89,7 +89,7 @@ template class AdvectionSimulation : public AMRSimulation

void fluxFunction(amrex::MultiFab const &consState, amrex::MultiFab &primVar, amrex::MultiFab &x1Flux, amrex::MultiFab &x1LeftState, - amrex::MultiFab &x1RightState, int ng_reconstruct, int nvars); + amrex::MultiFab &x1RightState, int ng_reconstruct, int nvars); double advectionVx_ = 1.0; // default double advectionVy_ = 0.0; // default @@ -122,7 +122,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 977bf549e..57f6e0c62 100644 --- a/src/Chemistry.hpp +++ b/src/Chemistry.hpp @@ -26,7 +26,7 @@ namespace quokka::chemistry { -AMREX_GPU_DEVICE void chemburner(burn_t &chemstate, 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) { diff --git a/src/CloudyCooling.hpp b/src/CloudyCooling.hpp index b1d93a8e4..dd6ee60f9 100644 --- a/src/CloudyCooling.hpp +++ b/src/CloudyCooling.hpp @@ -9,7 +9,6 @@ /// \brief Defines methods for interpolating cooling rates from Cloudy tables. /// - #include "AMReX.H" #include "AMReX_Extension.H" #include "AMReX_GpuQualifiers.H" diff --git a/src/EOS.hpp b/src/EOS.hpp index e77cd3ef1..644af4f77 100644 --- a/src/EOS.hpp +++ b/src/EOS.hpp @@ -41,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, 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, 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, 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, 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, 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, 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, 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/GrackleDataReader.cpp b/src/GrackleDataReader.cpp index fe67798d6..eb0645bd9 100644 --- a/src/GrackleDataReader.cpp +++ b/src/GrackleDataReader.cpp @@ -129,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](static_cast(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); @@ -143,7 +144,7 @@ void initialize_cloudy_data(cloudy_data &my_cloudy, char const *group_name, std: { // Read Cooling data - auto *temp_data = new double[my_cloudy.data_size]; // NOLINT(cppcoreguidelines-owning-memory) + 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); @@ -169,7 +170,7 @@ void initialize_cloudy_data(cloudy_data &my_cloudy, char const *group_name, std: { // Read Heating data - auto *temp_data = new double[my_cloudy.data_size]; // NOLINT(cppcoreguidelines-owning-memory) + auto *temp_data = new double[my_cloudy.data_size]; // NOLINT(cppcoreguidelines-owning-memory) parameter_name = fmt::format("/CoolingRates/{}/Heating", group_name); @@ -200,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 - auto *temp_data = new double[my_cloudy.data_size]; // NOLINT(cppcoreguidelines-owning-memory) + 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/RadhydroSimulation.hpp b/src/RadhydroSimulation.hpp index 9bf015b70..8d6edfa74 100644 --- a/src/RadhydroSimulation.hpp +++ b/src/RadhydroSimulation.hpp @@ -214,8 +214,8 @@ template class RadhydroSimulation : public AMRSimulation &dstfluxes, std::array &srcfluxes, int srccomp, - 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; @@ -254,10 +254,10 @@ template class RadhydroSimulation : public AMRSimulation dx) -> std::tuple, std::array>; - auto computeHydroFluxes(amrex::MultiFab const &consVar, int nvars, int lev) + auto computeHydroFluxes(amrex::MultiFab const &consVar, int nvars, int lev) -> std::pair, std::array>; - auto computeFOHydroFluxes(amrex::MultiFab const &consVar, int nvars, int lev) + auto computeFOHydroFluxes(amrex::MultiFab const &consVar, int nvars, int lev) -> std::pair, std::array>; template @@ -425,7 +425,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 @@ -750,7 +750,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()"); @@ -769,7 +769,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()"); @@ -922,7 +922,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 diff --git a/src/fextract.hpp b/src/fextract.hpp index 19447cace..2343732a8 100644 --- a/src/fextract.hpp +++ b/src/fextract.hpp @@ -9,6 +9,7 @@ #include #include -auto fextract(amrex::MultiFab &mf, amrex::Geometry &geom, int idir, amrex::Real slice_coord, bool center = false) -> std::tuple, amrex::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/hydro_system.hpp b/src/hydro_system.hpp index 63e0966f4..0198ff7c9 100644 --- a/src/hydro_system.hpp +++ b/src/hydro_system.hpp @@ -106,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 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); diff --git a/src/linear_advection.hpp b/src/linear_advection.hpp index bc2f34783..a7046e539 100644 --- a/src/linear_advection.hpp +++ b/src/linear_advection.hpp @@ -26,7 +26,7 @@ template class LinearAdvectionSystem : public HyperbolicSys // static member functions - static void ConservedToPrimitive(amrex::MultiFab const &cons_mf, amrex::MultiFab &primVar_mf, int nghost, 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); @@ -35,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, double dt, - amrex::GpuArray dx_in, 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, double dt, - amrex::GpuArray dx_in, 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, - double advectionVx, int nvars); + static void ComputeFluxes(amrex::MultiFab &x1Flux_mf, amrex::MultiFab const &x1LeftState_mf, amrex::MultiFab const &x1RightState_mf, double advectionVx, + int nvars); }; template diff --git a/src/planck_integral.hpp b/src/planck_integral.hpp index e0031899d..934e5e7ae 100644 --- a/src/planck_integral.hpp +++ b/src/planck_integral.hpp @@ -16,7 +16,6 @@ #include "AMReX_GpuQualifiers.H" #include "AMReX_REAL.H" - using Real = amrex::Real; static constexpr bool USE_SECOND_ORDER = false; diff --git a/src/radiation_system.hpp b/src/radiation_system.hpp index 41bbf1c0a..5f3110aca 100644 --- a/src/radiation_system.hpp +++ b/src/radiation_system.hpp @@ -605,9 +605,9 @@ template AMREX_GPU_HOST_DEVICE auto RadSystem::C const double chi = (3.0 + 4.0 * (f * f)) / (5.0 + 2.0 * f_fac); #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.) + // 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/root_finding.hpp b/src/root_finding.hpp index 5ae86f572..d30155922 100644 --- a/src/root_finding.hpp +++ b/src/root_finding.hpp @@ -71,9 +71,9 @@ namespace quokka::math template class eps_tolerance { public: - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE eps_tolerance() : eps(4 * std::numeric_limits::epsilon()) { } + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE eps_tolerance() : eps(4 * std::numeric_limits::epsilon()) {} AMREX_GPU_HOST_DEVICE - AMREX_FORCE_INLINE explicit eps_tolerance(amrex::Real eps_) : eps(eps_) { } + AMREX_FORCE_INLINE explicit eps_tolerance(amrex::Real eps_) : eps(eps_) {} AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE explicit eps_tolerance(unsigned bits) { @@ -315,7 +315,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::pair toms748_solve(F f, cons b = a; } else if (fb == 0) { a = b; -} + } return std::make_pair(a, b); } diff --git a/src/simulation.hpp b/src/simulation.hpp index c61dadf6c..5f20e7fd9 100644 --- a/src/simulation.hpp +++ b/src/simulation.hpp @@ -919,7 +919,8 @@ template void AMRSimulation::ellipticSolveAllLev // N.B.: This function actually works for subcycled or not subcycled, as long as // nsubsteps[lev] is set correctly. -template auto AMRSimulation::timeStepWithSubcycling(int lev, amrex::Real time, bool /*coarseTimeBoundary*/, int stepsLeft) -> int +template +auto AMRSimulation::timeStepWithSubcycling(int lev, amrex::Real time, bool /*coarseTimeBoundary*/, int stepsLeft) -> int { BL_PROFILE("AMRSimulation::timeStepWithSubcycling()"); @@ -1027,13 +1028,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); // NOLINT + fr_as_crse->CrseAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, geom[lev].CellSize(), dt_lev, + amrex::RunOn::Gpu); // NOLINT } 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); // NOLINT + fr_as_fine->FineAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, geom[lev].CellSize(), dt_lev, + amrex::RunOn::Gpu); // NOLINT } } From bb48f8c7886204624870347c67fc0310879614fa Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Mon, 11 Dec 2023 14:47:39 -0500 Subject: [PATCH 04/18] don't change interpolation or root finding for now --- src/interpolate.cpp | 36 +++++++++++++++++------------------- src/root_finding.hpp | 25 ++++++------------------- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/src/interpolate.cpp b/src/interpolate.cpp index f041e3c0d..b7e5043ac 100644 --- a/src/interpolate.cpp +++ b/src/interpolate.cpp @@ -1,6 +1,3 @@ -#include -#include - #include "interpolate.hpp" #define LIKELY_IN_CACHE_SIZE 8 @@ -33,8 +30,7 @@ int64_t binary_search_with_guess(const double key, const double *arr, int64_t le /* Handle keys outside of the arr range first */ if (key > arr[len - 1]) { return len; - } - if (key < arr[0]) { + } else if (key < arr[0]) { return -1; } @@ -43,11 +39,10 @@ int64_t binary_search_with_guess(const double key, const double *arr, int64_t le * From above we know key >= arr[0] when we start. */ if (len <= 4) { - int64_t i = 0; + int64_t i; - for (i = 1; i < len && key >= arr[i]; ++i) { + for (i = 1; i < len && key >= arr[i]; ++i) ; - } return i - 1; } @@ -74,22 +69,25 @@ int64_t binary_search_with_guess(const double key, const double *arr, int64_t le /* key >= arr[guess] */ if (key < arr[guess + 1]) { return guess; - } - /* key >= arr[guess + 1] */ - if (key < arr[guess + 2]) { - return guess + 1; - } /* key >= arr[guess + 2] */ - imin = guess + 2; - /* last attempt to restrict search to items in - * cache */ - if (guess < len - LIKELY_IN_CACHE_SIZE - 1 && key < arr[guess + LIKELY_IN_CACHE_SIZE]) { - imax = guess + LIKELY_IN_CACHE_SIZE; + } else { + /* key >= arr[guess + 1] */ + if (key < arr[guess + 2]) { + return guess + 1; + } else { + /* key >= arr[guess + 2] */ + imin = guess + 2; + /* last attempt to restrict search to items in + * cache */ + if (guess < len - LIKELY_IN_CACHE_SIZE - 1 && key < arr[guess + LIKELY_IN_CACHE_SIZE]) { + imax = guess + LIKELY_IN_CACHE_SIZE; + } + } } } /* finally, find index by bisection */ while (imin < imax) { - const int64_t imid = imin + ((imax - imin) >> 1); // NOLINT(hicpp-signed-bitwise) + const int64_t imid = imin + ((imax - imin) >> 1); if (key >= arr[imid]) { imin = imid + 1; } else { diff --git a/src/root_finding.hpp b/src/root_finding.hpp index d30155922..329550549 100644 --- a/src/root_finding.hpp +++ b/src/root_finding.hpp @@ -71,14 +71,14 @@ namespace quokka::math template class eps_tolerance { public: - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE eps_tolerance() : eps(4 * std::numeric_limits::epsilon()) {} + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE eps_tolerance() { eps = 4 * std::numeric_limits::epsilon(); } AMREX_GPU_HOST_DEVICE - AMREX_FORCE_INLINE explicit eps_tolerance(amrex::Real eps_) : eps(eps_) {} + AMREX_FORCE_INLINE explicit eps_tolerance(amrex::Real eps_) { eps = eps_; } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE explicit eps_tolerance(unsigned bits) { BOOST_MATH_STD_USING - eps = (std::max)(T(ldexp(1.0F, 1 - bits)), T(4 * std::numeric_limits::epsilon())); // NOLINT(cppcoreguidelines-prefer-member-initializer) + eps = (std::max)(T(ldexp(1.0F, 1 - bits)), T(4 * std::numeric_limits::epsilon())); } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator()(const T &a, const T &b) { @@ -285,19 +285,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::pair toms748_solve(F f, cons BOOST_MATH_STD_USING // For ADL of std math functions int count = max_iter; - T a; - T b; - T fa; - T fb; - T c; - T u; - T fu; - T a0; - T b0; - T d; - T fd; - T e; - T fe; + T a, b, fa, fb, c, u, fu, a0, b0, d, fd, e, fe; static const T mu = 0.5F; // initialise a, b and fa, fb: @@ -311,11 +299,10 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::pair toms748_solve(F f, cons if (tol(a, b) || (fa == 0) || (fb == 0)) { max_iter = 0; - if (fa == 0) { + if (fa == 0) b = a; - } else if (fb == 0) { + else if (fb == 0) a = b; - } return std::make_pair(a, b); } From 11ffd399bb193e23e3493bd5218d99fcebcb7459 Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Mon, 11 Dec 2023 14:49:17 -0500 Subject: [PATCH 05/18] move NOLINT to correct line --- src/simulation.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/simulation.hpp b/src/simulation.hpp index 5f20e7fd9..bfc9a4d19 100644 --- a/src/simulation.hpp +++ b/src/simulation.hpp @@ -1028,15 +1028,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); // NOLINT + fr_as_crse->CrseAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, geom[lev].CellSize(), dt_lev, // NOLINT(readability-container-data-pointer) + 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); // NOLINT + fr_as_fine->FineAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, geom[lev].CellSize(), dt_lev, // NOLINT(readability-container-data-pointer) + amrex::RunOn::Gpu); } } From a73c5468922967fed4c416ef84f04e14cb74274a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:49:33 +0000 Subject: [PATCH 06/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/simulation.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/simulation.hpp b/src/simulation.hpp index bfc9a4d19..204774451 100644 --- a/src/simulation.hpp +++ b/src/simulation.hpp @@ -1028,14 +1028,16 @@ 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, // NOLINT(readability-container-data-pointer) + fr_as_crse->CrseAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, geom[lev].CellSize(), + dt_lev, // NOLINT(readability-container-data-pointer) 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, // NOLINT(readability-container-data-pointer) + fr_as_fine->FineAdd(mfi, {AMREX_D_DECL(&fluxArrays[0], &fluxArrays[1], &fluxArrays[2])}, geom[lev].CellSize(), + dt_lev, // NOLINT(readability-container-data-pointer) amrex::RunOn::Gpu); } } From 2ab601ba8e0348b9f09ef3e0d92bd2fbc1973758 Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Mon, 11 Dec 2023 14:55:28 -0500 Subject: [PATCH 07/18] re-fix NOLINT after autoformat --- src/simulation.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/simulation.hpp b/src/simulation.hpp index 204774451..3a6cda222 100644 --- a/src/simulation.hpp +++ b/src/simulation.hpp @@ -1028,17 +1028,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, // NOLINT(readability-container-data-pointer) - 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, // NOLINT(readability-container-data-pointer) - 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); } } From f4de1ca4e32ef7b8d8f83fb5a716ea8f2079bd8a Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Mon, 11 Dec 2023 16:47:43 -0500 Subject: [PATCH 08/18] fix build --- src/ShockCloud/test_cloudy.cpp | 2 +- src/interpolate.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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/interpolate.cpp b/src/interpolate.cpp index b7e5043ac..99b881e12 100644 --- a/src/interpolate.cpp +++ b/src/interpolate.cpp @@ -1,3 +1,6 @@ +#include +#include + #include "interpolate.hpp" #define LIKELY_IN_CACHE_SIZE 8 From 20be61a20f57efa65fa28f593594c405c3bec56c Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Mon, 11 Dec 2023 20:18:25 -0500 Subject: [PATCH 09/18] isnan() -> std::isnan() --- src/interpolate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interpolate.cpp b/src/interpolate.cpp index 99b881e12..6de4f0be3 100644 --- a/src/interpolate.cpp +++ b/src/interpolate.cpp @@ -124,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])); } } @@ -150,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; } From b9c2cc92b8d28ffdf04ddff63bb796ec6c9036dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 18:20:39 +0000 Subject: [PATCH 10/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/simulation.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulation.hpp b/src/simulation.hpp index 82701076c..0e4e61d6b 100644 --- a/src/simulation.hpp +++ b/src/simulation.hpp @@ -49,9 +49,9 @@ namespace filesystem = experimental::filesystem; #include "AMReX_FillPatcher.H" #include "AMReX_GpuQualifiers.H" #include "AMReX_INT.H" -#include "AMReX_Interpolater.H" #include "AMReX_IndexType.H" #include "AMReX_IntVect.H" +#include "AMReX_Interpolater.H" #include "AMReX_MultiFabUtil.H" #include "AMReX_ParallelDescriptor.H" #include "AMReX_REAL.H" From 5e5f60a00db6bfe504e592a208afac272948cacd Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Thu, 8 Feb 2024 15:21:50 -0500 Subject: [PATCH 11/18] update microphysics --- extern/Microphysics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/Microphysics b/extern/Microphysics index fbeddb367..b5d1a91a9 160000 --- a/extern/Microphysics +++ b/extern/Microphysics @@ -1 +1 @@ -Subproject commit fbeddb367c6ef7d71052e23c20deda164243e643 +Subproject commit b5d1a91a99bcbd68bc3b864392fe103f61b76e3a From 5e85623f2cace292d37eaebaa8cc60f92a711cbb Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Thu, 8 Feb 2024 15:37:47 -0500 Subject: [PATCH 12/18] add amrex:: --- src/FCQuantities/test_fc_quantities.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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); From 858bfa8794a4ff965e6ff2ae2e530922e7ff4edd Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Thu, 8 Feb 2024 15:52:49 -0500 Subject: [PATCH 13/18] add amrex:: --- src/NSCBC/channel.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/NSCBC/channel.cpp b/src/NSCBC/channel.cpp index 98763f765..ba40faefe 100644 --- a/src/NSCBC/channel.cpp +++ b/src/NSCBC/channel.cpp @@ -71,12 +71,12 @@ namespace 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) +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 From aeffe434bc48be551c4d93b6e0e16ecea785fffc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 20:53:02 +0000 Subject: [PATCH 14/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/NSCBC/channel.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/NSCBC/channel.cpp b/src/NSCBC/channel.cpp index ba40faefe..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 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) +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 +#if 0 // workaround AMDGPU compiler bug }; // namespace #endif From 1a7175e45239c4ef32d13229c4021b7c661d1ddf Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Thu, 8 Feb 2024 19:50:46 -0500 Subject: [PATCH 15/18] update microphysics --- extern/Microphysics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/Microphysics b/extern/Microphysics index b5d1a91a9..348ca2f58 160000 --- a/extern/Microphysics +++ b/extern/Microphysics @@ -1 +1 @@ -Subproject commit b5d1a91a99bcbd68bc3b864392fe103f61b76e3a +Subproject commit 348ca2f5801c8cf80fa5910efe5f036bf4f737fe From c207ace0ed3c10e1aa7ae34397e92b0d181f96f1 Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Thu, 8 Feb 2024 19:54:48 -0500 Subject: [PATCH 16/18] fix missing amrex:: --- src/NSCBC/vortex.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/NSCBC/vortex.cpp b/src/NSCBC/vortex.cpp index 6ef755777..f239b52a3 100644 --- a/src/NSCBC/vortex.cpp +++ b/src/NSCBC/vortex.cpp @@ -64,13 +64,13 @@ 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) +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) From 09e957df237887e14e1afddd587fcc230f168ea1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 00:55:00 +0000 Subject: [PATCH 17/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/NSCBC/vortex.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/NSCBC/vortex.cpp b/src/NSCBC/vortex.cpp index f239b52a3..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; -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::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 +}; // namespace template <> void RadhydroSimulation::setInitialConditionsOnGrid(quokka::grid grid_elem) { From 025538cbf5a01a3aab25418bbd4fdc052144f9c8 Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Thu, 8 Feb 2024 21:08:19 -0500 Subject: [PATCH 18/18] Update planck_integral.hpp --- src/planck_integral.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/planck_integral.hpp b/src/planck_integral.hpp index 487cb11d6..fa84fce90 100644 --- a/src/planck_integral.hpp +++ b/src/planck_integral.hpp @@ -253,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_