From c231e197077ac6d10f695f58628af2c9b2c300f9 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Mar 2019 21:55:22 -0500 Subject: [PATCH 01/10] Fix profile option in CMakeLists.txt --- CMakeLists.txt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 930b1e0bb8..15c3cd1b72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,9 +35,6 @@ endif() #=============================================================================== if(dagmc) find_package(DAGMC REQUIRED) - if(NOT DAGMC_FOUND) - message(FATAL_ERROR "Could not find DAGMC installation") - endif() link_directories(${DAGMC_LIBRARY_DIRS}) endif() @@ -63,10 +60,7 @@ if(NOT DEFINED HDF5_PREFER_PARALLEL) endif() endif() -find_package(HDF5 COMPONENTS HL) -if(NOT HDF5_FOUND) - message(FATAL_ERROR "Could not find HDF5") -endif() +find_package(HDF5 REQUIRED COMPONENTS HL) if(HDF5_IS_PARALLEL) if(NOT MPI_ENABLED) message(FATAL_ERROR "Parallel HDF5 must be used with MPI.") @@ -95,7 +89,7 @@ if(debug) list(APPEND cxxflags -g -O0) endif() if(profile) - list(APPEND cxxflags -pg) + list(APPEND cxxflags -g -fno-omit-frame-pointer) endif() if(optimize) list(REMOVE_ITEM cxxflags -O2) @@ -103,8 +97,8 @@ if(optimize) endif() # Show flags being used -message(STATUS "C++ flags: ${cxxflags}") -message(STATUS "Linker flags: ${ldflags}") +message(STATUS "OpenMC C++ flags: ${cxxflags}") +message(STATUS "OpenMC Linker flags: ${ldflags}") #=============================================================================== # pugixml library @@ -146,7 +140,7 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # the RPATH to be used when installing, but only if it's not a system directory list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endif() #=============================================================================== From 2982ce884dabe47fc284616b73d269d80bb0cd85 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 30 Jan 2019 11:06:06 -0600 Subject: [PATCH 02/10] Rely on FindHDF5.cmake that is distributed with CMake --- CMakeLists.txt | 8 +- cmake/Modules/FindHDF5.cmake | 399 ----------------------------------- 2 files changed, 4 insertions(+), 403 deletions(-) delete mode 100644 cmake/Modules/FindHDF5.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 15c3cd1b72..2bad48f582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) -project(openmc CXX) +project(openmc C CXX) # Setup output directories set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -60,7 +60,7 @@ if(NOT DEFINED HDF5_PREFER_PARALLEL) endif() endif() -find_package(HDF5 REQUIRED COMPONENTS HL) +find_package(HDF5 REQUIRED COMPONENTS C HL) if(HDF5_IS_PARALLEL) if(NOT MPI_ENABLED) message(FATAL_ERROR "Parallel HDF5 must be used with MPI.") @@ -270,8 +270,8 @@ endif() # target_link_libraries treats any arguments starting with - but not -l as # linker flags. Thus, we can pass both linker flags and libraries together. -target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} pugixml - faddeeva xtensor) +target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} + pugixml faddeeva xtensor) if(dagmc) target_compile_definitions(libopenmc PRIVATE DAGMC) diff --git a/cmake/Modules/FindHDF5.cmake b/cmake/Modules/FindHDF5.cmake deleted file mode 100644 index 7492ea750a..0000000000 --- a/cmake/Modules/FindHDF5.cmake +++ /dev/null @@ -1,399 +0,0 @@ -#.rst: -# FindHDF5 -# -------- -# -# Find HDF5, a library for reading and writing self describing array data. -# -# -# -# This module invokes the HDF5 wrapper compiler that should be installed -# alongside HDF5. Depending upon the HDF5 Configuration, the wrapper -# compiler is called either h5cc or h5pcc. If this succeeds, the module -# will then call the compiler with the -show argument to see what flags -# are used when compiling an HDF5 client application. -# -# The module will optionally accept the COMPONENTS argument. If no -# COMPONENTS are specified, then the find module will default to finding -# only the HDF5 C library. If one or more COMPONENTS are specified, the -# module will attempt to find the language bindings for the specified -# components. The only valid components are C, CXX, Fortran, HL, and -# Fortran_HL. If the COMPONENTS argument is not given, the module will -# attempt to find only the C bindings. -# -# On UNIX systems, this module will read the variable -# HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a -# static link to a dynamic link for HDF5 and all of it's dependencies. -# To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES -# variable is set before the call to find_package. -# -# To provide the module with a hint about where to find your HDF5 -# installation, you can set the environment variable HDF5_ROOT. The -# Find module will then look in this path when searching for HDF5 -# executables, paths, and libraries. -# -# In addition to finding the includes and libraries required to compile -# an HDF5 client application, this module also makes an effort to find -# tools that come with the HDF5 distribution that may be useful for -# regression testing. -# -# This module will define the following variables: -# -# :: -# -# HDF5_INCLUDE_DIRS - Location of the hdf5 includes -# HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) -# HDF5_DEFINITIONS - Required compiler definitions for HDF5 -# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings. -# HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings -# HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings -# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API -# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran -# bindings. -# HDF5_LIBRARIES - Required libraries for all requested bindings -# HDF5_FOUND - true if HDF5 was found on the system -# HDF5_VERSION - HDF5 version in format Major.Minor.Release -# HDF5_LIBRARY_DIRS - the full set of library directories -# HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support -# HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler -# HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler -# HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler -# HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool - -#============================================================================= -# Copyright 2015 Axel Huebl, Helmholtz-Zentrum Dresden - Rossendorf -# Copyright 2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# This module is maintained by Will Dicharry . - -include(SelectLibraryConfigurations) -include(FindPackageHandleStandardArgs) - -# List of the valid HDF5 components -set( HDF5_VALID_COMPONENTS - C - CXX - Fortran - HL - Fortran_HL -) - -# Validate the list of find components. -if( NOT HDF5_FIND_COMPONENTS ) - set( HDF5_LANGUAGE_BINDINGS "C" ) -else() - # add the extra specified components, ensuring that they are valid. - foreach( component ${HDF5_FIND_COMPONENTS} ) - list( FIND HDF5_VALID_COMPONENTS ${component} component_location ) - if( ${component_location} EQUAL -1 ) - message( FATAL_ERROR - "\"${component}\" is not a valid HDF5 component." ) - else() - list( APPEND HDF5_LANGUAGE_BINDINGS ${component} ) - endif() - endforeach() -endif() - -# Determine whether to search for serial or parallel executable first -if(HDF5_PREFER_PARALLEL) - set(HDF5_C_COMPILER_NAMES h5pcc h5cc) - set(HDF5_CXX_COMPILER_NAMES h5pc++ h5c++) - set(HDF5_Fortran_COMPILER_NAMES h5pfc h5fc) -else() - set(HDF5_C_COMPILER_NAMES h5cc h5pcc) - set(HDF5_CXX_COMPILER_NAMES h5c++ h5pc++) - set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc) -endif() - -# try to find the HDF5 wrapper compilers -find_program( HDF5_C_COMPILER_EXECUTABLE - NAMES ${HDF5_C_COMPILER_NAMES} - HINTS ENV HDF5_ROOT - PATH_SUFFIXES bin Bin - DOC "HDF5 Wrapper compiler. Used only to detect HDF5 compile flags." ) -mark_as_advanced( HDF5_C_COMPILER_EXECUTABLE ) - -find_program( HDF5_CXX_COMPILER_EXECUTABLE - NAMES ${HDF5_CXX_COMPILER_NAMES} - HINTS ENV HDF5_ROOT - PATH_SUFFIXES bin Bin - DOC "HDF5 C++ Wrapper compiler. Used only to detect HDF5 compile flags." ) -mark_as_advanced( HDF5_CXX_COMPILER_EXECUTABLE ) - -find_program( HDF5_Fortran_COMPILER_EXECUTABLE - NAMES ${HDF5_Fortran_COMPILER_NAMES} - HINTS ENV HDF5_ROOT - PATH_SUFFIXES bin Bin - DOC "HDF5 Fortran Wrapper compiler. Used only to detect HDF5 compile flags." ) -mark_as_advanced( HDF5_Fortran_COMPILER_EXECUTABLE ) - -unset(HDF5_C_COMPILER_NAMES) -unset(HDF5_CXX_COMPILER_NAMES) -unset(HDF5_Fortran_COMPILER_NAMES) - -find_program( HDF5_DIFF_EXECUTABLE - NAMES h5diff - HINTS ENV HDF5_ROOT - PATH_SUFFIXES bin Bin - DOC "HDF5 file differencing tool." ) -mark_as_advanced( HDF5_DIFF_EXECUTABLE ) - -# Invoke the HDF5 wrapper compiler. The compiler return value is stored to the -# return_value argument, the text output is stored to the output variable. -macro( _HDF5_invoke_compiler language output return_value ) - if( HDF5_${language}_COMPILER_EXECUTABLE ) - exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} - ARGS -show - OUTPUT_VARIABLE ${output} - RETURN_VALUE ${return_value} - ) - if( ${${return_value}} EQUAL 0 ) - # do nothing - else() - message( STATUS - "Unable to determine HDF5 ${language} flags from HDF5 wrapper." ) - endif() - endif() -endmacro() - -# Parse a compile line for definitions, includes, library paths, and libraries. -macro( _HDF5_parse_compile_line - compile_line_var - include_paths - definitions - library_paths - libraries ) - - # Match the include paths - string( REGEX MATCHALL "-I([^\" ]+)" include_path_flags - "${${compile_line_var}}" - ) - foreach( IPATH ${include_path_flags} ) - string( REGEX REPLACE "^-I" "" IPATH ${IPATH} ) - string( REPLACE "//" "/" IPATH ${IPATH} ) - list( APPEND ${include_paths} ${IPATH} ) - endforeach() - - # Match the definitions - string( REGEX MATCHALL "-D[^ ]*" definition_flags "${${compile_line_var}}" ) - foreach( DEF ${definition_flags} ) - list( APPEND ${definitions} ${DEF} ) - endforeach() - - # Match the library paths - string( REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" library_path_flags - "${${compile_line_var}}" - ) - - foreach( LPATH ${library_path_flags} ) - string( REGEX REPLACE "^-L" "" LPATH ${LPATH} ) - string( REPLACE "//" "/" LPATH ${LPATH} ) - list( APPEND ${library_paths} ${LPATH} ) - endforeach() - - # now search for the library names specified in the compile line (match -l...) - # match only -l's preceded by a space or comma - # this is to exclude directory names like xxx-linux/ - string( REGEX MATCHALL "[, ]-l([^\", ]+)" library_name_flags - "${${compile_line_var}}" ) - # strip the -l from all of the library flags and add to the search list - foreach( LIB ${library_name_flags} ) - string( REGEX REPLACE "^[, ]-l" "" LIB ${LIB} ) - list( APPEND ${libraries} ${LIB} ) - endforeach() -endmacro() - -# Try to find HDF5 using an installed hdf5-config.cmake -if( NOT HDF5_FOUND ) - find_package( HDF5 QUIET NO_MODULE ) - if( HDF5_FOUND ) - set( HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR} ) - set( HDF5_LIBRARIES ) - set( HDF5_C_TARGET hdf5 ) - set( HDF5_CXX_TARGET hdf5_cpp ) - set( HDF5_HL_TARGET hdf5_hl ) - set( HDF5_Fortran_TARGET hdf5_fortran ) - set( HDF5_Fortran_HL_TARGET hdf5_hl_fortran ) - foreach( _component ${HDF5_LANGUAGE_BINDINGS} ) - list( FIND HDF5_VALID_COMPONENTS ${_component} _component_location ) - get_target_property( _comp_location ${HDF5_${_component}_TARGET} LOCATION ) - if( _comp_location ) - set( HDF5_${_component}_LIBRARY ${_comp_location} CACHE PATH - "HDF5 ${_component} library" ) - mark_as_advanced( HDF5_${_component}_LIBRARY ) - list( APPEND HDF5_LIBRARIES ${HDF5_${_component}_LIBRARY} ) - endif() - endforeach() - endif() -endif() - -if( NOT HDF5_FOUND ) - _HDF5_invoke_compiler( C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE ) - _HDF5_invoke_compiler( CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE ) - _HDF5_invoke_compiler( Fortran HDF5_Fortran_COMPILE_LINE HDF5_Fortran_RETURN_VALUE ) - set(HDF5_HL_COMPILE_LINE ${HDF5_C_COMPILE_LINE}) - set(HDF5_Fortran_HL_COMPILE_LINE ${HDF5_Fortran_COMPILE_LINE}) - - # seed the initial lists of libraries to find with items we know we need - set( HDF5_C_LIBRARY_NAMES_INIT hdf5 ) - set( HDF5_HL_LIBRARY_NAMES_INIT hdf5_hl ${HDF5_C_LIBRARY_NAMES_INIT} ) - set( HDF5_CXX_LIBRARY_NAMES_INIT hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT} ) - set( HDF5_Fortran_LIBRARY_NAMES_INIT hdf5_fortran - ${HDF5_C_LIBRARY_NAMES_INIT} ) - set( HDF5_Fortran_HL_LIBRARY_NAMES_INIT hdf5hl_fortran hdf5_hl - ${HDF5_Fortran_LIBRARY_NAMES_INIT} ) - - foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} ) - if( HDF5_${LANGUAGE}_COMPILE_LINE ) - _HDF5_parse_compile_line( HDF5_${LANGUAGE}_COMPILE_LINE - HDF5_${LANGUAGE}_INCLUDE_FLAGS - HDF5_${LANGUAGE}_DEFINITIONS - HDF5_${LANGUAGE}_LIBRARY_DIRS - HDF5_${LANGUAGE}_LIBRARY_NAMES - ) - - # take a guess that the includes may be in the 'include' sibling - # directory of a library directory. - foreach( dir ${HDF5_${LANGUAGE}_LIBRARY_DIRS} ) - list( APPEND HDF5_${LANGUAGE}_INCLUDE_FLAGS ${dir}/../include ) - endforeach() - endif() - - # set the definitions for the language bindings. - list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} ) - - # find the HDF5 include directories - if(${LANGUAGE} MATCHES "Fortran") - set(HDF5_INCLUDE_FILENAME hdf5.mod) - else() - set(HDF5_INCLUDE_FILENAME hdf5.h) - endif() - - find_path( HDF5_${LANGUAGE}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} - HINTS - ${HDF5_${LANGUAGE}_INCLUDE_FLAGS} - ENV - HDF5_ROOT - PATHS - $ENV{HOME}/.local/include - PATH_SUFFIXES - include - Include - ) - mark_as_advanced( HDF5_${LANGUAGE}_INCLUDE_DIR ) - list( APPEND HDF5_INCLUDE_DIRS ${HDF5_${LANGUAGE}_INCLUDE_DIR} ) - - # find the HDF5 libraries - foreach( LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES_INIT} ) - if( UNIX AND HDF5_USE_STATIC_LIBRARIES ) - # According to bug 1643 on the CMake bug tracker, this is the - # preferred method for searching for a static library. - # See http://www.cmake.org/Bug/view.php?id=1643. We search - # first for the full static library name, but fall back to a - # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG lib${LIB}d.a ${LIB}d ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} ) - else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ) - endif() - find_library( HDF5_${LIB}_LIBRARY_DEBUG - NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} - ENV HDF5_ROOT - PATH_SUFFIXES lib Lib ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE - NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} - ENV HDF5_ROOT - PATH_SUFFIXES lib Lib ) - select_library_configurations( HDF5_${LIB} ) - list(APPEND HDF5_${LANGUAGE}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) - endforeach() - list( APPEND HDF5_LIBRARY_DIRS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} ) - - # When the wrapper lists a library with -l, e.g. -lz, simply use it as - # is. If find_library is called for these libraries, you end up with - # local libraries that will not be suitable when cross-compiling for the - # Intel Xeon Phi. - foreach(LIBNAME ${HDF5_${LANGUAGE}_LIBRARY_NAMES}) - list(APPEND HDF5_${LANGUAGE}_LIBRARIES "-l${LIBNAME}") - endforeach() - - # Append the libraries for this language binding to the list of all - # required libraries. - list(APPEND HDF5_LIBRARIES ${HDF5_${LANGUAGE}_LIBRARIES}) - endforeach() - - # We may have picked up some duplicates in various lists during the above - # process for the language bindings (both the C and C++ bindings depend on - # libz for example). Remove the duplicates. It appears that the default - # CMake behavior is to remove duplicates from the end of a list. However, - # for link lines, this is incorrect since unresolved symbols are searched - # for down the link line. Therefore, we reverse the list, remove the - # duplicates, and then reverse it again to get the duplicates removed from - # the beginning. - macro( _remove_duplicates_from_beginning _list_name ) - list( REVERSE ${_list_name} ) - list( REMOVE_DUPLICATES ${_list_name} ) - list( REVERSE ${_list_name} ) - endmacro() - - if( HDF5_INCLUDE_DIRS ) - _remove_duplicates_from_beginning( HDF5_INCLUDE_DIRS ) - endif() - if( HDF5_LIBRARY_DIRS ) - _remove_duplicates_from_beginning( HDF5_LIBRARY_DIRS ) - endif() - - # If the HDF5 include directory was found, open H5pubconf.h to determine if - # HDF5 was compiled with parallel IO support - set( HDF5_IS_PARALLEL FALSE ) - set( HDF5_VERSION "" ) - foreach( _dir IN LISTS HDF5_INCLUDE_DIRS ) - foreach(_hdr "${_dir}/H5pubconf.h" "${_dir}/H5pubconf-64.h" "${_dir}/H5pubconf-32.h") - if( EXISTS "${_hdr}" ) - file( STRINGS "${_hdr}" - HDF5_HAVE_PARALLEL_DEFINE - REGEX "HAVE_PARALLEL 1" ) - if( HDF5_HAVE_PARALLEL_DEFINE ) - set( HDF5_IS_PARALLEL TRUE ) - endif() - unset(HDF5_HAVE_PARALLEL_DEFINE) - - file( STRINGS "${_hdr}" - HDF5_VERSION_DEFINE - REGEX "^[ \t]*#[ \t]*define[ \t]+H5_VERSION[ \t]+" ) - if( "${HDF5_VERSION_DEFINE}" MATCHES - "H5_VERSION[ \t]+\"([0-9]+\\.[0-9]+\\.[0-9]+).*\"" ) - set( HDF5_VERSION "${CMAKE_MATCH_1}" ) - endif() - unset(HDF5_VERSION_DEFINE) - endif() - endforeach() - endforeach() - set( HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL - "HDF5 library compiled with parallel IO support" ) - mark_as_advanced( HDF5_IS_PARALLEL ) - - # For backwards compatibility we set HDF5_INCLUDE_DIR to the value of - # HDF5_INCLUDE_DIRS - if( HDF5_INCLUDE_DIRS ) - set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) - endif() - -endif() - -find_package_handle_standard_args( HDF5 - REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS - VERSION_VAR HDF5_VERSION -) From 1b48802da1951571ef5c6bd87db8ec5e6e0348af Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Mar 2019 21:58:52 -0500 Subject: [PATCH 03/10] Use message(STATUS ...) in two places in CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bad48f582..4033d2466d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ option(dagmc "Enable support for DAGMC (CAD) geometry" OFF) set(MPI_ENABLED FALSE) if($ENV{CXX} MATCHES "(mpi[^/]*|CC)$") - message("-- Detected MPI wrapper: $ENV{CXX}") + message(STATUS "Detected MPI wrapper: $ENV{CXX}") set(MPI_ENABLED TRUE) endif() @@ -65,7 +65,7 @@ if(HDF5_IS_PARALLEL) if(NOT MPI_ENABLED) message(FATAL_ERROR "Parallel HDF5 must be used with MPI.") endif() - message("-- Using parallel HDF5") + message(STATUS "Using parallel HDF5") endif() #=============================================================================== From 34a3fe2519f59a33c819e340edf5c607cc3af824 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Mar 2019 22:11:03 -0500 Subject: [PATCH 04/10] Fix Cell.from_xml_element when multiple temperatures are specified --- openmc/cell.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openmc/cell.py b/openmc/cell.py index 8503deffa1..8381fa8d86 100644 --- a/openmc/cell.py +++ b/openmc/cell.py @@ -571,7 +571,10 @@ class Cell(IDManagerMixin): # Check for other attributes t = get_text(elem, 'temperature') if t is not None: - c.temperature = float(t) + if ' ' in t: + c.temperature = [float(t_i) for t_i in t.split()] + else: + c.temperature = float(t) for key in ('temperature', 'rotation', 'translation'): value = get_text(elem, key) if value is not None: From fc8b2a5001e4c8a830e14d5be9654509179e0ccc Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 26 Mar 2019 07:57:55 -0500 Subject: [PATCH 05/10] Add two papers to publication list --- docs/source/publications.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/source/publications.rst b/docs/source/publications.rst index 762f9329ed..e1c0f6de00 100644 --- a/docs/source/publications.rst +++ b/docs/source/publications.rst @@ -59,7 +59,7 @@ Coupling and Multi-physics - Ze-Long Zhao, Yongwei Yang, and Shuang Hong, "`Application of FLUKA and OpenMC in coupled physics calculation of target and subcritical reactor for ADS - `_," *Nucl. Sci. Tech.*, **30** + `_," *Nucl. Sci. Tech.*, **30**: 10 (2019). - April Novak, Paul Romano, Brycen Wendt, Ron Rahaman, Elia Merzari, Leslie @@ -134,6 +134,11 @@ Geometry and Visualization Miscellaneous ------------- +- Faisal Qayyum, Muhammad R. Ali, Awais Zahur, and R. Khan, "`Improvements in + methodology to determine feedback reactivity coefficients + `_," *Nucl. Sci. Tech.*, **30**: 63 + (2019). + - Amanda L. Lund and Paul K. Romano, "`Implementation and Validation of Photon Transport in OpenMC `_", Argonne National Laboratory, Technical Report ANL/MCS-TM-381 (2018). @@ -464,6 +469,11 @@ Parallelism Depletion --------- +- Zhao-Qing Liu, Ze-Long Zhao, Yong-Wei Yang, Yu-Cui Gao, Hai-Yan Meng, and + Qing-Yu Gao, "`Development and validation of depletion code system IMPC-Burnup + for ADS `_," *Nucl. Sci. Tech.*, + **30**: 44 (2019). + - Colin Josey, Benoit Forget, and Kord Smith, "`High order methods for the integration of the Bateman equations and other problems of the form of y' = F(y,t)y `_," *J. Comput. Phys.*, From 1d5242ede19f379e99a43ad2c6f5c07497b54281 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 15 Mar 2019 15:36:45 -0500 Subject: [PATCH 06/10] Fix a whole bunch of -Wall warnings --- include/openmc/error.h | 4 ++-- include/openmc/plot.h | 5 ++++- src/bremsstrahlung.cpp | 2 +- src/cross_sections.cpp | 1 - src/dagmc.cpp | 6 +++--- src/distribution_energy.cpp | 3 +++ src/endf.cpp | 3 +-- src/geometry.cpp | 3 +-- src/hdf5_interface.cpp | 5 +++++ src/initialize.cpp | 1 - src/lattice.cpp | 1 - src/material.cpp | 3 +-- src/mgxs.cpp | 2 -- src/nuclide.cpp | 2 +- src/output.cpp | 9 ++++----- src/particle_restart.cpp | 4 ++++ src/photon.cpp | 5 ----- src/physics.cpp | 21 +++++++-------------- src/plot.cpp | 7 ++++--- src/secondary_kalbach.cpp | 2 +- src/secondary_nbody.cpp | 2 ++ src/tallies/tally.cpp | 1 - src/tallies/trigger.cpp | 2 +- 23 files changed, 45 insertions(+), 49 deletions(-) diff --git a/include/openmc/error.h b/include/openmc/error.h index 206c9b5b2d..062368f17a 100644 --- a/include/openmc/error.h +++ b/include/openmc/error.h @@ -29,13 +29,13 @@ set_errmsg(const std::stringstream& message) [[noreturn]] void fatal_error(const std::string& message, int err=-1); -inline +[[noreturn]] inline void fatal_error(const std::stringstream& message) { fatal_error(message.str()); } -inline +[[noreturn]] inline void fatal_error(const char* message) { fatal_error({message, std::strlen(message)}); diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 2752add9cf..8e5aa02a6d 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -138,6 +138,10 @@ T PlotBase::get_map() const { in_i = 1; out_i = 2; break; +#ifdef __GNUC__ + default: + __builtin_unreachable(); +#endif } // set initial position @@ -168,7 +172,6 @@ T PlotBase::get_map() const { if (level >=0) {j = level + 1;} if (found_cell) { data.set_value(y, x, p, j); - Cell* c = model::cells[p.coord_[j].cell].get(); } } // inner for } // outer for diff --git a/src/bremsstrahlung.cpp b/src/bremsstrahlung.cpp index 3b9d8b591b..e6b76d19d5 100644 --- a/src/bremsstrahlung.cpp +++ b/src/bremsstrahlung.cpp @@ -45,7 +45,7 @@ void thick_target_bremsstrahlung(Particle& p, double* E_lost) auto n_e = data::ttb_e_grid.size(); // Find the lower bounding index of the incident electron energy - int j = lower_bound_index(data::ttb_e_grid.cbegin(), + size_t j = lower_bound_index(data::ttb_e_grid.cbegin(), data::ttb_e_grid.cend(), e); if (j == n_e - 1) --j; diff --git a/src/cross_sections.cpp b/src/cross_sections.cpp index e91cfc8756..2216b37daf 100644 --- a/src/cross_sections.cpp +++ b/src/cross_sections.cpp @@ -247,7 +247,6 @@ read_ce_cross_sections(const std::vector>& nuc_temps, LibraryKey key {Library::Type::photon, element}; int idx = data::library_map[key]; std::string& filename = data::libraries[idx].path_; - int i_element = data::element_map[element]; write_message("Reading " + element + " from " + filename, 6); // Open file and make sure version is sufficient diff --git a/src/dagmc.cpp b/src/dagmc.cpp index b50d65d88a..8add1f4f37 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -142,7 +142,7 @@ void load_dagmc_geometry() model::DAG = new moab::DagMC(); } - /// Materials \\\ + // --- Materials --- // create uwuw instance UWUW uwuw(DAGMC_FILENAME.c_str()); @@ -176,7 +176,7 @@ void load_dagmc_geometry() rval = model::DAG->parse_properties(keywords, dum, delimiters.c_str()); MB_CHK_ERR_CONT(rval); - /// Cells (Volumes) \\\ + // --- Cells (Volumes) --- // initialize cell objects int n_cells = model::DAG->num_entities(3); @@ -298,7 +298,7 @@ void load_dagmc_geometry() "This may result in lost particles and rapid simulation failure."); } - /// Surfaces \\\ + // --- Surfaces --- // initialize surface objects int n_surfaces = model::DAG->num_entities(2); diff --git a/src/distribution_energy.cpp b/src/distribution_energy.cpp index e311e322d2..1b9be7346b 100644 --- a/src/distribution_energy.cpp +++ b/src/distribution_energy.cpp @@ -245,6 +245,9 @@ double ContinuousTabular::sample(double E) const E_out = E_l_k + (std::sqrt(std::max(0.0, p_l_k*p_l_k + 2.0*frac*(r1 - c_k))) - p_l_k)/frac; } + } else { + throw std::runtime_error{"Unexpected interpolation for continuous energy " + "distribution."}; } // Now interpolate between incident energy bins i and i + 1 diff --git a/src/endf.cpp b/src/endf.cpp index 86f08b8a86..464bc974c2 100644 --- a/src/endf.cpp +++ b/src/endf.cpp @@ -164,9 +164,8 @@ double Tabulated1D::operator()(double x) const Interpolation interp; if (n_regions_ == 0) { interp = Interpolation::lin_lin; - } else if (n_regions_ == 1) { + } else { interp = int_[0]; - } else if (n_regions_ > 1) { for (int j = 0; j < n_regions_; ++j) { if (i < nbt_[j]) { interp = int_[j]; diff --git a/src/geometry.cpp b/src/geometry.cpp index 6eaa61fe24..8791dd9573 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -39,7 +39,6 @@ bool check_cell_overlap(Particle* p) // Loop through each coordinate level for (int j = 0; j < n_coord; j++) { Universe& univ = *model::universes[p->coord_[j].universe]; - int n = univ.cells_.size(); // Loop through each cell on this level for (auto index_cell : univ.cells_) { @@ -351,7 +350,7 @@ BoundaryInfo distance_to_boundary(Particle* p) double d_lat = INFINITY; double d_surf = INFINITY; int32_t level_surf_cross; - std::array level_lat_trans; + std::array level_lat_trans {}; // Loop over each coordinate level. for (int i = 0; i < p->n_coord_; i++) { diff --git a/src/hdf5_interface.cpp b/src/hdf5_interface.cpp index d85a4cc9e9..1fb10b7066 100644 --- a/src/hdf5_interface.cpp +++ b/src/hdf5_interface.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "xtensor/xtensor.hpp" @@ -47,6 +48,8 @@ get_shape(hid_t obj_id, hsize_t* dims) dspace = H5Dget_space(obj_id); } else if (type == H5I_ATTR) { dspace = H5Aget_space(obj_id); + } else { + throw std::runtime_error{"Expected dataset or attribute in call to get_shape."}; } H5Sget_simple_extent_dims(dspace, dims, nullptr); H5Sclose(dspace); @@ -70,6 +73,8 @@ std::vector object_shape(hid_t obj_id) dspace = H5Dget_space(obj_id); } else if (type == H5I_ATTR) { dspace = H5Aget_space(obj_id); + } else { + throw std::runtime_error{"Expected dataset or attribute in call to object_shape."}; } int n = H5Sget_simple_extent_ndims(dspace); diff --git a/src/initialize.cpp b/src/initialize.cpp index 61390651f5..f8a4f4a39a 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -121,7 +121,6 @@ void initialize_mpi(MPI_Comm intracomm) int parse_command_line(int argc, char* argv[]) { - char buffer[256]; // buffer for reading attribute int last_flag = 0; for (int i=1; i < argc; ++i) { std::string arg {argv[i]}; diff --git a/src/lattice.cpp b/src/lattice.cpp index 6e0f2331f0..eb6282bacb 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -800,7 +800,6 @@ HexLattice::is_valid_index(int indx) const { int nx {2*n_rings_ - 1}; int ny {2*n_rings_ - 1}; - int nz {n_axial_}; int iz = indx / (nx * ny); int iy = (indx - nx*ny*iz) / nx; int ix = indx - nx*ny*iz - nx*iy; diff --git a/src/material.cpp b/src/material.cpp index 94a6214836..de0d7e5de5 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -1283,12 +1283,11 @@ openmc_material_set_densities(int32_t index, int n, const char** name, const dou } // Set total density to the sum of the vector - int err = mat->set_density(sum_density, "atom/b-cm"); // Assign S(a,b) tables mat->init_thermal(); - return 0; + return err; } else { set_errmsg("Index in materials array is out of bounds."); return OPENMC_E_OUT_OF_BOUNDS; diff --git a/src/mgxs.cpp b/src/mgxs.cpp index d345cdb22d..efe562fa28 100644 --- a/src/mgxs.cpp +++ b/src/mgxs.cpp @@ -329,8 +329,6 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector& mat_kTs, // Force all of the following data to be the same; these will be verified // to be true later int in_scatter_format = micros[0]->scatter_format; - int in_num_groups = micros[0]->num_groups; - int in_num_delayed_groups = micros[0]->num_delayed_groups; bool in_is_isotropic = micros[0]->is_isotropic; std::vector in_polar = micros[0]->polar; std::vector in_azimuthal = micros[0]->azimuthal; diff --git a/src/nuclide.cpp b/src/nuclide.cpp index 8a6f1aa57b..7f034fd41f 100644 --- a/src/nuclide.cpp +++ b/src/nuclide.cpp @@ -97,7 +97,7 @@ Nuclide::Nuclide(hid_t group, const std::vector& temperature, int i_nucl // Determine closest temperature double min_delta_T = INFTY; - double T_actual; + double T_actual = 0.0; for (auto T : temps_available) { double delta_T = std::abs(T - T_desired); if (delta_T < min_delta_T) { diff --git a/src/output.cpp b/src/output.cpp index df0976d94a..ee74a27e15 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -283,9 +283,9 @@ print_overlap_check() { #ifdef OPENMC_MPI std::vector temp(model::overlap_check_count); - int err = MPI_Reduce(temp.data(), model::overlap_check_count.data(), - model::overlap_check_count.size(), MPI_INT64_T, - MPI_SUM, 0, mpi::intracomm); + MPI_Reduce(temp.data(), model::overlap_check_count.data(), + model::overlap_check_count.size(), MPI_INT64_T, + MPI_SUM, 0, mpi::intracomm); #endif if (mpi::master) { @@ -482,7 +482,7 @@ void print_runtime() // Calculate particle rate in active/inactive batches int n_active = simulation::current_batch - settings::n_inactive; - double speed_inactive; + double speed_inactive = 0.0; double speed_active; if (settings::restart_run) { if (simulation::restart_batch < settings::n_inactive) { @@ -492,7 +492,6 @@ void print_runtime() speed_active = (settings::n_particles * n_active * settings::gen_per_batch) / time_active.elapsed(); } else { - speed_inactive = 0.0; speed_active = (settings::n_particles * (settings::n_batches - simulation::restart_batch) * settings::gen_per_batch) / time_active.elapsed(); diff --git a/src/particle_restart.cpp b/src/particle_restart.cpp index 0bc677cfd8..b2017bbebe 100644 --- a/src/particle_restart.cpp +++ b/src/particle_restart.cpp @@ -14,6 +14,7 @@ #include // for copy #include +#include #include namespace openmc { @@ -90,6 +91,9 @@ void run_particle_restart() case RUN_MODE_FIXEDSOURCE: particle_seed = p.id_; break; + default: + throw std::runtime_error{"Unexpected run mode: " + + std::to_string(previous_run_mode)}; } set_particle_seed(particle_seed); diff --git a/src/photon.cpp b/src/photon.cpp index 79345b90e0..8a0ddf9aa9 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -550,11 +550,6 @@ void PhotonInteraction::pair_production(double alpha, double* E_electron, // "PENELOPE-2011: A Code System for Monte Carlo Simulation of Electron and // Photon Transport," OECD-NEA, Issy-les-Moulineaux, France (2011). - // Compute the minimum and maximum values of the electron reduced energy, - // i.e. the fraction of the photon energy that is given to the electron - double e_min = 1.0/alpha; - double e_max = 1.0 - 1.0/alpha; - // Compute the high-energy Coulomb correction double a = Z_ / FINE_STRUCTURE; double c = a*a*(1.0/(1.0 + a*a) + 0.202059 + a*a*(-0.03693 + a*a*(0.00835 + diff --git a/src/physics.cpp b/src/physics.cpp index 1cfd316580..e28c5a00ed 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -421,20 +421,11 @@ int sample_element(Particle* p) // Get pointers to elements, densities const auto& mat {model::materials[p->material_]}; - int n = mat->nuclide_.size(); - int i = 0; double prob = 0.0; - int i_element; - while (prob < cutoff) { - // Check to make sure that a nuclide was sampled - if (i >= n) { - p->write_restart(); - fatal_error("Did not sample any element during collision."); - } - + for (int i = 0; i < mat->element_.size(); ++i) { // Find atom density - i_element = mat->element_[i]; + int i_element = mat->element_[i]; double atom_density = mat->atom_density_[i]; // Determine microscopic cross section @@ -442,10 +433,12 @@ int sample_element(Particle* p) // Increment probability to compare to cutoff prob += sigma; - ++i; + if (prob > cutoff) return i_element; } - return i_element; + // If we made it here, no element was sampled + p->write_restart(); + fatal_error("Did not sample any element during collision."); } Reaction* sample_fission(int i_nuclide, const Particle* p) @@ -614,7 +607,7 @@ void scatter(Particle* p, int i_nuclide) // INELASTIC SCATTERING int j = 0; - int i; + int i = 0; while (prob < cutoff) { i = nuc->index_inelastic_scatter_[j]; ++j; diff --git a/src/plot.cpp b/src/plot.cpp index 02fb42d76b..74279cad51 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -80,8 +80,6 @@ std::unordered_map plot_map; extern "C" int openmc_plot_geometry() { - int err; - for (auto pl : model::plots) { std::stringstream ss; ss << "Processing plot " << pl.id_ << ": " @@ -695,6 +693,10 @@ void draw_mesh_lines(Plot pl, ImageData& data) outer = 1; inner = 2; break; +#ifdef __GNUC__ + default: + __builtin_unreachable(); +#endif } Position ll_plot {pl.origin_}; @@ -806,7 +808,6 @@ void create_voxel(Plot pl) // Write current date and time write_attribute(file_id, "date_and_time", time_stamp().c_str()); - hsize_t three = 3; std::array pixels; std::copy(pl.pixels_.begin(), pl.pixels_.end(), pixels.begin()); write_attribute(file_id, "num_voxels", pixels); diff --git a/src/secondary_kalbach.cpp b/src/secondary_kalbach.cpp index cec5344def..e3974f357e 100644 --- a/src/secondary_kalbach.cpp +++ b/src/secondary_kalbach.cpp @@ -199,7 +199,7 @@ void KalbachMann::sample(double E_in, double& E_out, double& mu) const km_r = distribution_[l].r[k]; km_a = distribution_[l].a[k]; - } else if (distribution_[l].interpolation == Interpolation::lin_lin) { + } else { // Linear-linear interpolation double E_l_k1 = distribution_[l].e_out[k+1]; double p_l_k1 = distribution_[l].p[k+1]; diff --git a/src/secondary_nbody.cpp b/src/secondary_nbody.cpp index dabd9de3a8..564fca73d8 100644 --- a/src/secondary_nbody.cpp +++ b/src/secondary_nbody.cpp @@ -55,6 +55,8 @@ void NBodyPhaseSpace::sample(double E_in, double& E_out, double& mu) const r6 = prn(); y = -std::log(r1*r2*r3*r4) - std::log(r5) * std::pow(std::cos(PI/2.0*r6), 2); break; + default: + throw std::runtime_error{"N-body phase space with >5 bodies."}; } // Now determine v and E_out diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 682db35405..fe1953b26e 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -328,7 +328,6 @@ Tally::set_scores(std::vector scores) // Iterate over the given scores. for (auto score_str : scores) { // Make sure a delayed group filter wasn't used with an incompatible score. - bool has_delayedgroup = delayedgroup_filter_ != C_NONE; if (delayedgroup_filter_ != C_NONE) { if (score_str != "delayed-nu-fission" && score_str != "decay-rate") fatal_error("Cannot tally " + score_str + "with a delayedgroup filter"); diff --git a/src/tallies/trigger.cpp b/src/tallies/trigger.cpp index c1b0a93649..d43be8b9ce 100644 --- a/src/tallies/trigger.cpp +++ b/src/tallies/trigger.cpp @@ -114,7 +114,7 @@ check_keff_trigger() if (settings::run_mode != RUN_MODE_EIGENVALUE) return 0.; double k_combined[2]; - int err = openmc_get_keff(k_combined); + openmc_get_keff(k_combined); double uncertainty = 0.; switch (settings::keff_trigger.metric) { From cca544292a99265ed5a9937e88f78114e47465e3 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 26 Mar 2019 16:16:06 -0500 Subject: [PATCH 07/10] Isolate __builtin_unreachable to macro --- include/openmc/error.h | 6 ++++++ src/nuclide.cpp | 4 +--- src/physics.cpp | 4 +--- src/plot.cpp | 4 +--- src/tallies/filter_particle.cpp | 4 +--- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/openmc/error.h b/include/openmc/error.h index 062368f17a..5f30f0252d 100644 --- a/include/openmc/error.h +++ b/include/openmc/error.h @@ -7,6 +7,12 @@ #include "openmc/capi.h" +#ifdef __GNUC__ +#define UNREACHABLE() __builtin_unreachable() +#else +#define UNREACHABLE() (void)0 +#endif + namespace openmc { inline void diff --git a/src/nuclide.cpp b/src/nuclide.cpp index 7f034fd41f..6094b79831 100644 --- a/src/nuclide.cpp +++ b/src/nuclide.cpp @@ -454,9 +454,7 @@ double Nuclide::nu(double E, EmissionMode mode, int group) const return (*fission_rx_[0]->products_[0].yield_)(E); } } -#ifdef __GNUC__ - __builtin_unreachable(); -#endif + UNREACHABLE(); } void Nuclide::calculate_elastic_xs(Particle& p) const diff --git a/src/physics.cpp b/src/physics.cpp index e28c5a00ed..0d0c603430 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -883,9 +883,7 @@ Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, } // case RVS, DBRC } // switch (sampling_method) -#ifdef __GNUC__ - __builtin_unreachable(); -#endif + UNREACHABLE(); } Direction diff --git a/src/plot.cpp b/src/plot.cpp index 74279cad51..57466eca1b 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -693,10 +693,8 @@ void draw_mesh_lines(Plot pl, ImageData& data) outer = 1; inner = 2; break; -#ifdef __GNUC__ default: - __builtin_unreachable(); -#endif + UNREACHABLE(); } Position ll_plot {pl.origin_}; diff --git a/src/tallies/filter_particle.cpp b/src/tallies/filter_particle.cpp index 1d4b849375..23a305b8dd 100644 --- a/src/tallies/filter_particle.cpp +++ b/src/tallies/filter_particle.cpp @@ -50,9 +50,7 @@ ParticleFilter::text_label(int bin) const case Particle::Type::positron: return "Particle: positron"; } -#ifdef __GNUC__ - __builtin_unreachable(); -#endif + UNREACHABLE(); } } // namespace openmc From 2efd58a694c802d4c814becc42a9ab13a3b76325 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 26 Mar 2019 22:43:33 -0500 Subject: [PATCH 08/10] Use dataset[()] instead of deprecated dataset.value --- openmc/data/angle_distribution.py | 2 +- openmc/data/correlated.py | 6 +-- openmc/data/energy_distribution.py | 2 +- openmc/data/function.py | 6 +-- openmc/data/kalbach_mann.py | 2 +- openmc/data/multipole.py | 16 +++---- openmc/data/neutron.py | 4 +- openmc/data/photon.py | 12 ++--- openmc/data/reaction.py | 2 +- openmc/data/thermal.py | 12 ++--- openmc/data/urr.py | 4 +- openmc/filter.py | 32 ++++++------- openmc/filter_expansion.py | 32 ++++++------- openmc/lattice.py | 26 +++++----- openmc/material.py | 12 ++--- openmc/mesh.py | 10 ++-- openmc/mgxs_library.py | 6 +-- openmc/particle_restart.py | 22 ++++----- openmc/statepoint.py | 76 +++++++++++++++--------------- openmc/summary.py | 24 +++++----- openmc/surface.py | 8 ++-- openmc/tallies.py | 2 +- openmc/universe.py | 2 +- openmc/volume.py | 6 +-- 24 files changed, 163 insertions(+), 163 deletions(-) diff --git a/openmc/data/angle_distribution.py b/openmc/data/angle_distribution.py index a1f498ba61..638590cff7 100644 --- a/openmc/data/angle_distribution.py +++ b/openmc/data/angle_distribution.py @@ -115,7 +115,7 @@ class AngleDistribution(EqualityMixin): Angular distribution """ - energy = group['energy'].value + energy = group['energy'][()] data = group['mu'] offsets = data.attrs['offsets'] interpolation = data.attrs['interpolation'] diff --git a/openmc/data/correlated.py b/openmc/data/correlated.py index 8cc4509cea..b760f2e2fd 100644 --- a/openmc/data/correlated.py +++ b/openmc/data/correlated.py @@ -210,15 +210,15 @@ class CorrelatedAngleEnergy(AngleEnergy): interp_data = group['energy'].attrs['interpolation'] energy_breakpoints = interp_data[0, :] energy_interpolation = interp_data[1, :] - energy = group['energy'].value + energy = group['energy'][()] offsets = group['energy_out'].attrs['offsets'] interpolation = group['energy_out'].attrs['interpolation'] n_discrete_lines = group['energy_out'].attrs['n_discrete_lines'] - dset_eout = group['energy_out'].value + dset_eout = group['energy_out'][()] energy_out = [] - dset_mu = group['mu'].value + dset_mu = group['mu'][()] mu = [] n_energy = len(energy) diff --git a/openmc/data/energy_distribution.py b/openmc/data/energy_distribution.py index 9e01a4b302..bff97bf813 100644 --- a/openmc/data/energy_distribution.py +++ b/openmc/data/energy_distribution.py @@ -1144,7 +1144,7 @@ class ContinuousTabular(EnergyDistribution): interp_data = group['energy'].attrs['interpolation'] energy_breakpoints = interp_data[0, :] energy_interpolation = interp_data[1, :] - energy = group['energy'].value + energy = group['energy'][()] data = group['distribution'] offsets = data.attrs['offsets'] diff --git a/openmc/data/function.py b/openmc/data/function.py index 36443e761e..f167a3c236 100644 --- a/openmc/data/function.py +++ b/openmc/data/function.py @@ -349,8 +349,8 @@ class Tabulated1D(Function1D): raise ValueError("Expected an HDF5 attribute 'type' equal to '" + cls.__name__ + "'") - x = dataset.value[0, :] - y = dataset.value[1, :] + x = dataset[0, :] + y = dataset[1, :] breakpoints = dataset.attrs['breakpoints'] interpolation = dataset.attrs['interpolation'] return cls(x, y, breakpoints, interpolation) @@ -434,7 +434,7 @@ class Polynomial(np.polynomial.Polynomial, Function1D): if dataset.attrs['type'].decode() != cls.__name__: raise ValueError("Expected an HDF5 attribute 'type' equal to '" + cls.__name__ + "'") - return cls(dataset.value) + return cls(dataset[()]) class Combination(EqualityMixin): diff --git a/openmc/data/kalbach_mann.py b/openmc/data/kalbach_mann.py index 4be0c15d52..c7df015a75 100644 --- a/openmc/data/kalbach_mann.py +++ b/openmc/data/kalbach_mann.py @@ -202,7 +202,7 @@ class KalbachMann(AngleEnergy): interp_data = group['energy'].attrs['interpolation'] energy_breakpoints = interp_data[0, :] energy_interpolation = interp_data[1, :] - energy = group['energy'].value + energy = group['energy'][()] data = group['distribution'] offsets = data.attrs['offsets'] diff --git a/openmc/data/multipole.py b/openmc/data/multipole.py index 9022061a09..38c7be123c 100644 --- a/openmc/data/multipole.py +++ b/openmc/data/multipole.py @@ -356,24 +356,24 @@ class WindowedMultipole(EqualityMixin): # Read scalars. - out.spacing = group['spacing'].value - out.sqrtAWR = group['sqrtAWR'].value - out.E_min = group['E_min'].value - out.E_max = group['E_max'].value + out.spacing = group['spacing'][()] + out.sqrtAWR = group['sqrtAWR'][()] + out.E_min = group['E_min'][()] + out.E_max = group['E_max'][()] # Read arrays. err = "WMP '{}' array shape is not consistent with the '{}' array shape" - out.data = group['data'].value + out.data = group['data'][()] - out.windows = group['windows'].value + out.windows = group['windows'][()] - out.broaden_poly = group['broaden_poly'].value.astype(np.bool) + out.broaden_poly = group['broaden_poly'][()].astype(np.bool) if out.broaden_poly.shape[0] != out.windows.shape[0]: raise ValueError(err.format('broaden_poly', 'windows')) - out.curvefit = group['curvefit'].value + out.curvefit = group['curvefit'][()] if out.curvefit.shape[0] != out.windows.shape[0]: raise ValueError(err.format('curvefit', 'windows')) diff --git a/openmc/data/neutron.py b/openmc/data/neutron.py index 2ff55700fd..cd1e406047 100644 --- a/openmc/data/neutron.py +++ b/openmc/data/neutron.py @@ -521,7 +521,7 @@ class IncidentNeutron(EqualityMixin): kTg = group['kTs'] kTs = [] for temp in kTg: - kTs.append(kTg[temp].value) + kTs.append(kTg[temp][()]) data = cls(name, atomic_number, mass_number, metastable, atomic_weight_ratio, kTs) @@ -529,7 +529,7 @@ class IncidentNeutron(EqualityMixin): # Read energy grid e_group = group['energy'] for temperature, dset in e_group.items(): - data.energy[temperature] = dset.value + data.energy[temperature] = dset[()] # Read reaction data rxs_group = group['reactions'] diff --git a/openmc/data/photon.py b/openmc/data/photon.py index 47bdbf1d96..c21a46e1f2 100644 --- a/openmc/data/photon.py +++ b/openmc/data/photon.py @@ -558,12 +558,12 @@ class IncidentPhoton(EqualityMixin): if not _COMPTON_PROFILES: filename = os.path.join(os.path.dirname(__file__), 'compton_profiles.h5') with h5py.File(filename, 'r') as f: - _COMPTON_PROFILES['pz'] = f['pz'].value + _COMPTON_PROFILES['pz'] = f['pz'][()] for i in range(1, 101): group = f['{:03}'.format(i)] - num_electrons = group['num_electrons'].value - binding_energy = group['binding_energy'].value*EV_PER_MEV - J = group['J'].value + num_electrons = group['num_electrons'][()] + binding_energy = group['binding_energy'][()]*EV_PER_MEV + J = group['J'][()] _COMPTON_PROFILES[i] = {'num_electrons': num_electrons, 'binding_energy': binding_energy, 'J': J} @@ -720,8 +720,8 @@ class IncidentPhoton(EqualityMixin): group = f['{:03}'.format(i)] _BREMSSTRAHLUNG[i] = { 'I': group.attrs['I'], - 'num_electrons': group['num_electrons'].value, - 'ionization_energy': group['ionization_energy'].value + 'num_electrons': group['num_electrons'][()], + 'ionization_energy': group['ionization_energy'][()] } filename = os.path.join(os.path.dirname(__file__), 'BREMX.DAT') diff --git a/openmc/data/reaction.py b/openmc/data/reaction.py index a988f2d6d2..c5abc73c34 100644 --- a/openmc/data/reaction.py +++ b/openmc/data/reaction.py @@ -938,7 +938,7 @@ class Reaction(EqualityMixin): 'Could not create reaction cross section for MT={} ' 'at T={} because no corresponding energy grid ' 'exists.'.format(mt, T)) - xs = Tgroup['xs'].value + xs = Tgroup['xs'][()] threshold_idx = Tgroup['xs'].attrs['threshold_idx'] - 1 tabulated_xs = Tabulated1D(energy[T][threshold_idx:], xs) tabulated_xs._threshold_idx = threshold_idx diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index b10cdeba4c..27ed7aa291 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -200,8 +200,8 @@ class CoherentElastic(EqualityMixin): Coherent elastic scattering cross section """ - bragg_edges = dataset.value[0, :] - factors = dataset.value[1, :] + bragg_edges = dataset[0, :] + factors = dataset[1, :] return cls(bragg_edges, factors) @@ -414,7 +414,7 @@ class ThermalScattering(EqualityMixin): kTg = group['kTs'] kTs = [] for temp in kTg: - kTs.append(kTg[temp].value) + kTs.append(kTg[temp][()]) temperatures = [str(int(round(kT / K_BOLTZMANN))) + "K" for kT in kTs] table = cls(name, atomic_weight_ratio, kTs) @@ -438,7 +438,7 @@ class ThermalScattering(EqualityMixin): # Angular distribution if 'mu_out' in elastic_group: - table.elastic_mu_out[T] = elastic_group['mu_out'].value + table.elastic_mu_out[T] = elastic_group['mu_out'][()] # Read thermal inelastic scattering if 'inelastic' in Tgroup: @@ -446,8 +446,8 @@ class ThermalScattering(EqualityMixin): table.inelastic_xs[T] = Tabulated1D.from_hdf5( inelastic_group['xs']) if table.secondary_mode in ('equal', 'skewed'): - table.inelastic_e_out[T] = inelastic_group['energy_out'].value - table.inelastic_mu_out[T] = inelastic_group['mu_out'].value + table.inelastic_e_out[T] = inelastic_group['energy_out'][()] + table.inelastic_mu_out[T] = inelastic_group['mu_out'][()] elif table.secondary_mode == 'continuous': table.inelastic_dist[T] = AngleEnergy.from_hdf5( inelastic_group) diff --git a/openmc/data/urr.py b/openmc/data/urr.py index 0edccf6f06..53961a50ac 100644 --- a/openmc/data/urr.py +++ b/openmc/data/urr.py @@ -166,8 +166,8 @@ class ProbabilityTables(EqualityMixin): absorption_flag = group.attrs['absorption'] multiply_smooth = bool(group.attrs['multiply_smooth']) - energy = group['energy'].value - table = group['table'].value + energy = group['energy'][()] + table = group['table'][()] return cls(energy, table, interpolation, inelastic_flag, absorption_flag, multiply_smooth) diff --git a/openmc/filter.py b/openmc/filter.py index ef68a4961a..49d3ff5de1 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -170,19 +170,19 @@ class Filter(IDManagerMixin, metaclass=FilterMeta): # If the HDF5 'type' variable matches this class's short_name, then # there is no overriden from_hdf5 method. Pass the bins to __init__. - if group['type'].value.decode() == cls.short_name.lower(): - out = cls(group['bins'].value, filter_id=filter_id) - out._num_bins = group['n_bins'].value + if group['type'][()].decode() == cls.short_name.lower(): + out = cls(group['bins'][()], filter_id=filter_id) + out._num_bins = group['n_bins'][()] return out # Search through all subclasses and find the one matching the HDF5 # 'type'. Call that class's from_hdf5 method. for subclass in cls._recursive_subclasses(): - if group['type'].value.decode() == subclass.short_name.lower(): + if group['type'][()].decode() == subclass.short_name.lower(): return subclass.from_hdf5(group, **kwargs) raise ValueError("Unrecognized Filter class: '" - + group['type'].value.decode() + "'") + + group['type'][()].decode() + "'") @property def bins(self): @@ -618,16 +618,16 @@ class MeshFilter(Filter): @classmethod def from_hdf5(cls, group, **kwargs): - if group['type'].value.decode() != cls.short_name.lower(): + if group['type'][()].decode() != cls.short_name.lower(): raise ValueError("Expected HDF5 data for filter type '" + cls.short_name.lower() + "' but got '" - + group['type'].value.decode() + " instead") + + group['type'][()].decode() + " instead") if 'meshes' not in kwargs: raise ValueError(cls.__name__ + " requires a 'meshes' keyword " "argument.") - mesh_id = group['bins'].value + mesh_id = group['bins'][()] mesh_obj = kwargs['meshes'][mesh_id] filter_id = int(group.name.split('/')[-1].lstrip('filter ')) @@ -1191,15 +1191,15 @@ class DistribcellFilter(Filter): @classmethod def from_hdf5(cls, group, **kwargs): - if group['type'].value.decode() != cls.short_name.lower(): + if group['type'][()].decode() != cls.short_name.lower(): raise ValueError("Expected HDF5 data for filter type '" + cls.short_name.lower() + "' but got '" - + group['type'].value.decode() + " instead") + + group['type'][()].decode() + " instead") filter_id = int(group.name.split('/')[-1].lstrip('filter ')) - out = cls(group['bins'].value, filter_id=filter_id) - out._num_bins = group['n_bins'].value + out = cls(group['bins'][()], filter_id=filter_id) + out._num_bins = group['n_bins'][()] return out @@ -1638,13 +1638,13 @@ class EnergyFunctionFilter(Filter): @classmethod def from_hdf5(cls, group, **kwargs): - if group['type'].value.decode() != cls.short_name.lower(): + if group['type'][()].decode() != cls.short_name.lower(): raise ValueError("Expected HDF5 data for filter type '" + cls.short_name.lower() + "' but got '" - + group['type'].value.decode() + " instead") + + group['type'][()].decode() + " instead") - energy = group['energy'].value - y = group['y'].value + energy = group['energy'][()] + y = group['y'][()] filter_id = int(group.name.split('/')[-1].lstrip('filter ')) return cls(energy, y, filter_id=filter_id) diff --git a/openmc/filter_expansion.py b/openmc/filter_expansion.py index 59457b6857..cc085df8a4 100644 --- a/openmc/filter_expansion.py +++ b/openmc/filter_expansion.py @@ -92,14 +92,14 @@ class LegendreFilter(ExpansionFilter): @classmethod def from_hdf5(cls, group, **kwargs): - if group['type'].value.decode() != cls.short_name.lower(): + if group['type'][()].decode() != cls.short_name.lower(): raise ValueError("Expected HDF5 data for filter type '" + cls.short_name.lower() + "' but got '" - + group['type'].value.decode() + " instead") + + group['type'][()].decode() + " instead") filter_id = int(group.name.split('/')[-1].lstrip('filter ')) - out = cls(group['order'].value, filter_id) + out = cls(group['order'][()], filter_id) return out @@ -198,15 +198,15 @@ class SpatialLegendreFilter(ExpansionFilter): @classmethod def from_hdf5(cls, group, **kwargs): - if group['type'].value.decode() != cls.short_name.lower(): + if group['type'][()].decode() != cls.short_name.lower(): raise ValueError("Expected HDF5 data for filter type '" + cls.short_name.lower() + "' but got '" - + group['type'].value.decode() + " instead") + + group['type'][()].decode() + " instead") filter_id = int(group.name.split('/')[-1].lstrip('filter ')) - order = group['order'].value - axis = group['axis'].value.decode() - min_, max_ = group['min'].value, group['max'].value + order = group['order'][()] + axis = group['axis'][()].decode() + min_, max_ = group['min'][()], group['max'][()] return cls(order, axis, min_, max_, filter_id) @@ -294,15 +294,15 @@ class SphericalHarmonicsFilter(ExpansionFilter): @classmethod def from_hdf5(cls, group, **kwargs): - if group['type'].value.decode() != cls.short_name.lower(): + if group['type'][()].decode() != cls.short_name.lower(): raise ValueError("Expected HDF5 data for filter type '" + cls.short_name.lower() + "' but got '" - + group['type'].value.decode() + " instead") + + group['type'][()].decode() + " instead") filter_id = int(group.name.split('/')[-1].lstrip('filter ')) - out = cls(group['order'].value, filter_id) - out.cosine = group['cosine'].value.decode() + out = cls(group['order'][()], filter_id) + out.cosine = group['cosine'][()].decode() return out @@ -437,14 +437,14 @@ class ZernikeFilter(ExpansionFilter): @classmethod def from_hdf5(cls, group, **kwargs): - if group['type'].value.decode() != cls.short_name.lower(): + if group['type'][()].decode() != cls.short_name.lower(): raise ValueError("Expected HDF5 data for filter type '" + cls.short_name.lower() + "' but got '" - + group['type'].value.decode() + " instead") + + group['type'][()].decode() + " instead") filter_id = int(group.name.split('/')[-1].lstrip('filter ')) - order = group['order'].value - x, y, r = group['x'].value, group['y'].value, group['r'].value + order = group['order'][()] + x, y, r = group['x'][()], group['y'][()], group['r'][()] return cls(order, x, y, r, filter_id) diff --git a/openmc/lattice.py b/openmc/lattice.py index 8bf4e47571..ac5799255a 100644 --- a/openmc/lattice.py +++ b/openmc/lattice.py @@ -100,15 +100,15 @@ class Lattice(IDManagerMixin, metaclass=ABCMeta): """ lattice_id = int(group.name.split('/')[-1].lstrip('lattice ')) - name = group['name'].value.decode() if 'name' in group else '' - lattice_type = group['type'].value.decode() + name = group['name'][()].decode() if 'name' in group else '' + lattice_type = group['type'][()].decode() if lattice_type == 'rectangular': - dimension = group['dimension'][...] - lower_left = group['lower_left'][...] - pitch = group['pitch'][...] - outer = group['outer'].value - universe_ids = group['universes'][...] + dimension = group['dimension'][()] + lower_left = group['lower_left'][()] + pitch = group['pitch'][()] + outer = group['outer'][()] + universe_ids = group['universes'][()] # Create the Lattice lattice = openmc.RectLattice(lattice_id, name) @@ -136,13 +136,13 @@ class Lattice(IDManagerMixin, metaclass=ABCMeta): lattice.universes = uarray elif lattice_type == 'hexagonal': - n_rings = group['n_rings'].value - n_axial = group['n_axial'].value - center = group['center'][...] - pitch = group['pitch'][...] - outer = group['outer'].value + n_rings = group['n_rings'][()] + n_axial = group['n_axial'][()] + center = group['center'][()] + pitch = group['pitch'][()] + outer = group['outer'][()] - universe_ids = group['universes'][...] + universe_ids = group['universes'][()] # Create the Lattice lattice = openmc.HexLattice(lattice_id, name) diff --git a/openmc/material.py b/openmc/material.py index 42c56acedb..55aef743c2 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -277,10 +277,10 @@ class Material(IDManagerMixin): """ mat_id = int(group.name.split('/')[-1].lstrip('material ')) - name = group['name'].value.decode() if 'name' in group else '' - density = group['atom_density'].value + name = group['name'][()].decode() if 'name' in group else '' + density = group['atom_density'][()] if 'nuclide_densities' in group: - nuc_densities = group['nuclide_densities'][...] + nuc_densities = group['nuclide_densities'][()] # Create the Material material = cls(mat_id, name) @@ -290,7 +290,7 @@ class Material(IDManagerMixin): # Read the names of the S(a,b) tables for this Material and add them if 'sab_names' in group: - sab_tables = group['sab_names'].value + sab_tables = group['sab_names'][()] for sab_table in sab_tables: name = sab_table.decode() material.add_s_alpha_beta(name) @@ -299,13 +299,13 @@ class Material(IDManagerMixin): material.set_density(density=density, units='atom/b-cm') if 'nuclides' in group: - nuclides = group['nuclides'].value + nuclides = group['nuclides'][()] # Add all nuclides to the Material for fullname, density in zip(nuclides, nuc_densities): name = fullname.decode().strip() material.add_nuclide(name, percent=density, percent_type='ao') if 'macroscopics' in group: - macroscopics = group['macroscopics'].value + macroscopics = group['macroscopics'][()] # Add all macroscopics to the Material for fullname in macroscopics: name = fullname.decode().strip() diff --git a/openmc/mesh.py b/openmc/mesh.py index f454a6f88c..ba07ec178b 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -174,11 +174,11 @@ class Mesh(IDManagerMixin): # Read and assign mesh properties mesh = cls(mesh_id) - mesh.type = group['type'].value.decode() - mesh.dimension = group['dimension'].value - mesh.lower_left = group['lower_left'].value - mesh.upper_right = group['upper_right'].value - mesh.width = group['width'].value + mesh.type = group['type'][()].decode() + mesh.dimension = group['dimension'][()] + mesh.lower_left = group['lower_left'][()] + mesh.upper_right = group['upper_right'][()] + mesh.width = group['width'][()] return mesh diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index 51c91ef176..f6864ebe4a 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -2219,7 +2219,7 @@ class XSdata(object): for xs_type in xs_types: set_func = 'set_' + xs_type.replace(' ', '_').replace('-', '_') if xs_type in temperature_group: - getattr(data, set_func)(temperature_group[xs_type].value, + getattr(data, set_func)(temperature_group[xs_type][()], float_temp) scatt_group = temperature_group['scatter_data'] @@ -2227,7 +2227,7 @@ class XSdata(object): # Get scatter matrix and 'un-flatten' it g_max = scatt_group['g_max'] g_min = scatt_group['g_min'] - flat_scatter = scatt_group['scatter_matrix'].value + flat_scatter = scatt_group['scatter_matrix'][()] scatter_matrix = np.zeros(data.xs_shapes["[G][G'][Order]"]) G = data.energy_groups.num_groups if data.representation == 'isotropic': @@ -2259,7 +2259,7 @@ class XSdata(object): # Repeat for multiplicity if 'multiplicity_matrix' in scatt_group: - flat_mult = scatt_group['multiplicity_matrix'].value + flat_mult = scatt_group['multiplicity_matrix'][()] mult_matrix = np.zeros(data.xs_shapes["[G][G']"]) flat_index = 0 for p in range(Np): diff --git a/openmc/particle_restart.py b/openmc/particle_restart.py index bc86669694..68a7614584 100644 --- a/openmc/particle_restart.py +++ b/openmc/particle_restart.py @@ -49,44 +49,44 @@ class Particle(object): @property def current_batch(self): - return self._f['current_batch'].value + return self._f['current_batch'][()] @property def current_generation(self): - return self._f['current_generation'].value + return self._f['current_generation'][()] @property def energy(self): - return self._f['energy'].value + return self._f['energy'][()] @property def generations_per_batch(self): - return self._f['generations_per_batch'].value + return self._f['generations_per_batch'][()] @property def id(self): - return self._f['id'].value + return self._f['id'][()] @property def type(self): - return self._f['type'].value + return self._f['type'][()] @property def n_particles(self): - return self._f['n_particles'].value + return self._f['n_particles'][()] @property def run_mode(self): - return self._f['run_mode'].value.decode() + return self._f['run_mode'][()].decode() @property def uvw(self): - return self._f['uvw'].value + return self._f['uvw'][()] @property def weight(self): - return self._f['weight'].value + return self._f['weight'][()] @property def xyz(self): - return self._f['xyz'].value + return self._f['xyz'][()] diff --git a/openmc/statepoint.py b/openmc/statepoint.py index df85603792..3dc6535841 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -161,35 +161,35 @@ class StatePoint(object): @property def cmfd_balance(self): - return self._f['cmfd/cmfd_balance'].value if self.cmfd_on else None + return self._f['cmfd/cmfd_balance'][()] if self.cmfd_on else None @property def cmfd_dominance(self): - return self._f['cmfd/cmfd_dominance'].value if self.cmfd_on else None + return self._f['cmfd/cmfd_dominance'][()] if self.cmfd_on else None @property def cmfd_entropy(self): - return self._f['cmfd/cmfd_entropy'].value if self.cmfd_on else None + return self._f['cmfd/cmfd_entropy'][()] if self.cmfd_on else None @property def cmfd_indices(self): - return self._f['cmfd/indices'].value if self.cmfd_on else None + return self._f['cmfd/indices'][()] if self.cmfd_on else None @property def cmfd_src(self): if self.cmfd_on: - data = self._f['cmfd/cmfd_src'].value + data = self._f['cmfd/cmfd_src'][()] return np.reshape(data, tuple(self.cmfd_indices), order='F') else: return None @property def cmfd_srccmp(self): - return self._f['cmfd/cmfd_srccmp'].value if self.cmfd_on else None + return self._f['cmfd/cmfd_srccmp'][()] if self.cmfd_on else None @property def current_batch(self): - return self._f['current_batch'].value + return self._f['current_batch'][()] @property def date_and_time(self): @@ -199,7 +199,7 @@ class StatePoint(object): @property def entropy(self): if self.run_mode == 'eigenvalue': - return self._f['entropy'].value + return self._f['entropy'][()] else: return None @@ -220,14 +220,14 @@ class StatePoint(object): @property def generations_per_batch(self): if self.run_mode == 'eigenvalue': - return self._f['generations_per_batch'].value + return self._f['generations_per_batch'][()] else: return None @property def global_tallies(self): if self._global_tallies is None: - data = self._f['global_tallies'].value + data = self._f['global_tallies'][()] gt = np.zeros(data.shape[0], dtype=[ ('name', 'a14'), ('sum', 'f8'), ('sum_sq', 'f8'), ('mean', 'f8'), ('std_dev', 'f8')]) @@ -248,42 +248,42 @@ class StatePoint(object): @property def k_cmfd(self): if self.cmfd_on: - return self._f['cmfd/k_cmfd'].value + return self._f['cmfd/k_cmfd'][()] else: return None @property def k_generation(self): if self.run_mode == 'eigenvalue': - return self._f['k_generation'].value + return self._f['k_generation'][()] else: return None @property def k_combined(self): if self.run_mode == 'eigenvalue': - return ufloat(*self._f['k_combined'].value) + return ufloat(*self._f['k_combined'][()]) else: return None @property def k_col_abs(self): if self.run_mode == 'eigenvalue': - return self._f['k_col_abs'].value + return self._f['k_col_abs'][()] else: return None @property def k_col_tra(self): if self.run_mode == 'eigenvalue': - return self._f['k_col_tra'].value + return self._f['k_col_tra'][()] else: return None @property def k_abs_tra(self): if self.run_mode == 'eigenvalue': - return self._f['k_abs_tra'].value + return self._f['k_abs_tra'][()] else: return None @@ -303,22 +303,22 @@ class StatePoint(object): @property def n_batches(self): - return self._f['n_batches'].value + return self._f['n_batches'][()] @property def n_inactive(self): if self.run_mode == 'eigenvalue': - return self._f['n_inactive'].value + return self._f['n_inactive'][()] else: return None @property def n_particles(self): - return self._f['n_particles'].value + return self._f['n_particles'][()] @property def n_realizations(self): - return self._f['n_realizations'].value + return self._f['n_realizations'][()] @property def path(self): @@ -330,20 +330,20 @@ class StatePoint(object): @property def run_mode(self): - return self._f['run_mode'].value.decode() + return self._f['run_mode'][()].decode() @property def runtime(self): - return {name: dataset.value + return {name: dataset[()] for name, dataset in self._f['runtime'].items()} @property def seed(self): - return self._f['seed'].value + return self._f['seed'][()] @property def source(self): - return self._f['source_bank'].value if self.source_present else None + return self._f['source_bank'][()] if self.source_present else None @property def source_present(self): @@ -376,24 +376,24 @@ class StatePoint(object): group = tallies_group['tally {}'.format(tally_id)] # Read the number of realizations - n_realizations = group['n_realizations'].value + n_realizations = group['n_realizations'][()] # Create Tally object and assign basic properties tally = openmc.Tally(tally_id) tally._sp_filename = self._f.filename - tally.name = group['name'].value.decode() if 'name' in group else '' - tally.estimator = group['estimator'].value.decode() + tally.name = group['name'][()].decode() if 'name' in group else '' + tally.estimator = group['estimator'][()].decode() tally.num_realizations = n_realizations # Read derivative information. if 'derivative' in group: - deriv_id = group['derivative'].value + deriv_id = group['derivative'][()] tally.derivative = self.tally_derivatives[deriv_id] # Read all filters - n_filters = group['n_filters'].value + n_filters = group['n_filters'][()] if n_filters > 0: - filter_ids = group['filters'].value + filter_ids = group['filters'][()] filters_group = self._f['tallies/filters'] for filter_id in filter_ids: filter_group = filters_group['filter {}'.format( @@ -403,15 +403,15 @@ class StatePoint(object): tally.filters.append(new_filter) # Read nuclide bins - nuclide_names = group['nuclides'].value + nuclide_names = group['nuclides'][()] # Add all nuclides to the Tally for name in nuclide_names: nuclide = openmc.Nuclide(name.decode().strip()) tally.nuclides.append(nuclide) - scores = group['score_bins'].value - n_score_bins = group['n_score_bins'].value + scores = group['score_bins'][()] + n_score_bins = group['n_score_bins'][()] # Add the scores to the Tally for j, score in enumerate(scores): @@ -445,14 +445,14 @@ class StatePoint(object): group = self._f['tallies/derivatives/derivative {}' .format(d_id)] deriv = openmc.TallyDerivative(derivative_id=d_id) - deriv.variable = group['independent variable'].value.decode() + deriv.variable = group['independent variable'][()].decode() if deriv.variable == 'density': - deriv.material = group['material'].value + deriv.material = group['material'][()] elif deriv.variable == 'nuclide_density': - deriv.material = group['material'].value - deriv.nuclide = group['nuclide'].value.decode() + deriv.material = group['material'][()] + deriv.nuclide = group['nuclide'][()].decode() elif deriv.variable == 'temperature': - deriv.material = group['material'].value + deriv.material = group['material'][()] self._derivs[d_id] = deriv self._derivs_read = True diff --git a/openmc/summary.py b/openmc/summary.py index 866dd8288a..2ab29c00a4 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -85,14 +85,14 @@ class Summary(object): def _read_nuclides(self): if 'nuclides/names' in self._f: - names = self._f['nuclides/names'].value - awrs = self._f['nuclides/awrs'].value + names = self._f['nuclides/names'][()] + awrs = self._f['nuclides/awrs'][()] for name, awr in zip(names, awrs): self._nuclides[name.decode()] = awr def _read_macroscopics(self): if 'macroscopics/names' in self._f: - names = self._f['macroscopics/names'].value + names = self._f['macroscopics/names'][()] for name in names: self._macroscopics = name.decode() @@ -130,34 +130,34 @@ class Summary(object): for key, group in self._f['geometry/cells'].items(): cell_id = int(key.lstrip('cell ')) - name = group['name'].value.decode() if 'name' in group else '' - fill_type = group['fill_type'].value.decode() + name = group['name'][()].decode() if 'name' in group else '' + fill_type = group['fill_type'][()].decode() if fill_type == 'material': - fill = group['material'].value + fill = group['material'][()] elif fill_type == 'universe': - fill = group['fill'].value + fill = group['fill'][()] else: - fill = group['lattice'].value + fill = group['lattice'][()] - region = group['region'].value.decode() if 'region' in group else '' + region = group['region'][()].decode() if 'region' in group else '' # Create this Cell cell = openmc.Cell(cell_id=cell_id, name=name) if fill_type == 'universe': if 'translation' in group: - translation = group['translation'][...] + translation = group['translation'][()] translation = np.asarray(translation, dtype=np.float64) cell.translation = translation if 'rotation' in group: - rotation = group['rotation'][...] + rotation = group['rotation'][()] rotation = np.asarray(rotation, dtype=np.int) cell._rotation = rotation elif fill_type == 'material': - cell.temperature = group['temperature'][...] + cell.temperature = group['temperature'][()] # Store Cell fill information for after Universe/Lattice creation cell_fills[cell.id] = (fill_type, fill) diff --git a/openmc/surface.py b/openmc/surface.py index 0f10e7f486..3dac4ed5b8 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -269,10 +269,10 @@ class Surface(IDManagerMixin, metaclass=ABCMeta): """ surface_id = int(group.name.split('/')[-1].lstrip('surface ')) - name = group['name'].value.decode() if 'name' in group else '' - surf_type = group['type'].value.decode() - bc = group['boundary_type'].value.decode() - coeffs = group['coefficients'][...] + name = group['name'][()].decode() if 'name' in group else '' + surf_type = group['type'][()].decode() + bc = group['boundary_type'][()].decode() + coeffs = group['coefficients'][()] # Create the Surface based on its type if surf_type == 'x-plane': diff --git a/openmc/tallies.py b/openmc/tallies.py index 291090b196..a5f3a17f32 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -217,7 +217,7 @@ class Tally(IDManagerMixin): f = h5py.File(self._sp_filename, 'r') # Extract Tally data from the file - data = f['tallies/tally {0}/results'.format(self.id)].value + data = f['tallies/tally {0}/results'.format(self.id)] sum = data[:, :, 0] sum_sq = data[:, :, 1] diff --git a/openmc/universe.py b/openmc/universe.py index 044da12e35..ee038ebef4 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -124,7 +124,7 @@ class Universe(IDManagerMixin): """ universe_id = int(group.name.split('/')[-1].lstrip('universe ')) - cell_ids = group['cells'].value + cell_ids = group['cells'][()] # Create this Universe universe = cls(universe_id) diff --git a/openmc/volume.py b/openmc/volume.py index af7c356aed..7ac4fdd0c6 100644 --- a/openmc/volume.py +++ b/openmc/volume.py @@ -211,9 +211,9 @@ class VolumeCalculation(object): domain_id = int(obj_name[7:]) ids.append(domain_id) group = f[obj_name] - volume = ufloat(*group['volume'].value) - nucnames = group['nuclides'].value - atoms_ = group['atoms'].value + volume = ufloat(*group['volume'][()]) + nucnames = group['nuclides'][()] + atoms_ = group['atoms'][()] atom_dict = OrderedDict() for name_i, atoms_i in zip(nucnames, atoms_): From 6bcec6fa19e0707190f3d11cf5c9b979ddad2734 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Wed, 27 Mar 2019 21:24:46 -0400 Subject: [PATCH 09/10] Remove operator tokens from simple cell RPN --- src/cell.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/cell.cpp b/src/cell.cpp index c7b92c8294..45817de421 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -336,6 +336,16 @@ CSGCell::CSGCell(pugi::xml_node cell_node) } } + // If this cell is simple, remove all the superfluous operator tokens. + if (simple_) { + std::vector stack; + for (auto token : rpn_) { + if (token < OP_UNION) stack.push_back(token); + } + rpn_ = std::vector(stack.rbegin(), stack.rend()); + rpn_.shrink_to_fit(); + } + // Read the translation vector. if (check_for_node(cell_node, "translation")) { if (fill_ == C_NONE) { @@ -522,19 +532,17 @@ bool CSGCell::contains_simple(Position r, Direction u, int32_t on_surface) const { for (int32_t token : rpn_) { - if (token < OP_UNION) { - // If the token is not an operator, evaluate the sense of particle with - // respect to the surface and see if the token matches the sense. If the - // particle's surface attribute is set and matches the token, that - // overrides the determination based on sense(). - if (token == on_surface) { - } else if (-token == on_surface) { - return false; - } else { - // Note the off-by-one indexing - bool sense = model::surfaces[abs(token)-1]->sense(r, u); - if (sense != (token > 0)) {return false;} - } + // Assume that no tokens are operators. Evaluate the sense of particle with + // respect to the surface and see if the token matches the sense. If the + // particle's surface attribute is set and matches the token, that + // overrides the determination based on sense(). + if (token == on_surface) { + } else if (-token == on_surface) { + return false; + } else { + // Note the off-by-one indexing + bool sense = model::surfaces[abs(token)-1]->sense(r, u); + if (sense != (token > 0)) {return false;} } } return true; From 2dc02c57743ad1ec49868b73e2cc7d4e139b8cf1 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Sun, 31 Mar 2019 07:38:18 -0400 Subject: [PATCH 10/10] Remove unneeded rpn tokens in-place --- src/cell.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cell.cpp b/src/cell.cpp index 45817de421..1baf7b44eb 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -325,7 +325,6 @@ CSGCell::CSGCell(pugi::xml_node cell_node) // Convert the infix region spec to RPN. rpn_ = generate_rpn(id_, region_); - rpn_.shrink_to_fit(); // Check if this is a simple cell. simple_ = true; @@ -338,13 +337,18 @@ CSGCell::CSGCell(pugi::xml_node cell_node) // If this cell is simple, remove all the superfluous operator tokens. if (simple_) { - std::vector stack; - for (auto token : rpn_) { - if (token < OP_UNION) stack.push_back(token); + size_t i0 = 0; + size_t i1 = 0; + while (i1 < rpn_.size()) { + if (rpn_[i1] < OP_UNION) { + rpn_[i0] = rpn_[i1]; + ++i0; + } + ++i1; } - rpn_ = std::vector(stack.rbegin(), stack.rend()); - rpn_.shrink_to_fit(); + rpn_.resize(i0); } + rpn_.shrink_to_fit(); // Read the translation vector. if (check_for_node(cell_node, "translation")) {