Skip to content
2 changes: 0 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Checks: >
-modernize-return-braced-init-list,
-modernize-use-constraints,
-modernize-use-designated-initializers,
-modernize-use-integer-sign-comparison,
-modernize-use-ranges,
-modernize-use-starts-ends-with,
-modernize-use-std-numbers,
Expand Down Expand Up @@ -83,6 +82,5 @@ HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx']
# -modernize-use-designated-initializers
# -modernize-use-std-numbers
# -modernize-use-ranges
# -modernize-use-integer-sign-comparison
# -modernize-use-starts-ends-with
# -readability-container-contains
23 changes: 12 additions & 11 deletions Src/Amr/AMReX_AmrLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif

#include <sstream>
#include <iterator>
#include <memory>
#include <limits>

Expand Down Expand Up @@ -108,7 +109,7 @@ AmrLevel::AmrLevel (Amr& papa,
}

// Note that this creates a distribution map associated with grids.
for (int i = 0; i < state.size(); i++)
for (int i = 0; i < std::ssize(state); i++)
{
MultiFab::RegionTag statedata_tag("StateData_Level_" + std::to_string(lev));
MultiFab::RegionTag statedata_index_tag("StateData_" + std::to_string(i) + "_Level_" + std::to_string(lev));
Expand Down Expand Up @@ -143,7 +144,7 @@ AmrLevel::writePlotFile (const std::string& dir,
// second component of pair is component # within the state_type
//
std::vector<std::pair<int,int> > plot_var_map;
for (int typ = 0; typ < desc_lst.size(); typ++)
for (int typ = 0; typ < std::ssize(desc_lst); typ++)
{
for (int comp = 0; comp < desc_lst[typ].nComp();comp++)
{
Expand Down Expand Up @@ -197,7 +198,7 @@ AmrLevel::writePlotFile (const std::string& dir,
//
// Names of variables
//
for (i =0; i < static_cast<int>(plot_var_map.size()); i++)
for (i =0; i < std::ssize(plot_var_map); i++)
{
int typ = plot_var_map[i].first;
int comp = plot_var_map[i].second;
Expand Down Expand Up @@ -286,7 +287,7 @@ AmrLevel::writePlotFile (const std::string& dir,
os << level << ' ' << grids.size() << ' ' << cur_time << '\n';
os << parent->levelSteps(level) << '\n';

for (i = 0; i < grids.size(); ++i)
for (i = 0; i < std::ssize(grids); ++i)
{
RealBox gridloc = RealBox(grids[i],geom.CellSize(),geom.ProbLo());
for (n = 0; n < AMREX_SPACEDIM; n++) {
Expand Down Expand Up @@ -326,7 +327,7 @@ AmrLevel::writePlotFile (const std::string& dir,
//
// Cull data from state variables -- use no ghost cells.
//
for (i = 0; i < static_cast<int>(plot_var_map.size()); i++)
for (i = 0; i < std::ssize(plot_var_map); i++)
{
int typ = plot_var_map[i].first;
int comp = plot_var_map[i].second;
Expand Down Expand Up @@ -477,7 +478,7 @@ AmrLevel::setTimeLevel (Real time,
Real dt_old,
Real dt_new)
{
for (int k = 0; k < desc_lst.size(); k++)
for (int k = 0; k < std::ssize(desc_lst); k++)
{
state[k].setTimeLevel(time,dt_old,dt_new);
}
Expand All @@ -486,7 +487,7 @@ AmrLevel::setTimeLevel (Real time,
bool
AmrLevel::isStateVariable (const std::string& name, int& state_indx, int& n)
{
for (state_indx = 0; state_indx < desc_lst.size(); state_indx++)
for (state_indx = 0; state_indx < std::ssize(desc_lst); state_indx++)
{
const StateDescriptor& desc = desc_lst[state_indx];

Expand Down Expand Up @@ -577,7 +578,7 @@ AmrLevel::~AmrLevel ()
void
AmrLevel::allocOldData ()
{
for (int i = 0; i < desc_lst.size(); i++)
for (int i = 0; i < std::ssize(desc_lst); i++)
{
state[i].allocOldData();
}
Expand All @@ -586,7 +587,7 @@ AmrLevel::allocOldData ()
void
AmrLevel::removeOldData ()
{
for (int i = 0; i < desc_lst.size(); i++)
for (int i = 0; i < std::ssize(desc_lst); i++)
{
state[i].removeOldData();
}
Expand All @@ -595,7 +596,7 @@ AmrLevel::removeOldData ()
void
AmrLevel::reset ()
{
for (int i = 0; i < desc_lst.size(); i++)
for (int i = 0; i < std::ssize(desc_lst); i++)
{
state[i].reset();
}
Expand Down Expand Up @@ -1013,7 +1014,7 @@ FillPatchIterator::Initialize (int boxGrow,
const IndexType& boxType = m_leveldata->boxArray().ixType();
const int level = m_amrlevel->level;

for (int i = 0, DComp = 0; i < static_cast<int>(m_range.size()); i++)
for (int i = 0, DComp = 0; i < std::ssize(m_range); i++)
{
const int SComp = m_range[i].first;
const int NComp = m_range[i].second;
Expand Down
4 changes: 3 additions & 1 deletion Src/Base/AMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#include <AMReX_MemProfiler.H>
#endif

#include <iterator>

#ifdef AMREX_USE_OMP
#include <AMReX_OpenMP.H>
#include <omp.h>
Expand Down Expand Up @@ -979,7 +981,7 @@ amrex::command_argument_count ()
std::string
amrex::get_command_argument (int number)
{
if (number < static_cast<int>(command_arguments.size())) {
if (number < std::ssize(command_arguments)) {
return command_arguments[number];
} else {
return std::string();
Expand Down
24 changes: 13 additions & 11 deletions Src/Base/AMReX_DistributionMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <string>
#include <cstring>
#include <iomanip>
#include <iterator>
#include <utility>

namespace {
int flag_verbose_mapper;
Expand Down Expand Up @@ -177,7 +179,7 @@ void
DistributionMapping::Sort (std::vector<LIpair>& vec,
bool reverse)
{
if (vec.size() > 1)
if (std::ssize(vec) > 1)
{
if (reverse) {
std::stable_sort(vec.begin(), vec.end(), LIpairGT());
Expand Down Expand Up @@ -766,7 +768,7 @@ DistributionMapping::KnapSackDoIt (const std::vector<Long>& wgts,
}
}

BL_ASSERT(static_cast<int>(vec.size()) == nteams);
BL_ASSERT(std::ssize(vec) == nteams);

std::vector<LIpair> LIpairV;

Expand Down Expand Up @@ -864,7 +866,7 @@ DistributionMapping::KnapSackProcessorMap (const std::vector<Long>& wgts,
m_ref->clear();
m_ref->m_pmap.resize(wgts.size());

if (static_cast<int>(wgts.size()) <= nprocs || nprocs < 2)
if (std::ssize(wgts) <= nprocs || nprocs < 2)
{
RoundRobinProcessorMap(static_cast<int>(wgts.size()),nprocs, sort);

Expand Down Expand Up @@ -894,7 +896,7 @@ DistributionMapping::KnapSackProcessorMap (const DistributionMapping& olddm,

ComputeDistributionMappingEfficiency(olddm, wgts, &old_efficiency);

if (static_cast<int>(wgts.size()) <= nprocs || nprocs < 2)
if (std::ssize(wgts) <= nprocs || nprocs < 2)
{
RoundRobinProcessorMap(static_cast<int>(wgts.size()),nprocs, false);
new_efficiency = Real(1);
Expand Down Expand Up @@ -927,7 +929,7 @@ DistributionMapping::KnapSackProcessorMap (const DistributionMapping& olddm,
w += wi;
}
}
if (i < static_cast<int>(kb.size())) {
if (i < std::ssize(kb)) {
lb.insert(lb.end(), kb.begin()+i, kb.end());
kb.erase ( kb.begin()+i, kb.end());
}
Expand Down Expand Up @@ -990,7 +992,7 @@ DistributionMapping::KnapSackProcessorMap (const DistributionMapping& olddm,
AMREX_ASSERT(max_weight > Real(0));
new_efficiency = avg_weight / max_weight;

if (new_efficiency < max_efficiency && wblv.size() > 1) {
if (new_efficiency < max_efficiency && std::ssize(wblv) > 1) {
BL_PROFILE("knapsack()swap");

std::sort(wblv.begin(), wblv.end());
Expand Down Expand Up @@ -1207,7 +1209,7 @@ Distribute (const std::vector<SFCToken>& tokens,
}
}

BL_ASSERT(static_cast<int>(v.size()) == nprocs);
BL_ASSERT(std::ssize(v) == nprocs);

int K = 0;
Real totalvol = 0;
Expand Down Expand Up @@ -1502,7 +1504,7 @@ DistributionMapping::SFCProcessorMap (const BoxArray& boxes,
bool sort)
{
BL_ASSERT( ! boxes.empty());
BL_ASSERT(boxes.size() == static_cast<int>(wgts.size()));
BL_ASSERT(boxes.size() == std::ssize(wgts));

m_ref->clear();
m_ref->m_pmap.resize(wgts.size());
Expand All @@ -1525,7 +1527,7 @@ DistributionMapping::SFCProcessorMap (const BoxArray& boxes,
bool sort)
{
BL_ASSERT( ! boxes.empty());
BL_ASSERT(boxes.size() == static_cast<int>(wgts.size()));
BL_ASSERT(boxes.size() == std::ssize(wgts));

m_ref->clear();
m_ref->m_pmap.resize(wgts.size());
Expand Down Expand Up @@ -1948,7 +1950,7 @@ operator<< (std::ostream& os,
{
os << "(DistributionMapping" << '\n';

for (int i = 0; i < pmap.ProcessorMap().size(); ++i)
for (int i = 0; i < std::ssize(pmap.ProcessorMap()); ++i)
{
os << "m_pmap[" << i << "] = " << pmap.ProcessorMap()[i] << '\n';
}
Expand Down Expand Up @@ -2018,7 +2020,7 @@ DistributionMapping MakeSimilarDM (const BoxArray& ba, const BoxArray& src_ba,
"input BoxArrays must have the same centering.");

Vector<int> pmap(ba.size());
for (int i = 0; i < static_cast<int>(ba.size()); ++i) {
for (int i = 0; i < std::ssize(ba); ++i) {
Box box = ba[i];
box.grow(ng);
bool first_only = false;
Expand Down
9 changes: 5 additions & 4 deletions Src/Base/AMReX_FabArray.H
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include <algorithm>
#include <cstring>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
Expand Down Expand Up @@ -1755,7 +1756,7 @@ bool
FabArray<FAB>::defined (int K) const noexcept
{
int li = localindex(K);
if (li >= 0 && li < static_cast<int>(m_fabs_v.size()) && m_fabs_v[li] != 0) {
if (li >= 0 && li < std::ssize(m_fabs_v) && m_fabs_v[li] != 0) {
return true;
}
else {
Expand All @@ -1768,7 +1769,7 @@ bool
FabArray<FAB>::defined (const MFIter& mfi) const noexcept
{
int li = mfi.LocalIndex();
if (li < static_cast<int>(m_fabs_v.size()) && m_fabs_v[li] != nullptr) {
if (li < std::ssize(m_fabs_v) && m_fabs_v[li] != nullptr) {
return true;
}
else {
Expand Down Expand Up @@ -1874,7 +1875,7 @@ FAB*
FabArray<FAB>::release (int K)
{
const int li = localindex(K);
if (li >= 0 && li < static_cast<int>(m_fabs_v.size()) && m_fabs_v[li] != nullptr) {
if (li >= 0 && li < std::ssize(m_fabs_v) && m_fabs_v[li] != nullptr) {
AMREX_ASSERT(m_single_chunk_arena == nullptr);
Long nbytes = amrex::nBytesOwned(*m_fabs_v[li]);
if (nbytes > 0) {
Expand All @@ -1894,7 +1895,7 @@ FAB*
FabArray<FAB>::release (const MFIter& mfi)
{
const int li = mfi.LocalIndex();
if (li >= 0 && li < static_cast<int>(m_fabs_v.size()) && m_fabs_v[li] != nullptr) {
if (li >= 0 && li < std::ssize(m_fabs_v) && m_fabs_v[li] != nullptr) {
AMREX_ASSERT(m_single_chunk_arena == nullptr);
Long nbytes = amrex::nBytesOwned(*m_fabs_v[li]);
if (nbytes > 0) {
Expand Down
7 changes: 4 additions & 3 deletions Src/Base/AMReX_GpuDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
#endif

#include <iostream>
#include <map>
#include <algorithm>
#include <exception>
#include <iterator>
#include <map>
#include <string>
#include <unordered_set>
#include <exception>

#if defined(AMREX_USE_CUDA)
#include <cuda_profiler_api.h>
Expand Down Expand Up @@ -758,7 +759,7 @@ Device::setStream (gpuStream_t s) noexcept
}
}
int const idx = streamIndex(s);
if (idx == static_cast<int>(gpu_stream_pool.size())) {
if (idx == std::ssize(gpu_stream_pool)) {
amrex::Abort("Gpu::Device::setStream: stream is not managed by AMReX.");
}
gpu_stream_index[tid] = idx;
Expand Down
5 changes: 3 additions & 2 deletions Src/Base/AMReX_NFiles.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <AMReX_NFiles.H>
#include <deque>
#include <iterator>
#include <set>
#include <utility>

Expand Down Expand Up @@ -504,7 +505,7 @@ bool NFilesIter::CheckNFiles(int nProcs, int nOutFiles, bool groupSets)
}
// amrex::Print() << "nOutFiles fileNumbers.size() = " << nOutFiles
// << " " << fileNumbers.size() << '\n';
if(nOutFiles != static_cast<int>(fileNumbers.size())) {
if(nOutFiles != std::ssize(fileNumbers)) {
// amrex::Print() << "**** Different number of files." << '\n';
return false;
}
Expand All @@ -529,7 +530,7 @@ Vector<int> NFilesIter::FileNumbersWritten()
procSet.insert(fileNumbersWriteOrder[f][r]);
}
}
if(total != nProcs || static_cast<int>(procSet.size()) != nProcs) {
if(total != nProcs || std::ssize(procSet) != nProcs) {
amrex::AllPrint() << "**** Error in NFilesIter::FileNumbersWritten(): "
<< " coordinatorProc nProcs total procSet.size() = "
<< coordinatorProc << " " << nProcs << " "
Expand Down
9 changes: 5 additions & 4 deletions Src/Base/AMReX_ParmParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <unordered_map>
Expand Down Expand Up @@ -903,7 +904,7 @@ void pp_entry_set_last_val (ParmParse::PP_entry const& entry, int ival, T ref, b
#pragma omp single nowait
#endif
{
if (ival >= int(entry.m_last_vals.size())) {
if (ival >= std::ssize(entry.m_last_vals)) {
entry.m_last_vals.resize(ival+1);
}
entry.m_last_vals[ival] = ref;
Expand Down Expand Up @@ -1082,7 +1083,7 @@ squeryval (const ParmParse::Table& table,
if (!(def->empty()) && is_toml_1d_array((*def)[0])) {
std::vector<T> toml_vals;
read_array_1d(toml_vals, (*def)[0]);
if (ival >= static_cast<int>(toml_vals.size())) {
if (ival >= std::ssize(toml_vals)) {
amrex::ErrorStream() << "ParmParse::queryval no value number "
<< ival << " for ";
if ( occurrence == ParmParse::LAST ) {
Expand Down Expand Up @@ -1265,7 +1266,7 @@ squeryarr (const ParmParse::Table& table,
std::is_same_v<T,double>);

int stop_ix = start_ix + num_val - 1;
if ( static_cast<int>(ref.size()) <= stop_ix )
if ( std::ssize(ref) <= stop_ix )
{
ref.resize(stop_ix + 1);
}
Expand Down Expand Up @@ -2833,7 +2834,7 @@ bool squeryarrWithParser (const ParmParse::Table& table,

auto const& entry = table.at(name);

AMREX_ALWAYS_ASSERT(int(vals.size()) == nvals);
AMREX_ALWAYS_ASSERT(std::ssize(vals) == nvals);
for (int ival = 0; ival < nvals; ++ival) {
bool r = pp_parser(table, parser_prefix, name, vals[ival], ptr[ival], true);
if (r) {
Expand Down
Loading
Loading