88#include < string>
99#include < algorithm>
1010
11+ namespace openmc {
12+
1113moab::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
0 commit comments