Skip to content

Commit

Permalink
Fix for UWUW Macro Conflict (#3150)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrick Shriwise <[email protected]>
  • Loading branch information
ahnaf-tahmid-chowdhury and pshriwise authored Oct 9, 2024
1 parent c0acc28 commit e047138
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ jobs:
echo "$HOME/NJOY2016/build" >> $GITHUB_PATH
$GITHUB_WORKSPACE/tools/ci/gha-install.sh
- name: display-config
shell: bash
run: |
openmc -v
- name: cache-xs
uses: actions/cache@v4
with:
Expand Down
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ endif()
if(OPENMC_USE_DAGMC)
target_compile_definitions(libopenmc PRIVATE DAGMC)
target_link_libraries(libopenmc dagmc-shared)

if(OPENMC_USE_UWUW)
target_compile_definitions(libopenmc PRIVATE OPENMC_UWUW)
target_link_libraries(libopenmc uwuw-shared)
endif()
elseif(OPENMC_USE_UWUW)
set(OPENMC_USE_UWUW OFF)
message(FATAL_ERROR "DAGMC must be enabled when UWUW is enabled.")
endif()

if(OPENMC_USE_LIBMESH)
Expand Down Expand Up @@ -546,11 +554,6 @@ if(OPENMC_USE_NCRYSTAL)
target_link_libraries(libopenmc NCrystal::NCrystal)
endif()

if (OPENMC_USE_UWUW)
target_compile_definitions(libopenmc PRIVATE UWUW)
target_link_libraries(libopenmc uwuw-shared)
endif()

#===============================================================================
# Log build info that this executable can report later
#===============================================================================
Expand Down
6 changes: 3 additions & 3 deletions cmake/OpenMCConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ if(@OPENMC_USE_MCPL@)
find_package(MCPL REQUIRED)
endif()

if(@OPENMC_USE_UWUW@)
find_package(UWUW REQUIRED)
endif()
if(@OPENMC_USE_UWUW@ AND NOT ${DAGMC_BUILD_UWUW})
message(FATAL_ERROR "UWUW is enabled in OpenMC but the DAGMC installation discovered was not configured with UWUW.")
endif()
34 changes: 18 additions & 16 deletions src/dagmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "openmc/settings.h"
#include "openmc/string_utils.h"

#ifdef UWUW
#ifdef OPENMC_UWUW
#include "uwuw.hpp"
#endif
#include <fmt/core.h>
Expand All @@ -29,7 +29,7 @@ const bool DAGMC_ENABLED = true;
const bool DAGMC_ENABLED = false;
#endif

#ifdef UWUW
#ifdef OPENMC_UWUW
const bool UWUW_ENABLED = true;
#else
const bool UWUW_ENABLED = false;
Expand Down Expand Up @@ -112,6 +112,11 @@ void DAGUniverse::initialize()
{
geom_type() = GeometryType::DAG;

#ifdef OPENMC_UWUW
// read uwuw materials from the .h5m file if present
read_uwuw_materials();
#endif

init_dagmc();

init_metadata();
Expand Down Expand Up @@ -431,16 +436,16 @@ void DAGUniverse::to_hdf5(hid_t universes_group) const

bool DAGUniverse::uses_uwuw() const
{
#ifdef UWUW
#ifdef OPENMC_UWUW
return uwuw_ && !uwuw_->material_library.empty();
#else
return false;
#endif // UWUW
#endif // OPENMC_UWUW
}

std::string DAGUniverse::get_uwuw_materials_xml() const
{
#ifdef UWUW
#ifdef OPENMC_UWUW
if (!uses_uwuw()) {
throw std::runtime_error("This DAGMC Universe does not use UWUW materials");
}
Expand All @@ -460,12 +465,12 @@ std::string DAGUniverse::get_uwuw_materials_xml() const
return ss.str();
#else
fatal_error("DAGMC was not configured with UWUW.");
#endif // UWUW
#endif // OPENMC_UWUW
}

void DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const
{
#ifdef UWUW
#ifdef OPENMC_UWUW
if (!uses_uwuw()) {
throw std::runtime_error(
"This DAGMC universe does not use UWUW materials.");
Expand All @@ -478,7 +483,7 @@ void DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const
mats_xml.close();
#else
fatal_error("DAGMC was not configured with UWUW.");
#endif
#endif // OPENMC_UWUW
}

void DAGUniverse::legacy_assign_material(
Expand Down Expand Up @@ -540,7 +545,7 @@ void DAGUniverse::legacy_assign_material(

void DAGUniverse::read_uwuw_materials()
{
#ifdef UWUW
#ifdef OPENMC_UWUW
// If no filename was provided, don't read UWUW materials
if (filename_ == "")
return;
Expand Down Expand Up @@ -580,16 +585,13 @@ void DAGUniverse::read_uwuw_materials()
}
#else
fatal_error("DAGMC was not configured with UWUW.");
#endif
#endif // OPENMC_UWUW
}

void DAGUniverse::uwuw_assign_material(
moab::EntityHandle vol_handle, std::unique_ptr<DAGCell>& c) const
{
#ifdef UWUW
// read materials from uwuw material file
read_uwuw_materials();

#ifdef OPENMC_UWUW
// lookup material in uwuw if present
std::string uwuw_mat = dmd_ptr->volume_material_property_data_eh[vol_handle];
if (uwuw_->material_library.count(uwuw_mat) != 0) {
Expand All @@ -601,11 +603,11 @@ void DAGUniverse::uwuw_assign_material(
} else {
fatal_error(fmt::format("Material with value '{}' not found in the "
"UWUW material library",
mat_str));
uwuw_mat));
}
#else
fatal_error("DAGMC was not configured with UWUW.");
#endif
#endif // OPENMC_UWUW
}
//==============================================================================
// DAGMC Cell implementation
Expand Down
2 changes: 1 addition & 1 deletion src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void print_build_info()
#ifdef COVERAGEBUILD
coverage = y;
#endif
#ifdef UWUW
#ifdef OPENMC_UWUW
uwuw = y;
#endif

Expand Down

0 comments on commit e047138

Please sign in to comment.