diff --git a/.github/actions/upstream-test/action.yml b/.github/actions/upstream-test/action.yml index 0cb8182274..68064d160b 100644 --- a/.github/actions/upstream-test/action.yml +++ b/.github/actions/upstream-test/action.yml @@ -8,7 +8,7 @@ inputs: geant_version: description: Version of Geant4 required: false - default: 10.7.4 + default: 11.1.2 ubuntu_version: description: Underlying OS version required: false diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml index c8d84031f4..902a9703f9 100644 --- a/.github/workflows/docker_publish.yml +++ b/.github/workflows/docker_publish.yml @@ -33,6 +33,7 @@ jobs: ] geant_version : [ 10.7.4, + 11.1.2 ] name: Installing Dependencies, Building DAGMC and running tests @@ -94,6 +95,7 @@ jobs: ] geant_version : [ 10.7.4, + 11.1.2 ] name: Pushing final images diff --git a/.github/workflows/linux_upstream_test_geant4.yml b/.github/workflows/linux_upstream_test_geant4.yml index d5871a4907..3e09d0161a 100644 --- a/.github/workflows/linux_upstream_test_geant4.yml +++ b/.github/workflows/linux_upstream_test_geant4.yml @@ -27,5 +27,5 @@ jobs: uses: ./.github/actions/upstream-test with: token: ${{ secrets.GITHUB_TOKEN }} - geant_version: 11.1.1 + geant_version: 11.1.2 diff --git a/.github/workflows/mac_build_test.yml b/.github/workflows/mac_build_test.yml index 59678ce08e..a959052f76 100644 --- a/.github/workflows/mac_build_test.yml +++ b/.github/workflows/mac_build_test.yml @@ -47,7 +47,7 @@ jobs: - name: Initial setup shell: bash -l {0} run: | - brew install eigen gcc@6 hdf5 + brew install eigen hdf5 - name: Environment Variables shell: bash -l {0} diff --git a/CI/Dockerfile b/CI/Dockerfile index 5eba2cfe5d..434d43a767 100644 --- a/CI/Dockerfile +++ b/CI/Dockerfile @@ -5,7 +5,7 @@ # Global ARGS set before the first build stage are accessable by all build stages ARG EMBREE_BRANCH='v3.6.1' -ARG geant4_version=10.7.4 +ARG geant4_version=11.1.2 ARG UBUNTU_VERSION=20.04 ARG MOAB_BRANCH=5.3.0 ARG double_down=OFF diff --git a/cmake/FindGeant4.cmake b/cmake/FindGeant4.cmake index b62365fbea..f22f19b60b 100644 --- a/cmake/FindGeant4.cmake +++ b/cmake/FindGeant4.cmake @@ -1,13 +1,19 @@ # Find Geant4 cmake config file set(Geant4_SEARCH_DIRS) -# Is this line necessary? -set(PACKAGE_FIND_VERSION ${Geant4_FIND_VERSION}) -file(GLOB Geant4_SEARCH_DIRS "${GEANT4_DIR}/lib*/Geant4-*") + +file(GLOB Geant4_SEARCH_DIRS "${GEANT4_DIR}/lib*/Geant4*") string(REPLACE "\n" ";" Geant4_SEARCH_DIRS ${Geant4_SEARCH_DIRS}) +list(APPEND Geant4_SEARCH_DIRS "${GEANT4_DIR}/lib/cmake/Geant4") + +find_path(Geant4_CMAKE_CONFIG + NAMES Geant4Config.cmake + PATHS ${Geant4_SEARCH_DIRS} + NO_DEFAULT_PATH +) find_path(Geant4_CMAKE_CONFIG_VERSION NAMES Geant4ConfigVersion.cmake - PATHS ${Geant4_SEARCH_DIRS} + PATHS ${Geant4_CMAKE_CONFIG} NO_DEFAULT_PATH ) @@ -21,11 +27,6 @@ else () message(FATAL_ERROR "Could not find Geant4") endif () -find_path(Geant4_CMAKE_CONFIG - NAMES Geant4Config.cmake - PATHS ${Geant4_SEARCH_DIRS} - NO_DEFAULT_PATH -) if (Geant4_CMAKE_CONFIG) set(Geant4_CMAKE_CONFIG ${Geant4_CMAKE_CONFIG}/Geant4Config.cmake) message(STATUS "Geant4_CMAKE_CONFIG: ${Geant4_CMAKE_CONFIG}") @@ -58,7 +59,7 @@ include(${Geant4_USE_FILE}) set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_SAVE}) message(STATUS "Geant4 version: ${Geant4_VERSION}") -message(STATUS "Geant4 version required: ${PACKAGE_FIND_VERSION}") +message(STATUS "Geant4 version required: ${Geant4_FIND_VERSION}") message(STATUS "Geant4 version compatible: ${PACKAGE_VERSION_COMPATIBLE}") message(STATUS "Geant4 version exact: ${PACKAGE_VERSION_EXACT}") message(STATUS "Geant4_INCLUDE_DIRS: ${Geant4_INCLUDE_DIRS}") diff --git a/doc/CHANGELOG.rst b/doc/CHANGELOG.rst index 874ba45d6f..82de1cac69 100644 --- a/doc/CHANGELOG.rst +++ b/doc/CHANGELOG.rst @@ -29,7 +29,7 @@ Next version * Adding const identifier to cross-reference methods (#906) **Fixed:** - * Patch to compile with Geant4 10.6 (#803) + * Patch to compile with Geant4 11.x (#803 #907) * Patched cmake-search paths for double-down and MOAB (#878) * Patch to compile with gcc-13 (#882) * Tweak conda environment for Windows build to avoid conflicting gtest headers (#888) diff --git a/src/geant4/CMakeLists.txt b/src/geant4/CMakeLists.txt index d203d00ced..7599946d9b 100644 --- a/src/geant4/CMakeLists.txt +++ b/src/geant4/CMakeLists.txt @@ -2,7 +2,11 @@ message("") find_package(Geant4 10.4.2 REQUIRED) -if ( Geant4_VERSION GREATER_EQUAL 10.6 ) +if ( Geant4_VERSION GREATER_EQUAL 11.0 ) + message(STATUS "Configuring DAGMC for Geant4 version >= 11.0") + add_compile_definitions(GEANT4_GT_10_6=1) + add_compile_definitions(GEANT4_GT_11=1) + elseif( Geant4_VERSION GREATER_EQUAL 10.6 ) message(STATUS "Configuring DAGMC for Geant4 version >= 10.6") add_compile_definitions(GEANT4_GT_10_6=1) endif() diff --git a/src/geant4/app/include/ExN01Analysis.hh b/src/geant4/app/include/ExN01Analysis.hh index 15618704ce..530d274df5 100644 --- a/src/geant4/app/include/ExN01Analysis.hh +++ b/src/geant4/app/include/ExN01Analysis.hh @@ -7,6 +7,10 @@ #ifndef ExN01Analysis_h #define ExN01Analysis_h 1 +#ifdef GEANT4_GT_11 +#include "G4AnalysisManager.hh" +#else #include "g4root.hh" +#endif #endif diff --git a/src/geant4/app/src/ExN01DetectorConstruction.cc b/src/geant4/app/src/ExN01DetectorConstruction.cc index 23b6e91dc1..bf9236bee0 100644 --- a/src/geant4/app/src/ExN01DetectorConstruction.cc +++ b/src/geant4/app/src/ExN01DetectorConstruction.cc @@ -51,8 +51,11 @@ G4VPhysicalVolume* ExN01DetectorConstruction::Construct() { // load the material from the UW^2 library std::map material_lib; material_lib = load_uwuw_materials(workflow_data); - +#ifdef GEANT4_GT_11 + G4VisAttributes* invis = new G4VisAttributes(G4VisAttributes::GetInvisible()); +#else G4VisAttributes* invis = new G4VisAttributes(G4VisAttributes::Invisible); +#endif //------------------------------------------------------ volumes // -- World Volume in which we place other volumes diff --git a/src/geant4/generate_geant4 b/src/geant4/generate_geant4 index 524b312394..af7b3c64af 100755 --- a/src/geant4/generate_geant4 +++ b/src/geant4/generate_geant4 @@ -2,11 +2,13 @@ from optparse import OptionParser import os,errno -from itaps import iMesh,iBase +import sys # for material handling -from pyne.material import Material,MaterialLibrary +from pyne.material import Material +from pyne.material_library import MaterialLibrary from pyne.nucname import name, znum, anum, id, alara from pyne.data import atomic_mass +from pyne import dagmc # for coloring the volumes import colorsys @@ -69,10 +71,9 @@ def parse_arguments(): if options.dag_file: try: fh = open(options.dag_file, "r") - except IOError: - print "Error: can\'t find DAG file" - else: fh.close() + except IOError: + print("Error: can't find DAG file: '{} ".format(options.dag_file)) if not options.directory: options.directory = os.getcwd() else: @@ -90,69 +91,17 @@ dag_filename : h5m filename Returns --------- -dag_volnames : dictionary of volume names - +dag_vol_names : list of volume names +dag_materials : dictionary of material assignments """ def _get_dag_info(dag_filename): - dag_vol_names = [] # list of dag volume names (Cubit id) - dag_materials = {} # list of material assignments from group - - # create imesh instance - dag_geom = iMesh.Mesh() - # load the file - dag_geom.load(dag_filename) - - # get all entities - ents = dag_geom.getEntities() - - # create a mesh set - mesh_set = dag_geom.getEntSets() - # list of volume ent handles - - mat_list = [] - # get all geom_dimension ents - geom_list = [] - - cat_list = [] - - vol_tag = dag_geom.getTagHandle('GEOM_DIMENSION') - - name_tag = dag_geom.getTagHandle('GLOBAL_ID') - mat_tag = dag_geom.getTagHandle('NAME') + dag_materials = dagmc.cell_material_assignments(dag_filename) - cat_tag = dag_geom.getTagHandle('CATEGORY') + dag_vol_names = list(dag_materials.keys()) - # get the list we need - for i in mesh_set: - tags = dag_geom.getAllTags(i) - for tag in tags: - if tag == vol_tag: - geom_list.append(i) - if tag == mat_tag: - mat_list.append(i) - if tag == cat_tag: - cat_list.append(i) - - # for the 3d entities - for entity in geom_list: - if vol_tag[entity] == 3: - dag_vol_names.append(str(name_tag[entity])) - - - # loop over all the volumes - for entity in geom_list: - # loop over the material sets - for meshset in mat_list: - # if volume in set - if meshset.contains(entity): - mat_name = mat_tag[meshset] - volume_name = name_tag[entity] - dag_materials[volume_name]="".join( chr( val ) for val in mat_name ) - - - return dag_vol_names,dag_materials + return dag_vol_names, dag_materials """ Function to pull out the pyne materials from the h5m file @@ -179,8 +128,8 @@ def _get_material_info(dag_file): mat_lib.from_hdf5(dag_file) materials = mat_lib.keys() except: - print "!! There are no materials in the h5m file !!" - print " Assuming all volumes contain vacuum " + print("There are no materials in the h5m file.\n" + "Assuming all volumes contain vacuum") materials = {} nuclides = set() @@ -534,7 +483,7 @@ dag_volume_names : list or dictionary of volume names def _setup_dagspecific_headers(dag_volume_names, tallies_needed): if not dag_volume_names: - print "dag volume names not assigned", sys.exc_info()[0] + print("DAGMC volume names are not assigned", sys.exc_info()[0]) raise headers = {} @@ -1679,12 +1628,11 @@ def _write_files(path, dictionary_files): for key in dictionary_files: try: fh = open(path+'/'+key, "w") - except IOError: - print "Error: "+file+" file exists" - else: for line in dictionary_files[key]: fh.write(line) fh.close + except IOError: + print("Error: '{}' file exists".format(key)) """ @@ -1707,10 +1655,6 @@ def _create_directory_structure(directory): _mkdir_p(directory+'/src') return -def _dagmc_volume_material(dagmc_h5m, index): - - return material_name - """ Function from http://stackoverflow.com/questions /600268/mkdir-p-functionality-in-python, to create @@ -1724,7 +1668,7 @@ def _mkdir_p(path): try: os.makedirs(path) except OSError: - print "Error: can\'t create directory, "+path + print("Error: can't create directory '{}' ".format(path)) raise