From 1b8bc2d01d3038fbf6d0eb1dd17ad331b587af82 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 27 Sep 2019 10:43:36 -0500 Subject: [PATCH 1/2] 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 652f3db8e1..8771b372a4 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 ba6ca08830..b25110e07a 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 685fd1da2e..9a1e206ac8 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; } From e7b28ab8d99c43aeb3419c52eeada0bf83cdd4a6 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 30 Sep 2019 14:31:26 -0500 Subject: [PATCH 2/2] Removing default values for set_id args as requested by @paulromano. --- include/openmc/material.h | 2 +- include/openmc/tallies/filter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/openmc/material.h b/include/openmc/material.h index 8771b372a4..70c6b38522 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 = -1); + void set_id(int32_t id); //! Get whether material is fissionable //! \return Whether material is fissionable diff --git a/include/openmc/tallies/filter.h b/include/openmc/tallies/filter.h index b25110e07a..ba6ca08830 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 = -1); + void set_id(int32_t id); //! Get number of bins //! \return Number of bins