mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Incorporating @paulromano's comments
This commit is contained in:
parent
59552944f5
commit
775cc1ae19
4 changed files with 17 additions and 17 deletions
|
|
@ -5,7 +5,6 @@
|
|||
#include <functional> // for hash
|
||||
#include <limits>
|
||||
#include <memory> // for unique_ptr
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
|
@ -153,12 +152,12 @@ public:
|
|||
//! Get all cell instances contained by this cell
|
||||
//! \return Map with cell indexes as keys and instances as values
|
||||
std::unordered_map<int32_t, std::vector<int32_t>>
|
||||
get_contained_cells();
|
||||
get_contained_cells() const;
|
||||
|
||||
protected:
|
||||
void
|
||||
get_contained_cells_inner(std::unordered_map<int32_t, std::vector<int32_t>>& contained_cells,
|
||||
std::vector<ParentCell>& parent_cells);
|
||||
std::vector<ParentCell>& parent_cells) const;
|
||||
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public:
|
|||
//! \param indx The index for a lattice tile.
|
||||
//! \return Distribcell offset i.e. the largest instance number for the target
|
||||
//! cell found in the geometry tree for this lattice index.
|
||||
virtual int32_t& offset(int map, int indx) = 0;
|
||||
virtual int32_t offset(int map, int indx) const = 0;
|
||||
|
||||
//! \brief Convert an array index to a useful human-readable string.
|
||||
//! \param indx The index for a lattice tile.
|
||||
|
|
@ -227,7 +227,7 @@ public:
|
|||
|
||||
int32_t& offset(int map, const int i_xyz[3]);
|
||||
|
||||
int32_t& offset(int map, int indx);
|
||||
int32_t offset(int map, int indx) const;
|
||||
|
||||
std::string index_to_string(int indx) const;
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ public:
|
|||
|
||||
int32_t& offset(int map, const int i_xyz[3]);
|
||||
|
||||
int32_t& offset(int map, int indx);
|
||||
int32_t offset(int map, int indx) const;
|
||||
|
||||
std::string index_to_string(int indx) const;
|
||||
|
||||
|
|
|
|||
15
src/cell.cpp
15
src/cell.cpp
|
|
@ -5,6 +5,7 @@
|
|||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
|
|
@ -275,8 +276,8 @@ Cell::set_temperature(double T, int32_t instance, bool set_contained)
|
|||
auto& cell = model::cells[entry.first];
|
||||
Expects(cell->type_ == Fill::MATERIAL);
|
||||
auto& instances = entry.second;
|
||||
for (auto instance = instances.begin(); instance != instances.end(); ++instance) {
|
||||
cell->set_temperature(T, *instance);
|
||||
for (auto instance : instances) {
|
||||
cell->set_temperature(T, instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1176,7 +1177,7 @@ openmc_cell_set_name(int32_t index, const char* name) {
|
|||
|
||||
|
||||
std::unordered_map<int32_t, std::vector<int32_t>>
|
||||
Cell::get_contained_cells() {
|
||||
Cell::get_contained_cells() const {
|
||||
std::unordered_map<int32_t, std::vector<int32_t>> contained_cells;
|
||||
std::vector<ParentCell> parent_cells;
|
||||
|
||||
|
|
@ -1191,20 +1192,20 @@ Cell::get_contained_cells() {
|
|||
//! Get all cells within this cell
|
||||
void
|
||||
Cell::get_contained_cells_inner(std::unordered_map<int32_t, std::vector<int32_t>>& contained_cells,
|
||||
std::vector<ParentCell>& parent_cells)
|
||||
std::vector<ParentCell>& parent_cells) const
|
||||
{
|
||||
|
||||
// filled by material, determine instance based on parent cells
|
||||
if (this->type_ == Fill::MATERIAL) {
|
||||
int instance = 0;
|
||||
if (this->distribcell_index_ >= 0) {
|
||||
for (int i = 0; i < parent_cells.size(); i++) {
|
||||
auto& cell = model::cells[parent_cells[i].cell_index];
|
||||
for (auto& parent_cell : parent_cells) {
|
||||
auto& cell = openmc::model::cells[parent_cell.cell_index];
|
||||
if (cell->type_ == Fill::UNIVERSE) {
|
||||
instance += cell->offset_[this->distribcell_index_];
|
||||
} else if (cell->type_ == Fill::LATTICE) {
|
||||
auto& lattice = model::lattices[cell->fill_];
|
||||
instance += lattice->offset(this->distribcell_index_, parent_cells[i].lattice_index);
|
||||
instance += lattice->offset(this->distribcell_index_, parent_cell.lattice_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,8 +342,8 @@ RectLattice::offset(int map, const int i_xyz[3])
|
|||
|
||||
//==============================================================================
|
||||
|
||||
int32_t&
|
||||
RectLattice::offset(int map, int indx)
|
||||
int32_t
|
||||
RectLattice::offset(int map, int indx) const
|
||||
{
|
||||
return offsets_[nx*ny*nz*map + indx];
|
||||
}
|
||||
|
|
@ -981,8 +981,8 @@ HexLattice::offset(int map, const int i_xyz[3])
|
|||
return offsets_[nx*ny*nz*map + nx*ny*i_xyz[2] + nx*i_xyz[1] + i_xyz[0]];
|
||||
}
|
||||
|
||||
int32_t&
|
||||
HexLattice::offset(int map, int indx)
|
||||
int32_t
|
||||
HexLattice::offset(int map, int indx) const
|
||||
{
|
||||
int nx {2*n_rings_ - 1};
|
||||
int ny {2*n_rings_ - 1};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue