diff --git a/CMakeLists.txt b/CMakeLists.txt index cbbe045c9..f81a9a1e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ option(debug "Compile with debug flags" OFF) option(optimize "Turn on all compiler optimization flags" OFF) option(coverage "Compile with coverage analysis flags" OFF) option(mpif08 "Use Fortran 2008 MPI interface" OFF) -option(cad "Enable support for CAD-based geometry" OFF) +option(dagmc "Enable support for DAGMC (CAD) geometry" OFF) # Maximum number of nested coordinates levels set(maxcoord 10 CACHE STRING "Maximum number of nested coordinate levels") @@ -40,14 +40,14 @@ if(MPI_ENABLED AND mpif08) endif() #=============================================================================== -# CAD Geometry Support - need DAGMC/MOAB +# DAGMC Geometry Support - need DAGMC/MOAB #=============================================================================== -if(cad) +if(dagmc) find_package(DAGMC REQUIRED) if(NOT DAGMC_FOUND) message(FATAL_ERROR "Could not find DAGMC installation") endif() - add_definitions(-DCAD) + add_definitions(-DDAGMC) link_directories(${DAGMC_LIBRARY_DIRS}) include_directories(${DAGMC_INCLUDE_DIRS}) endif() @@ -311,7 +311,7 @@ add_library(libopenmc SHARED src/algorithm.F90 src/bank_header.F90 src/api.F90 - src/cad_header.F90 + src/dagmc_header.F90 src/cmfd_data.F90 src/cmfd_execute.F90 src/cmfd_header.F90 @@ -400,8 +400,8 @@ add_library(libopenmc SHARED src/tallies/tally_header.F90 src/tallies/trigger.F90 src/tallies/trigger_header.F90 - src/cad.cpp - src/cad.h + src/dagmc.cpp + src/dagmc.h src/cell.cpp src/cmfd_execute.cpp src/distribution.cpp diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 1f3bbe7a4..b7353b305 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -13,7 +13,7 @@ #include "openmc/constants.h" #include "openmc/position.h" -#ifdef CAD +#ifdef DAGMC #include "DagMC.hpp" #endif @@ -167,12 +167,12 @@ protected: bool contains_complex(Position r, Direction u, int32_t on_surface) const; }; -#ifdef CAD -class CADCell : public Cell +#ifdef DAGMC +class DAGMCCell : public Cell { public: moab::DagMC *dagmc_ptr; - explicit CADCell(); + explicit DAGMCCell(); std::pair distance(Position p, Direction u, int32_t on_surface) const; bool contains(Position p, Direction u, int32_t on_surface) const; diff --git a/include/openmc/surface.h b/include/openmc/surface.h index 7a1181719..0588dabc1 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -12,7 +12,7 @@ #include "openmc/constants.h" #include "openmc/position.h" -#ifdef CAD +#ifdef DAGMC #include "DagMC.hpp" #endif @@ -133,14 +133,14 @@ class CSGSurface : public Surface }; //============================================================================== -//! A `Surface` representing a CAD-based surface in DAGMC. +//! A `Surface` representing a DAGMC-based surface in DAGMC. //============================================================================== -#ifdef CAD -class CADSurface : public Surface +#ifdef DAGMC +class DAGMCSurface : public Surface { public: moab::DagMC* dagmc_ptr; - explicit CADSurface(); + explicit DAGMCSurface(); double evaluate(Position p) const; double distance(Position p, Direction u, bool coincident) const; diff --git a/src/api.F90 b/src/api.F90 index 5058b0ab1..38329ad80 100644 --- a/src/api.F90 +++ b/src/api.F90 @@ -29,8 +29,8 @@ module openmc_api use timer_header use volume_calc, only: openmc_calculate_volumes -#ifdef CAD - use cad_header, only: free_memory_cad +#ifdef DAGMC + use dagmc_header, only: free_memory_dagmc #endif implicit none @@ -330,8 +330,8 @@ contains call free_memory_tally_filter() call free_memory_tally_derivative() call free_memory_bank() -#ifdef CAD - call free_memory_cad() +#ifdef DAGMC + call free_memory_dagmc() #endif ! Deallocate CMFD diff --git a/src/cad.h b/src/cad.h deleted file mode 100644 index 1a1663cdb..000000000 --- a/src/cad.h +++ /dev/null @@ -1,18 +0,0 @@ - -#ifdef CAD - -#ifndef CAD_H -#define CAD_H - -#include "DagMC.hpp" -#include "openmc/cell.h" -#include "openmc/surface.h" - -extern moab::DagMC* DAGMC; - -extern "C" void load_cad_geometry_c(); -extern "C" void free_memory_cad_c(); - -#endif // CAD_H - -#endif diff --git a/src/cad_header.F90 b/src/cad_header.F90 deleted file mode 100644 index 898211454..000000000 --- a/src/cad_header.F90 +++ /dev/null @@ -1,30 +0,0 @@ -#ifdef CAD - -module cad_header - - use, intrinsic :: ISO_C_BINDING - - implicit none - - interface - subroutine load_cad_geometry_c() bind(C) - end subroutine load_cad_geometry_c - - subroutine free_memory_cad_c() bind(C) - end subroutine free_memory_cad_c - - end interface - -contains - - subroutine load_cad_geometry() - call load_cad_geometry_c() - end subroutine load_cad_geometry - - subroutine free_memory_cad() - call free_memory_cad_c() - end subroutine free_memory_cad - -end module cad_header - -#endif diff --git a/src/cell.cpp b/src/cell.cpp index 82ae2cc3d..80d144884 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -592,12 +592,12 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const } //============================================================================== -// CAD Cell implementation +// DAGMC Cell implementation //============================================================================== -#ifdef CAD -CADCell::CADCell() : Cell{} {}; +#ifdef DAGMC +DAGMCCell::DAGMCCell() : Cell{} {}; -std::pair CADCell::distance(Position p, Direction u, int32_t on_surface) const { +std::pair DAGMCCell::distance(Position p, Direction u, int32_t on_surface) const { moab::ErrorCode rval; moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id_); moab::EntityHandle hit_surf; @@ -618,7 +618,7 @@ std::pair CADCell::distance(Position p, Direction u, int32_t on return result; } -bool CADCell::contains(Position p, Direction u, int32_t on_surface) const { +bool DAGMCCell::contains(Position p, Direction u, int32_t on_surface) const { moab::ErrorCode rval; moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id_); @@ -628,7 +628,7 @@ bool CADCell::contains(Position p, Direction u, int32_t on_surface) const { return bool(result); } -void CADCell::to_hdf5(hid_t group_id) const { return; } +void DAGMCCell::to_hdf5(hid_t group_id) const { return; } #endif //============================================================================== @@ -771,9 +771,9 @@ extern "C" { int cell_type(Cell* c) {return c->type_;} -#ifdef CAD +#ifdef DAGMC - int32_t next_cell(CADCell* cur_cell, CADSurface *surf_xed ) { + int32_t next_cell(DAGMCCell* cur_cell, DAGMCSurface *surf_xed ) { moab::EntityHandle surf = surf_xed->dagmc_ptr->entity_by_id(2,surf_xed->id_); moab::EntityHandle vol = cur_cell->dagmc_ptr->entity_by_id(3,cur_cell->id_); diff --git a/src/cad.cpp b/src/dagmc.cpp similarity index 64% rename from src/cad.cpp rename to src/dagmc.cpp index 7680932db..b701583ef 100644 --- a/src/cad.cpp +++ b/src/dagmc.cpp @@ -1,28 +1,28 @@ -#ifdef CAD +#ifdef DAGMC -#include "cad.h" +#include "dagmc.h" #include "openmc/error.h" #include #include -moab::DagMC* DAGMC; +moab::DagMC* DAG; #define TOLOWER(S) std::transform(S.begin(), S.end(), S.begin(), ::tolower) -void load_cad_geometry_c() +void load_dagmc_geometry_c() { - if(!DAGMC) { - DAGMC = new moab::DagMC(); + if(!DAG) { + DAG = new moab::DagMC(); } - int32_t cad_univ_id = 0; // universe is always 0 for CAD + int32_t dagmc_univ_id = 0; // universe is always 0 for DAGMC - moab::ErrorCode rval = DAGMC->load_file("dagmc.h5m"); + moab::ErrorCode rval = DAG->load_file("dagmc.h5m"); MB_CHK_ERR_CONT(rval); - rval = DAGMC->init_OBBTree(); + rval = DAG->init_OBBTree(); MB_CHK_ERR_CONT(rval); std::vector< std::string > prop_keywords; @@ -30,46 +30,46 @@ void load_cad_geometry_c() prop_keywords.push_back("boundary"); std::map ph; - DAGMC->parse_properties(prop_keywords, ph, ":"); + DAG->parse_properties(prop_keywords, ph, ":"); MB_CHK_ERR_CONT(rval); // initialize cell objects - openmc::n_cells = DAGMC->num_entities(3); + openmc::n_cells = DAG->num_entities(3); for(int i = 0; i < openmc::n_cells; i++) { - moab::EntityHandle vol_handle = DAGMC->entity_by_index(3, i+1); + moab::EntityHandle vol_handle = DAG->entity_by_index(3, i+1); // set cell ids using global IDs - openmc::CADCell* c = new openmc::CADCell(); - c->id_ = DAGMC->id_by_index(3, i+1); - c->dagmc_ptr = DAGMC; - c->universe_ = cad_univ_id; // set to zero for now + openmc::DAGMCCell* c = new openmc::DAGMCCell(); + c->id_ = DAG->id_by_index(3, i+1); + c->dagmc_ptr = DAG; + c->universe_ = dagmc_univ_id; // set to zero for now c->fill_ = openmc::C_NONE; // no fill, single universe openmc::cells.push_back(c); openmc::cell_map[c->id_] = c->id_; // Populate the Universe vector and dict - auto it = openmc::universe_map.find(cad_univ_id); + auto it = openmc::universe_map.find(dagmc_univ_id); if (it == openmc::universe_map.end()) { openmc::universes.push_back(new openmc::Universe()); - openmc::universes.back()-> id_ = cad_univ_id; + openmc::universes.back()-> id_ = dagmc_univ_id; openmc::universes.back()->cells_.push_back(i); - openmc::universe_map[cad_univ_id] = openmc::universes.size() - 1; + openmc::universe_map[dagmc_univ_id] = openmc::universes.size() - 1; } else { openmc::universes[it->second]->cells_.push_back(i); } - if(DAGMC->is_implicit_complement(vol_handle)) { + if(DAG->is_implicit_complement(vol_handle)) { // assuming implicit complement is void for now c->material_.push_back(openmc::MATERIAL_VOID); continue; } - if(DAGMC->has_prop(vol_handle, "mat")){ + if(DAG->has_prop(vol_handle, "mat")){ std::string mat_value; - rval = DAGMC->prop_value(vol_handle, "mat", mat_value); + rval = DAG->prop_value(vol_handle, "mat", mat_value); MB_CHK_ERR_CONT(rval); TOLOWER(mat_value); @@ -87,21 +87,21 @@ void load_cad_geometry_c() } // initialize surface objects - openmc::n_surfaces = DAGMC->num_entities(2); + openmc::n_surfaces = DAG->num_entities(2); openmc::surfaces.resize(openmc::n_surfaces); for(int i = 0; i < openmc::n_surfaces; i++) { - moab::EntityHandle surf_handle = DAGMC->entity_by_index(2, i+1); + moab::EntityHandle surf_handle = DAG->entity_by_index(2, i+1); // set cell ids using global IDs - openmc::CADSurface* s = new openmc::CADSurface(); - s->id_ = DAGMC->id_by_index(2, i+1); - s->dagmc_ptr = DAGMC; + openmc::DAGMCSurface* s = new openmc::DAGMCSurface(); + s->id_ = DAG->id_by_index(2, i+1); + s->dagmc_ptr = DAG; - if(DAGMC->has_prop(surf_handle, "boundary")) { + if(DAG->has_prop(surf_handle, "boundary")) { std::string bc_value; - rval = DAGMC->prop_value(surf_handle, "boundary", bc_value); + rval = DAG->prop_value(surf_handle, "boundary", bc_value); MB_CHK_ERR_CONT(rval); TOLOWER(bc_value); @@ -115,7 +115,7 @@ void load_cad_geometry_c() s->bc_ = openmc::BC_REFLECT; } else if(bc_value == "periodic") { - openmc::fatal_error("Periodic boundary condition not supported in CAD."); + openmc::fatal_error("Periodic boundary condition not supported in DAGMC."); } else { std::stringstream err_msg; @@ -137,9 +137,9 @@ void load_cad_geometry_c() return; } -void free_memory_cad_c() +void free_memory_dagmc_c() { - delete DAGMC; + delete DAG; } #endif diff --git a/src/dagmc.h b/src/dagmc.h new file mode 100644 index 000000000..d417b072f --- /dev/null +++ b/src/dagmc.h @@ -0,0 +1,18 @@ + +#ifdef DAGMC + +#ifndef DAGMC_H +#define DAGMC_H + +#include "DagMC.hpp" +#include "openmc/cell.h" +#include "openmc/surface.h" + +extern moab::DagMC* DAG; + +extern "C" void load_dagmc_geometry_c(); +extern "C" void free_memory_dagmc_c(); + +#endif // DAGMC_H + +#endif diff --git a/src/dagmc_header.F90 b/src/dagmc_header.F90 new file mode 100644 index 000000000..cb9b66481 --- /dev/null +++ b/src/dagmc_header.F90 @@ -0,0 +1,30 @@ +#ifdef DAGMC + +module dagmc_header + + use, intrinsic :: ISO_C_BINDING + + implicit none + + interface + subroutine load_dagmc_geometry_c() bind(C) + end subroutine load_dagmc_geometry_c + + subroutine free_memory_dagmc_c() bind(C) + end subroutine free_memory_dagmc_c + + end interface + +contains + + subroutine load_dagmc_geometry() + call load_dagmc_geometry_c() + end subroutine load_dagmc_geometry + + subroutine free_memory_dagmc() + call free_memory_dagmc_c() + end subroutine free_memory_dagmc + +end module dagmc_header + +#endif diff --git a/src/geometry.F90 b/src/geometry.F90 index c06084888..72caab359 100644 --- a/src/geometry.F90 +++ b/src/geometry.F90 @@ -56,7 +56,7 @@ module geometry subroutine neighbor_lists() bind(C) end subroutine neighbor_lists -#ifdef CAD +#ifdef DAGMC function next_cell_c(current_cell, surface_crossed) & bind(C, name="next_cell") result(new_cell) @@ -72,7 +72,7 @@ module geometry contains -#ifdef CAD +#ifdef DAGMC function next_cell(c, s) result(new_cell) type(Cell), intent(in) :: c diff --git a/src/input_xml.F90 b/src/input_xml.F90 index eef112b3a..00415bfe8 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -11,8 +11,8 @@ module input_xml use error, only: fatal_error, warning, write_message, openmc_err_msg use geometry, only: neighbor_lists use geometry_header -#ifdef CAD - use cad_header +#ifdef DAGMC + use dagmc_header #endif use hdf5_interface use list_header, only: ListChar, ListInt, ListReal @@ -351,15 +351,15 @@ contains end subroutine read_settings_xml_f -#ifdef CAD +#ifdef DAGMC !=============================================================================== -! READ_GEOMETRY_CAD reads data from a DAGMC .h5m file, checking +! READ_GEOMETRY_DAGMC reads data from a DAGMC .h5m file, checking ! for material properties and surface boundary conditions ! some universe information is spoofed for now !=============================================================================== - subroutine read_geometry_cad() + subroutine read_geometry_dagmc() integer :: i, j integer :: univ_id @@ -375,12 +375,12 @@ contains filename = trim(path_input) // "dagmc.h5m" inquire(FILE=filename, EXIST=file_exists) if (.not. file_exists) then - call fatal_error("Geometry CAD file '" // trim(filename) // "' does not & + call fatal_error("Geometry DAGMC file '" // trim(filename) // "' does not & &exist!") end if - call write_message("Reading CAD geometry...", 5) - call load_cad_geometry() + call write_message("Reading DAGMC geometry...", 5) + call load_dagmc_geometry() call allocate_surfaces() call allocate_cells() @@ -405,7 +405,7 @@ contains return - end subroutine read_geometry_cad + end subroutine read_geometry_dagmc #endif @@ -436,9 +436,9 @@ contains type(VectorInt) :: univ_ids ! List of all universe IDs type(DictIntInt) :: cells_in_univ_dict ! Used to count how many cells each ! universe contains -#ifdef CAD +#ifdef DAGMC if (dagmc) then - call read_geometry_cad() + call read_geometry_dagmc() return end if #endif @@ -941,7 +941,7 @@ contains end if ! Create list of macroscopic x/s based on those specified, just treat - ! them as nuclides. This is all really a facade so the user thinks they + ! them as nuclides. This is all really a fadagmce so the user thinks they ! are entering in macroscopic data but the code treats them the same ! as nuclides internally. ! Get pointer list of XML diff --git a/src/settings.F90 b/src/settings.F90 index 6625ccef0..5929bdd93 100644 --- a/src/settings.F90 +++ b/src/settings.F90 @@ -80,7 +80,7 @@ module settings ! Mode to run in (fixed source, eigenvalue, plotting, etc) integer(C_INT), bind(C) :: run_mode - ! flag for use of CAD geometry + ! flag for use of DAGMC geometry logical(C_BOOL), bind(C) :: dagmc ! Restart run diff --git a/src/settings.cpp b/src/settings.cpp index 60a805a01..311ba1af3 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -213,9 +213,9 @@ void read_settings_xml() dagmc = get_node_value_bool(root, "dagmc"); } -#ifndef CAD +#ifndef DAGMC if (dagmc) { - fatal_error("CAD mode unsupported for this build of OpenMC"); + fatal_error("DAGMC mode unsupported for this build of OpenMC"); } #endif diff --git a/src/summary.cpp b/src/summary.cpp index 1eeb28185..4d54b2c86 100644 --- a/src/summary.cpp +++ b/src/summary.cpp @@ -9,7 +9,7 @@ namespace openmc { extern "C" void write_geometry(hid_t file_id) { -#ifdef CAD +#ifdef DAGMC if (settings::dagmc) { return; } diff --git a/src/surface.cpp b/src/surface.cpp index ad30a37fc..fb43f0f00 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -245,17 +245,17 @@ CSGSurface::to_hdf5(hid_t group_id) const } //============================================================================== -// CADSurface implementation +// DAGMCSurface implementation //============================================================================== -#ifdef CAD -CADSurface::CADSurface() : Surface{} {} // empty constructor +#ifdef DAGMC +DAGMCSurface::DAGMCSurface() : Surface{} {} // empty constructor -double CADSurface::evaluate(Position r) const +double DAGMCSurface::evaluate(Position r) const { return 0.0; } -double CADSurface::distance(Position p, Direction u, bool coincident) const { +double DAGMCSurface::distance(Position p, Direction u, bool coincident) const { moab::ErrorCode rval; moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id_); moab::EntityHandle hit_surf; @@ -266,7 +266,7 @@ double CADSurface::distance(Position p, Direction u, bool coincident) const { return dist; } -Direction CADSurface::normal(Position p) const { +Direction DAGMCSurface::normal(Position p) const { moab::ErrorCode rval; Direction u; moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id_); @@ -275,7 +275,7 @@ Direction CADSurface::normal(Position p) const { return u; } -BoundingBox CADSurface::bounding_box() const { +BoundingBox DAGMCSurface::bounding_box() const { moab::ErrorCode rval; moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id_); double min[3], max[3]; @@ -284,7 +284,7 @@ BoundingBox CADSurface::bounding_box() const { return BoundingBox(min[0], max[0], min[1], max[1], min[2], max[2]); } -void CADSurface::to_hdf5(hid_t group_id) const {} +void DAGMCSurface::to_hdf5(hid_t group_id) const {} #endif //============================================================================== // PeriodicSurface implementation diff --git a/src/tracking.F90 b/src/tracking.F90 index 84ab56cf6..352d9bc7b 100644 --- a/src/tracking.F90 +++ b/src/tracking.F90 @@ -7,7 +7,7 @@ module tracking use geometry_header, only: cells use geometry, only: find_cell, distance_to_boundary, cross_lattice,& check_cell_overlap -#ifdef CAD +#ifdef DAGMC use geometry, only: next_cell #endif @@ -473,7 +473,7 @@ contains ! ========================================================================== ! SEARCH NEIGHBOR LISTS FOR NEXT CELL -#ifdef CAD +#ifdef DAGMC if (dagmc) then i_cell = next_cell(cells(p % last_cell(1) + 1), surfaces(ABS(p % surface))) ! save material and temp