Skip to content

Commit 146d700

Browse files
committed
Some updates to get the CAD build working again.
1 parent 289a6b3 commit 146d700

10 files changed

Lines changed: 75 additions & 70 deletions

File tree

‎include/openmc/settings.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extern "C" bool ufs_on; //!< uniform fission site method on?
4545
extern "C" bool urr_ptables_on; //!< use unresolved resonance prob. tables?
4646
extern "C" bool write_all_tracks; //!< write track files for every particle?
4747
extern "C" bool write_initial_source; //!< write out initial source file?
48+
extern "C" bool dagmc; //!< indicator of DAGMC geometry
4849

4950
// Paths to various files
5051
extern std::string path_cross_sections; //!< path to cross_sections.xml
@@ -86,7 +87,6 @@ extern "C" int trigger_batch_interval; //!< Batch interval for triggers
8687
extern "C" int verbosity; //!< How verbose to make output
8788
extern "C" double weight_cutoff; //!< Weight cutoff for Russian roulette
8889
extern "C" double weight_survive; //!< Survival weight after Russian roulette
89-
9090
} // namespace settings
9191

9292
//! Read settings from XML file

‎include/openmc/surface.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ class CADSurface : public Surface
147147
Direction normal(Position p) const;
148148
//! Get the bounding box of this surface.
149149
BoundingBox bounding_box() const;
150+
151+
void to_hdf5(hid_t group_id) const;
150152
};
151153
#endif
152154
//==============================================================================

‎src/cad.cpp‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifdef CAD
33

44
#include "cad.h"
5-
#include "error.h"
5+
#include "openmc/error.h"
66

77
#include <string>
88
#include <algorithm>
@@ -59,25 +59,25 @@ void load_cad_geometry_c()
5959

6060
c->fill_ = openmc::C_NONE;
6161

62-
openmc::global_cells.push_back(c);
62+
openmc::cells.push_back(c);
6363
openmc::cell_map[c->id_] = c->id_;
6464

6565
// Populate the Universe vector and dict
6666
auto it = openmc::universe_map.find(cad_univ_id);
6767
if (it == openmc::universe_map.end()) {
68-
openmc::global_universes.push_back(new openmc::Universe());
69-
openmc::global_universes.back()-> id = cad_univ_id;
70-
openmc::global_universes.back()->cells.push_back(i);
71-
openmc::universe_map[cad_univ_id] = openmc::global_universes.size() - 1;
68+
openmc::universes.push_back(new openmc::Universe());
69+
openmc::universes.back()-> id_ = cad_univ_id;
70+
openmc::universes.back()->cells_.push_back(i);
71+
openmc::universe_map[cad_univ_id] = openmc::universes.size() - 1;
7272
}
7373
else {
74-
openmc::global_universes[it->second]->cells.push_back(i);
74+
openmc::universes[it->second]->cells_.push_back(i);
7575
}
7676

7777

7878
if(DAGMC->is_implicit_complement(vol_handle)) {
7979
// assuming implicit complement is void for now
80-
c->material.push_back(openmc::MATERIAL_VOID);
80+
c->material_.push_back(openmc::MATERIAL_VOID);
8181
continue;
8282
}
8383

@@ -88,29 +88,29 @@ void load_cad_geometry_c()
8888
TOLOWER(mat_value);
8989

9090
if(mat_value == "void") {
91-
c->material.push_back(openmc::MATERIAL_VOID);
91+
c->material_.push_back(openmc::MATERIAL_VOID);
9292
}
9393
else {
94-
c->material.push_back(std::stoi(mat_value));
94+
c->material_.push_back(std::stoi(mat_value));
9595
}
9696
}
9797
else {
9898
std::cout << "Warning: volume without material found!" << std::endl;
99-
c->material.push_back(openmc::MATERIAL_VOID);
99+
c->material_.push_back(openmc::MATERIAL_VOID);
100100
}
101101
}
102102

103103
// initialize surface objects
104104
openmc::n_surfaces = DAGMC->num_entities(2);
105-
openmc::global_surfaces.resize(openmc::n_surfaces);
105+
openmc::surfaces.resize(openmc::n_surfaces);
106106

107107
for(int i = 0; i < openmc::n_surfaces; i++)
108108
{
109109
moab::EntityHandle surf_handle = DAGMC->entity_by_index(2, i+1);
110110

111111
// set cell ids using global IDs
112112
openmc::CADSurface* s = new openmc::CADSurface();
113-
s->id = DAGMC->id_by_index(2, i+1);
113+
s->id_ = DAGMC->id_by_index(2, i+1);
114114
s->dagmc_ptr = DAGMC;
115115

116116
if(DAGMC->has_prop(surf_handle, "boundary")) {
@@ -120,32 +120,32 @@ void load_cad_geometry_c()
120120
TOLOWER(bc_value);
121121

122122
if(bc_value == "transmit" || bc_value == "transmission") {
123-
s->bc = openmc::BC_TRANSMIT;
123+
s->bc_ = openmc::BC_TRANSMIT;
124124
}
125125
else if(bc_value == "vacuum") {
126-
s->bc = openmc::BC_VACUUM;
126+
s->bc_ = openmc::BC_VACUUM;
127127
}
128128
else if(bc_value == "reflective" || bc_value == "reflect" || bc_value == "reflecting") {
129-
s->bc = openmc::BC_REFLECT;
129+
s->bc_ = openmc::BC_REFLECT;
130130
}
131131
else if(bc_value == "periodic") {
132132
openmc::fatal_error("Periodic boundary condition not supported in CAD.");
133133
}
134134
else {
135135
std::stringstream err_msg;
136-
err_msg << "Unknown boundary condition \"" << s->bc
137-
<< "\" specified on surface " << s->id;
136+
err_msg << "Unknown boundary condition \"" << s->bc_
137+
<< "\" specified on surface " << s->id_;
138138
openmc::fatal_error(err_msg);
139139
}
140140
}
141141
// if no BC property is found, set to transmit
142142
else {
143-
s->bc = openmc::BC_TRANSMIT;
143+
s->bc_ = openmc::BC_TRANSMIT;
144144
}
145145

146146
// add to global array and map
147-
openmc::global_surfaces[i] = s;
148-
openmc::surface_map[s->id] = s->id;
147+
openmc::surfaces[i] = s;
148+
openmc::surface_map[s->id_] = s->id_;
149149
}
150150

151151
return;

‎src/cad.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#define CAD_H
66

77
#include "DagMC.hpp"
8-
#include "cell.h"
9-
#include "surface.h"
8+
#include "openmc/cell.h"
9+
#include "openmc/surface.h"
1010

1111
extern moab::DagMC* DAGMC;
1212

‎src/cell.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ CADCell::CADCell() : Cell{} {};
599599

600600
std::pair<double, int32_t> CADCell::distance(Position p, Direction u, int32_t on_surface) const {
601601

602-
moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id);
602+
moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id_);
603603
moab::EntityHandle hit_surf;
604604
double dist;
605605
dagmc_ptr->ray_fire(vol, p.xyz, u.xyz, hit_surf, dist);
@@ -620,7 +620,7 @@ std::pair<double, int32_t> CADCell::distance(Position p, Direction u, int32_t on
620620

621621
bool CADCell::contains(Position p, Direction u, int32_t on_surface) const {
622622

623-
moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id);
623+
moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id_);
624624

625625
int result = 0;
626626
dagmc_ptr->point_in_volume(vol, p.xyz, result, u.xyz);
@@ -772,8 +772,8 @@ extern "C" {
772772
#ifdef CAD
773773

774774
int32_t next_cell(CADCell* cur_cell, CADSurface *surf_xed ) {
775-
moab::EntityHandle surf = surf_xed->dagmc_ptr->entity_by_id(2,surf_xed->id);
776-
moab::EntityHandle vol = cur_cell->dagmc_ptr->entity_by_id(3,cur_cell->id);
775+
moab::EntityHandle surf = surf_xed->dagmc_ptr->entity_by_id(2,surf_xed->id_);
776+
moab::EntityHandle vol = cur_cell->dagmc_ptr->entity_by_id(3,cur_cell->id_);
777777

778778
moab::EntityHandle new_vol;
779779
cur_cell->dagmc_ptr->next_vol(surf, vol, new_vol);

‎src/input_xml.F90‎

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,6 @@ subroutine read_settings_xml_f(root_ptr) bind(C)
219219
! Get proper XMLNode type given pointer
220220
root % ptr = root_ptr
221221

222-
! Check for use of CAD geometry
223-
if (check_for_node(root, "dagmc")) then
224-
#ifdef CAD
225-
call get_node_value_bool(root, "dagmc", dagmc)
226-
#else
227-
if (dagmc) then
228-
call fatal_error("CAD mode unsupported for this build of OpenMC")
229-
end if
230-
#endif
231-
end if
232-
233222
if (run_mode == MODE_EIGENVALUE) then
234223
! Preallocate space for keff and entropy by generation
235224
call k_generation % reserve(n_max_batches*gen_per_batch)
@@ -597,10 +586,10 @@ subroutine read_geometry_cad()
597586
do i = 1, n_cells
598587
c => cells(i)
599588
! additional metadata spoofing
600-
allocate(c % sqrtKT(1))
601-
c % sqrtkT(1) = -1.0 ! rely on temps from elsewhere
589+
! allocate(c % sqrtKT(1))
590+
! c % sqrtkT(1) = -1.0 ! rely on temps from elsewhere
602591
univ_id = c % universe()
603-
if (.not. allocated(c%region)) allocate(c%region(0))
592+
! if (.not. allocated(c%region)) allocate(c%region(0))
604593

605594
if (.not. cells_in_univ_dict % has(univ_id)) then
606595
n_universes = n_universes + 1
@@ -615,30 +604,30 @@ subroutine read_geometry_cad()
615604

616605
! ==========================================================================
617606
! SETUP UNIVERSES
618-
607+
619608
! Allocate universes, universe cell arrays, and assign base universe
620-
allocate(universes(n_universes))
621-
do i = 1, n_universes
622-
associate (u => universes(i))
623-
u % id = univ_ids % data(i)
624-
! Allocate cell list
625-
n_cells_in_univ = cells_in_univ_dict % get(u % id)
626-
allocate(u % cells(n_cells_in_univ))
627-
u % cells(:) = 0
628-
end associate
629-
end do
609+
! allocate(universes(n_universes))
610+
! do i = 1, n_universes
611+
! associate (u => universes(i))
612+
! u % id = univ_ids % data(i)
613+
! ! Allocate cell list
614+
! n_cells_in_univ = cells_in_univ_dict % get(u % id)
615+
! allocate(u % cells(n_cells_in_univ))
616+
! u % cells(:) = 0
617+
! end associate
618+
! end do
630619

631-
root_universe = 0 + 1
620+
root_universe = find_root_universe()
632621

633-
do i = 1, n_cells
634-
! Get index in universes array
635-
j = universe_dict % get(cells(i) % universe())
636-
! Set the first zero entry in the universe cells array to the index in the
637-
! global cells array
638-
associate (u => universes(j))
639-
u % cells(find(u % cells, 0)) = i
640-
end associate
641-
end do
622+
! do i = 1, n_cells
623+
! ! Get index in universes array
624+
! j = universe_dict % get(cells(i) % universe())
625+
! ! Set the first zero entry in the universe cells array to the index in the
626+
! ! global cells array
627+
! associate (u => universes(j))
628+
! u % cells(find(u % cells, 0)) = i
629+
! end associate
630+
! end do
642631

643632
! Clear dictionary
644633
call cells_in_univ_dict%clear()

‎src/settings.F90‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module settings
8181
integer(C_INT), bind(C) :: run_mode
8282

8383
! flag for use of CAD geometry
84-
logical, bind(C) :: dagmc = .false.
84+
logical(C_BOOL), bind(C) :: dagmc
8585

8686
! Restart run
8787
logical(C_BOOL), bind(C) :: restart_run

‎src/settings.cpp‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ bool ufs_on {false};
5656
bool urr_ptables_on {true};
5757
bool write_all_tracks {false};
5858
bool write_initial_source {false};
59-
59+
bool dagmc {false};
60+
6061
std::string path_cross_sections;
6162
std::string path_input;
6263
std::string path_multipole;
@@ -207,6 +208,17 @@ void read_settings_xml()
207208
verbosity = std::stoi(get_node_value(root, "verbosity"));
208209
}
209210

211+
// DAGMC geometry check
212+
if (check_for_node(root, "dagmc")) {
213+
dagmc = get_node_value_bool(root, "dagmc");
214+
}
215+
216+
#ifndef CAD
217+
if (dagmc) {
218+
fatal_error("CAD mode unsupported for this build of OpenMC");
219+
}
220+
#endif
221+
210222
// To this point, we haven't displayed any output since we didn't know what
211223
// the verbosity is. Now that we checked for it, show the title if necessary
212224
if (openmc_master) {

‎src/summary.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
#include "openmc/hdf5_interface.h"
33
#include "openmc/lattice.h"
44
#include "openmc/surface.h"
5-
5+
#include "openmc/settings.h"
66

77
namespace openmc {
88

99
extern "C" void
1010
write_geometry(hid_t file_id) {
1111

1212
#ifdef CAD
13-
if (dagmc) {
13+
if (settings::dagmc) {
1414
return;
1515
}
1616
#endif

‎src/surface.cpp‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ double CADSurface::evaluate(Position r) const
257257
}
258258

259259
double CADSurface::distance(Position p, Direction u, bool coincident) const {
260-
moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id);
260+
moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id_);
261261
moab::EntityHandle hit_surf;
262262
double dist;
263263
dagmc_ptr->ray_fire(surf, p.xyz, u.xyz, hit_surf, dist, NULL, 0, 0);
@@ -267,17 +267,19 @@ double CADSurface::distance(Position p, Direction u, bool coincident) const {
267267

268268
Direction CADSurface::normal(Position p) const {
269269
Direction u;
270-
moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id);
270+
moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id_);
271271
dagmc_ptr->get_angle(surf, p.xyz, u.xyz);
272272
return u;
273273
}
274274

275275
BoundingBox CADSurface::bounding_box() const {
276-
moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id);
276+
moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id_);
277277
double min[3], max[3];
278278
dagmc_ptr->getobb(surf, min, max);
279279
return BoundingBox(min[0], max[0], min[1], max[1], min[2], max[2]);
280280
}
281+
282+
void CADSurface::to_hdf5(hid_t group_id) const {}
281283
#endif
282284
//==============================================================================
283285
// PeriodicSurface implementation

0 commit comments

Comments
 (0)