diff --git a/include/openmc/cell.h b/include/openmc/cell.h index b941acd7f6..88996226c1 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -172,12 +172,12 @@ protected: #ifdef DAGMC class DAGCell : public Cell { - public: - moab::DagMC *dagmc_ptr_; +public: + moab::DagMC* dagmc_ptr_; DAGCell(); - std::pair distance(Position p, Direction u, int32_t on_surface) const; - bool contains(Position p, Direction u, int32_t on_surface) const; + std::pair distance(Position r, Direction u, int32_t on_surface) const; + bool contains(Position r, Direction u, int32_t on_surface) const; void to_hdf5(hid_t group_id) const; diff --git a/include/openmc/dagmc.h b/include/openmc/dagmc.h index 309cf17068..8dd60516f0 100644 --- a/include/openmc/dagmc.h +++ b/include/openmc/dagmc.h @@ -8,11 +8,14 @@ #include "openmc/cell.h" #include "openmc/surface.h" +namespace openmc { + extern moab::DagMC* DAG; -extern "C" void load_dagmc_geometry_c(); -extern "C" void free_memory_dagmc_c(); +extern "C" void load_dagmc_geometry(); +extern "C" void free_memory_dagmc(); +} #endif // DAGMC_H #endif diff --git a/include/openmc/surface.h b/include/openmc/surface.h index 3f2b4d14b5..ba97734a21 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -44,15 +44,7 @@ extern std::map surface_map; //============================================================================== struct BoundingBox -{ - - BoundingBox(double x_min, double x_max, - double y_min, double y_max, - double z_min, double z_max) : - xmin(x_min), xmax(x_max), - ymin(y_min), ymax(y_max), - zmin(z_min), zmax(z_max) {} - +{ double xmin; double xmax; double ymin; @@ -141,10 +133,10 @@ class DAGSurface : public Surface public: moab::DagMC* dagmc_ptr_; DAGSurface(); - double evaluate(Position p) const; - double distance(Position p, Direction u, + double evaluate(Position r) const; + double distance(Position r, Direction u, bool coincident) const; - Direction normal(Position p) const; + Direction normal(Position r) const; //! Get the bounding box of this surface. BoundingBox bounding_box() const; diff --git a/src/cell.cpp b/src/cell.cpp index d1c8651124..865dcd5f76 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -595,12 +595,12 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const #ifdef DAGMC DAGCell::DAGCell() : Cell{} {}; -std::pair DAGCell::distance(Position p, Direction u, int32_t on_surface) const { +std::pair DAGCell::distance(Position r, Direction u, int32_t on_surface) const { moab::ErrorCode rval; moab::EntityHandle vol = dagmc_ptr_->entity_by_id(3, id_); moab::EntityHandle hit_surf; double dist; - double pnt[3] = {p.x, p.y, p.z}; + double pnt[3] = {r.x, r.y, r.z}; double dir[3] = {u.x, u.y, u.z}; rval = dagmc_ptr_->ray_fire(vol, pnt, dir, hit_surf, dist); MB_CHK_ERR_CONT(rval); @@ -611,21 +611,19 @@ std::pair DAGCell::distance(Position p, Direction u, int32_t on surf_idx = -1; } - std::pair result(dist, surf_idx); - - return result; + return {dist, surf_idx}; } -bool DAGCell::contains(Position p, Direction u, int32_t on_surface) const { +bool DAGCell::contains(Position r, Direction u, int32_t on_surface) const { moab::ErrorCode rval; moab::EntityHandle vol = dagmc_ptr_->entity_by_id(3, id_); int result = 0; - double pnt[3] = {p.x, p.y, p.z}; + double pnt[3] = {r.x, r.y, r.z}; double dir[3] = {u.x, u.y, u.z}; rval = dagmc_ptr_->point_in_volume(vol, pnt, result, dir); MB_CHK_ERR_CONT(rval); - return bool(result); + return result; } void DAGCell::to_hdf5(hid_t group_id) const { return; } @@ -773,7 +771,7 @@ extern "C" { #ifdef DAGMC - int32_t next_cell(DAGCell* cur_cell, DAGSurface *surf_xed ) { + int32_t next_cell(DAGCell* cur_cell, DAGSurface* 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/dagmc.cpp b/src/dagmc.cpp index 4e38263d70..61f6fe789a 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -8,9 +8,11 @@ #include #include +namespace openmc { + moab::DagMC* DAG; -void load_dagmc_geometry_c() +void load_dagmc_geometry() { if (!DAG) { DAG = new moab::DagMC(); @@ -24,7 +26,7 @@ void load_dagmc_geometry_c() rval = DAG->init_OBBTree(); MB_CHK_ERR_CONT(rval); - std::vector< std::string > prop_keywords; + std::vector prop_keywords; prop_keywords.push_back("mat"); prop_keywords.push_back("boundary"); @@ -33,34 +35,34 @@ void load_dagmc_geometry_c() MB_CHK_ERR_CONT(rval); // initialize cell objects - openmc::n_cells = DAG->num_entities(3); - for (int i = 0; i < openmc::n_cells; i++) { + n_cells = DAG->num_entities(3); + for (int i = 0; i < n_cells; i++) { moab::EntityHandle vol_handle = DAG->entity_by_index(3, i+1); // set cell ids using global IDs - openmc::DAGCell* c = new openmc::DAGCell(); + DAGCell* c = new DAGCell(); 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 + c->fill_ = C_NONE; // no fill, single universe - openmc::cells.push_back(c); - openmc::cell_map[c->id_] = c->id_; + cells.push_back(c); + cell_map[c->id_] = c->id_; // Populate the Universe vector and dict - 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_ = dagmc_univ_id; - openmc::universes.back()->cells_.push_back(i); - openmc::universe_map[dagmc_univ_id] = openmc::universes.size() - 1; + auto it = universe_map.find(dagmc_univ_id); + if (it == universe_map.end()) { + universes.push_back(new Universe()); + universes.back()-> id_ = dagmc_univ_id; + universes.back()->cells_.push_back(i); + universe_map[dagmc_univ_id] = universes.size() - 1; } else { - openmc::universes[it->second]->cells_.push_back(i); + universes[it->second]->cells_.push_back(i); } if (DAG->is_implicit_complement(vol_handle)) { // assuming implicit complement is void for now - c->material_.push_back(openmc::MATERIAL_VOID); + c->material_.push_back(MATERIAL_VOID); continue; } @@ -68,28 +70,28 @@ void load_dagmc_geometry_c() std::string mat_value; rval = DAG->prop_value(vol_handle, "mat", mat_value); MB_CHK_ERR_CONT(rval); - openmc::to_lower(mat_value); + to_lower(mat_value); if (mat_value == "void" || mat_value == "vacuum") { - c->material_.push_back(openmc::MATERIAL_VOID); + c->material_.push_back(MATERIAL_VOID); } else { c->material_.push_back(std::stoi(mat_value)); } } else { std::cout << c->id_ << std::endl; - openmc::fatal_error("A volume without a material was found."); + fatal_error("A volume without a material was found."); } } // initialize surface objects - openmc::n_surfaces = DAG->num_entities(2); - openmc::surfaces.resize(openmc::n_surfaces); + n_surfaces = DAG->num_entities(2); + surfaces.resize(n_surfaces); - for (int i = 0; i < openmc::n_surfaces; i++) { + for (int i = 0; i < n_surfaces; i++) { moab::EntityHandle surf_handle = DAG->entity_by_index(2, i+1); // set cell ids using global IDs - openmc::DAGSurface* s = new openmc::DAGSurface(); + DAGSurface* s = new DAGSurface(); s->id_ = DAG->id_by_index(2, i+1); s->dagmc_ptr_ = DAG; @@ -97,37 +99,38 @@ void load_dagmc_geometry_c() std::string bc_value; rval = DAG->prop_value(surf_handle, "boundary", bc_value); MB_CHK_ERR_CONT(rval); - openmc::to_lower(bc_value); + to_lower(bc_value); if (bc_value == "transmit" || bc_value == "transmission") { - s->bc_ = openmc::BC_TRANSMIT; + s->bc_ = BC_TRANSMIT; } else if (bc_value == "vacuum") { - s->bc_ = openmc::BC_VACUUM; + s->bc_ = BC_VACUUM; } else if (bc_value == "reflective" || bc_value == "reflect" || bc_value == "reflecting") { - s->bc_ = openmc::BC_REFLECT; + s->bc_ = BC_REFLECT; } else if (bc_value == "periodic") { - openmc::fatal_error("Periodic boundary condition not supported in DAGMC."); + fatal_error("Periodic boundary condition not supported in DAGMC."); } else { std::stringstream err_msg; err_msg << "Unknown boundary condition \"" << s->bc_ << "\" specified on surface " << s->id_; - openmc::fatal_error(err_msg); + fatal_error(err_msg); } } else { // if no BC property is found, set to transmit - s->bc_ = openmc::BC_TRANSMIT; + s->bc_ = BC_TRANSMIT; } // add to global array and map - openmc::surfaces[i] = s; - openmc::surface_map[s->id_] = s->id_; + surfaces[i] = s; + surface_map[s->id_] = s->id_; } return; } -void free_memory_dagmc_c() +void free_memory_dagmc() { delete DAG; } +} #endif diff --git a/src/dagmc_header.F90 b/src/dagmc_header.F90 index cb9b664810..9895791ac0 100644 --- a/src/dagmc_header.F90 +++ b/src/dagmc_header.F90 @@ -7,24 +7,14 @@ module dagmc_header implicit none interface - subroutine load_dagmc_geometry_c() bind(C) - end subroutine load_dagmc_geometry_c + subroutine load_dagmc_geometry() bind(C) + end subroutine load_dagmc_geometry - subroutine free_memory_dagmc_c() bind(C) - end subroutine free_memory_dagmc_c + subroutine free_memory_dagmc() bind(C) + end subroutine free_memory_dagmc 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/input_xml.F90 b/src/input_xml.F90 index f90d874b47..9fefbbfcdc 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -403,8 +403,6 @@ contains root_universe = find_root_universe() - return - end subroutine read_geometry_dagmc #endif diff --git a/src/summary.cpp b/src/summary.cpp index 4d54b2c869..7a0c4324a5 100644 --- a/src/summary.cpp +++ b/src/summary.cpp @@ -10,9 +10,7 @@ extern "C" void write_geometry(hid_t file_id) { #ifdef DAGMC - if (settings::dagmc) { - return; - } + if (settings::dagmc) return; #endif auto geom_group = create_group(file_id, "geometry"); diff --git a/src/surface.cpp b/src/surface.cpp index 00acf0df1c..85543fe266 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -255,12 +255,12 @@ double DAGSurface::evaluate(Position r) const return 0.0; } -double DAGSurface::distance(Position p, Direction u, bool coincident) const { +double DAGSurface::distance(Position r, Direction u, bool coincident) const { moab::ErrorCode rval; moab::EntityHandle surf = dagmc_ptr_->entity_by_id(2, id_); moab::EntityHandle hit_surf; double dist; - double pnt[3] = {p.x, p.y, p.z}; + double pnt[3] = {r.x, r.y, r.z}; double dir[3] = {u.x, u.y, u.z}; rval = dagmc_ptr_->ray_fire(surf, pnt, dir, hit_surf, dist, NULL, 0, 0); MB_CHK_ERR_CONT(rval); @@ -268,11 +268,11 @@ double DAGSurface::distance(Position p, Direction u, bool coincident) const { return dist; } -Direction DAGSurface::normal(Position p) const { +Direction DAGSurface::normal(Position r) const { moab::ErrorCode rval; Direction u; moab::EntityHandle surf = dagmc_ptr_->entity_by_id(2, id_); - double pnt[3] = {p.x, p.y, p.z}; + double pnt[3] = {r.x, r.y, r.z}; double dir[3] = {u.x, u.y, u.z}; rval = dagmc_ptr_->get_angle(surf, pnt, dir); MB_CHK_ERR_CONT(rval); @@ -285,7 +285,7 @@ BoundingBox DAGSurface::bounding_box() const { double min[3], max[3]; rval = dagmc_ptr_->getobb(surf, min, max); MB_CHK_ERR_CONT(rval); - return BoundingBox(min[0], max[0], min[1], max[1], min[2], max[2]); + return {min[0], max[0], min[1], max[1], min[2], max[2]}; } void DAGSurface::to_hdf5(hid_t group_id) const {} diff --git a/src/tracking.F90 b/src/tracking.F90 index 352d9bc7bc..8cf2fc05c7 100644 --- a/src/tracking.F90 +++ b/src/tracking.F90 @@ -319,7 +319,6 @@ contains class(Surface), pointer :: surf class(Surface), pointer :: surf2 ! periodic partner surface - i_surface = abs(p % surface) surf => surfaces(i_surface) if (verbosity >= 10 .or. trace) then @@ -475,7 +474,7 @@ contains #ifdef DAGMC if (dagmc) then - i_cell = next_cell(cells(p % last_cell(1) + 1), surfaces(ABS(p % surface))) + i_cell = next_cell(cells(p % last_cell(1) + 1), surfaces(abs(p % surface))) ! save material and temp p % last_material = p % material p % last_sqrtkT = p % sqrtKT