diff --git a/CMakeLists.txt b/CMakeLists.txt index f943d0969..930b1e0bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,9 +20,6 @@ option(optimize "Turn on all compiler optimization flags" OFF) option(coverage "Compile with coverage analysis flags" OFF) option(dagmc "Enable support for DAGMC (CAD) geometry" OFF) -# Maximum number of nested coordinates levels -set(maxcoord 10 CACHE STRING "Maximum number of nested coordinate levels") - #=============================================================================== # MPI for distributed-memory parallelism #=============================================================================== @@ -260,7 +257,6 @@ target_include_directories(libopenmc # Set compile flags target_compile_options(libopenmc PRIVATE ${cxxflags}) -target_compile_definitions(libopenmc PUBLIC -DMAX_COORD=${maxcoord}) if (HDF5_IS_PARALLEL) target_compile_definitions(libopenmc PRIVATE -DPHDF5) endif() diff --git a/docs/source/usersguide/install.rst b/docs/source/usersguide/install.rst index d44ee9594..96b4f5024 100644 --- a/docs/source/usersguide/install.rst +++ b/docs/source/usersguide/install.rst @@ -243,9 +243,6 @@ coverage Compile and link code instrumented for coverage analysis. This is typically used in conjunction with gcov_. -maxcoord - Maximum number of nested coordinate levels in geometry. Defaults to 10. - To set any of these options (e.g. turning on debug mode), the following form should be used: diff --git a/include/openmc/geometry.h b/include/openmc/geometry.h index a2da2c5f2..9bb1a9ae7 100644 --- a/include/openmc/geometry.h +++ b/include/openmc/geometry.h @@ -15,7 +15,8 @@ namespace openmc { namespace model { -extern "C" int root_universe; +extern int root_universe; //!< Index of root universe +extern int n_coord_levels; //!< Number of CSG coordinate levels extern std::vector overlap_check_count; diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index 5898c61f3..ffcdcf885 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -57,7 +57,7 @@ void finalize_geometry(std::vector>& nuc_temps, //! \return The index of the root universe. //============================================================================== -extern "C" int32_t find_root_universe(); +int32_t find_root_universe(); //============================================================================== //! Populate all data structures needed for distribcells. @@ -74,7 +74,7 @@ void prepare_distribcell(); //! the root universe). //============================================================================== -extern "C" void count_cell_instances(int32_t univ_indx); +void count_cell_instances(int32_t univ_indx); //============================================================================== //! Recursively search through universes and count universe instances. @@ -84,8 +84,7 @@ extern "C" void count_cell_instances(int32_t univ_indx); //! search_univ. //============================================================================== -extern "C" int -count_universe_instances(int32_t search_univ, int32_t target_univ_id); +int count_universe_instances(int32_t search_univ, int32_t target_univ_id); //============================================================================== //! Build a character array representing the path to a distribcell instance. @@ -107,7 +106,7 @@ distribcell_path(int32_t target_cell, int32_t map, int32_t target_offset); //! \return The number of coordinate levels. //============================================================================== -extern "C" int maximum_levels(int32_t univ); +int maximum_levels(int32_t univ); //============================================================================== //! Deallocates global vectors and maps for cells, universes, and lattices. diff --git a/include/openmc/particle.h b/include/openmc/particle.h index 2130b6454..ef1e076bb 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -229,11 +229,11 @@ public: int n_coord_ {1}; //!< number of current coordinate levels int cell_instance_; //!< offset for distributed properties - LocalCoord coord_[MAX_COORD]; //!< coordinates for all levels + std::vector coord_; //!< coordinates for all levels // Particle coordinates before crossing a surface int n_coord_last_ {1}; //!< number of current coordinates - int cell_last_[MAX_COORD]; //!< coordinates for all levels + std::vector cell_last_; //!< coordinates for all levels // Energy data double E_; //!< post-collision energy in eV diff --git a/src/geometry.cpp b/src/geometry.cpp index 3c1c11b0e..cde2cdc1b 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -22,6 +22,7 @@ namespace openmc { namespace model { int root_universe {-1}; +int n_coord_levels; std::vector overlap_check_count; @@ -257,7 +258,7 @@ find_cell(Particle* p, bool use_neighbor_lists) } // Reset all the deeper coordinate levels. - for (int i = p->n_coord_; i < MAX_COORD; i++) { + for (int i = p->n_coord_; i < p->coord_.size(); i++) { p->coord_[i].reset(); } diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index c560743f8..e19b5f946 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -217,14 +217,8 @@ void finalize_geometry(std::vector>& nuc_temps, // Determine desired temperatures for each nuclide and S(a,b) table get_temperatures(nuc_temps, thermal_temps); - // Check to make sure there are not too many nested coordinate levels in the - // geometry since the coordinate list is statically allocated for performance - // reasons - if (maximum_levels(model::root_universe) > MAX_COORD) { - fatal_error("Too many nested coordinate levels in the geometry. " - "Try increasing the maximum number of coordinate levels by " - "providing the CMake -Dmaxcoord= option."); - } + // Determine number of nested coordinate levels in the geometry + model::n_coord_levels = maximum_levels(model::root_universe); } //============================================================================== diff --git a/src/particle.cpp b/src/particle.cpp index 88ff251dd..c6f73f4f1 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -50,7 +50,9 @@ LocalCoord::reset() Particle::Particle() { - // Clear coordinate lists + // Create and clear coordinate levels + coord_.resize(model::n_coord_levels); + cell_last_.resize(model::n_coord_levels); clear(); for (int& n : n_delayed_bank_) {