Skip to content

Commit 2ad76be

Browse files
committed
Code updates/changes as requested by @paulromano
1 parent 8793287 commit 2ad76be

10 files changed

Lines changed: 67 additions & 86 deletions

File tree

‎include/openmc/cell.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ class CSGCell : public Cell
172172
#ifdef DAGMC
173173
class DAGCell : public Cell
174174
{
175-
public:
176-
moab::DagMC *dagmc_ptr_;
175+
public:
176+
moab::DagMC* dagmc_ptr_;
177177
DAGCell();
178178

179-
std::pair<double, int32_t> distance(Position p, Direction u, int32_t on_surface) const;
180-
bool contains(Position p, Direction u, int32_t on_surface) const;
179+
std::pair<double, int32_t> distance(Position r, Direction u, int32_t on_surface) const;
180+
bool contains(Position r, Direction u, int32_t on_surface) const;
181181

182182
void to_hdf5(hid_t group_id) const;
183183

‎include/openmc/dagmc.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
#include "openmc/cell.h"
99
#include "openmc/surface.h"
1010

11+
namespace openmc {
12+
1113
extern moab::DagMC* DAG;
1214

13-
extern "C" void load_dagmc_geometry_c();
14-
extern "C" void free_memory_dagmc_c();
15+
extern "C" void load_dagmc_geometry();
16+
extern "C" void free_memory_dagmc();
1517

18+
}
1619
#endif // DAGMC_H
1720

1821
#endif

‎include/openmc/surface.h‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,7 @@ extern std::map<int, int> surface_map;
4444
//==============================================================================
4545

4646
struct BoundingBox
47-
{
48-
49-
BoundingBox(double x_min, double x_max,
50-
double y_min, double y_max,
51-
double z_min, double z_max) :
52-
xmin(x_min), xmax(x_max),
53-
ymin(y_min), ymax(y_max),
54-
zmin(z_min), zmax(z_max) {}
55-
47+
{
5648
double xmin;
5749
double xmax;
5850
double ymin;
@@ -141,10 +133,10 @@ class DAGSurface : public Surface
141133
public:
142134
moab::DagMC* dagmc_ptr_;
143135
DAGSurface();
144-
double evaluate(Position p) const;
145-
double distance(Position p, Direction u,
136+
double evaluate(Position r) const;
137+
double distance(Position r, Direction u,
146138
bool coincident) const;
147-
Direction normal(Position p) const;
139+
Direction normal(Position r) const;
148140
//! Get the bounding box of this surface.
149141
BoundingBox bounding_box() const;
150142

‎src/cell.cpp‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,12 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const
595595
#ifdef DAGMC
596596
DAGCell::DAGCell() : Cell{} {};
597597

598-
std::pair<double, int32_t> DAGCell::distance(Position p, Direction u, int32_t on_surface) const {
598+
std::pair<double, int32_t> DAGCell::distance(Position r, Direction u, int32_t on_surface) const {
599599
moab::ErrorCode rval;
600600
moab::EntityHandle vol = dagmc_ptr_->entity_by_id(3, id_);
601601
moab::EntityHandle hit_surf;
602602
double dist;
603-
double pnt[3] = {p.x, p.y, p.z};
603+
double pnt[3] = {r.x, r.y, r.z};
604604
double dir[3] = {u.x, u.y, u.z};
605605
rval = dagmc_ptr_->ray_fire(vol, pnt, dir, hit_surf, dist);
606606
MB_CHK_ERR_CONT(rval);
@@ -611,21 +611,19 @@ std::pair<double, int32_t> DAGCell::distance(Position p, Direction u, int32_t on
611611
surf_idx = -1;
612612
}
613613

614-
std::pair<double, int> result(dist, surf_idx);
615-
616-
return result;
614+
return {dist, surf_idx};
617615
}
618616

619-
bool DAGCell::contains(Position p, Direction u, int32_t on_surface) const {
617+
bool DAGCell::contains(Position r, Direction u, int32_t on_surface) const {
620618
moab::ErrorCode rval;
621619
moab::EntityHandle vol = dagmc_ptr_->entity_by_id(3, id_);
622620

623621
int result = 0;
624-
double pnt[3] = {p.x, p.y, p.z};
622+
double pnt[3] = {r.x, r.y, r.z};
625623
double dir[3] = {u.x, u.y, u.z};
626624
rval = dagmc_ptr_->point_in_volume(vol, pnt, result, dir);
627625
MB_CHK_ERR_CONT(rval);
628-
return bool(result);
626+
return result;
629627
}
630628

631629
void DAGCell::to_hdf5(hid_t group_id) const { return; }
@@ -773,7 +771,7 @@ extern "C" {
773771

774772
#ifdef DAGMC
775773

776-
int32_t next_cell(DAGCell* cur_cell, DAGSurface *surf_xed ) {
774+
int32_t next_cell(DAGCell* cur_cell, DAGSurface* surf_xed ) {
777775
moab::EntityHandle surf = surf_xed->dagmc_ptr_->entity_by_id(2,surf_xed->id_);
778776
moab::EntityHandle vol = cur_cell->dagmc_ptr_->entity_by_id(3,cur_cell->id_);
779777

‎src/dagmc.cpp‎

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
#include <string>
99
#include <algorithm>
1010

11+
namespace openmc {
12+
1113
moab::DagMC* DAG;
1214

13-
void load_dagmc_geometry_c()
15+
void load_dagmc_geometry()
1416
{
1517
if (!DAG) {
1618
DAG = new moab::DagMC();
@@ -24,7 +26,7 @@ void load_dagmc_geometry_c()
2426
rval = DAG->init_OBBTree();
2527
MB_CHK_ERR_CONT(rval);
2628

27-
std::vector< std::string > prop_keywords;
29+
std::vector<std::string> prop_keywords;
2830
prop_keywords.push_back("mat");
2931
prop_keywords.push_back("boundary");
3032

@@ -33,101 +35,102 @@ void load_dagmc_geometry_c()
3335
MB_CHK_ERR_CONT(rval);
3436

3537
// initialize cell objects
36-
openmc::n_cells = DAG->num_entities(3);
37-
for (int i = 0; i < openmc::n_cells; i++) {
38+
n_cells = DAG->num_entities(3);
39+
for (int i = 0; i < n_cells; i++) {
3840
moab::EntityHandle vol_handle = DAG->entity_by_index(3, i+1);
3941

4042
// set cell ids using global IDs
41-
openmc::DAGCell* c = new openmc::DAGCell();
43+
DAGCell* c = new DAGCell();
4244
c->id_ = DAG->id_by_index(3, i+1);
4345
c->dagmc_ptr_ = DAG;
4446
c->universe_ = dagmc_univ_id; // set to zero for now
45-
c->fill_ = openmc::C_NONE; // no fill, single universe
47+
c->fill_ = C_NONE; // no fill, single universe
4648

47-
openmc::cells.push_back(c);
48-
openmc::cell_map[c->id_] = c->id_;
49+
cells.push_back(c);
50+
cell_map[c->id_] = c->id_;
4951

5052
// Populate the Universe vector and dict
51-
auto it = openmc::universe_map.find(dagmc_univ_id);
52-
if (it == openmc::universe_map.end()) {
53-
openmc::universes.push_back(new openmc::Universe());
54-
openmc::universes.back()-> id_ = dagmc_univ_id;
55-
openmc::universes.back()->cells_.push_back(i);
56-
openmc::universe_map[dagmc_univ_id] = openmc::universes.size() - 1;
53+
auto it = universe_map.find(dagmc_univ_id);
54+
if (it == universe_map.end()) {
55+
universes.push_back(new Universe());
56+
universes.back()-> id_ = dagmc_univ_id;
57+
universes.back()->cells_.push_back(i);
58+
universe_map[dagmc_univ_id] = universes.size() - 1;
5759
} else {
58-
openmc::universes[it->second]->cells_.push_back(i);
60+
universes[it->second]->cells_.push_back(i);
5961
}
6062

6163
if (DAG->is_implicit_complement(vol_handle)) {
6264
// assuming implicit complement is void for now
63-
c->material_.push_back(openmc::MATERIAL_VOID);
65+
c->material_.push_back(MATERIAL_VOID);
6466
continue;
6567
}
6668

6769
if (DAG->has_prop(vol_handle, "mat")){
6870
std::string mat_value;
6971
rval = DAG->prop_value(vol_handle, "mat", mat_value);
7072
MB_CHK_ERR_CONT(rval);
71-
openmc::to_lower(mat_value);
73+
to_lower(mat_value);
7274

7375
if (mat_value == "void" || mat_value == "vacuum") {
74-
c->material_.push_back(openmc::MATERIAL_VOID);
76+
c->material_.push_back(MATERIAL_VOID);
7577
} else {
7678
c->material_.push_back(std::stoi(mat_value));
7779
}
7880
} else {
7981
std::cout << c->id_ << std::endl;
80-
openmc::fatal_error("A volume without a material was found.");
82+
fatal_error("A volume without a material was found.");
8183
}
8284
}
8385

8486
// initialize surface objects
85-
openmc::n_surfaces = DAG->num_entities(2);
86-
openmc::surfaces.resize(openmc::n_surfaces);
87+
n_surfaces = DAG->num_entities(2);
88+
surfaces.resize(n_surfaces);
8789

88-
for (int i = 0; i < openmc::n_surfaces; i++) {
90+
for (int i = 0; i < n_surfaces; i++) {
8991
moab::EntityHandle surf_handle = DAG->entity_by_index(2, i+1);
9092

9193
// set cell ids using global IDs
92-
openmc::DAGSurface* s = new openmc::DAGSurface();
94+
DAGSurface* s = new DAGSurface();
9395
s->id_ = DAG->id_by_index(2, i+1);
9496
s->dagmc_ptr_ = DAG;
9597

9698
if (DAG->has_prop(surf_handle, "boundary")) {
9799
std::string bc_value;
98100
rval = DAG->prop_value(surf_handle, "boundary", bc_value);
99101
MB_CHK_ERR_CONT(rval);
100-
openmc::to_lower(bc_value);
102+
to_lower(bc_value);
101103

102104
if (bc_value == "transmit" || bc_value == "transmission") {
103-
s->bc_ = openmc::BC_TRANSMIT;
105+
s->bc_ = BC_TRANSMIT;
104106
} else if (bc_value == "vacuum") {
105-
s->bc_ = openmc::BC_VACUUM;
107+
s->bc_ = BC_VACUUM;
106108
} else if (bc_value == "reflective" || bc_value == "reflect" || bc_value == "reflecting") {
107-
s->bc_ = openmc::BC_REFLECT;
109+
s->bc_ = BC_REFLECT;
108110
} else if (bc_value == "periodic") {
109-
openmc::fatal_error("Periodic boundary condition not supported in DAGMC.");
111+
fatal_error("Periodic boundary condition not supported in DAGMC.");
110112
} else {
111113
std::stringstream err_msg;
112114
err_msg << "Unknown boundary condition \"" << s->bc_
113115
<< "\" specified on surface " << s->id_;
114-
openmc::fatal_error(err_msg);
116+
fatal_error(err_msg);
115117
}
116118
} else { // if no BC property is found, set to transmit
117-
s->bc_ = openmc::BC_TRANSMIT;
119+
s->bc_ = BC_TRANSMIT;
118120
}
119121

120122
// add to global array and map
121-
openmc::surfaces[i] = s;
122-
openmc::surface_map[s->id_] = s->id_;
123+
surfaces[i] = s;
124+
surface_map[s->id_] = s->id_;
123125
}
124126

125127
return;
126128
}
127129

128-
void free_memory_dagmc_c()
130+
void free_memory_dagmc()
129131
{
130132
delete DAG;
131133
}
132134

135+
}
133136
#endif

‎src/dagmc_header.F90‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,14 @@ module dagmc_header
77
implicit none
88

99
interface
10-
subroutine load_dagmc_geometry_c() bind(C)
11-
end subroutine load_dagmc_geometry_c
10+
subroutine load_dagmc_geometry() bind(C)
11+
end subroutine load_dagmc_geometry
1212

13-
subroutine free_memory_dagmc_c() bind(C)
14-
end subroutine free_memory_dagmc_c
13+
subroutine free_memory_dagmc() bind(C)
14+
end subroutine free_memory_dagmc
1515

1616
end interface
1717

18-
contains
19-
20-
subroutine load_dagmc_geometry()
21-
call load_dagmc_geometry_c()
22-
end subroutine load_dagmc_geometry
23-
24-
subroutine free_memory_dagmc()
25-
call free_memory_dagmc_c()
26-
end subroutine free_memory_dagmc
27-
2818
end module dagmc_header
2919

3020
#endif

‎src/input_xml.F90‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,6 @@ subroutine read_geometry_dagmc()
403403

404404
root_universe = find_root_universe()
405405

406-
return
407-
408406
end subroutine read_geometry_dagmc
409407

410408
#endif

‎src/summary.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ extern "C" void
1010
write_geometry(hid_t file_id) {
1111

1212
#ifdef DAGMC
13-
if (settings::dagmc) {
14-
return;
15-
}
13+
if (settings::dagmc) return;
1614
#endif
1715

1816
auto geom_group = create_group(file_id, "geometry");

‎src/surface.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,24 +255,24 @@ double DAGSurface::evaluate(Position r) const
255255
return 0.0;
256256
}
257257

258-
double DAGSurface::distance(Position p, Direction u, bool coincident) const {
258+
double DAGSurface::distance(Position r, Direction u, bool coincident) const {
259259
moab::ErrorCode rval;
260260
moab::EntityHandle surf = dagmc_ptr_->entity_by_id(2, id_);
261261
moab::EntityHandle hit_surf;
262262
double dist;
263-
double pnt[3] = {p.x, p.y, p.z};
263+
double pnt[3] = {r.x, r.y, r.z};
264264
double dir[3] = {u.x, u.y, u.z};
265265
rval = dagmc_ptr_->ray_fire(surf, pnt, dir, hit_surf, dist, NULL, 0, 0);
266266
MB_CHK_ERR_CONT(rval);
267267
if (dist < 0.0) dist = INFTY;
268268
return dist;
269269
}
270270

271-
Direction DAGSurface::normal(Position p) const {
271+
Direction DAGSurface::normal(Position r) const {
272272
moab::ErrorCode rval;
273273
Direction u;
274274
moab::EntityHandle surf = dagmc_ptr_->entity_by_id(2, id_);
275-
double pnt[3] = {p.x, p.y, p.z};
275+
double pnt[3] = {r.x, r.y, r.z};
276276
double dir[3] = {u.x, u.y, u.z};
277277
rval = dagmc_ptr_->get_angle(surf, pnt, dir);
278278
MB_CHK_ERR_CONT(rval);
@@ -285,7 +285,7 @@ BoundingBox DAGSurface::bounding_box() const {
285285
double min[3], max[3];
286286
rval = dagmc_ptr_->getobb(surf, min, max);
287287
MB_CHK_ERR_CONT(rval);
288-
return BoundingBox(min[0], max[0], min[1], max[1], min[2], max[2]);
288+
return {min[0], max[0], min[1], max[1], min[2], max[2]};
289289
}
290290

291291
void DAGSurface::to_hdf5(hid_t group_id) const {}

‎src/tracking.F90‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ subroutine cross_surface(p)
319319
class(Surface), pointer :: surf
320320
class(Surface), pointer :: surf2 ! periodic partner surface
321321

322-
323322
i_surface = abs(p % surface)
324323
surf => surfaces(i_surface)
325324
if (verbosity >= 10 .or. trace) then
@@ -475,7 +474,7 @@ subroutine cross_surface(p)
475474

476475
#ifdef DAGMC
477476
if (dagmc) then
478-
i_cell = next_cell(cells(p % last_cell(1) + 1), surfaces(ABS(p % surface)))
477+
i_cell = next_cell(cells(p % last_cell(1) + 1), surfaces(abs(p % surface)))
479478
! save material and temp
480479
p % last_material = p % material
481480
p % last_sqrtkT = p % sqrtKT

0 commit comments

Comments
 (0)