From e41ae3604ea6a7448219be7ae764337ac0043edc Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Mon, 27 Mar 2023 18:36:49 -0500 Subject: [PATCH 1/7] Clone material. Refs #2442 --- include/openmc/material.h | 3 +++ src/material.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/openmc/material.h b/include/openmc/material.h index 8db9bb6283..36a6acf933 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -90,6 +90,9 @@ public: void set_densities( const vector& name, const vector& density); + //! Clone the material by deep-copying all members + void clone(); + //---------------------------------------------------------------------------- // Accessors diff --git a/src/material.cpp b/src/material.cpp index 74a8d7e350..ec82a7eea5 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -353,6 +353,37 @@ Material::~Material() model::material_map.erase(id_); } +void Material::clone() +{ + std::unique_ptr mat = std::make_unique(); + mat->index_ = model::materials.size(); + mat->set_id(C_NONE); + + // set all other parameters to whatever the calling Material has + mat->name_ = name_; + mat->nuclide_ = nuclide_; + mat->element_ = element_; + mat->ncrystal_mat_ = ncrystal_mat_; + mat->atom_density_ = atom_density_; + mat->density_ = density_; + mat->density_gpcc_ = density_gpcc_; + mat->volume_ = volume_; + mat->fissionable_ = fissionable_; + mat->depletable_ = depletable_; + mat->p0_ = p0_; + mat->mat_nuclide_index_ = mat_nuclide_index_; + mat->thermal_tables_ = thermal_tables_; + mat->temperature_ = temperature_; + + if (ttb_) + { + std::unique_ptr ptr2{new Bremsstrahlung{*ttb_}}; + mat->ttb_ = std::move(ptr2); + } + + model::materials.push_back(std::move(mat)); +} + void Material::finalize() { // Set fissionable if any nuclide is fissionable From a44c1f89de907292863b47ecdc62b10cb6685d40 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Mon, 27 Mar 2023 19:21:30 -0500 Subject: [PATCH 2/7] Address review comments. Refs #2442 --- src/material.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index ec82a7eea5..165a5c2e79 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -353,7 +353,7 @@ Material::~Material() model::material_map.erase(id_); } -void Material::clone() +Material & Material::clone() { std::unique_ptr mat = std::make_unique(); mat->index_ = model::materials.size(); @@ -376,12 +376,10 @@ void Material::clone() mat->temperature_ = temperature_; if (ttb_) - { - std::unique_ptr ptr2{new Bremsstrahlung{*ttb_}}; - mat->ttb_ = std::move(ptr2); - } + mat->ttb_ = std::make_unique(*ttb_); model::materials.push_back(std::move(mat)); + return *mat; } void Material::finalize() From fa222a4b314dac399d471fd2016e839a9c98549a Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Mon, 27 Mar 2023 19:23:04 -0500 Subject: [PATCH 3/7] Address review comments. --- include/openmc/material.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/openmc/material.h b/include/openmc/material.h index 36a6acf933..36d7c34c6d 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -91,7 +91,7 @@ public: const vector& name, const vector& density); //! Clone the material by deep-copying all members - void clone(); + Material & clone(); //---------------------------------------------------------------------------- // Accessors From b84a021c58623e8198cf315c6993e64e3b051613 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Tue, 28 Mar 2023 13:50:02 -0500 Subject: [PATCH 4/7] Improve documentation. Refs #2442 --- include/openmc/material.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/openmc/material.h b/include/openmc/material.h index 36d7c34c6d..deaee2469b 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -90,7 +90,10 @@ public: void set_densities( const vector& name, const vector& density); - //! Clone the material by deep-copying all members + //! Clone the material by deep-copying all members, except for the ID, + // which will get auto-assigned to the next available ID. After creating + // the new material, it is added to openmc::model::materials. + //! \return reference to the cloned material Material & clone(); //---------------------------------------------------------------------------- From ca061bc7e5ecad80ca074070438ebeab9b791b0b Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Tue, 28 Mar 2023 19:20:49 -0500 Subject: [PATCH 5/7] Return non-null. --- src/material.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material.cpp b/src/material.cpp index 165a5c2e79..092055aa17 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -379,7 +379,7 @@ Material & Material::clone() mat->ttb_ = std::make_unique(*ttb_); model::materials.push_back(std::move(mat)); - return *mat; + return *model::materials.back(); } void Material::finalize() From c3fdf4edd2ee6dc7d9ea2a9e5c48c3d0efb670f4 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Wed, 29 Mar 2023 14:40:37 -0500 Subject: [PATCH 6/7] Group openmc::model lines together. Refs #2442 --- src/material.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index 092055aa17..82dd0d4d9e 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -356,8 +356,6 @@ Material::~Material() Material & Material::clone() { std::unique_ptr mat = std::make_unique(); - mat->index_ = model::materials.size(); - mat->set_id(C_NONE); // set all other parameters to whatever the calling Material has mat->name_ = name_; @@ -378,6 +376,8 @@ Material & Material::clone() if (ttb_) mat->ttb_ = std::make_unique(*ttb_); + mat->index_ = model::materials.size(); + mat->set_id(C_NONE); model::materials.push_back(std::move(mat)); return *model::materials.back(); } From 5fcb7208dfe9316407a9598e7aff5c498f218cd6 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 29 Mar 2023 14:41:03 -0500 Subject: [PATCH 7/7] Change version number to 0.13.4-dev --- CMakeLists.txt | 2 +- docs/source/conf.py | 2 +- include/openmc/version.h.in | 2 +- openmc/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dcaa6fb37..866050a98d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(openmc C CXX) # Set version numbers set(OPENMC_VERSION_MAJOR 0) set(OPENMC_VERSION_MINOR 13) -set(OPENMC_VERSION_RELEASE 3) +set(OPENMC_VERSION_RELEASE 4) set(OPENMC_VERSION ${OPENMC_VERSION_MAJOR}.${OPENMC_VERSION_MINOR}.${OPENMC_VERSION_RELEASE}) configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY) diff --git a/docs/source/conf.py b/docs/source/conf.py index 988e626cf9..8dbbfc6d44 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -71,7 +71,7 @@ copyright = '2011-2023, Massachusetts Institute of Technology, UChicago Argonne # The short X.Y version. version = "0.13" # The full version, including alpha/beta/rc tags. -release = "0.13.3" +release = "0.13.4" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/include/openmc/version.h.in b/include/openmc/version.h.in index a518e0d63b..e1c2b0541a 100644 --- a/include/openmc/version.h.in +++ b/include/openmc/version.h.in @@ -10,7 +10,7 @@ namespace openmc { constexpr int VERSION_MAJOR {@OPENMC_VERSION_MAJOR@}; constexpr int VERSION_MINOR {@OPENMC_VERSION_MINOR@}; constexpr int VERSION_RELEASE {@OPENMC_VERSION_RELEASE@}; -constexpr bool VERSION_DEV {false}; +constexpr bool VERSION_DEV {true}; constexpr std::array VERSION {VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE}; // clang-format on diff --git a/openmc/__init__.py b/openmc/__init__.py index f94cd038f8..ac9e02e168 100644 --- a/openmc/__init__.py +++ b/openmc/__init__.py @@ -38,4 +38,4 @@ from .config import * from openmc.model import rectangular_prism, hexagonal_prism, Model -__version__ = '0.13.3' +__version__ = '0.13.4-dev'