Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for UWUW Macro Conflict #3150

Merged
merged 18 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -509,6 +509,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 @@ -545,11 +553,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()
2 changes: 1 addition & 1 deletion include/openmc/dagmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class DAGUniverse : public Universe {
//! \param[in] vol_handle The DAGMC material assignment string
//! \param[in] c The OpenMC cell to which the material is assigned
void uwuw_assign_material(
moab::EntityHandle vol_handle, std::unique_ptr<DAGCell>& c) const;
pshriwise marked this conversation as resolved.
Show resolved Hide resolved
moab::EntityHandle vol_handle, std::unique_ptr<DAGCell>& c);

//! Assign a material to a cell based
//! \param[in] mat_string The DAGMC material assignment string
Expand Down
36 changes: 19 additions & 17 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
moab::EntityHandle vol_handle, std::unique_ptr<DAGCell>& c)
{
#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