Fixed a bug in distribcell offsets logic (#3424)

This commit is contained in:
GuySten 2025-07-30 20:10:34 +03:00 committed by GitHub
parent 6f5e1347d4
commit a64cc96ed5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 325 additions and 87 deletions

View file

@ -226,6 +226,8 @@ public:
void set_temperature(
double T, int32_t instance = -1, bool set_contained = false);
int32_t n_instances() const;
//! Set the rotation matrix of a cell instance
//! \param[in] rot The rotation matrix of length 3 or 9
void set_rotation(const vector<double>& rot);
@ -312,12 +314,11 @@ public:
//----------------------------------------------------------------------------
// Data members
int32_t id_; //!< Unique ID
std::string name_; //!< User-defined name
Fill type_; //!< Material, universe, or lattice
int32_t universe_; //!< Universe # this cell is in
int32_t fill_; //!< Universe # filling this cell
int32_t n_instances_ {0}; //!< Number of instances of this cell
int32_t id_; //!< Unique ID
std::string name_; //!< User-defined name
Fill type_; //!< Material, universe, or lattice
int32_t universe_; //!< Universe # this cell is in
int32_t fill_; //!< Universe # filling this cell
//! \brief Index corresponding to this cell in distribcell arrays
int distribcell_index_ {C_NONE};

View file

@ -15,8 +15,6 @@
namespace openmc {
namespace model {
extern std::unordered_map<int32_t, std::unordered_map<int32_t, int32_t>>
universe_cell_counts;
extern std::unordered_map<int32_t, int32_t> universe_level_counts;
} // namespace model
@ -80,15 +78,13 @@ void prepare_distribcell(
const std::vector<int32_t>* user_distribcells = nullptr);
//==============================================================================
//! Recursively search through the geometry and count cell instances.
//! Recursively search through the geometry and count universe instances.
//!
//! This function will update the Cell::n_instances value for each cell in the
//! geometry.
//! \param univ_indx The index of the universe to begin searching from (probably
//! the root universe).
//! This function will update Universe.n_instances_ for each
//! universe in the geometry.
//==============================================================================
void count_cell_instances(int32_t univ_indx);
void count_universe_instances();
//==============================================================================
//! Recursively search through universes and count universe instances.

View file

@ -76,7 +76,7 @@ public:
}
//! Populate the distribcell offset tables.
int32_t fill_offset_table(int32_t offset, int32_t target_univ_id, int map,
int32_t fill_offset_table(int32_t target_univ_id, int map,
std::unordered_map<int32_t, int32_t>& univ_count_memo);
//! \brief Check lattice indices.

View file

@ -29,6 +29,7 @@ class Universe {
public:
int32_t id_; //!< Unique ID
vector<int32_t> cells_; //!< Cells within this universe
int32_t n_instances_; //!< Number of instances of this universe
//! \brief Write universe information to an HDF5 group.
//! \param group_id An HDF5 group id.