From 1b8bc2d01d3038fbf6d0eb1dd17ad331b587af82 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 27 Sep 2019 10:43:36 -0500 Subject: [PATCH] Correcting default values in set_id methods. Initializing material ids to match the initialization logic. --- include/openmc/material.h | 4 ++-- include/openmc/tallies/filter.h | 2 +- src/material.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/openmc/material.h b/include/openmc/material.h index 652f3db8e..8771b372a 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -120,7 +120,7 @@ public: //! Assign a unique ID to the material //! \param[in] Unique ID to assign. A value of -1 indicates that an ID //! should be automatically assigned. - void set_id(int32_t id); + void set_id(int32_t id = -1); //! Get whether material is fissionable //! \return Whether material is fissionable @@ -132,7 +132,7 @@ public: //---------------------------------------------------------------------------- // Data - int32_t id_; //!< Unique ID + int32_t id_ {-1}; //!< Unique ID std::string name_; //!< Name of material std::vector nuclide_; //!< Indices in nuclides vector std::vector element_; //!< Indices in elements vector diff --git a/include/openmc/tallies/filter.h b/include/openmc/tallies/filter.h index ba6ca0883..b25110e07 100644 --- a/include/openmc/tallies/filter.h +++ b/include/openmc/tallies/filter.h @@ -104,7 +104,7 @@ public: //! Assign a unique ID to the filter //! \param[in] Unique ID to assign. A value of -1 indicates that an ID should //! be automatically assigned - void set_id(int32_t id); + void set_id(int32_t id = -1); //! Get number of bins //! \return Number of bins diff --git a/src/material.cpp b/src/material.cpp index 685fd1da2..9a1e206ac 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -873,8 +873,8 @@ void Material::set_id(int32_t id) // If no ID specified, auto-assign next ID in sequence if (id == -1) { id = 0; - for (const auto& f : model::materials) { - id = std::max(id, f->id_); + for (const auto& m : model::materials) { + id = std::max(id, m->id_); } ++id; }