2018-05-21 16:32:44 -04:00
|
|
|
//! \file geometry_aux.h
|
|
|
|
|
//! Auxilary functions for geometry initialization and general data handling.
|
|
|
|
|
|
2018-08-20 14:40:32 -05:00
|
|
|
#ifndef OPENMC_GEOMETRY_AUX_H
|
|
|
|
|
#define OPENMC_GEOMETRY_AUX_H
|
2018-05-21 16:32:44 -04:00
|
|
|
|
|
|
|
|
#include <cstdint>
|
2018-10-11 22:27:13 -04:00
|
|
|
#include <string>
|
2019-11-08 14:43:35 -06:00
|
|
|
#include <unordered_map>
|
2021-08-10 08:06:54 -05:00
|
|
|
#include <vector>
|
2018-05-21 16:32:44 -04:00
|
|
|
|
2021-04-22 16:46:23 -04:00
|
|
|
#include "openmc/vector.h"
|
2022-11-03 20:10:22 -05:00
|
|
|
#include "openmc/xml_interface.h"
|
2021-04-22 16:46:23 -04:00
|
|
|
|
2018-05-21 16:32:44 -04:00
|
|
|
namespace openmc {
|
2019-10-07 00:11:51 -05:00
|
|
|
|
2019-11-06 16:07:28 -06:00
|
|
|
namespace model {
|
2019-11-08 14:43:35 -06:00
|
|
|
extern std::unordered_map<int32_t, int32_t> universe_level_counts;
|
2019-11-06 16:07:28 -06:00
|
|
|
} // namespace model
|
2018-05-21 16:32:44 -04:00
|
|
|
|
2022-11-03 20:10:22 -05:00
|
|
|
//! Read geometry from XML file
|
2019-02-15 06:35:59 -06:00
|
|
|
void read_geometry_xml();
|
|
|
|
|
|
2022-11-03 20:10:22 -05:00
|
|
|
//! Read geometry from XML node
|
2022-12-07 11:02:10 -06:00
|
|
|
//! \param[in] root node of geometry XML element
|
2022-11-03 20:10:22 -05:00
|
|
|
void read_geometry_xml(pugi::xml_node root);
|
|
|
|
|
|
2018-05-21 16:32:44 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Replace Universe, Lattice, and Material IDs with indices.
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2019-01-23 10:35:28 -06:00
|
|
|
void adjust_indices();
|
2018-05-21 16:32:44 -04:00
|
|
|
|
2018-08-19 14:57:28 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Assign defaults to cells with undefined temperatures.
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2019-01-23 10:35:28 -06:00
|
|
|
void assign_temperatures();
|
|
|
|
|
|
2025-09-18 23:11:06 -05:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Finalize densities (compute density multipliers).
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
void finalize_cell_densities();
|
|
|
|
|
|
2019-01-23 10:35:28 -06:00
|
|
|
//==============================================================================
|
|
|
|
|
//! \brief Obtain a list of temperatures that each nuclide/thermal scattering
|
|
|
|
|
//! table appears at in the model. Later, this list is used to determine the
|
|
|
|
|
//! actual temperatures to read (which may be different if interpolation is
|
|
|
|
|
//! used)
|
|
|
|
|
//!
|
|
|
|
|
//! \param[out] nuc_temps Vector of temperatures for each nuclide
|
|
|
|
|
//! \param[out] thermal_temps Vector of tempratures for each thermal scattering
|
|
|
|
|
//! table
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2021-04-29 16:23:54 -04:00
|
|
|
void get_temperatures(
|
|
|
|
|
vector<vector<double>>& nuc_temps, vector<vector<double>>& thermal_temps);
|
2019-01-23 10:35:28 -06:00
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
//! \brief Perform final setup for geometry
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2021-01-29 14:33:43 +00:00
|
|
|
void finalize_geometry();
|
2018-08-19 14:57:28 -04:00
|
|
|
|
2018-05-21 16:32:44 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Figure out which Universe is the root universe.
|
|
|
|
|
//!
|
|
|
|
|
//! This function looks for a universe that is not listed in a Cell::fill or in
|
|
|
|
|
//! a Lattice.
|
2018-10-22 10:22:55 -04:00
|
|
|
//! \return The index of the root universe.
|
2018-05-21 16:32:44 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
|
2019-03-18 12:26:53 -05:00
|
|
|
int32_t find_root_universe();
|
2018-05-21 16:32:44 -04:00
|
|
|
|
|
|
|
|
//==============================================================================
|
2018-08-19 18:39:28 -04:00
|
|
|
//! Populate all data structures needed for distribcells.
|
2021-08-05 17:03:37 -05:00
|
|
|
//! \param user_distribcells A set of cell indices to create distribcell data
|
|
|
|
|
//! structures for regardless of whether or not they are part of a tally
|
|
|
|
|
//! filter.
|
2018-05-21 16:32:44 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
|
2021-08-10 08:06:54 -05:00
|
|
|
void prepare_distribcell(
|
|
|
|
|
const std::vector<int32_t>* user_distribcells = nullptr);
|
2018-05-21 16:32:44 -04:00
|
|
|
|
|
|
|
|
//==============================================================================
|
2025-07-30 20:10:34 +03:00
|
|
|
//! Recursively search through the geometry and count universe instances.
|
2018-05-21 16:32:44 -04:00
|
|
|
//!
|
2025-07-30 20:10:34 +03:00
|
|
|
//! This function will update Universe.n_instances_ for each
|
|
|
|
|
//! universe in the geometry.
|
2018-05-21 16:32:44 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
|
2025-07-30 20:10:34 +03:00
|
|
|
void count_universe_instances();
|
2018-05-21 16:32:44 -04:00
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
//! Recursively search through universes and count universe instances.
|
2018-10-22 10:22:55 -04:00
|
|
|
//! \param search_univ The index of the universe to begin searching from.
|
|
|
|
|
//! \param target_univ_id The ID of the universe to be counted.
|
2020-02-29 19:17:20 -05:00
|
|
|
//! \param univ_count_memo Memoized counts that make this function faster for
|
|
|
|
|
//! large systems. The first call to this function for each target_univ_id
|
|
|
|
|
//! should start with an empty memo.
|
2018-10-22 10:22:55 -04:00
|
|
|
//! \return The number of instances of target_univ_id in the geometry tree under
|
2018-05-21 16:32:44 -04:00
|
|
|
//! search_univ.
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2020-02-29 19:17:20 -05:00
|
|
|
int count_universe_instances(int32_t search_univ, int32_t target_univ_id,
|
|
|
|
|
std::unordered_map<int32_t, int32_t>& univ_count_memo);
|
2018-05-21 16:32:44 -04:00
|
|
|
|
2018-05-25 20:32:17 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Build a character array representing the path to a distribcell instance.
|
2018-10-22 10:22:55 -04:00
|
|
|
//! \param target_cell The index of the Cell in the global Cell array.
|
|
|
|
|
//! \param map The index of the distribcell mapping corresponding to the target
|
2018-05-25 20:32:17 -04:00
|
|
|
//! cell.
|
2018-10-22 10:22:55 -04:00
|
|
|
//! \param target_offset An instance number for a distributed cell.
|
|
|
|
|
//! \return The unique traversal through the geometry tree that leads to the
|
2018-10-11 22:27:13 -04:00
|
|
|
//! desired instance of the target cell.
|
2018-05-25 20:32:17 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
|
2018-10-11 22:27:13 -04:00
|
|
|
std::string distribcell_path(
|
|
|
|
|
int32_t target_cell, int32_t map, int32_t target_offset);
|
2018-05-25 20:32:17 -04:00
|
|
|
|
2018-05-21 19:36:07 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Determine the maximum number of nested coordinate levels in the geometry.
|
2018-10-22 10:22:55 -04:00
|
|
|
//! \param univ The index of the universe to begin seraching from (probably the
|
2018-05-21 19:36:07 -04:00
|
|
|
//! root universe).
|
2018-10-22 10:22:55 -04:00
|
|
|
//! \return The number of coordinate levels.
|
2018-05-21 19:36:07 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
|
2019-03-18 12:26:53 -05:00
|
|
|
int maximum_levels(int32_t univ);
|
2018-05-21 19:36:07 -04:00
|
|
|
|
2023-03-21 16:44:12 -05:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Check whether or not a universe is the root universe using its ID.
|
|
|
|
|
//! \param univ_id The ID of the universe to check.
|
|
|
|
|
//! \return Whether or not it is the root universe.
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
bool is_root_universe(int32_t univ_id);
|
|
|
|
|
|
2018-05-27 14:54:51 -04:00
|
|
|
//==============================================================================
|
|
|
|
|
//! Deallocates global vectors and maps for cells, universes, and lattices.
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2019-02-21 08:32:32 -06:00
|
|
|
void free_memory_geometry();
|
2018-05-27 14:54:51 -04:00
|
|
|
|
2018-05-21 16:32:44 -04:00
|
|
|
} // namespace openmc
|
2018-08-20 14:40:32 -05:00
|
|
|
#endif // OPENMC_GEOMETRY_AUX_H
|