Skip to content

Commit

Permalink
address clang-tidy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lucafedeli88 committed Sep 17, 2024
1 parent fc9cc97 commit 75187c7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
18 changes: 9 additions & 9 deletions Source/ablastr/fields/MultiFabRegister.H
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ namespace ablastr::fields
*/
void
alloc_like (
std::string other_name,
const std::string& other_name,
int other_level
);

Expand Down Expand Up @@ -361,12 +361,12 @@ namespace ablastr::fields
*/
MultiLevelScalarField
get_mr_levels (
std::string name,
const std::string& name,
int finest_level
);
[[nodiscard]] ConstMultiLevelScalarField
get_mr_levels (
std::string name,
const std::string& name,
int finest_level
) const;

Expand All @@ -380,12 +380,12 @@ namespace ablastr::fields
*/
VectorField
get_alldirs (
std::string name,
const std::string&,
int level
);
[[nodiscard]] ConstVectorField
get_alldirs (
std::string name,
const std::string& name,
int level
) const;

Expand All @@ -400,12 +400,12 @@ namespace ablastr::fields
*/
MultiLevelVectorField
get_mr_levels_alldirs (
std::string name,
const std::string& name,
int finest_level
);
[[nodiscard]] ConstMultiLevelVectorField
get_mr_levels_alldirs (
std::string name,
const std::string& name,
int finest_level
) const;

Expand Down Expand Up @@ -508,11 +508,11 @@ namespace ablastr::fields
private:
amrex::MultiFab *
internal_get (
std::string key
const std::string& key
);
[[nodiscard]] amrex::MultiFab const *
internal_get (
std::string key
const std::string& key
) const;

/** data storage: ownership and lifetime control */
Expand Down
46 changes: 23 additions & 23 deletions Source/ablastr/fields/MultiFabRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace ablastr::fields

void
MultiFabRegister::alloc_like (
std::string /* other_name */,
const std::string& /* other_name */,
int /* other_level */
)
{
Expand Down Expand Up @@ -267,7 +267,7 @@ namespace ablastr::fields

// remake MultiFab with new distribution map
if (mf_owner.m_level == level && !mf_owner.is_alias()) {
amrex::MultiFab & mf = mf_owner.m_mf;
const amrex::MultiFab & mf = mf_owner.m_mf;
amrex::IntVect const & ng = mf.nGrowVect();
const auto tag = amrex::MFInfo().SetTag(mf.tags()[0]);
amrex::MultiFab new_mf(mf.boxArray(), new_dm, mf.nComp(), ng, tag);
Expand All @@ -294,7 +294,7 @@ namespace ablastr::fields
}

if (mf_owner.m_level == level && mf_owner.is_alias()) {
amrex::MultiFab & mf = m_mf_register[mf_owner.m_owner].m_mf;
const amrex::MultiFab & mf = m_mf_register[mf_owner.m_owner].m_mf;
amrex::MultiFab new_mf(mf, amrex::make_alias, 0, mf.nComp());

// no copy via Redistribute: the owner was already redistributed
Expand Down Expand Up @@ -330,7 +330,7 @@ namespace ablastr::fields

amrex::MultiFab*
MultiFabRegister::internal_get (
std::string key
const std::string& key
)
{
if (m_mf_register.count(key) == 0) {
Expand All @@ -345,7 +345,7 @@ namespace ablastr::fields

amrex::MultiFab const *
MultiFabRegister::internal_get (
std::string key
const std::string& key
) const
{
if (m_mf_register.count(key) == 0) {
Expand Down Expand Up @@ -402,7 +402,7 @@ namespace ablastr::fields

MultiLevelScalarField
MultiFabRegister::get_mr_levels (
std::string name,
const std::string& name,
int finest_level
)
{
Expand All @@ -417,7 +417,7 @@ namespace ablastr::fields

ConstMultiLevelScalarField
MultiFabRegister::get_mr_levels (
std::string name,
const std::string& name,
int finest_level
) const
{
Expand All @@ -432,18 +432,18 @@ namespace ablastr::fields

VectorField
MultiFabRegister::get_alldirs (
std::string name,
const std::string& name,
int level
)
{
// TODO: Technically, we should search field_on_level via std::unique_copy
std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};
const std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};

// insert a new level
VectorField vectorField;

// insert components
for (Direction dir : all_dirs)
for (const Direction& dir : all_dirs)
{
vectorField[dir] = get(name, dir, level);
}
Expand All @@ -452,18 +452,18 @@ namespace ablastr::fields

ConstVectorField
MultiFabRegister::get_alldirs (
std::string name,
const std::string& name,
int level
) const
{
// TODO: Technically, we should search field_on_level via std::unique_copy
std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};
const std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};

// insert a new level
ConstVectorField vectorField;

// insert components
for (Direction dir : all_dirs)
for (const Direction& dir: all_dirs)
{
vectorField[dir] = get(name, dir, level);
}
Expand All @@ -472,23 +472,23 @@ namespace ablastr::fields

MultiLevelVectorField
MultiFabRegister::get_mr_levels_alldirs (
std::string name,
const std::string& name,
int finest_level
)
{
MultiLevelVectorField field_on_level;
field_on_level.reserve(finest_level+1);

// TODO: Technically, we should search field_on_level via std::unique_copy
std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};
const std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};

for (int lvl = 0; lvl <= finest_level; lvl++)
{
// insert a new level
field_on_level.push_back(VectorField{});

// insert components
for (Direction dir : all_dirs)
for (const Direction& dir : all_dirs)
{
field_on_level[lvl][dir] = get(name, dir, lvl);
}
Expand All @@ -498,23 +498,23 @@ namespace ablastr::fields

ConstMultiLevelVectorField
MultiFabRegister::get_mr_levels_alldirs (
std::string name,
const std::string& name,
int finest_level
) const
{
ConstMultiLevelVectorField field_on_level;
field_on_level.reserve(finest_level+1);

// TODO: Technically, we should search field_on_level via std::unique_copy
std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};
const std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};

for (int lvl = 0; lvl <= finest_level; lvl++)
{
// insert a new level
field_on_level.push_back(ConstVectorField{});

// insert components
for (Direction dir : all_dirs)
for (const Direction& dir : all_dirs)
{
field_on_level[lvl][dir] = get(name, dir, lvl);
}
Expand Down Expand Up @@ -610,12 +610,12 @@ namespace ablastr::fields
const std::array< std::unique_ptr<amrex::MultiFab>, 3 > & old_vectorfield
)
{
std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};
const std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};

VectorField field_on_level;

// insert components
for (auto dir : {0, 1, 2})
for (const auto dir : {0, 1, 2})
{
field_on_level[Direction{dir}] = old_vectorfield[dir].get();
}
Expand All @@ -632,15 +632,15 @@ namespace ablastr::fields
MultiLevelVectorField field_on_level;
field_on_level.reserve(finest_level+1);

std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};
const std::vector<Direction> all_dirs = {Direction{0}, Direction{1}, Direction{2}};

for (int lvl = 0; lvl <= finest_level; lvl++)
{
// insert a new level
field_on_level.push_back(VectorField{});

// insert components
for (auto dir : {0, 1, 2})
for (const auto dir : {0, 1, 2})
{
field_on_level[lvl][Direction{dir}] = old_vector_on_levels[lvl][dir].get();
}
Expand Down

0 comments on commit 75187c7

Please sign in to comment.