OpenMC/include/openmc/geometry_aux.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

147 lines
6 KiB
C
Raw Permalink Normal View History

2018-05-21 16:32:44 -04:00
//! \file geometry_aux.h
//! Auxilary functions for geometry initialization and general data handling.
#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>
#include <unordered_map>
#include <vector>
2018-05-21 16:32:44 -04:00
#include "openmc/vector.h"
#include "openmc/xml_interface.h"
2018-05-21 16:32:44 -04:00
namespace openmc {
namespace model {
extern std::unordered_map<int32_t, int32_t> universe_level_counts;
} // namespace model
2018-05-21 16:32:44 -04:00
//! Read geometry from XML file
2019-02-15 06:35:59 -06:00
void read_geometry_xml();
//! Read geometry from XML node
2022-12-07 11:02:10 -06:00
//! \param[in] root node of geometry XML element
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();
//==============================================================================
//! 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
//==============================================================================
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.
//! \return The index of the root universe.
2018-05-21 16:32:44 -04: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.
//! \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
//==============================================================================
void prepare_distribcell(
const std::vector<int32_t>* user_distribcells = nullptr);
2018-05-21 16:32:44 -04:00
//==============================================================================
//! Recursively search through the geometry and count universe instances.
2018-05-21 16:32:44 -04:00
//!
//! This function will update Universe.n_instances_ for each
//! universe in the geometry.
2018-05-21 16:32:44 -04:00
//==============================================================================
void count_universe_instances();
2018-05-21 16:32:44 -04:00
//==============================================================================
//! Recursively search through universes and count universe instances.
//! \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.
//! \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.
//! \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.
//! \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.
//! \param univ The index of the universe to begin seraching from (probably the
2018-05-21 19:36:07 -04:00
//! root universe).
//! \return The number of coordinate levels.
2018-05-21 19:36:07 -04:00
//==============================================================================
int maximum_levels(int32_t univ);
2018-05-21 19:36:07 -04: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);
//==============================================================================
//! Deallocates global vectors and maps for cells, universes, and lattices.
//==============================================================================
2019-02-21 08:32:32 -06:00
void free_memory_geometry();
2018-05-21 16:32:44 -04:00
} // namespace openmc
#endif // OPENMC_GEOMETRY_AUX_H