Skip to content

Commit

Permalink
Clang-tidy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gsjaardema committed Sep 13, 2023
1 parent 51f3901 commit 0e67441
Show file tree
Hide file tree
Showing 84 changed files with 6,889 additions and 6,422 deletions.
13 changes: 5 additions & 8 deletions packages/seacas/applications/ejoin/EJ_mapping.C
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ void build_local_element_map(RegionVector &part_mesh, std::vector<INT> &local_el
size_t offset = 0;
for (auto &p : part_mesh) {

const Ioss::ElementBlockContainer &ebs = p->get_element_blocks();
Ioss::ElementBlockContainer::const_iterator i = ebs.begin();
const auto &ebs = p->get_element_blocks();
auto i = ebs.begin();

while (i != ebs.end()) {
const auto *eb = *i++;
Expand Down Expand Up @@ -255,12 +255,9 @@ void generate_element_ids(RegionVector &part_mesh, const std::vector<INT> &local
bool has_map = false;
size_t offset = 0;
for (auto &p : part_mesh) {
const Ioss::ElementBlockContainer &ebs = p->get_element_blocks();
Ioss::ElementBlockContainer::const_iterator i = ebs.begin();

while (i != ebs.end()) {
Ioss::ElementBlock *eb = *i++;
INT num_elem = eb->entity_count();
const auto &ebs = p->get_element_blocks();
for (auto *eb : ebs) {
INT num_elem = eb->entity_count();
if (!entity_is_omitted(eb)) {
std::vector<INT> part_ids;
eb->get_field_data("ids", part_ids);
Expand Down
4 changes: 2 additions & 2 deletions packages/seacas/applications/ejoin/EJ_vector3d.C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(C) 1999-2020 National Technology & Engineering Solutions
// Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
// NTESS, the U.S. Government retains certain rights in this software.
//
Expand Down Expand Up @@ -90,7 +90,7 @@ vector3d operator/(const vector3d &lhs, double scalar)
return tmp /= scalar;
}

return vector3d(HUGE_VAL, HUGE_VAL, HUGE_VAL);
return {HUGE_VAL, HUGE_VAL, HUGE_VAL};
}

vector3d &vector3d::operator/=(double scalar)
Expand Down
4 changes: 2 additions & 2 deletions packages/seacas/applications/ejoin/EJ_vector3d.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions
// Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
// NTESS, the U.S. Government retains certain rights in this software.
//
Expand Down Expand Up @@ -47,7 +47,7 @@ vector3d operator-(const vector3d &lhs, const vector3d &rhs);
//----------------------------------------------------------------------------
inline vector3d vector3d::cross(const vector3d &from) const
{
return vector3d(y * from.z - z * from.y, z * from.x - x * from.z, x * from.y - y * from.x);
return {y * from.z - z * from.y, z * from.x - x * from.z, x * from.y - y * from.x};
}
//----------------------------------------------------------------------------
inline vector3d &vector3d::operator+=(const vector3d &from)
Expand Down
20 changes: 10 additions & 10 deletions packages/seacas/applications/ejoin/EJoin.C
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ namespace {

// Assuming (with checks) that the output side blocks will be
// iterated in same order as input side blocks...
Ioss::SideBlockContainer::const_iterator II = out_eb.begin();
auto II = out_eb.begin();

for (const auto &pm : part_mesh) {
size_t element_offset = pm->get_property("element_offset").get_int();
Expand Down Expand Up @@ -1201,7 +1201,7 @@ namespace {

// Assuming (with checks) that the output side blocks will be
// iterated in same order as input side blocks...
Ioss::SideBlockContainer::const_iterator II = out_eb.begin();
auto II = out_eb.begin();

for (const auto &pm : part_mesh) {
const Ioss::SideSetContainer &is = pm->get_sidesets();
Expand Down Expand Up @@ -1438,29 +1438,29 @@ namespace {
if (!variable_list.empty() && variable_list[0].first == "none") {
return;
}
const Ioss::SideSetContainer &os = output_region.get_sidesets();
const auto &os = output_region.get_sidesets();

Ioss::SideBlockContainer out_eb;
// Put all output side blocks in the same list...
for (const auto &oss : os) {
const Ioss::SideBlockContainer &obs = oss->get_side_blocks();
const auto &obs = oss->get_side_blocks();
std::copy(obs.begin(), obs.end(), std::back_inserter(out_eb));
}

// Assuming (with checks) that the output side blocks will be
// iterated in same order as input side blocks...
Ioss::SideBlockContainer::const_iterator II = out_eb.begin();
auto II = out_eb.begin();

for (const auto &pm : part_mesh) {
const Ioss::SideSetContainer &is = pm->get_sidesets();
const auto &is = pm->get_sidesets();
for (const auto &iss : is) {
if (!entity_is_omitted(iss)) {
size_t id = iss->get_property("id").get_int();
const Ioss::SideBlockContainer &ebs = iss->get_side_blocks();
size_t id = iss->get_property("id").get_int();
const auto &ebs = iss->get_side_blocks();
for (const auto &eb : ebs) {
SMART_ASSERT((pm->name() + "_" + eb->name() == (*II)->name()) ||
(eb->name() == (*II)->name()));
Ioss::NameList fields = eb->field_describe(Ioss::Field::TRANSIENT);
auto fields = eb->field_describe(Ioss::Field::TRANSIENT);
for (const auto &field_name : fields) {
if (valid_variable(field_name, id, variable_list)) {
Ioss::Field field = eb->get_field(field_name);
Expand All @@ -1478,7 +1478,7 @@ namespace {
Ioss::Field::RoleType role, const std::string &prefix)
{
// Check for transient fields...
Ioss::NameList fields = ige->field_describe(role);
auto fields = ige->field_describe(role);

// Iterate through results fields and transfer to output
// database... If a prefix is specified, only transfer fields
Expand Down
17 changes: 8 additions & 9 deletions packages/seacas/applications/epu/EP_Internals.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions
* Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand Down Expand Up @@ -92,8 +92,7 @@ namespace Excn {
{
public:
Internals(int exoid, int maximum_name_length)
: exodusFilePtr(exoid), nodeMapVarID(), elementMapVarID(), commIndexVar(0),
elemCommIndexVar(0), maximumNameLength(maximum_name_length)
: exodusFilePtr(exoid), maximumNameLength(maximum_name_length)
{
}

Expand Down Expand Up @@ -126,11 +125,11 @@ namespace Excn {
int put_non_define_data(const std::vector<EdgeBlock<INT>> &edgeblocks);
int put_non_define_data(const std::vector<FaceBlock<INT>> &faceblocks);

int exodusFilePtr;
int nodeMapVarID[3];
int elementMapVarID[2];
int commIndexVar;
int elemCommIndexVar;
int maximumNameLength;
int exodusFilePtr{};
int nodeMapVarID[3]{};
int elementMapVarID[2]{};
int commIndexVar{};
int elemCommIndexVar{};
int maximumNameLength{};
};
} // namespace Excn
9 changes: 3 additions & 6 deletions packages/seacas/applications/epu/EP_ParallelDisks.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions
* Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand All @@ -20,15 +20,12 @@ namespace Excn {
public:
ParallelDisks();
~ParallelDisks();
ParallelDisks(const ParallelDisks &) = delete;
ParallelDisks &operator=(const ParallelDisks &) = delete;

static void Create_IO_Filename(std::string & /*name*/, int processor, int num_processors);

void rename_file_for_mp(const std::string &rootdir, const std::string &subdir,
std::string &name, int node, int numproc) const;

private:
// not defined (the parallel disks object is unique!)
ParallelDisks(const ParallelDisks &);
ParallelDisks &operator=(const ParallelDisks &);
};
} // namespace Excn
4 changes: 2 additions & 2 deletions packages/seacas/applications/epu/EP_SystemInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -663,13 +663,13 @@ namespace {
StringVector name_id = SLIB::tokenize(*I, ":");
std::string var_name = LowerCase(name_id[0]);
if (name_id.size() == 1) {
(*variable_list).push_back(std::make_pair(var_name, 0));
(*variable_list).emplace_back(var_name, 0);
}
else {
for (size_t i = 1; i < name_id.size(); i++) {
// Convert string to integer...
int id = std::stoi(name_id[i]);
(*variable_list).push_back(std::make_pair(var_name, id));
(*variable_list).emplace_back(var_name, id);
}
}
++I;
Expand Down
8 changes: 4 additions & 4 deletions packages/seacas/applications/epu/EP_Variables.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions
* Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand All @@ -20,7 +20,7 @@ namespace Excn {

struct Variables
{
explicit Variables(ObjectType otype) : objectType(otype), outputCount(0), addProcessorId(false)
explicit Variables(ObjectType otype) : objectType(otype)
{
SMART_ASSERT(otype == Excn::ObjectType::EBLK || otype == Excn::ObjectType::NSET ||
otype == Excn::ObjectType::SSET || otype == Excn::ObjectType::NODE ||
Expand Down Expand Up @@ -69,8 +69,8 @@ namespace Excn {
bool add_processor_id() const { return addProcessorId; }

ObjectType objectType;
int outputCount;
bool addProcessorId;
int outputCount{0};
bool addProcessorId{false};
IntVector index_{};
std::string type_{};
};
Expand Down
6 changes: 3 additions & 3 deletions packages/seacas/applications/exodiff/ED_SystemInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,14 @@ bool SystemInterface::parse_options(int argc, char **argv)
const char *temp = options_.retrieve("TimeStepOffset");
if (temp != nullptr) {
errno = 0;
time_step_offset = strtol(temp, NULL, 10);
time_step_offset = strtol(temp, nullptr, 10);
SMART_ASSERT(errno == 0);
}
else {
const char *temp2 = options_.retrieve("T");
if (temp2 != nullptr) {
errno = 0;
time_step_offset = strtol(temp2, NULL, 10);
time_step_offset = strtol(temp2, nullptr, 10);
SMART_ASSERT(errno == 0);
}
}
Expand Down Expand Up @@ -833,7 +833,7 @@ bool SystemInterface::parse_options(int argc, char **argv)
const char *temp = options_.retrieve("max_warnings");
if (temp != nullptr) {
errno = 0;
max_warnings = strtol(temp, NULL, 10);
max_warnings = strtol(temp, nullptr, 10);
SMART_ASSERT(errno == 0);
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/seacas/applications/exodiff/edge_block.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions
// Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
// NTESS, the U.S. Government retains certain rights in this software.
//
Expand All @@ -16,16 +16,16 @@ template <typename INT> class Edge_Block : public Exo_Entity
Edge_Block();
Edge_Block(int file_id, size_t id);
Edge_Block(int file_id, size_t id, size_t ne);
Edge_Block(const Edge_Block &) = delete; // Not written.
const Edge_Block &operator=(const Edge_Block &) = delete; // Not written.

~Edge_Block() override;

size_t Edge_Index(size_t position) const;

int Check_State() const;

private:
Edge_Block(const Edge_Block &) = delete; // Not written.
const Edge_Block &operator=(const Edge_Block &) = delete; // Not written.

void entity_load_params() override;

EXOTYPE exodus_type() const override;
Expand Down
6 changes: 4 additions & 2 deletions packages/seacas/applications/exodiff/exoII_read.C
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ namespace {

template <typename INT> ExoII_Read<INT>::ExoII_Read() = default;

template <typename INT> ExoII_Read<INT>::ExoII_Read(const std::string &fname) : file_name(fname) {}
template <typename INT> ExoII_Read<INT>::ExoII_Read(std::string fname) : file_name(std::move(fname))
{
}

template <typename INT> ExoII_Read<INT>::~ExoII_Read()
{
Expand Down Expand Up @@ -1005,7 +1007,7 @@ template <typename INT> void ExoII_Read<INT>::Get_Init_Data()

coord_names.clear();
for (int i = 0; i < dimension; ++i) {
coord_names.push_back(coords[i]);
coord_names.emplace_back(coords[i]);
}
free_name_array(coords, 3);

Expand Down
4 changes: 2 additions & 2 deletions packages/seacas/applications/exodiff/exoII_read.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(C) 1999-2022 National Technology & Engineering Solutions
// Copyright(C) 1999-2023 National Technology & Engineering Solutions
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
// NTESS, the U.S. Government retains certain rights in this software.
//
Expand Down Expand Up @@ -32,7 +32,7 @@ template <typename INT> class ExoII_Read
{
public:
ExoII_Read();
explicit ExoII_Read(const std::string &fname);
explicit ExoII_Read(std::string fname);
virtual ~ExoII_Read();
const ExoII_Read &operator=(const ExoII_Read &) = delete;
ExoII_Read(const ExoII_Read &) = delete;
Expand Down
3 changes: 1 addition & 2 deletions packages/seacas/applications/exodiff/exodiff.C
Original file line number Diff line number Diff line change
Expand Up @@ -1063,8 +1063,7 @@ bool Equal_Values(const double *values, size_t count, double *value)
{
SMART_ASSERT(values != nullptr);
*value = values[0];
return (std::adjacent_find(values, values + count, std::not_equal_to<double>()) ==
values + count);
return (std::adjacent_find(values, values + count, std::not_equal_to<>()) == values + count);
}

template <typename INT>
Expand Down
7 changes: 3 additions & 4 deletions packages/seacas/applications/exodiff/face_block.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(C) 1999-2022 National Technology & Engineering Solutions
// Copyright(C) 1999-2023 National Technology & Engineering Solutions
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
// NTESS, the U.S. Government retains certain rights in this software.
//
Expand All @@ -17,15 +17,14 @@ template <typename INT> class Face_Block : public Exo_Entity
Face_Block(int file_id, size_t id);
Face_Block(int file_id, size_t id, size_t ne);
~Face_Block() override;
Face_Block(const Face_Block &) = delete; // Not written.
const Face_Block &operator=(const Face_Block &) = delete; // Not written.

size_t Face_Index(size_t position) const;

int Check_State() const;

private:
Face_Block(const Face_Block &) = delete; // Not written.
const Face_Block &operator=(const Face_Block &) = delete; // Not written.

void entity_load_params() override;

EXOTYPE exodus_type() const override;
Expand Down
7 changes: 3 additions & 4 deletions packages/seacas/applications/exodiff/side_set.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions
// Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
// NTESS, the U.S. Government retains certain rights in this software.
//
Expand All @@ -17,6 +17,8 @@ template <typename INT> class Side_Set : public Exo_Entity
Side_Set(int file_id, size_t id);
Side_Set(int file_id, size_t id, size_t ns, size_t ndf = 0);
~Side_Set() override;
Side_Set(const Side_Set &) = delete;
const Side_Set &operator=(const Side_Set &) = delete;

void apply_map(const std::vector<INT> &elmt_map);
const INT *Elements() const;
Expand All @@ -32,9 +34,6 @@ template <typename INT> class Side_Set : public Exo_Entity
size_t Distribution_Factor_Count() const { return num_dist_factors; }

private:
Side_Set(const Side_Set &); // Not written.
const Side_Set &operator=(const Side_Set &); // Not written.

void load_sides(const std::vector<INT> &elmt_map) const;
void load_df() const;
void entity_load_params() override;
Expand Down
Loading

0 comments on commit 0e67441

Please sign in to comment.