Skip to content

Commit 8606420

Browse files
committed
Add implicit complement name to DAGMC cell durin sync DAGMC universes
1 parent 8d872be commit 8606420

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

openmc/dagmc.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,13 @@ def sync_dagmc_cells(self, mats: Iterable[openmc.Material]):
623623
fill = [mats_per_id[mat.id] for mat in dag_cell.fill if mat]
624624
else:
625625
fill = mats_per_id[dag_cell.fill.id] if dag_cell.fill else None
626-
self.add_cell(openmc.DAGMCCell(cell_id=dag_cell_id, fill=fill))
626+
name = dag_cell.name
627+
if dag_cell_id in self._cells:
628+
self._cells[dag_cell_id].name = name
629+
self._cells[dag_cell_id].fill = fill
630+
else:
631+
self.add_cell(
632+
openmc.DAGMCCell(cell_id=dag_cell_id, name=name, fill=fill))
627633

628634
@add_plot_params
629635
def plot(self, *args, **kwargs):

src/dagmc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ void DAGUniverse::init_geometry(const MaterialOverrides& material_overrides,
282282
: dagmc_instance_->id_by_index(3, c->dag_index());
283283
c->universe_ = this->id_;
284284
c->fill_ = C_NONE; // no fill, single universe
285+
if (dagmc_instance_->is_implicit_complement(vol_handle)) {
286+
c->name_ = "implicit complement";
287+
}
285288

286289
auto in_map = model::cell_map.find(c->id_);
287290
if (in_map == model::cell_map.end()) {

tests/unit_tests/dagmc/test_model.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ def test_dagmc_replace_material_assignment(model):
9494
assert univ.cells[cell_id].fill == mats["foo"]
9595

9696

97+
def test_dagmc_sync_cell_names(model):
98+
dag_univ = None
99+
for univ in model.geometry.get_all_universes().values():
100+
if isinstance(univ, openmc.DAGMCUniverse):
101+
dag_univ = univ
102+
break
103+
104+
assert dag_univ is not None
105+
106+
for cell_id, cell in dag_univ.cells.items():
107+
assert cell.name == openmc.lib.cells[cell_id].name
108+
109+
assert any(cell.name == "implicit complement"
110+
for cell in dag_univ.cells.values())
111+
112+
97113
def test_dagmc_add_material_override_with_id(model):
98114
mats = {}
99115
mats["foo"] = openmc.Material(name="foo")

0 commit comments

Comments
 (0)