mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Support void materials in C API Python bindings
This commit is contained in:
parent
4be18cb9e9
commit
f485693fa0
3 changed files with 15 additions and 15 deletions
|
|
@ -115,14 +115,15 @@ class Cell(_FortranObjectWithID):
|
|||
def fill(self, fill):
|
||||
if isinstance(fill, Iterable):
|
||||
n = len(fill)
|
||||
indices = (c_int*n)(*(m._index for m in fill))
|
||||
_dll.openmc_cell_set_fill(self._index, 1, 1, indices)
|
||||
indices = (c_int32*n)(*(m._index if m is not None else -1
|
||||
for m in fill))
|
||||
_dll.openmc_cell_set_fill(self._index, 1, n, indices)
|
||||
elif isinstance(fill, Material):
|
||||
materials = [fill]
|
||||
indices = (c_int*1)(fill._index)
|
||||
indices = (c_int32*1)(fill._index)
|
||||
_dll.openmc_cell_set_fill(self._index, 1, 1, indices)
|
||||
elif fill is None:
|
||||
indices = (c_int32*1)(-1)
|
||||
_dll.openmc_cell_set_fill(self._index, 1, 1, indices)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
def set_temperature(self, T, instance=None):
|
||||
"""Set the temperature of a cell
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@ class Material(_FortranObjectWithID):
|
|||
index = index.value
|
||||
else:
|
||||
index = mapping[uid]._index
|
||||
elif index == -1:
|
||||
# Special value indicates void material
|
||||
return None
|
||||
|
||||
if index not in cls.__instances:
|
||||
instance = super(Material, cls).__new__(cls)
|
||||
|
|
|
|||
|
|
@ -544,16 +544,12 @@ contains
|
|||
c % type = FILL_MATERIAL
|
||||
do i = 1, n
|
||||
j = indices(i)
|
||||
if (j == 0) then
|
||||
c % material(i) = MATERIAL_VOID
|
||||
if ((j >= 1 .and. j <= n_materials) .or. j == MATERIAL_VOID) then
|
||||
c % material(i) = j
|
||||
else
|
||||
if (j >= 1 .and. j <= n_materials) then
|
||||
c % material(i) = j
|
||||
else
|
||||
err = E_OUT_OF_BOUNDS
|
||||
call set_errmsg("Index " // trim(to_str(j)) // " in the &
|
||||
&materials array is out of bounds.")
|
||||
end if
|
||||
err = E_OUT_OF_BOUNDS
|
||||
call set_errmsg("Index " // trim(to_str(j)) // " in the &
|
||||
&materials array is out of bounds.")
|
||||
end if
|
||||
end do
|
||||
case (FILL_UNIVERSE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue