mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Make more use of C_NONE for un-initalized ids
This commit is contained in:
parent
eabf3e2a86
commit
ede575ea04
3 changed files with 12 additions and 12 deletions
|
|
@ -857,12 +857,12 @@ void Material::calculate_photon_xs(Particle& p) const
|
|||
|
||||
void Material::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= -1);
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in material map if an ID was already assigned before
|
||||
if (id_ != -1) {
|
||||
if (id_ != C_NONE) {
|
||||
model::material_map.erase(id_);
|
||||
id_ = -1;
|
||||
id_ = C_NONE;
|
||||
}
|
||||
|
||||
// Make sure no other material has same ID
|
||||
|
|
@ -871,7 +871,7 @@ void Material::set_id(int32_t id)
|
|||
}
|
||||
|
||||
// If no ID specified, auto-assign next ID in sequence
|
||||
if (id == -1) {
|
||||
if (id == C_NONE) {
|
||||
id = 0;
|
||||
for (const auto& m : model::materials) {
|
||||
id = std::max(id, m->id_);
|
||||
|
|
|
|||
|
|
@ -148,12 +148,12 @@ Filter* Filter::create(const std::string& type, int32_t id)
|
|||
|
||||
void Filter::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= -1);
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in filter map if an ID was already assigned before
|
||||
if (id_ != -1) {
|
||||
if (id_ != C_NONE) {
|
||||
model::filter_map.erase(id_);
|
||||
id_ = -1;
|
||||
id_ = C_NONE;
|
||||
}
|
||||
|
||||
// Make sure no other filter has same ID
|
||||
|
|
@ -162,7 +162,7 @@ void Filter::set_id(int32_t id)
|
|||
}
|
||||
|
||||
// If no ID specified, auto-assign next ID in sequence
|
||||
if (id == -1) {
|
||||
if (id == C_NONE) {
|
||||
id = 0;
|
||||
for (const auto& f : model::tally_filters) {
|
||||
id = std::max(id, f->id_);
|
||||
|
|
|
|||
|
|
@ -483,12 +483,12 @@ Tally::create(int32_t id)
|
|||
void
|
||||
Tally::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= -1);
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in tally map if an ID was already assigned before
|
||||
if (id_ != -1) {
|
||||
if (id_ != C_NONE) {
|
||||
model::tally_map.erase(id_);
|
||||
id_ = -1;
|
||||
id_ = C_NONE;
|
||||
}
|
||||
|
||||
// Make sure no other tally has the same ID
|
||||
|
|
@ -497,7 +497,7 @@ Tally::set_id(int32_t id)
|
|||
}
|
||||
|
||||
// If no ID specified, auto-assign next ID in sequence
|
||||
if (id == -1) {
|
||||
if (id == C_NONE) {
|
||||
id = 0;
|
||||
for (const auto& t : model::tallies) {
|
||||
id = std::max(id, t->id_);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue