From 9c0a2ce9acaa26cb2acaf50ac815ec7467d90fcb Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Thu, 3 Aug 2023 14:49:56 -0700 Subject: [PATCH] Clang-Tidy changes in Src/Extern --- Src/Extern/HDF5/AMReX_ParticleHDF5.H | 65 +++++++++++-------- Src/Extern/HDF5/AMReX_PlotFileUtilHDF5.cpp | 20 +++--- .../HDF5/AMReX_WriteBinaryParticleDataHDF5.H | 30 +++++---- Src/Extern/HYPRE/AMReX_HypreIJIface.cpp | 29 ++++++--- Src/Extern/PETSc/AMReX_PETSc.cpp | 6 +- .../ProfParser/AMReX_ProfParserBatch.cpp | 44 ++++++------- .../SUNDIALS/AMReX_NVector_MultiFab.cpp | 12 ++-- Src/Extern/SUNDIALS/AMReX_SUNMemory.cpp | 18 ++--- .../SUNDIALS/AMReX_SundialsIntegrator.H | 20 +++--- Src/Extern/SUNDIALS/AMReX_Sundials_Core.cpp | 2 +- 10 files changed, 139 insertions(+), 107 deletions(-) diff --git a/Src/Extern/HDF5/AMReX_ParticleHDF5.H b/Src/Extern/HDF5/AMReX_ParticleHDF5.H index db58f07d6a3..6bd18ab9227 100644 --- a/Src/Extern/HDF5/AMReX_ParticleHDF5.H +++ b/Src/Extern/HDF5/AMReX_ParticleHDF5.H @@ -155,10 +155,10 @@ ParticleContainer_impl AMREX_ASSERT( int_comp_names.size() == NStructInt + NumIntComps() ); Vector write_real_comp; - for (int i = 0; i < NStructReal + NumRealComps(); ++i) write_real_comp.push_back(1); + for (int i = 0; i < NStructReal + NumRealComps(); ++i) { write_real_comp.push_back(1); } Vector write_int_comp; - for (int i = 0; i < NStructInt + NumIntComps(); ++i) write_int_comp.push_back(1); + for (int i = 0; i < NStructInt + NumIntComps(); ++i) { write_int_comp.push_back(1); } WriteHDF5ParticleData(dir, name, write_real_comp, write_int_comp, @@ -312,10 +312,10 @@ ParticleContainer_impl AMREX_ASSERT( int_comp_names.size() == NStructInt + NArrayInt ); Vector write_real_comp; - for (int i = 0; i < NStructReal + NumRealComps(); ++i) write_real_comp.push_back(1); + for (int i = 0; i < NStructReal + NumRealComps(); ++i) { write_real_comp.push_back(1); } Vector write_int_comp; - for (int i = 0; i < NStructInt + NumIntComps(); ++i) write_int_comp.push_back(1); + for (int i = 0; i < NStructInt + NumIntComps(); ++i) { write_int_comp.push_back(1); } WriteHDF5ParticleData(dir, name, write_real_comp, write_int_comp, @@ -335,10 +335,10 @@ ParticleContainer_impl AMREX_ASSERT(real_comp_names.size() == NStructReal + NumRealComps()); Vector write_real_comp; - for (int i = 0; i < NStructReal + NumRealComps(); ++i) write_real_comp.push_back(1); + for (int i = 0; i < NStructReal + NumRealComps(); ++i) { write_real_comp.push_back(1); } Vector write_int_comp; - for (int i = 0; i < NStructInt + NumIntComps(); ++i) write_int_comp.push_back(1); + for (int i = 0; i < NStructInt + NumIntComps(); ++i) { write_int_comp.push_back(1); } Vector int_comp_names; for (int i = 0; i < NStructInt + NumIntComps(); ++i ) @@ -604,8 +604,9 @@ ParticleContainer_impl hsize_t chunk_dim = 1024; chunk_env = getenv("HDF5_CHUNK_SIZE"); - if (chunk_env != NULL) + if (chunk_env != NULL) { chunk_dim = atoi(chunk_env); + } H5Pset_chunk(dcpl_int, 1, &chunk_dim); H5Pset_chunk(dcpl_real, 1, &chunk_dim); @@ -626,7 +627,7 @@ ParticleContainer_impl pos = compression.find("ZFP"); if (pos != std::string::npos) { ret = H5Z_zfp_initialize(); - if (ret < 0) amrex::Abort("ZFP initialize failed!"); + if (ret < 0) { amrex::Abort("ZFP initialize failed!"); } } #endif @@ -815,22 +816,25 @@ ParticleContainer_impl H5Sclose(real_dset_space); real_file_offset = 0; - for (int i = 0; i < ParallelDescriptor::MyProc(); i++) + for (int i = 0; i < ParallelDescriptor::MyProc(); i++) { real_file_offset += all_mfi_real_total_size[i]; + } my_real_offset = real_file_offset; my_real_count = 0; int max_mfi_count = 0, write_count = 0; - for (int i = 0; i < ParallelDescriptor::MyProc(); i++) - if (max_mfi_count < all_mfi_cnt[i]) + for (int i = 0; i < ParallelDescriptor::MyProc(); i++) { + if (max_mfi_count < all_mfi_cnt[i]) { max_mfi_count = all_mfi_cnt[i]; + } + } for (MFIter mfi(state); mfi.isValid(); ++mfi) { const int grid = mfi.index(); - if (count[grid] == 0) continue; + if (count[grid] == 0) { continue; } Vector istuff; Vector rstuff; @@ -851,7 +855,7 @@ ParticleContainer_impl #else ret = H5Dwrite(int_dset_id, H5T_NATIVE_INT, int_mem_space, int_dset_space, dxpl_col, istuff.dataPtr()); #endif - if (ret < 0) amrex::Abort("H5Dwrite int_dset failed!"); + if (ret < 0) { amrex::Abort("H5Dwrite int_dset failed!"); } H5Sclose(int_dset_space); H5Sclose(int_mem_space); @@ -864,20 +868,21 @@ ParticleContainer_impl /* my_real_offset << ", my_real_count = " << my_real_count << ", total_real_size = " << total_real_size << '\n'; */ real_dset_space = H5Screate_simple(1, &total_real_size, NULL); H5Sselect_hyperslab (real_dset_space, H5S_SELECT_SET, &my_real_offset, NULL, &my_real_count, NULL); - if (sizeof(typename ParticleType::RealType) == 4) + if (sizeof(typename ParticleType::RealType) == 4) { #ifdef AMREX_USE_HDF5_ASYNC ret = H5Dwrite_async(real_dset_id, H5T_NATIVE_FLOAT, real_mem_space, real_dset_space, dxpl_col, rstuff.dataPtr(), es_par_g); #else ret = H5Dwrite(real_dset_id, H5T_NATIVE_FLOAT, real_mem_space, real_dset_space, dxpl_col, rstuff.dataPtr()); #endif - else + } else { #ifdef AMREX_USE_HDF5_ASYNC ret = H5Dwrite_async(real_dset_id, H5T_NATIVE_DOUBLE, real_mem_space, real_dset_space, dxpl_col, rstuff.dataPtr(), es_par_g); #else ret = H5Dwrite(real_dset_id, H5T_NATIVE_DOUBLE, real_mem_space, real_dset_space, dxpl_col, rstuff.dataPtr()); #endif + } - if (ret < 0) amrex::Abort("H5Dwrite real_dset failed!"); + if (ret < 0) { amrex::Abort("H5Dwrite real_dset failed!"); } H5Sclose(real_mem_space); H5Sclose(real_dset_space); @@ -896,16 +901,18 @@ ParticleContainer_impl #ifdef AMREX_USE_HDF5_ASYNC H5Dwrite_async(int_dset_id, H5T_NATIVE_INT, int_dset_space, int_dset_space, dxpl_col, NULL, es_par_g); - if (sizeof(typename ParticleType::RealType) == 4) + if (sizeof(typename ParticleType::RealType) == 4) { H5Dwrite_async(real_dset_id, H5T_NATIVE_FLOAT, real_dset_space, real_dset_space, dxpl_col, NULL, es_par_g); - else + } else { H5Dwrite_async(real_dset_id, H5T_NATIVE_DOUBLE, real_dset_space, real_dset_space, dxpl_col, NULL, es_par_g); + } #else H5Dwrite(int_dset_id, H5T_NATIVE_INT, int_dset_space, int_dset_space, dxpl_col, NULL); - if (sizeof(typename ParticleType::RealType) == 4) + if (sizeof(typename ParticleType::RealType) == 4) { H5Dwrite(real_dset_id, H5T_NATIVE_FLOAT, real_dset_space, real_dset_space, dxpl_col, NULL); - else + } else { H5Dwrite(real_dset_id, H5T_NATIVE_DOUBLE, real_dset_space, real_dset_space, dxpl_col, NULL); + } #endif H5Sclose(int_dset_space); @@ -931,8 +938,9 @@ ParticleContainer_impl #endif my_int_offset = 0; - for (int i = 0; i < ParallelDescriptor::MyProc(); i++) + for (int i = 0; i < ParallelDescriptor::MyProc(); i++) { my_int_offset += all_mfi_cnt[i]; + } my_int_count = my_mfi_cnt; int_mem_space = H5Screate_simple(1, &my_int_count, NULL); /* std::cout << "Rank " << ParallelDescriptor::MyProc() << ": my_int_offset = " << */ @@ -944,7 +952,7 @@ ParticleContainer_impl #else ret = H5Dwrite(offset_id, H5T_NATIVE_INT, int_mem_space, offset_space, dxpl_col, &(my_nparticles[0])); #endif - if (ret < 0) amrex::Abort("H5Dwrite offset failed!"); + if (ret < 0) { amrex::Abort("H5Dwrite offset failed!"); } H5Pclose(dcpl_int); H5Pclose(dcpl_real); @@ -986,8 +994,9 @@ ParticleContainer_impl const auto strttime = amrex::second(); std::string fullname = dir; - if (!fullname.empty() && fullname[fullname.size()-1] != '/') + if (!fullname.empty() && fullname[fullname.size()-1] != '/') { fullname += '/'; + } fullname += file; fullname += ".h5"; @@ -1097,8 +1106,9 @@ ParticleContainer_impl msg += aname; amrex::Abort(msg.c_str()); } - if (ni != NStructInt + NumIntComps()) + if (ni != NStructInt + NumIntComps()) { amrex::Abort("ParticleContainer::Restart(): ni != NStructInt"); + } aname = "nparticles"; Long nparticles; @@ -1285,7 +1295,7 @@ ParticleContainer_impl const int rank = ParallelDescriptor::MyProc(); const int NReaders = MaxReaders(); - if (rank >= NReaders) return; + if (rank >= NReaders) { return; } const int Navg = ngrids[lev] / NReaders; const int Nleft = ngrids[lev] - Navg * NReaders; @@ -1378,10 +1388,11 @@ ParticleContainer_impl hsize_t real_offset = offset*rChunkSize; real_dspace = H5Screate_simple(1, &real_cnt, NULL); H5Sselect_hyperslab (real_fspace, H5S_SELECT_SET, &real_offset, NULL, &real_cnt, NULL); - if (sizeof(RTYPE) == 4) + if (sizeof(RTYPE) == 4) { H5Dread(real_dset, H5T_NATIVE_FLOAT, real_dspace, real_fspace, H5P_DEFAULT, rstuff.dataPtr()); - else + } else { H5Dread(real_dset, H5T_NATIVE_DOUBLE, real_dspace, real_fspace, H5P_DEFAULT, rstuff.dataPtr()); + } H5Sclose(real_fspace); H5Sclose(real_dspace); diff --git a/Src/Extern/HDF5/AMReX_PlotFileUtilHDF5.cpp b/Src/Extern/HDF5/AMReX_PlotFileUtilHDF5.cpp index 13d62b7f790..eb0c1af1c33 100644 --- a/Src/Extern/HDF5/AMReX_PlotFileUtilHDF5.cpp +++ b/Src/Extern/HDF5/AMReX_PlotFileUtilHDF5.cpp @@ -470,7 +470,7 @@ void WriteMultiLevelPlotfileHDF5SingleDset (const std::string& plotfilename, pos = compression.find("ZFP"); if (pos != std::string::npos) { ret = H5Z_zfp_initialize(); - if (ret < 0) amrex::Abort("ZFP initialize failed!"); + if (ret < 0) { amrex::Abort("ZFP initialize failed!"); } } #endif @@ -912,7 +912,7 @@ void WriteMultiLevelPlotfileHDF5MultiDset (const std::string& plotfilename, pos = compression.find("ZFP"); if (pos != std::string::npos) { ret = H5Z_zfp_initialize(); - if (ret < 0) amrex::Abort("ZFP initialize failed!"); + if (ret < 0) { amrex::Abort("ZFP initialize failed!"); } } #endif @@ -920,7 +920,7 @@ void WriteMultiLevelPlotfileHDF5MultiDset (const std::string& plotfilename, pos = compression.find("SZ"); if (pos != std::string::npos) { ret = H5Z_SZ_Init((char*)value_env.c_str()); - if (ret < 0) amrex::Abort("ZFP initialize failed, check SZ config file!"); + if (ret < 0) { amrex::Abort("ZFP initialize failed, check SZ config file!"); } } #endif @@ -1161,24 +1161,26 @@ void WriteMultiLevelPlotfileHDF5MultiDset (const std::string& plotfilename, snprintf(dataname, sizeof dataname, "data:datatype=%d", jj); #ifdef AMREX_USE_HDF5_ASYNC dataset = H5Dcreate_async(grp, dataname, H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT, lev_dcpl_id, H5P_DEFAULT, es_id_g); - if(dataset < 0) std::cout << ParallelDescriptor::MyProc() << "create data failed! ret = " << dataset << std::endl; + if(dataset < 0) { std::cout << ParallelDescriptor::MyProc() << "create data failed! ret = " << dataset << std::endl; } - if (hs_procsize[0] == 0) + if (hs_procsize[0] == 0) { H5Sselect_none(dataspace); - else + } else { H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, ch_offset, NULL, hs_procsize, NULL); + } ret = H5Dwrite_async(dataset, H5T_NATIVE_DOUBLE, memdataspace, dataspace, dxpl_col, a_buffer_ind.dataPtr(), es_id_g); if(ret < 0) { std::cout << ParallelDescriptor::MyProc() << "Write data failed! ret = " << ret << std::endl; break; } H5Dclose_async(dataset, es_id_g); #else dataset = H5Dcreate(grp, dataname, H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT, lev_dcpl_id, H5P_DEFAULT); - if(dataset < 0) std::cout << ParallelDescriptor::MyProc() << "create data failed! ret = " << dataset << std::endl; + if(dataset < 0) { std::cout << ParallelDescriptor::MyProc() << "create data failed! ret = " << dataset << std::endl; } - if (hs_procsize[0] == 0) + if (hs_procsize[0] == 0) { H5Sselect_none(dataspace); - else + } else { H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, ch_offset, NULL, hs_procsize, NULL); + } ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, memdataspace, dataspace, dxpl_col, a_buffer_ind.dataPtr()); if(ret < 0) { std::cout << ParallelDescriptor::MyProc() << "Write data failed! ret = " << ret << std::endl; break; } diff --git a/Src/Extern/HDF5/AMReX_WriteBinaryParticleDataHDF5.H b/Src/Extern/HDF5/AMReX_WriteBinaryParticleDataHDF5.H index d3869ad2453..e808e01e33e 100644 --- a/Src/Extern/HDF5/AMReX_WriteBinaryParticleDataHDF5.H +++ b/Src/Extern/HDF5/AMReX_WriteBinaryParticleDataHDF5.H @@ -147,7 +147,7 @@ void WriteHDF5ParticleDataSync (PC const& pc, #endif std::string pdir = dir; - if ( ! pdir.empty() && pdir[pdir.size()-1] != '/') pdir += '/'; + if ( ! pdir.empty() && pdir[pdir.size()-1] != '/') { pdir += '/'; } pdir += name; if ( ! pc.GetLevelDirectoriesCreated()) { @@ -250,7 +250,7 @@ void WriteHDF5ParticleDataSync (PC const& pc, } fid = H5Fcreate(HDF5FileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fid < 0) amrex::FileOpenFailed(HDF5FileName.c_str()); + if (fid < 0) { amrex::FileOpenFailed(HDF5FileName.c_str()); } // // First thing written is our Checkpoint/Restart version string. @@ -259,20 +259,23 @@ void WriteHDF5ParticleDataSync (PC const& pc, // particles so that we can Restart from the checkpoint files. // std::string versionName = is_checkpoint ? PC::CheckpointVersion() : PC::PlotfileVersion(); - if (sizeof(typename PC::ParticleType::RealType) == 4) + if (sizeof(typename PC::ParticleType::RealType) == 4) { versionName += "_single"; - else + } else { versionName += "_double"; + } CreateWriteHDF5AttrString(fid, "version_name", versionName.c_str()); int num_output_real = 0; - for (int i = 0; i < pc.NumRealComps() + NStructReal; ++i) - if (write_real_comp[i]) ++num_output_real; + for (int i = 0; i < pc.NumRealComps() + NStructReal; ++i) { + if (write_real_comp[i]) { ++num_output_real; } + } int num_output_int = 0; - for (int i = 0; i < pc.NumIntComps() + NStructInt; ++i) - if (write_int_comp[i]) ++num_output_int; + for (int i = 0; i < pc.NumIntComps() + NStructInt; ++i) { + if (write_int_comp[i]) { ++num_output_int; } + } // AMREX_SPACEDIM and N for sanity checking. int ndim = AMREX_SPACEDIM; @@ -392,8 +395,9 @@ void WriteHDF5ParticleDataSync (PC const& pc, #else fid = H5Fopen(HDF5FileName.c_str(), H5F_ACC_RDWR, fapl); #endif - if (fid < 0) + if (fid < 0) { FileOpenFailed(HDF5FileName.c_str()); + } char level_name[64]; for (int lev = 0; lev <= pc.finestLevel(); lev++) @@ -406,10 +410,11 @@ void WriteHDF5ParticleDataSync (PC const& pc, #endif bool gotsome; - if(pc.usePrePost) + if(pc.usePrePost) { gotsome = (pc.nParticlesAtLevelPrePost[lev] > 0); - else + } else { gotsome = (pc.NumberOfParticlesAtLevel(lev) > 0); + } MFInfo info; info.SetAlloc(false); @@ -423,8 +428,9 @@ void WriteHDF5ParticleDataSync (PC const& pc, Vector count(state.size(),0); Vector where(state.size(),0); - if(pc.usePrePost) + if(pc.usePrePost) { pc.filePrefixPrePost[lev] = HDF5FileName; + } if (gotsome) { diff --git a/Src/Extern/HYPRE/AMReX_HypreIJIface.cpp b/Src/Extern/HYPRE/AMReX_HypreIJIface.cpp index aaf1ecea689..0466343d7db 100644 --- a/Src/Extern/HYPRE/AMReX_HypreIJIface.cpp +++ b/Src/Extern/HYPRE/AMReX_HypreIJIface.cpp @@ -102,9 +102,10 @@ void HypreIJIface::run_hypre_setup () { if (m_need_setup || m_recompute_preconditioner) { BL_PROFILE("HypreIJIface::run_hypre_setup()"); - if (m_has_preconditioner) + if (m_has_preconditioner) { m_solverPrecondPtr( m_solver, m_precondSolvePtr, m_precondSetupPtr, m_precond); + } m_solverSetupPtr(m_solver, m_parA, m_parRhs, m_parSln); m_need_setup = false; @@ -137,8 +138,9 @@ void HypreIJIface::solve ( m_solverSetTolPtr(m_solver, rel_tol); m_solverSetMaxIterPtr(m_solver, max_iter); - if ((abs_tol > 0.0) && (m_solverSetAbsTolPtr != nullptr)) + if ((abs_tol > 0.0) && (m_solverSetAbsTolPtr != nullptr)) { m_solverSetAbsTolPtr(m_solver, abs_tol); + } // setup run_hypre_setup(); @@ -156,14 +158,15 @@ void HypreIJIface::solve ( HYPRE_IJVectorPrint(m_sln, slnfile.c_str()); // Increment counter if the user has requested output of multiple solves - if (!m_overwrite_files) ++m_write_counter; + if (!m_overwrite_files) { ++m_write_counter; } } - if (m_verbose > 1) + if (m_verbose > 1) { amrex::Print() << "HYPRE " << m_solver_name << ": Num. iterations = " << m_num_iterations << "; Relative residual = " << m_final_res_norm << std::endl; + } } void HypreIJIface::parse_inputs (const std::string& prefix) @@ -177,10 +180,11 @@ void HypreIJIface::parse_inputs (const std::string& prefix) pp.queryAdd("overwrite_existing_matrix_files", m_overwrite_files); pp.queryAdd("adjust_singular_matrix", m_adjust_singular_matrix); - if (m_verbose > 2) + if (m_verbose > 2) { amrex::Print() << "HYPRE: solver = " << m_solver_name << "; preconditioner = " << m_preconditioner_name << std::endl; + } if (m_preconditioner_name == "none") { m_has_preconditioner = false; @@ -230,8 +234,9 @@ void HypreIJIface::init_solver ( void HypreIJIface::boomeramg_precond_configure (const std::string& prefix) { - if (m_verbose > 2) + if (m_verbose > 2) { amrex::Print() << "Creating BoomerAMG preconditioner" << std::endl; + } HYPRE_BoomerAMGCreate(&m_precond); // Setup the pointers @@ -291,14 +296,16 @@ void HypreIJIface::boomeramg_precond_configure (const std::string& prefix) hpp.pp.getarr("bamg_non_galerkin_level_levels", levels); hpp.pp.getarr("bamg_non_galerkin_level_tols", tols); - if (levels.size() != tols.size()) + if (levels.size() != tols.size()) { amrex::Abort( "HypreIJIface: Invalid sizes for non-Galerkin level " "tolerances"); + } - for (size_t i = 0; i < levels.size(); ++i) + for (size_t i = 0; i < levels.size(); ++i) { HYPRE_BoomerAMGSetLevelNonGalerkinTol( m_precond, tols[i], levels[i]); + } } } @@ -418,14 +425,16 @@ void HypreIJIface::boomeramg_solver_configure (const std::string& prefix) bool use_old_default = true; hpp.pp.queryAdd("bamg_use_old_default", use_old_default); - if (use_old_default) + if (use_old_default) { HYPRE_BoomerAMGSetOldDefault(m_solver); + } } void HypreIJIface::gmres_solver_configure (const std::string& prefix) { - if (m_verbose > 2) + if (m_verbose > 2) { amrex::Print() << "Creating GMRES solver" << std::endl; + } HYPRE_ParCSRGMRESCreate(m_comm, &m_solver); // Setup pointers diff --git a/Src/Extern/PETSc/AMReX_PETSc.cpp b/Src/Extern/PETSc/AMReX_PETSc.cpp index 5b6f82cec85..6d6835e6808 100644 --- a/Src/Extern/PETSc/AMReX_PETSc.cpp +++ b/Src/Extern/PETSc/AMReX_PETSc.cpp @@ -20,7 +20,7 @@ namespace amrex { struct amrex_KSP { amrex_KSP () = default; - ~amrex_KSP () { if (a) KSPDestroy(&a); } + ~amrex_KSP () { if (a) { KSPDestroy(&a); } } amrex_KSP (amrex_KSP const&) = delete; amrex_KSP (amrex_KSP &&) = delete; amrex_KSP& operator= (amrex_KSP const&) = delete; @@ -31,7 +31,7 @@ struct amrex_KSP struct amrex_Mat { amrex_Mat () = default; - ~amrex_Mat () { if (a) MatDestroy(&a); } + ~amrex_Mat () { if (a) { MatDestroy(&a); } } amrex_Mat (amrex_Mat const&) = delete; amrex_Mat (amrex_Mat &&) = delete; amrex_Mat& operator= (amrex_Mat const&) = delete; @@ -42,7 +42,7 @@ struct amrex_Mat struct amrex_Vec { amrex_Vec () = default; - ~amrex_Vec () { if (a) VecDestroy(&a); } + ~amrex_Vec () { if (a) { VecDestroy(&a); } } amrex_Vec (amrex_Vec const&) = delete; amrex_Vec (amrex_Vec &&) = delete; amrex_Vec& operator= (amrex_Vec const&) = delete; diff --git a/Src/Extern/ProfParser/AMReX_ProfParserBatch.cpp b/Src/Extern/ProfParser/AMReX_ProfParserBatch.cpp index 4c0e5e25413..388b2366a2f 100644 --- a/Src/Extern/ProfParser/AMReX_ProfParserBatch.cpp +++ b/Src/Extern/ProfParser/AMReX_ProfParserBatch.cpp @@ -106,23 +106,23 @@ bool ProfParserBatchFunctions(int argc, char *argv[], bool runDefault, if(argc > 2) { // parse the command line int ia(1); while(ia < argc-1) { - if(bIOP) cout << "argv[" << ia << "] = " << argv[ia] << endl; + if(bIOP) { std::cout << "argv[" << ia << "] = " << argv[ia] << endl; } if(strcmp(argv[ia], "-v") == 0) { if(ia < argc-2) { verbose = atoi(argv[ia+1]); } - if(bIOP) cout << "*** verbose = " << verbose << endl; + if(bIOP) { std::cout << "*** verbose = " << verbose << endl; } ++ia; } else if(strcmp(argv[ia], "-ws") == 0) { bWriteSummary = true; } else if(strcmp(argv[ia], "-check") == 0) { // ---- commprof options - if(bIOP) cout << "*** data integrity check." << endl; + if(bIOP) { std::cout << "*** data integrity check." << endl; } runCheck = true; } else if(strcmp(argv[ia], "-stats") == 0) { - if(bIOP) cout << "*** print database statistics." << endl; + if(bIOP) { std::cout << "*** print database statistics." << endl; } runStats = true; } else if(strcmp(argv[ia], "-timelinepf") == 0) { - if(bIOP) cout << "*** output a timeline plotfile." << endl; + if(bIOP) { std::cout << "*** output a timeline plotfile." << endl; } runTimelinePF = true; runStats = true; } else if(strcmp(argv[ia], "-actpf") == 0) { @@ -134,59 +134,59 @@ bool ProfParserBatchFunctions(int argc, char *argv[], bool runDefault, << actFNames[actFNames.size() - 1] << endl; ++ia; } else if(strcmp(argv[ia], "-sr") == 0) { - if(bIOP) cout << "*** send receive pairing." << endl; + if(bIOP) { std::cout << "*** send receive pairing." << endl; } runSendRecv = true; } else if(strcmp(argv[ia], "-srlist") == 0) { - if(bIOP) cout << "*** send receive pairing list." << endl; + if(bIOP) { std::cout << "*** send receive pairing list." << endl; } runSendRecvList = true; } else if(strcmp(argv[ia], "-sendspf") == 0) { - if(bIOP) cout << "*** sendspf." << endl; + if(bIOP) { std::cout << "*** sendspf." << endl; } runSendsPF = true; } else if(strcmp(argv[ia], "-gl") == 0) { - if(bIOP) cout << "*** grdlog." << endl; + if(bIOP) { std::cout << "*** grdlog." << endl; } glOnly = true; } else if(strcmp(argv[ia], "-tce") == 0) { - if(bIOP) cout << "*** topolcoords for edison." << endl; + if(bIOP) { std::cout << "*** topolcoords for edison." << endl; } tcEdisonOnly = true; } else if(strcmp(argv[ia], "-spd") == 0) { - if(bIOP) cout << "*** sync point data." << endl; + if(bIOP) { std::cout << "*** sync point data." << endl; } runSyncPointData = true; } else if(strcmp(argv[ia], "-redist") == 0) { - if(bIOP) cout << "*** redist." << endl; + if(bIOP) { std::cout << "*** redist." << endl; } runRedist = true; } else if(strcmp(argv[ia], "-msil") == 0) { if(ia < argc-2) { maxSmallImageLength = atoi(argv[ia+1]); } - if(bIOP) cout << "*** msil = " << maxSmallImageLength << endl; + if(bIOP) { std::cout << "*** msil = " << maxSmallImageLength << endl; } ++ia; } else if(strcmp(argv[ia], "-rra") == 0) { if(ia < argc-2) { refRatioAll = atoi(argv[ia+1]); } - if(bIOP) cout << "*** rra = " << refRatioAll << endl; + if(bIOP) { std::cout << "*** rra = " << refRatioAll << endl; } ++ia; } else if(strcmp(argv[ia], "-nts") == 0) { if(ia < argc-2) { nTimeSlots = atoi(argv[ia+1]); } - if(bIOP) cout << "*** nts = " << nTimeSlots << endl; + if(bIOP) { std::cout << "*** nts = " << nTimeSlots << endl; } ++ia; } else if(strcmp(argv[ia], "-proc") == 0) { if(ia < argc-2) { whichProc = atoi(argv[ia+1]); } - if(bIOP) cout << "*** whichProc = " << whichProc << endl; + if(bIOP) { std::cout << "*** whichProc = " << whichProc << endl; } ++ia; } else if(strcmp(argv[ia], "-of") == 0) { if(ia < argc-2) { outfileName = argv[ia+1]; filenameSet = true; } - if(bIOP) cout << "*** outfileName = " << outfileName << endl; + if(bIOP) { std::cout << "*** outfileName = " << outfileName << endl; } ++ia; } else if(strcmp(argv[ia], "-proxmap") == 0) { - if(bIOP) cout << "*** proxmap." << endl; + if(bIOP) { std::cout << "*** proxmap." << endl; } proxMap = true; } else if(strcmp(argv[ia], "-mff") == 0) { // ---- region and trace options @@ -210,9 +210,9 @@ bool ProfParserBatchFunctions(int argc, char *argv[], bool runDefault, Real gpct(atof(argv[ia+1])); if(gpct >= 0.0 && gpct <= 100.0) { RegionsProfStats::SetGPercent(gpct); - if(bIOP) cout << "*** gpct = " << gpct << endl; + if(bIOP) { std::cout << "*** gpct = " << gpct << endl; } } else { - if(bIOP) cout << "*** gpct must be in range [0.0, 100.0]" << endl; + if(bIOP) { std::cout << "*** gpct must be in range [0.0, 100.0]" << endl; } } } ++ia; @@ -221,10 +221,10 @@ bool ProfParserBatchFunctions(int argc, char *argv[], bool runDefault, } else if(strcmp(argv[ia], "-prof") == 0) { bParserProf = true; } else if(strcmp(argv[ia], "-dispatch") == 0) { - if(bIOP) cout << "*** using dispatch interface." << endl; + if(bIOP) { std::cout << "*** using dispatch interface." << endl; } bUseDispatch = true; } else { - if(bIOP) cerr << "*** Error: bad command line arg: " << argv[ia] << endl; + if(bIOP) { std::cerr << "*** Error: bad command line arg: " << argv[ia] << endl; } } ++ia; } diff --git a/Src/Extern/SUNDIALS/AMReX_NVector_MultiFab.cpp b/Src/Extern/SUNDIALS/AMReX_NVector_MultiFab.cpp index 1674a83343a..8408f75c41d 100644 --- a/Src/Extern/SUNDIALS/AMReX_NVector_MultiFab.cpp +++ b/Src/Extern/SUNDIALS/AMReX_NVector_MultiFab.cpp @@ -29,7 +29,7 @@ N_Vector N_VNewEmpty_MultiFab(sunindextype length, ::sundials::Context* sunctx) { /* Create vector */ N_Vector v = N_VNewEmpty(*sunctx); - if (v == nullptr) return(nullptr); + if (v == nullptr) { return(nullptr); } v->ops->nvclone = N_VClone_MultiFab; v->ops->nvcloneempty = N_VCloneEmpty_MultiFab; @@ -85,7 +85,7 @@ N_Vector N_VNew_MultiFab(sunindextype length, ::sundials::Context* sunctx) { N_Vector v = N_VNewEmpty_MultiFab(length, sunctx); - if (v == nullptr) return(nullptr); + if (v == nullptr) { return(nullptr); } // Create and attach new MultiFab if (length > 0) @@ -107,7 +107,7 @@ N_Vector N_VMake_MultiFab(sunindextype length, amrex::MultiFab *v_mf, ::sundials::Context* sunctx) { N_Vector v = N_VNewEmpty_MultiFab(length, sunctx); - if (v == nullptr) return(nullptr); + if (v == nullptr) { return(nullptr); } if (length > 0) { @@ -157,11 +157,11 @@ int N_VGetOwnMF_MultiFab(N_Vector v) N_Vector N_VCloneEmpty_MultiFab(N_Vector w) { - if (w == nullptr) return(nullptr); + if (w == nullptr) { return(nullptr); } /* Create vector and copy operations */ N_Vector v = N_VNewEmpty(w->sunctx); - if (v == nullptr) return(nullptr); + if (v == nullptr) { return(nullptr); } N_VCopyOps(w, v); /* Create content */ @@ -182,7 +182,7 @@ N_Vector N_VCloneEmpty_MultiFab(N_Vector w) N_Vector N_VClone_MultiFab(N_Vector w) { N_Vector v = N_VCloneEmpty_MultiFab(w); - if (v == nullptr) return(nullptr); + if (v == nullptr) { return(nullptr); } sunindextype length = amrex::sundials::N_VGetLength_MultiFab(w); diff --git a/Src/Extern/SUNDIALS/AMReX_SUNMemory.cpp b/Src/Extern/SUNDIALS/AMReX_SUNMemory.cpp index 043c44b0634..285cdb2f17b 100644 --- a/Src/Extern/SUNDIALS/AMReX_SUNMemory.cpp +++ b/Src/Extern/SUNDIALS/AMReX_SUNMemory.cpp @@ -37,7 +37,7 @@ namespace { { SUNMemory mem = SUNMemoryNewEmpty(); - if (mem == nullptr) return -1; + if (mem == nullptr) { return -1; } mem->ptr = nullptr; mem->own = SUNTRUE; mem->type = mem_type; @@ -48,7 +48,7 @@ namespace { return 0; } else { - free(mem); + std::free(mem); memptr = nullptr; return -1; } @@ -59,22 +59,22 @@ namespace { int Dealloc(SUNMemoryHelper, SUNMemory mem, void* /*queue*/) { - if (mem == nullptr) return 0; + if (mem == nullptr) { return 0; } auto* arena = getArena(mem->type); if (arena) { if(mem->own) { arena->free(mem->ptr); - free(mem); + std::free(mem); return 0; } } else { - free(mem); + std::free(mem); return -1; } - free(mem); + std::free(mem); return 0; } @@ -93,8 +93,8 @@ namespace { void ActuallyDestroySUNMemoryHelper(SUNMemoryHelper helper) { - if (helper->ops) free(helper->ops); - free(helper); + if (helper->ops) { std::free(helper->ops); } + std::free(helper); } SUNMemoryHelper CreateMemoryHelper(::sundials::Context* sunctx) @@ -173,7 +173,7 @@ void MemoryHelper::Initialize(int nthreads) std::fill(the_sunmemory_helper.begin(), the_sunmemory_helper.end(), nullptr); } for (int i = 0; i < nthreads; i++) { - if (initialized[i]) continue; + if (initialized[i]) { continue; } initialized[i] = 1; BL_ASSERT(the_sunmemory_helper[i] == nullptr); the_sunmemory_helper[i] = new MemoryHelper(The_Sundials_Context(i)); diff --git a/Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H b/Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H index 8981cfed3c4..85e4cab9220 100644 --- a/Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H +++ b/Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H @@ -493,17 +493,19 @@ public: if(use_mri_strategy_test) { - if(use_erk3) + if(use_erk3) { inner_mem = ARKStepCreate(SundialsUserFun::f0, nullptr, time, nv_S, sunctx); // explicit bc (explicit f, implicit f, time, data) - else + } else { inner_mem = ARKStepCreate(nullptr, SundialsUserFun::f0, time, nv_S, sunctx); // implicit + } } else { - if(use_erk3) + if(use_erk3) { inner_mem = ARKStepCreate(SundialsUserFun::f_fast, nullptr, time, nv_S, sunctx); - else + } else { inner_mem = ARKStepCreate(nullptr, SundialsUserFun::f_fast, time, nv_S, sunctx); + } } ARKStepSetFixedStep(inner_mem, hfixed_mri); // Specify fixed time step size @@ -549,8 +551,9 @@ public: B->b[0] = 1.0; B->q=1; B->p=0; - } else + } else { amrex::Error("MRI method not implemented"); + } return B; }; @@ -592,11 +595,12 @@ public: LS = SUNLinSol_SPGMR(nv_S, PREC_NONE, 10, sunctx); NLS = SUNNonlinSol_FixedPoint(nv_S, 50, sunctx); - if (use_implicit_inner) ARKStepSetNonlinearSolver(inner_mem, NLS); - if(use_linear) + if (use_implicit_inner) { ARKStepSetNonlinearSolver(inner_mem, NLS); } + if(use_linear) { MRIStepSetLinearSolver(mristep_mem, LS, nullptr); - else + } else { MRIStepSetNonlinearSolver(mristep_mem, NLS); + } MRIStepSetUserData(mristep_mem, &udata); /* Pass udata to user functions */ MRIStepSetPostprocessStageFn(mristep_mem, SundialsUserFun::ProcessStage); diff --git a/Src/Extern/SUNDIALS/AMReX_Sundials_Core.cpp b/Src/Extern/SUNDIALS/AMReX_Sundials_Core.cpp index 80a3a33b18d..286662058a3 100644 --- a/Src/Extern/SUNDIALS/AMReX_Sundials_Core.cpp +++ b/Src/Extern/SUNDIALS/AMReX_Sundials_Core.cpp @@ -22,7 +22,7 @@ void Initialize(int nthreads) std::fill(the_sundials_context.begin(), the_sundials_context.end(), nullptr); } for (int i = 0; i < nthreads; i++) { - if (initialized[i]) continue; + if (initialized[i]) { continue; } initialized[i] = 1; BL_ASSERT(the_sundials_context[i] == nullptr); the_sundials_context[i] = new ::sundials::Context();