diff --git a/src/api.F90 b/src/api.F90 index b39a2f8fa..05d276015 100644 --- a/src/api.F90 +++ b/src/api.F90 @@ -29,6 +29,10 @@ module openmc_api use timer_header use volume_calc, only: openmc_calculate_volumes +#ifdef CAD + use cad_header, only: free_memory_cad +#endif + implicit none private @@ -149,6 +153,7 @@ contains root_universe = -1 run_CE = .true. run_mode = -1 + dagmc = .false. satisfy_triggers = .false. call openmc_set_seed(DEFAULT_SEED) source_latest = .false. @@ -325,7 +330,10 @@ contains call free_memory_tally_filter() call free_memory_tally_derivative() call free_memory_bank() - +#ifdef CAD + call free_memory_cad() +#endif + ! Deallocate CMFD call deallocate_cmfd(cmfd) diff --git a/src/cad.cpp b/src/cad.cpp index 58eeeff48..325fda9de 100644 --- a/src/cad.cpp +++ b/src/cad.cpp @@ -42,7 +42,7 @@ void load_cad_geometry_c() return; } -void dealloc_cad_c() +void free_memory_cad_c() { delete DAGMC; } diff --git a/src/cad.h b/src/cad.h index c3dc49715..ff2540841 100644 --- a/src/cad.h +++ b/src/cad.h @@ -5,7 +5,9 @@ #include "cell.h" #include "surface.h" +extern moab::DagMC* DAGMC; + extern "C" void load_cad_geometry_c(); -extern "C" void dealloc_cad_c(); +extern "C" void free_memory_cad_c(); #endif // CAD_H diff --git a/src/cad_header.F90 b/src/cad_header.F90 index 1fc6dbf16..3c53254c9 100644 --- a/src/cad_header.F90 +++ b/src/cad_header.F90 @@ -9,8 +9,8 @@ module cad_header subroutine load_cad_geometry_c() bind(C) end subroutine load_cad_geometry_c - subroutine dealloc_cad_c() bind(C) - end subroutine dealloc_cad_c + subroutine free_memory_cad_c() bind(C) + end subroutine free_memory_cad_c end interface @@ -20,8 +20,8 @@ contains call load_cad_geometry_c() end subroutine load_cad_geometry - subroutine dealloc_cad() - call dealloc_cad_c() - end subroutine dealloc_cad + subroutine free_memory_cad() + call free_memory_cad_c() + end subroutine free_memory_cad end module cad_header diff --git a/src/constants.F90 b/src/constants.F90 index a3118f84d..80c1d2322 100644 --- a/src/constants.F90 +++ b/src/constants.F90 @@ -429,7 +429,12 @@ module constants MODE_EIGENVALUE = 2, & ! K eigenvalue mode MODE_PLOTTING = 3, & ! Plotting mode MODE_PARTICLE = 4, & ! Particle restart mode +#ifdef CAD + MODE_VOLUME = 5, & ! Volume calculation mode + MODE_CAD = 6 ! CAD-based Geometry mode +#else MODE_VOLUME = 5 ! Volume calculation mode +#endif ! Electron treatments integer, parameter :: & diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 7361dd85b..16c107d13 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -11,6 +11,7 @@ module input_xml use error, only: fatal_error, warning, write_message, openmc_err_msg use geometry, only: neighbor_lists use geometry_header + use cad_header use hdf5_interface use list_header, only: ListChar, ListInt, ListReal use material_header @@ -216,6 +217,17 @@ contains ! Get proper XMLNode type given pointer root % ptr = root_ptr + ! Check for use of CAD geometry + if (check_for_node(root, "dagmc")) then +#ifdef CAD + call get_node_value_bool(root, "dagmc", dagmc) +#else + if (dagmc) then + call fatal_error("CAD mode unsupported for this build of OpenMC") + end if +#endif + end if + if (run_mode == MODE_EIGENVALUE) then ! Preallocate space for keff and entropy by generation call k_generation % reserve(n_max_batches*gen_per_batch) @@ -375,6 +387,12 @@ contains type(DictIntInt) :: cells_in_univ_dict ! Used to count how many cells each ! universe contains + if (dagmc) then + call write_message("Reading CAD geometry...", 5) + call load_cad_geometry() + return + end if + ! Display output message call write_message("Reading geometry XML file...", 5) diff --git a/src/settings.F90 b/src/settings.F90 index ec7bbf2c8..4efe25102 100644 --- a/src/settings.F90 +++ b/src/settings.F90 @@ -80,6 +80,9 @@ module settings ! Mode to run in (fixed source, eigenvalue, plotting, etc) integer(C_INT), bind(C) :: run_mode + ! flag for use of CAD geometry + logical, bind(C) :: dagmc = .false. + ! Restart run logical(C_BOOL), bind(C) :: restart_run diff --git a/src/xml_interface.F90 b/src/xml_interface.F90 index 7aa86556b..39c6330ec 100644 --- a/src/xml_interface.F90 +++ b/src/xml_interface.F90 @@ -12,6 +12,7 @@ module xml_interface public :: check_for_node public :: get_node_list public :: get_node_value + public :: get_node_value_bool public :: get_node_array public :: node_value_string public :: node_word_count