Adding code for handling universes and other Fortran-side cell attributes. Skipping geometry writeout for CAD runs for now.

This commit is contained in:
shriwise 2018-05-15 11:55:09 -05:00 committed by pshriwise
parent 8dc0ba2b62
commit 3f2fc67d0b
3 changed files with 77 additions and 1 deletions

View file

@ -38,6 +38,7 @@ void load_cad_geometry_c()
openmc::CADSurface* s = new openmc::CADSurface();
s->id = DAGMC->id_by_index(2, i);
s->dagmc_ptr = DAGMC;
s->bc = openmc::BC_TRANSMIT;
openmc::surfaces_c[i] = s;
openmc::surface_dict[s->id] = i;
}

View file

@ -180,7 +180,7 @@ contains
! After reading input and basic geometry setup is complete, build lists of
! neighboring cells for efficient tracking
call neighbor_lists()
! Assign temperatures to cells that don't have temperatures already assigned
call assign_temperatures()
@ -394,6 +394,73 @@ contains
call load_cad_geometry()
call allocate_surfaces()
call allocate_cells()
! setup universe data structs
do i = 1, n_cells
c => cells(i)
! additional metadata spoofing
allocate(c % material(1))
c % material(1) = 40
c % fill = NONE
allocate(c % sqrtKT(1))
c % sqrtkT(1) = 293
c % sqrtkT(:) = sqrt(K_BOLTZMANN * c % sqrtkT(:))
univ_id = c % universe()
if (.not. allocated(c%region)) allocate(c%region(0))
if (.not. cells_in_univ_dict % has(univ_id)) then
n_universes = n_universes + 1
n_cells_in_univ = 1
call universe_dict % set(univ_id, n_universes)
call univ_ids % push_back(univ_id)
else
n_cells_in_univ = 1 + cells_in_univ_dict % get(univ_id)
end if
call cells_in_univ_dict % set(univ_id, n_cells_in_univ)
end do
! ==========================================================================
! SETUP UNIVERSES
! Allocate universes, universe cell arrays, and assign base universe
allocate(universes(n_universes))
do i = 1, n_universes
associate (u => universes(i))
u % id = univ_ids % data(i)
! Allocate cell list
n_cells_in_univ = cells_in_univ_dict % get(u % id)
allocate(u % cells(n_cells_in_univ))
u % cells(:) = 0
! Check whether universe is a fill universe
if (find(fill_univ_ids, u % id) == -1) then
if (root_universe > 0) then
call fatal_error("Two or more universes are not used as fill &
&universes, so it is not possible to distinguish which one &
&is the root universe.")
else
root_universe = i
end if
end if
end associate
end do
do i = 1, n_cells
! Get index in universes array
j = universe_dict % get(cells(i) % universe())
! Set the first zero entry in the universe cells array to the index in the
! global cells array
associate (u => universes(j))
u % cells(find(u % cells, 0)) = i
end associate
end do
! Clear dictionary
call cells_in_univ_dict%clear()
return
end if
#endif

View file

@ -8,6 +8,14 @@ namespace openmc {
extern "C" void
write_geometry(hid_t file_id) {
#ifdef CAD
if (dagmc) {
return;
}
#endif
auto geom_group = create_group(file_id, "geometry");
write_attribute(geom_group, "n_cells", cells.size());
write_attribute(geom_group, "n_surfaces", surfaces.size());