Skip to content

Commit e047138

Browse files
Fix for UWUW Macro Conflict (#3150)
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
1 parent c0acc28 commit e047138

5 files changed

Lines changed: 35 additions & 25 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ jobs:
131131
echo "$HOME/NJOY2016/build" >> $GITHUB_PATH
132132
$GITHUB_WORKSPACE/tools/ci/gha-install.sh
133133
134+
- name: display-config
135+
shell: bash
136+
run: |
137+
openmc -v
138+
134139
- name: cache-xs
135140
uses: actions/cache@v4
136141
with:

‎CMakeLists.txt‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,14 @@ endif()
510510
if(OPENMC_USE_DAGMC)
511511
target_compile_definitions(libopenmc PRIVATE DAGMC)
512512
target_link_libraries(libopenmc dagmc-shared)
513+
514+
if(OPENMC_USE_UWUW)
515+
target_compile_definitions(libopenmc PRIVATE OPENMC_UWUW)
516+
target_link_libraries(libopenmc uwuw-shared)
517+
endif()
518+
elseif(OPENMC_USE_UWUW)
519+
set(OPENMC_USE_UWUW OFF)
520+
message(FATAL_ERROR "DAGMC must be enabled when UWUW is enabled.")
513521
endif()
514522

515523
if(OPENMC_USE_LIBMESH)
@@ -546,11 +554,6 @@ if(OPENMC_USE_NCRYSTAL)
546554
target_link_libraries(libopenmc NCrystal::NCrystal)
547555
endif()
548556

549-
if (OPENMC_USE_UWUW)
550-
target_compile_definitions(libopenmc PRIVATE UWUW)
551-
target_link_libraries(libopenmc uwuw-shared)
552-
endif()
553-
554557
#===============================================================================
555558
# Log build info that this executable can report later
556559
#===============================================================================

‎cmake/OpenMCConfig.cmake.in‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ if(@OPENMC_USE_MCPL@)
3939
find_package(MCPL REQUIRED)
4040
endif()
4141

42-
if(@OPENMC_USE_UWUW@)
43-
find_package(UWUW REQUIRED)
44-
endif()
42+
if(@OPENMC_USE_UWUW@ AND NOT ${DAGMC_BUILD_UWUW})
43+
message(FATAL_ERROR "UWUW is enabled in OpenMC but the DAGMC installation discovered was not configured with UWUW.")
44+
endif()

‎src/dagmc.cpp‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "openmc/settings.h"
1212
#include "openmc/string_utils.h"
1313

14-
#ifdef UWUW
14+
#ifdef OPENMC_UWUW
1515
#include "uwuw.hpp"
1616
#endif
1717
#include <fmt/core.h>
@@ -29,7 +29,7 @@ const bool DAGMC_ENABLED = true;
2929
const bool DAGMC_ENABLED = false;
3030
#endif
3131

32-
#ifdef UWUW
32+
#ifdef OPENMC_UWUW
3333
const bool UWUW_ENABLED = true;
3434
#else
3535
const bool UWUW_ENABLED = false;
@@ -112,6 +112,11 @@ void DAGUniverse::initialize()
112112
{
113113
geom_type() = GeometryType::DAG;
114114

115+
#ifdef OPENMC_UWUW
116+
// read uwuw materials from the .h5m file if present
117+
read_uwuw_materials();
118+
#endif
119+
115120
init_dagmc();
116121

117122
init_metadata();
@@ -431,16 +436,16 @@ void DAGUniverse::to_hdf5(hid_t universes_group) const
431436

432437
bool DAGUniverse::uses_uwuw() const
433438
{
434-
#ifdef UWUW
439+
#ifdef OPENMC_UWUW
435440
return uwuw_ && !uwuw_->material_library.empty();
436441
#else
437442
return false;
438-
#endif // UWUW
443+
#endif // OPENMC_UWUW
439444
}
440445

441446
std::string DAGUniverse::get_uwuw_materials_xml() const
442447
{
443-
#ifdef UWUW
448+
#ifdef OPENMC_UWUW
444449
if (!uses_uwuw()) {
445450
throw std::runtime_error("This DAGMC Universe does not use UWUW materials");
446451
}
@@ -460,12 +465,12 @@ std::string DAGUniverse::get_uwuw_materials_xml() const
460465
return ss.str();
461466
#else
462467
fatal_error("DAGMC was not configured with UWUW.");
463-
#endif // UWUW
468+
#endif // OPENMC_UWUW
464469
}
465470

466471
void DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const
467472
{
468-
#ifdef UWUW
473+
#ifdef OPENMC_UWUW
469474
if (!uses_uwuw()) {
470475
throw std::runtime_error(
471476
"This DAGMC universe does not use UWUW materials.");
@@ -478,7 +483,7 @@ void DAGUniverse::write_uwuw_materials_xml(const std::string& outfile) const
478483
mats_xml.close();
479484
#else
480485
fatal_error("DAGMC was not configured with UWUW.");
481-
#endif
486+
#endif // OPENMC_UWUW
482487
}
483488

484489
void DAGUniverse::legacy_assign_material(
@@ -540,7 +545,7 @@ void DAGUniverse::legacy_assign_material(
540545

541546
void DAGUniverse::read_uwuw_materials()
542547
{
543-
#ifdef UWUW
548+
#ifdef OPENMC_UWUW
544549
// If no filename was provided, don't read UWUW materials
545550
if (filename_ == "")
546551
return;
@@ -580,16 +585,13 @@ void DAGUniverse::read_uwuw_materials()
580585
}
581586
#else
582587
fatal_error("DAGMC was not configured with UWUW.");
583-
#endif
588+
#endif // OPENMC_UWUW
584589
}
585590

586591
void DAGUniverse::uwuw_assign_material(
587592
moab::EntityHandle vol_handle, std::unique_ptr<DAGCell>& c) const
588593
{
589-
#ifdef UWUW
590-
// read materials from uwuw material file
591-
read_uwuw_materials();
592-
594+
#ifdef OPENMC_UWUW
593595
// lookup material in uwuw if present
594596
std::string uwuw_mat = dmd_ptr->volume_material_property_data_eh[vol_handle];
595597
if (uwuw_->material_library.count(uwuw_mat) != 0) {
@@ -601,11 +603,11 @@ void DAGUniverse::uwuw_assign_material(
601603
} else {
602604
fatal_error(fmt::format("Material with value '{}' not found in the "
603605
"UWUW material library",
604-
mat_str));
606+
uwuw_mat));
605607
}
606608
#else
607609
fatal_error("DAGMC was not configured with UWUW.");
608-
#endif
610+
#endif // OPENMC_UWUW
609611
}
610612
//==============================================================================
611613
// DAGMC Cell implementation

‎src/output.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void print_build_info()
347347
#ifdef COVERAGEBUILD
348348
coverage = y;
349349
#endif
350-
#ifdef UWUW
350+
#ifdef OPENMC_UWUW
351351
uwuw = y;
352352
#endif
353353

0 commit comments

Comments
 (0)