mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Change openmc_find -> openmc_find_cell
This commit is contained in:
parent
6d5ab25a2c
commit
1f760461a3
3 changed files with 23 additions and 28 deletions
|
|
@ -37,7 +37,7 @@ extern "C" {
|
|||
int openmc_filter_set_id(int32_t index, int32_t id);
|
||||
int openmc_filter_set_type(int32_t index, const char* type);
|
||||
int openmc_finalize();
|
||||
int openmc_find(double* xyz, int rtype, int32_t* id, int32_t* instance);
|
||||
int openmc_find_cell(double* xyz, int32_t* index, int32_t* instance);
|
||||
int openmc_get_cell_index(int32_t id, int32_t* index);
|
||||
int openmc_get_filter_index(int32_t id, int32_t* index);
|
||||
void openmc_get_filter_next_id(int32_t* id);
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ _dll.openmc_calculate_volumes.restype = c_int
|
|||
_dll.openmc_calculate_volumes.errcheck = _error_handler
|
||||
_dll.openmc_finalize.restype = c_int
|
||||
_dll.openmc_finalize.errcheck = _error_handler
|
||||
_dll.openmc_find.argtypes = [POINTER(c_double*3), c_int, POINTER(c_int32),
|
||||
POINTER(c_int32)]
|
||||
_dll.openmc_find.restype = c_int
|
||||
_dll.openmc_find.errcheck = _error_handler
|
||||
_dll.openmc_find_cell.argtypes = [POINTER(c_double*3), POINTER(c_int32),
|
||||
POINTER(c_int32)]
|
||||
_dll.openmc_find_cell.restype = c_int
|
||||
_dll.openmc_find_cell.errcheck = _error_handler
|
||||
_dll.openmc_hard_reset.restype = c_int
|
||||
_dll.openmc_hard_reset.errcheck = _error_handler
|
||||
_dll.openmc_init.argtypes = [c_int, POINTER(POINTER(c_char)), c_void_p]
|
||||
|
|
@ -84,10 +84,10 @@ def find_cell(xyz):
|
|||
indicates which instance it is, i.e., 0 would be the first instance.
|
||||
|
||||
"""
|
||||
uid = c_int32()
|
||||
index = c_int32()
|
||||
instance = c_int32()
|
||||
_dll.openmc_find((c_double*3)(*xyz), 1, uid, instance)
|
||||
return openmc.capi.cells[uid.value], instance.value
|
||||
_dll.openmc_find_cell((c_double*3)(*xyz), index, instance)
|
||||
return openmc.capi.Cell(index=index.value), instance.value
|
||||
|
||||
|
||||
def find_material(xyz):
|
||||
|
|
@ -104,11 +104,15 @@ def find_material(xyz):
|
|||
Material containing the point, or None is no material is found
|
||||
|
||||
"""
|
||||
uid = c_int32()
|
||||
index = c_int32()
|
||||
instance = c_int32()
|
||||
_dll.openmc_find((c_double*3)(*xyz), 2, uid, instance)
|
||||
return openmc.capi.materials[uid.value] if uid != 0 else None
|
||||
_dll.openmc_find_cell((c_double*3)(*xyz), index, instance)
|
||||
|
||||
mats = openmc.capi.Cell(index=index.value).fill
|
||||
if isinstance(mats, openmc.capi.Material):
|
||||
return mats
|
||||
else:
|
||||
return mats[instance]
|
||||
|
||||
def hard_reset():
|
||||
"""Reset tallies, timers, and pseudo-random number generator state."""
|
||||
|
|
|
|||
25
src/api.F90
25
src/api.F90
|
|
@ -51,7 +51,7 @@ module openmc_api
|
|||
public :: openmc_filter_set_id
|
||||
public :: openmc_filter_set_type
|
||||
public :: openmc_finalize
|
||||
public :: openmc_find
|
||||
public :: openmc_find_cell
|
||||
public :: openmc_get_cell_index
|
||||
public :: openmc_get_keff
|
||||
public :: openmc_get_filter_index
|
||||
|
|
@ -188,13 +188,12 @@ contains
|
|||
end function openmc_finalize
|
||||
|
||||
!===============================================================================
|
||||
! OPENMC_FIND determines the ID or a cell or material at a given point in space
|
||||
! OPENMC_FIND_CELL determines what cell contains a given point in space
|
||||
!===============================================================================
|
||||
|
||||
function openmc_find(xyz, rtype, id, instance) result(err) bind(C)
|
||||
function openmc_find_cell(xyz, index, instance) result(err) bind(C)
|
||||
real(C_DOUBLE), intent(in) :: xyz(3) ! Cartesian point
|
||||
integer(C_INT), intent(in), value :: rtype ! 1 for cell, 2 for material
|
||||
integer(C_INT32_T), intent(out) :: id
|
||||
integer(C_INT32_T), intent(out) :: index
|
||||
integer(C_INT32_T), intent(out) :: instance
|
||||
integer(C_INT) :: err
|
||||
|
||||
|
|
@ -206,30 +205,22 @@ contains
|
|||
p % coord(1) % uvw(:) = [ZERO, ZERO, ONE]
|
||||
call find_cell(p, found)
|
||||
|
||||
id = -1
|
||||
index = -1
|
||||
instance = -1
|
||||
err = E_UNASSIGNED
|
||||
|
||||
if (found) then
|
||||
if (rtype == 1) then
|
||||
id = cells(p % coord(p % n_coord) % cell) % id()
|
||||
elseif (rtype == 2) then
|
||||
if (p % material == MATERIAL_VOID) then
|
||||
id = 0
|
||||
else
|
||||
id = materials(p % material) % id()
|
||||
end if
|
||||
end if
|
||||
index = p % coord(p % n_coord) % cell
|
||||
instance = p % cell_instance - 1
|
||||
err = 0
|
||||
else
|
||||
err = E_GEOMETRY
|
||||
call set_errmsg("Could not find cell/material at position (" // &
|
||||
call set_errmsg("Could not find cell at position (" // &
|
||||
trim(to_str(xyz(1))) // "," // trim(to_str(xyz(2))) // "," // &
|
||||
trim(to_str(xyz(3))) // ").")
|
||||
end if
|
||||
|
||||
end function openmc_find
|
||||
end function openmc_find_cell
|
||||
|
||||
!===============================================================================
|
||||
! OPENMC_HARD_RESET reset tallies and timers as well as the pseudorandom
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue