From 3cfe71621bb0f6bbb6cd45b448c2370396db4070 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 8 Nov 2018 13:21:37 -0600 Subject: [PATCH] Put global variables in cell.h in model namespace --- include/openmc/capi.h | 1 - include/openmc/cell.h | 17 ++++-- src/cell.cpp | 88 ++++++++++++++++-------------- src/dagmc.cpp | 27 ++++----- src/geometry.cpp | 20 +++---- src/geometry_aux.cpp | 78 +++++++++++++------------- src/lattice.cpp | 16 +++--- src/output.cpp | 6 +- src/plot.cpp | 16 +++--- src/source.cpp | 2 +- src/summary.cpp | 10 ++-- src/tallies/filter_cell.cpp | 8 +-- src/tallies/filter_cellborn.cpp | 2 +- src/tallies/filter_cellfrom.cpp | 2 +- src/tallies/filter_distribcell.cpp | 14 ++--- src/tallies/filter_universe.cpp | 8 +-- 16 files changed, 162 insertions(+), 153 deletions(-) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index fd664b2a9..91d038d46 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -135,7 +135,6 @@ extern "C" { // Global variables extern char openmc_err_msg[256]; - extern int32_t n_cells; extern int32_t n_lattices; extern int32_t n_materials; extern int n_nuclides; diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 5a889023b..f2c8f0f71 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -39,16 +39,21 @@ constexpr int32_t OP_UNION {std::numeric_limits::max() - 4}; // Global variables //============================================================================== +class Cell; +class Universe; + +namespace model { + extern "C" int32_t n_cells; -class Cell; extern std::vector cells; extern std::unordered_map cell_map; -class Universe; extern std::vector universes; extern std::unordered_map universe_map; +} // namespace model + //============================================================================== //! A geometry primitive that fills all space and contains cells. //============================================================================== @@ -145,13 +150,13 @@ public: virtual ~Cell() {} }; - + class CSGCell : public Cell { public: CSGCell(); - + explicit CSGCell(pugi::xml_node cell_node); bool @@ -163,7 +168,7 @@ public: void to_hdf5(hid_t group_id) const; - + protected: bool contains_simple(Position r, Direction u, int32_t on_surface) const; bool contains_complex(Position r, Direction u, int32_t on_surface) const; @@ -183,6 +188,6 @@ public: }; #endif - + } // namespace openmc #endif // OPENMC_CELL_H diff --git a/src/cell.cpp b/src/cell.cpp index 65582d780..2e4c0144a 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -21,6 +21,8 @@ namespace openmc { // Global variables //============================================================================== +namespace model { + int32_t n_cells {0}; std::vector cells; @@ -29,6 +31,8 @@ std::unordered_map cell_map; std::vector universes; std::unordered_map universe_map; +} // namespace model + //============================================================================== //! Convert region specification string to integer tokens. //! @@ -197,7 +201,7 @@ Universe::to_hdf5(hid_t universes_group) const // Write the contained cells. if (cells_.size() > 0) { std::vector cell_ids; - for (auto i_cell : cells_) cell_ids.push_back(cells[i_cell]->id_); + for (auto i_cell : cells_) cell_ids.push_back(model::cells[i_cell]->id_); write_dataset(group, "cells", cell_ids); } @@ -209,7 +213,7 @@ Universe::to_hdf5(hid_t universes_group) const //============================================================================== CSGCell::CSGCell() {} // empty constructor - + CSGCell::CSGCell(pugi::xml_node cell_node) { if (check_for_node(cell_node, "id")) { @@ -446,7 +450,7 @@ CSGCell::to_hdf5(hid_t cell_group) const write_string(group, "name", name_, false); } - write_dataset(group, "universe", universes[universe_]->id_); + write_dataset(group, "universe", model::universes[universe_]->id_); // Write the region specification. if (!region_.empty()) { @@ -494,7 +498,7 @@ CSGCell::to_hdf5(hid_t cell_group) const } else if (type_ == FILL_UNIVERSE) { write_dataset(group, "fill_type", "universe"); - write_dataset(group, "fill", universes[fill_]->id_); + write_dataset(group, "fill", model::universes[fill_]->id_); if (translation_ != Position(0, 0, 0)) { write_dataset(group, "translation", translation_); } @@ -609,10 +613,10 @@ DAGCell::distance(Position r, Direction u, int32_t on_surface) const } else { // indicate that particle is lost surf_idx = -1; } - + return {dist, surf_idx}; } - + bool DAGCell::contains(Position r, Direction u, int32_t on_surface) const { moab::ErrorCode rval; @@ -622,7 +626,7 @@ bool DAGCell::contains(Position r, Direction u, int32_t on_surface) const double pnt[3] = {r.x, r.y, r.z}; double dir[3] = {u.x, u.y, u.z}; rval = dagmc_ptr_->point_in_volume(vol, pnt, result, dir); - MB_CHK_ERR_CONT(rval); + MB_CHK_ERR_CONT(rval); return result; } @@ -638,23 +642,23 @@ extern "C" void read_cells(pugi::xml_node* node) { // Count the number of cells. - for (pugi::xml_node cell_node: node->children("cell")) {n_cells++;} - if (n_cells == 0) { + for (pugi::xml_node cell_node: node->children("cell")) {model::n_cells++;} + if (model::n_cells == 0) { fatal_error("No cells found in geometry.xml!"); } // Loop over XML cell elements and populate the array. - cells.reserve(n_cells); + model::cells.reserve(model::n_cells); for (pugi::xml_node cell_node: node->children("cell")) { - cells.push_back(new CSGCell(cell_node)); + model::cells.push_back(new CSGCell(cell_node)); } // Fill the cell map. - for (int i = 0; i < cells.size(); i++) { - int32_t id = cells[i]->id_; - auto search = cell_map.find(id); - if (search == cell_map.end()) { - cell_map[id] = i; + for (int i = 0; i < model::cells.size(); i++) { + int32_t id = model::cells[i]->id_; + auto search = model::cell_map.find(id); + if (search == model::cell_map.end()) { + model::cell_map[id] = i; } else { std::stringstream err_msg; err_msg << "Two or more cells use the same unique ID: " << id; @@ -663,22 +667,22 @@ read_cells(pugi::xml_node* node) } // Populate the Universe vector and map. - for (int i = 0; i < cells.size(); i++) { - int32_t uid = cells[i]->universe_; - auto it = universe_map.find(uid); - if (it == universe_map.end()) { - universes.push_back(new Universe()); - universes.back()->id_ = uid; - universes.back()->cells_.push_back(i); - universe_map[uid] = universes.size() - 1; + for (int i = 0; i < model::cells.size(); i++) { + int32_t uid = model::cells[i]->universe_; + auto it = model::universe_map.find(uid); + if (it == model::universe_map.end()) { + model::universes.push_back(new Universe()); + model::universes.back()->id_ = uid; + model::universes.back()->cells_.push_back(i); + model::universe_map[uid] = model::universes.size() - 1; } else { - universes[it->second]->cells_.push_back(i); + model::universes[it->second]->cells_.push_back(i); } } - universes.shrink_to_fit(); + model::universes.shrink_to_fit(); // Allocate the cell overlap count if necessary. - if (settings::check_overlaps) overlap_check_count.resize(n_cells, 0); + if (settings::check_overlaps) overlap_check_count.resize(model::n_cells, 0); } //============================================================================== @@ -688,9 +692,9 @@ read_cells(pugi::xml_node* node) extern "C" int openmc_cell_get_fill(int32_t index, int* type, int32_t** indices, int32_t* n) { - if (index >= 1 && index <= cells.size()) { + if (index >= 1 && index <= model::cells.size()) { //TODO: off-by-one - Cell& c {*cells[index - 1]}; + Cell& c {*model::cells[index - 1]}; *type = c.type_; if (c.type_ == FILL_MATERIAL) { *indices = c.material_.data(); @@ -710,9 +714,9 @@ extern "C" int openmc_cell_set_fill(int32_t index, int type, int32_t n, const int32_t* indices) { - if (index >= 1 && index <= cells.size()) { + if (index >= 1 && index <= model::cells.size()) { //TODO: off-by-one - Cell& c {*cells[index - 1]}; + Cell& c {*model::cells[index - 1]}; if (type == FILL_MATERIAL) { c.type_ = FILL_MATERIAL; c.material_.clear(); @@ -745,9 +749,9 @@ openmc_cell_set_fill(int32_t index, int type, int32_t n, extern "C" int openmc_cell_set_temperature(int32_t index, double T, const int32_t* instance) { - if (index >= 1 && index <= cells.size()) { + if (index >= 1 && index <= model::cells.size()) { //TODO: off-by-one - Cell& c {*cells[index - 1]}; + Cell& c {*model::cells[index - 1]}; if (instance) { if (*instance >= 0 && *instance < c.sqrtkT_.size()) { @@ -775,7 +779,7 @@ openmc_cell_set_temperature(int32_t index, double T, const int32_t* instance) //============================================================================== extern "C" { - Cell* cell_pointer(int32_t cell_ind) {return cells[cell_ind];} + Cell* cell_pointer(int32_t cell_ind) {return model::cells[cell_ind];} int32_t cell_id(Cell* c) {return c->id_;} @@ -785,9 +789,9 @@ extern "C" { c->id_ = id; // Find the index of this cell and update the cell map. - for (int i = 0; i < cells.size(); i++) { - if (cells[i] == c) { - cell_map[id] = i; + for (int i = 0; i < model::cells.size(); i++) { + if (model::cells[i] == c) { + model::cell_map[id] = i; break; } } @@ -830,17 +834,17 @@ extern "C" { void extend_cells_c(int32_t n) { - cells.reserve(cells.size() + n); + model::cells.reserve(model::cells.size() + n); for (int32_t i = 0; i < n; i++) { - cells.push_back(new CSGCell()); + model::cells.push_back(new CSGCell()); } - n_cells = cells.size(); + model::n_cells = model::cells.size(); } - int32_t universe_id(int i_univ) {return universes[i_univ]->id_;} + int32_t universe_id(int i_univ) {return model::universes[i_univ]->id_;} void universes_to_hdf5(hid_t universes_group) - {for (Universe* u : universes) u->to_hdf5(universes_group);} + {for (Universe* u : model::universes) u->to_hdf5(universes_group);} } diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 7c1127867..f11fbe203 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -1,5 +1,6 @@ - #include "openmc/dagmc.h" + +#include "openmc/cell.h" #include "openmc/error.h" #include "openmc/string_utils.h" #include "openmc/settings.h" @@ -38,12 +39,12 @@ void load_dagmc_geometry() MB_CHK_ERR_CONT(rval); // initialize cell objects - n_cells = DAG->num_entities(3); + model::n_cells = DAG->num_entities(3); // Allocate the cell overlap count if necessary. - if (settings::check_overlaps) overlap_check_count.resize(n_cells, 0); + if (settings::check_overlaps) overlap_check_count.resize(model::n_cells, 0); - for (int i = 0; i < n_cells; i++) { + for (int i = 0; i < model::n_cells; i++) { moab::EntityHandle vol_handle = DAG->entity_by_index(3, i+1); // set cell ids using global IDs @@ -53,18 +54,18 @@ void load_dagmc_geometry() c->universe_ = dagmc_univ_id; // set to zero for now c->fill_ = C_NONE; // no fill, single universe - cells.push_back(c); - cell_map[c->id_] = i; + model::cells.push_back(c); + model::cell_map[c->id_] = i; // Populate the Universe vector and dict - auto it = universe_map.find(dagmc_univ_id); - if (it == universe_map.end()) { - universes.push_back(new Universe()); - universes.back()-> id_ = dagmc_univ_id; - universes.back()->cells_.push_back(i); - universe_map[dagmc_univ_id] = universes.size() - 1; + auto it = model::universe_map.find(dagmc_univ_id); + if (it == model::universe_map.end()) { + model::universes.push_back(new Universe()); + model::universes.back()-> id_ = dagmc_univ_id; + model::universes.back()->cells_.push_back(i); + model::universe_map[dagmc_univ_id] = model::universes.size() - 1; } else { - universes[it->second]->cells_.push_back(i); + model::universes[it->second]->cells_.push_back(i); } if (DAG->is_implicit_complement(vol_handle)) { diff --git a/src/geometry.cpp b/src/geometry.cpp index cff5657a5..e4591cf9e 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -24,17 +24,17 @@ check_cell_overlap(Particle* p) { // Loop through each coordinate level for (int j = 0; j < n_coord; j++) { - Universe& univ = *universes[p->coord[j].universe]; + Universe& univ = *model::universes[p->coord[j].universe]; int n = univ.cells_.size(); // Loop through each cell on this level for (auto index_cell : univ.cells_) { - Cell& c = *cells[index_cell]; + Cell& c = *model::cells[index_cell]; if (c.contains(p->coord[j].xyz, p->coord[j].uvw, p->surface)) { if (index_cell != p->coord[j].cell) { std::stringstream err_msg; err_msg << "Overlapping cells detected: " << c.id_ << ", " - << cells[p->coord[j].cell]->id_ << " on universe " + << model::cells[p->coord[j].cell]->id_ << " on universe " << univ.id_; fatal_error(err_msg); } @@ -71,7 +71,7 @@ find_cell(Particle* p, int search_surf) { search_cells = &surfaces[-search_surf-1]->neighbor_neg_; } else { // No surface was indicated, search all cells in the universe. - search_cells = &universes[i_universe]->cells_; + search_cells = &model::universes[i_universe]->cells_; } // Find which cell of this universe the particle is in. @@ -81,17 +81,17 @@ find_cell(Particle* p, int search_surf) { i_cell = (*search_cells)[i]; // Make sure the search cell is in the same universe. - if (cells[i_cell]->universe_ != i_universe) continue; + if (model::cells[i_cell]->universe_ != i_universe) continue; Position r {p->coord[p->n_coord-1].xyz}; Direction u {p->coord[p->n_coord-1].uvw}; int32_t surf = p->surface; - if (cells[i_cell]->contains(r, u, surf)) { + if (model::cells[i_cell]->contains(r, u, surf)) { p->coord[p->n_coord-1].cell = i_cell; if (settings::verbosity >= 10 || simulation::trace) { std::stringstream msg; - msg << " Entering cell " << cells[i_cell]->id_; + msg << " Entering cell " << model::cells[i_cell]->id_; write_message(msg, 1); } found = true; @@ -100,7 +100,7 @@ find_cell(Particle* p, int search_surf) { } if (found) { - Cell& c {*cells[i_cell]}; + Cell& c {*model::cells[i_cell]}; if (c.type_ == FILL_MATERIAL) { //======================================================================= //! Found a material cell which means this is the lowest coord level. @@ -109,7 +109,7 @@ find_cell(Particle* p, int search_surf) { if (c.material_.size() > 1 || c.sqrtkT_.size() > 1) { int offset = 0; for (int i = 0; i < p->n_coord; i++) { - Cell& c_i {*cells[p->coord[i].cell]}; + Cell& c_i {*model::cells[p->coord[i].cell]}; if (c_i.type_ == FILL_UNIVERSE) { offset += c_i.offset_[c.distribcell_index_]; } else if (c_i.type_ == FILL_LATTICE) { @@ -326,7 +326,7 @@ distance_to_boundary(Particle* p, double* dist, int* surface_crossed, for (int i = 0; i < p->n_coord; i++) { Position r {p->coord[i].xyz}; Direction u {p->coord[i].uvw}; - Cell& c {*cells[p->coord[i].cell]}; + Cell& c {*model::cells[p->coord[i].cell]}; // Find the oncoming surface in this cell and the distance to it. auto surface_distance = c.distance(r, u, p->surface); diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index e3934480b..5662bd8de 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -24,12 +24,12 @@ void adjust_indices() { // Adjust material/fill idices. - for (Cell* c : cells) { + for (Cell* c : model::cells) { if (c->fill_ != C_NONE) { int32_t id = c->fill_; - auto search_univ = universe_map.find(id); + auto search_univ = model::universe_map.find(id); auto search_lat = lattice_map.find(id); - if (search_univ != universe_map.end()) { + if (search_univ != model::universe_map.end()) { c->type_ = FILL_UNIVERSE; c->fill_ = search_univ->second; } else if (search_lat != lattice_map.end()) { @@ -61,9 +61,9 @@ adjust_indices() } // Change cell.universe values from IDs to indices. - for (Cell* c : cells) { - auto search = universe_map.find(c->universe_); - if (search != universe_map.end()) { + for (Cell* c : model::cells) { + auto search = model::universe_map.find(c->universe_); + if (search != model::universe_map.end()) { c->universe_ = search->second; } else { std::stringstream err_msg; @@ -84,7 +84,7 @@ adjust_indices() void assign_temperatures() { - for (Cell* c : cells) { + for (Cell* c : model::cells) { // Ignore non-material cells and cells with defined temperature. if (c->material_.size() == 0) continue; if (c->sqrtkT_.size() > 0) continue; @@ -117,7 +117,7 @@ find_root_universe() { // Find all the universes listed as a cell fill. std::unordered_set fill_univ_ids; - for (Cell* c : cells) { + for (Cell* c : model::cells) { fill_univ_ids.insert(c->fill_); } @@ -134,8 +134,8 @@ find_root_universe() // Figure out which universe is not in the set. This is the root universe. bool root_found {false}; int32_t root_univ; - for (int32_t i = 0; i < universes.size(); i++) { - auto search = fill_univ_ids.find(universes[i]->id_); + for (int32_t i = 0; i < model::universes.size(); i++) { + auto search = fill_univ_ids.find(model::universes[i]->id_); if (search == fill_univ_ids.end()) { if (root_found) { fatal_error("Two or more universes are not used as fill universes, so " @@ -160,8 +160,8 @@ neighbor_lists() { write_message("Building neighboring cells lists for each surface...", 6); - for (int i = 0; i < cells.size(); i++) { - for (auto token : cells[i]->region_) { + for (int i = 0; i < model::cells.size(); i++) { + for (auto token : model::cells[i]->region_) { // Skip operator tokens. if (std::abs(token) >= OP_UNION) continue; @@ -196,8 +196,8 @@ prepare_distribcell() // Find all cells with distributed materials or temperatures. Make sure that // the number of materials/temperatures matches the number of cell instances. - for (int i = 0; i < cells.size(); i++) { - Cell& c {*cells[i]}; + for (int i = 0; i < model::cells.size(); i++) { + Cell& c {*model::cells[i]}; if (c.material_.size() > 1) { if (c.material_.size() != c.n_instances_) { @@ -228,10 +228,10 @@ prepare_distribcell() // unique distribcell array index. int distribcell_index = 0; std::vector target_univ_ids; - for (Universe* u : universes) { + for (Universe* u : model::universes) { for (auto cell_indx : u->cells_) { if (distribcells.find(cell_indx) != distribcells.end()) { - cells[cell_indx]->distribcell_index_ = distribcell_index; + model::cells[cell_indx]->distribcell_index_ = distribcell_index; target_univ_ids.push_back(u->id_); ++distribcell_index; } @@ -240,7 +240,7 @@ prepare_distribcell() // Allocate the cell and lattice offset tables. int n_maps = target_univ_ids.size(); - for (Cell* c : cells) { + for (Cell* c : model::cells) { if (c->type_ != FILL_MATERIAL) { c->offset_.resize(n_maps, C_NONE); } @@ -252,10 +252,10 @@ prepare_distribcell() // Fill the cell and lattice offset tables. for (int map = 0; map < target_univ_ids.size(); map++) { auto target_univ_id = target_univ_ids[map]; - for (Universe* univ : universes) { + for (Universe* univ : model::universes) { int32_t offset {0}; // TODO: is this a bug? It matches F90 implementation. for (int32_t cell_indx : univ->cells_) { - Cell& c = *cells[cell_indx]; + Cell& c = *model::cells[cell_indx]; if (c.type_ == FILL_UNIVERSE) { c.offset_[map] = offset; @@ -276,8 +276,8 @@ prepare_distribcell() void count_cell_instances(int32_t univ_indx) { - for (int32_t cell_indx : universes[univ_indx]->cells_) { - Cell& c = *cells[cell_indx]; + for (int32_t cell_indx : model::universes[univ_indx]->cells_) { + Cell& c = *model::cells[cell_indx]; ++c.n_instances_; if (c.type_ == FILL_UNIVERSE) { @@ -300,13 +300,13 @@ int count_universe_instances(int32_t search_univ, int32_t target_univ_id) { // If this is the target, it can't contain itself. - if (universes[search_univ]->id_ == target_univ_id) { + if (model::universes[search_univ]->id_ == target_univ_id) { return 1; } int count {0}; - for (int32_t cell_indx : universes[search_univ]->cells_) { - Cell& c = *cells[cell_indx]; + for (int32_t cell_indx : model::universes[search_univ]->cells_) { + Cell& c = *model::cells[cell_indx]; if (c.type_ == FILL_UNIVERSE) { int32_t next_univ = c.fill_; @@ -338,7 +338,7 @@ distribcell_path_inner(int32_t target_cell, int32_t map, int32_t target_offset, // write to the path and return. for (int32_t cell_indx : search_univ.cells_) { if ((cell_indx == target_cell) && (offset == target_offset)) { - Cell& c = *cells[cell_indx]; + Cell& c = *model::cells[cell_indx]; path << "c" << c.id_; return path.str(); } @@ -350,7 +350,7 @@ distribcell_path_inner(int32_t target_cell, int32_t map, int32_t target_offset, std::vector::const_reverse_iterator cell_it {search_univ.cells_.crbegin()}; for (; cell_it != search_univ.cells_.crend(); ++cell_it) { - Cell& c = *cells[*cell_it]; + Cell& c = *model::cells[*cell_it]; // Material cells don't contain other cells so ignore them. if (c.type_ != FILL_MATERIAL) { @@ -370,14 +370,14 @@ distribcell_path_inner(int32_t target_cell, int32_t map, int32_t target_offset, } // Add the cell to the path string. - Cell& c = *cells[*cell_it]; + Cell& c = *model::cells[*cell_it]; path << "c" << c.id_ << "->"; if (c.type_ == FILL_UNIVERSE) { // Recurse into the fill cell. offset += c.offset_[map]; path << distribcell_path_inner(target_cell, map, target_offset, - *universes[c.fill_], offset); + *model::universes[c.fill_], offset); return path.str(); } else { // Recurse into the lattice cell. @@ -390,7 +390,7 @@ distribcell_path_inner(int32_t target_cell, int32_t map, int32_t target_offset, offset = temp_offset; path << "(" << lat.index_to_string(it.indx_) << ")->"; path << distribcell_path_inner(target_cell, map, target_offset, - *universes[*it], offset); + *model::universes[*it], offset); return path.str(); } } @@ -401,7 +401,7 @@ distribcell_path_inner(int32_t target_cell, int32_t map, int32_t target_offset, std::string distribcell_path(int32_t target_cell, int32_t map, int32_t target_offset) { - auto& root_univ = *universes[openmc_root_universe]; + auto& root_univ = *model::universes[openmc_root_universe]; return distribcell_path_inner(target_cell, map, target_offset, root_univ, 0); } @@ -412,8 +412,8 @@ maximum_levels(int32_t univ) { int levels_below {0}; - for (int32_t cell_indx : universes[univ]->cells_) { - Cell& c = *cells[cell_indx]; + for (int32_t cell_indx : model::universes[univ]->cells_) { + Cell& c = *model::cells[cell_indx]; if (c.type_ == FILL_UNIVERSE) { int32_t next_univ = c.fill_; levels_below = std::max(levels_below, maximum_levels(next_univ)); @@ -435,14 +435,14 @@ maximum_levels(int32_t univ) void free_memory_geometry_c() { - for (Cell* c : cells) {delete c;} - cells.clear(); - cell_map.clear(); - n_cells = 0; + for (Cell* c : model::cells) {delete c;} + model::cells.clear(); + model::cell_map.clear(); + model::n_cells = 0; - for (Universe* u : universes) {delete u;} - universes.clear(); - universe_map.clear(); + for (Universe* u : model::universes) {delete u;} + model::universes.clear(); + model::universe_map.clear(); for (Lattice* lat : lattices) {delete lat;} lattices.clear(); diff --git a/src/lattice.cpp b/src/lattice.cpp index 14b679903..1df21774f 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -65,8 +65,8 @@ Lattice::adjust_indices() // Adjust the indices for the universes array. for (LatticeIter it = begin(); it != end(); ++it) { int uid = *it; - auto search = universe_map.find(uid); - if (search != universe_map.end()) { + auto search = model::universe_map.find(uid); + if (search != model::universe_map.end()) { *it = search->second; } else { std::stringstream err_msg; @@ -78,8 +78,8 @@ Lattice::adjust_indices() // Adjust the index for the outer universe. if (outer_ != NO_OUTER_UNIVERSE) { - auto search = universe_map.find(outer_); - if (search != universe_map.end()) { + auto search = model::universe_map.find(outer_); + if (search != model::universe_map.end()) { outer_ = search->second; } else { std::stringstream err_msg; @@ -118,7 +118,7 @@ Lattice::to_hdf5(hid_t lattices_group) const } if (outer_ != NO_OUTER_UNIVERSE) { - int32_t outer_id = universes[outer_]->id_; + int32_t outer_id = model::universes[outer_]->id_; write_dataset(lat_group, "outer", outer_id); } else { write_dataset(lat_group, "outer", outer_); @@ -370,7 +370,7 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const for (int j = 0; j < nx; j++) { int indx1 = nx*ny*m + nx*k + j; int indx2 = nx*ny*m + nx*(ny-k-1) + j; - out[indx2] = universes[universes_[indx1]]->id_; + out[indx2] = model::universes[universes_[indx1]]->id_; } } } @@ -387,7 +387,7 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const for (int j = 0; j < nx; j++) { int indx1 = nx*k + j; int indx2 = nx*(ny-k-1) + j; - out[indx2] = universes[universes_[indx1]]->id_; + out[indx2] = model::universes[universes_[indx1]]->id_; } } @@ -847,7 +847,7 @@ HexLattice::to_hdf5_inner(hid_t lat_group) const // This array position is never used; put a -1 to indicate this. out[indx] = -1; } else { - out[indx] = universes[universes_[indx]]->id_; + out[indx] = model::universes[universes_[indx]]->id_; } } } diff --git a/src/output.cpp b/src/output.cpp index 13db31144..79c3f7f0b 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -140,11 +140,11 @@ print_overlap_check() { std::cout << " Cell ID No. Overlap Checks\n"; std::vector sparse_cell_ids; - for (int i = 0; i < n_cells; i++) { - std::cout << " " << std::setw(8) << cells[i]->id_ << std::setw(17) + for (int i = 0; i < model::n_cells; i++) { + std::cout << " " << std::setw(8) << model::cells[i]->id_ << std::setw(17) << overlap_check_count[i] << "\n"; if (overlap_check_count[i] < 10) { - sparse_cell_ids.push_back(cells[i]->id_); + sparse_cell_ids.push_back(model::cells[i]->id_); } } diff --git a/src/plot.cpp b/src/plot.cpp index 45529ba97..403b27884 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -362,8 +362,8 @@ Plot::set_default_colors(pugi::xml_node plot_node) } if ("cell" == pl_color_by) { color_by_ = PlotColorBy::cells; - colors_.resize(n_cells); - for (int i = 0; i < n_cells; i++) { + colors_.resize(model::n_cells); + for (int i = 0; i < model::n_cells; i++) { colors_[i] = random_color(); } @@ -413,8 +413,8 @@ Plot::set_user_colors(pugi::xml_node plot_node) } // Add RGB if (PlotColorBy::cells == color_by_) { - if (cell_map.find(col_id) != cell_map.end()) { - col_id = cell_map[col_id]; + if (model::cell_map.find(col_id) != model::cell_map.end()) { + col_id = model::cell_map[col_id]; colors_[col_id] = user_rgb; } else { std::stringstream err_msg; @@ -576,8 +576,8 @@ Plot::set_mask(pugi::xml_node plot_node) // in the cell and material arrays for (auto& col_id : iarray) { if (PlotColorBy::cells == color_by_) { - if (cell_map.find(col_id) != cell_map.end()) { - col_id = cell_map[col_id]; + if (model::cell_map.find(col_id) != model::cell_map.end()) { + col_id = model::cell_map[col_id]; } else { std::stringstream err_msg; @@ -661,7 +661,7 @@ void position_rgb(Particle p, Plot pl, RGBColor& rgb, int& id) } else { if (PlotColorBy::mats == pl.color_by_) { // Assign color based on material - Cell* c = cells[p.coord[j].cell]; + Cell* c = model::cells[p.coord[j].cell]; if (c->type_ == FILL_UNIVERSE) { // If we stopped on a middle universe level, treat as if not found rgb = pl.not_found_; @@ -677,7 +677,7 @@ void position_rgb(Particle p, Plot pl, RGBColor& rgb, int& id) } else if (PlotColorBy::cells == pl.color_by_) { // Assign color based on cell rgb = pl.colors_[p.coord[j].cell]; - id = cells[p.coord[j].cell]->id_; + id = model::cells[p.coord[j].cell]->id_; } } // endif found_cell } diff --git a/src/source.cpp b/src/source.cpp index 315ff2cdd..782fb97a2 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -167,7 +167,7 @@ Bank SourceDistribution::sample() const if (space_box) { if (space_box->only_fissionable()) { // Determine material - auto c = cells[cell_index - 1]; + auto c = model::cells[cell_index - 1]; int32_t mat_index = c->material_[instance]; auto m = materials[mat_index]; diff --git a/src/summary.cpp b/src/summary.cpp index d2f083657..8431e2a5f 100644 --- a/src/summary.cpp +++ b/src/summary.cpp @@ -10,7 +10,7 @@ extern "C" void write_geometry(hid_t file_id) { auto geom_group = create_group(file_id, "geometry"); - + #ifdef DAGMC if (settings::dagmc) { write_attribute(geom_group, "dagmc", 1); @@ -18,13 +18,13 @@ write_geometry(hid_t file_id) { } #endif - write_attribute(geom_group, "n_cells", cells.size()); + write_attribute(geom_group, "n_cells", model::cells.size()); write_attribute(geom_group, "n_surfaces", surfaces.size()); - write_attribute(geom_group, "n_universes", universes.size()); + write_attribute(geom_group, "n_universes", model::universes.size()); write_attribute(geom_group, "n_lattices", lattices.size()); auto cells_group = create_group(geom_group, "cells"); - for (Cell* c : cells) c->to_hdf5(cells_group); + for (Cell* c : model::cells) c->to_hdf5(cells_group); close_group(cells_group); auto surfaces_group = create_group(geom_group, "surfaces"); @@ -32,7 +32,7 @@ write_geometry(hid_t file_id) { close_group(surfaces_group); auto universes_group = create_group(geom_group, "universes"); - for (Universe* u : universes) u->to_hdf5(universes_group); + for (Universe* u : model::universes) u->to_hdf5(universes_group); close_group(universes_group); auto lattices_group = create_group(geom_group, "lattices"); diff --git a/src/tallies/filter_cell.cpp b/src/tallies/filter_cell.cpp index 9e0a6721e..12dc38df1 100644 --- a/src/tallies/filter_cell.cpp +++ b/src/tallies/filter_cell.cpp @@ -21,8 +21,8 @@ CellFilter::initialize() { // Convert cell IDs to indices of the global array. for (auto& c : cells_) { - auto search = cell_map.find(c); - if (search != cell_map.end()) { + auto search = model::cell_map.find(c); + if (search != model::cell_map.end()) { c = search->second; } else { std::stringstream err_msg; @@ -56,7 +56,7 @@ CellFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); std::vector cell_ids; - for (auto c : cells_) cell_ids.push_back(cells[c]->id_); + for (auto c : cells_) cell_ids.push_back(model::cells[c]->id_); write_dataset(filter_group, "bins", cell_ids); } @@ -64,7 +64,7 @@ std::string CellFilter::text_label(int bin) const { //TODO: off-by-one - return "Cell " + std::to_string(cells[cells_[bin-1]]->id_); + return "Cell " + std::to_string(model::cells[cells_[bin-1]]->id_); } //============================================================================== diff --git a/src/tallies/filter_cellborn.cpp b/src/tallies/filter_cellborn.cpp index 4f86ad34c..b173b2e39 100644 --- a/src/tallies/filter_cellborn.cpp +++ b/src/tallies/filter_cellborn.cpp @@ -20,7 +20,7 @@ std::string CellbornFilter::text_label(int bin) const { //TODO: off-by-one - return "Birth Cell " + std::to_string(cells[cells_[bin-1]]->id_); + return "Birth Cell " + std::to_string(model::cells[cells_[bin-1]]->id_); } } // namespace openmc diff --git a/src/tallies/filter_cellfrom.cpp b/src/tallies/filter_cellfrom.cpp index b4b1a57ef..1262ebecd 100644 --- a/src/tallies/filter_cellfrom.cpp +++ b/src/tallies/filter_cellfrom.cpp @@ -22,7 +22,7 @@ std::string CellFromFilter::text_label(int bin) const { //TODO: off-by-one - return "Cell from " + std::to_string(cells[cells_[bin-1]]->id_); + return "Cell from " + std::to_string(model::cells[cells_[bin-1]]->id_); } } // namespace openmc diff --git a/src/tallies/filter_distribcell.cpp b/src/tallies/filter_distribcell.cpp index 39459672f..8af01b906 100644 --- a/src/tallies/filter_distribcell.cpp +++ b/src/tallies/filter_distribcell.cpp @@ -22,10 +22,10 @@ void DistribcellFilter::initialize() { // Convert the cell ID to an index of the global array. - auto search = cell_map.find(cell_); - if (search != cell_map.end()) { + auto search = model::cell_map.find(cell_); + if (search != model::cell_map.end()) { cell_ = search->second; - n_bins_ = cells[cell_]->n_instances_; + n_bins_ = model::cells[cell_]->n_instances_; } else { std::stringstream err_msg; err_msg << "Could not find cell " << cell_ @@ -39,9 +39,9 @@ DistribcellFilter::get_all_bins(const Particle* p, int estimator, FilterMatch& match) const { int offset = 0; - auto distribcell_index = cells[cell_]->distribcell_index_; + auto distribcell_index = model::cells[cell_]->distribcell_index_; for (int i = 0; i < p->n_coord; i++) { - auto& c {*cells[p->coord[i].cell]}; + auto& c {*model::cells[p->coord[i].cell]}; if (c.type_ == FILL_UNIVERSE) { offset += c.offset_[distribcell_index]; } else if (c.type_ == FILL_LATTICE) { @@ -66,13 +66,13 @@ void DistribcellFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); - write_dataset(filter_group, "bins", cells[cell_]->id_); + write_dataset(filter_group, "bins", model::cells[cell_]->id_); } std::string DistribcellFilter::text_label(int bin) const { - auto map = cells[cell_]->distribcell_index_; + auto map = model::cells[cell_]->distribcell_index_; //TODO: off-by-one auto path = distribcell_path(cell_, map, bin-1); return "Distributed Cell " + path; diff --git a/src/tallies/filter_universe.cpp b/src/tallies/filter_universe.cpp index 05d8c3e0d..ecd12b237 100644 --- a/src/tallies/filter_universe.cpp +++ b/src/tallies/filter_universe.cpp @@ -20,8 +20,8 @@ UniverseFilter::initialize() { // Convert universe IDs to indices of the global array. for (auto& u : universes_) { - auto search = universe_map.find(u); - if (search != universe_map.end()) { + auto search = model::universe_map.find(u); + if (search != model::universe_map.end()) { u = search->second; } else { std::stringstream err_msg; @@ -56,7 +56,7 @@ UniverseFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); std::vector universe_ids; - for (auto u : universes_) universe_ids.push_back(universes[u]->id_); + for (auto u : universes_) universe_ids.push_back(model::universes[u]->id_); write_dataset(filter_group, "bins", universe_ids); } @@ -64,7 +64,7 @@ std::string UniverseFilter::text_label(int bin) const { //TODO: off-by-one - return "Universe " + std::to_string(universes[universes_[bin-1]]->id_); + return "Universe " + std::to_string(model::universes[universes_[bin-1]]->id_); } } // namespace openmc