1818
1919__all__ = [
2020 'Mesh' , 'RegularMesh' , 'RectilinearMesh' , 'CylindricalMesh' ,
21- 'SphericalMesh' , 'UnstructuredMesh' , 'meshes' , 'MeshMaterialVolumes'
21+ 'SphericalMesh' , 'HexagonalMesh' , ' UnstructuredMesh' , 'meshes' , 'MeshMaterialVolumes'
2222]
2323
2424
108108_dll .openmc_spherical_mesh_set_grid .restype = c_int
109109_dll .openmc_spherical_mesh_set_grid .errcheck = _error_handler
110110
111+ _dll .openmc_hexagonal_mesh_get_grid .argtypes = [c_int32 ,
112+ POINTER (POINTER (c_double )), POINTER (c_int ), POINTER (c_double ),
113+ POINTER (POINTER (c_double )), POINTER (c_double ), POINTER (c_char_p )]
114+ _dll .openmc_hexagonal_mesh_get_grid .restype = c_int
115+ _dll .openmc_hexagonal_mesh_get_grid .errcheck = _error_handler
111116
112117class Mesh (_FortranObjectWithID ):
113118 """Base class to represent mesh objects
@@ -727,6 +732,91 @@ def set_grid(self, r_grid, theta_grid, phi_grid):
727732 ntheta , phi_grid , nphi )
728733
729734
735+ class HexagonalMesh (Mesh ):
736+ """HexagonalMesh stored internally.
737+
738+ This class exposes a mesh that is stored internally in the OpenMC
739+ library. To obtain a view of a mesh with a given ID, use the
740+ :data:`openmc.lib.meshes` mapping.
741+
742+ Parameters
743+ ----------
744+ index : int
745+ Index in the `meshes` array.
746+
747+ Attributes
748+ ----------
749+ id : int
750+ ID of the mesh
751+ z_grid : numpy.ndarray
752+ 1-D array of mesh boundary points along the z-axis.
753+ pitch : float
754+ Radial pitch of the hexagonal mesh in cm.
755+ num_rings : int
756+ Number of radial ring positions in the xy-plane
757+ orientation : {'x', 'y'}
758+ The orientation of the lattice. The 'x' orientation means that each
759+ lattice element has two faces that are perpendicular to the x-axis,
760+ while the 'y' orientation means that each lattice element has two faces
761+ that are perpendicular to the y-axis. By default, the orientation is
762+ 'y'.
763+ origin : numpy.ndarray
764+ 1-D array of length 3 the (x,y,z) origin of the mesh in
765+ cartesian coordinates
766+ n_elements : int
767+ Total number of mesh elements.
768+ volumes : numpy.ndarray
769+ Volume of each mesh element in [cm^3]
770+ bounding_box : openmc.BoundingBox
771+ Axis-aligned bounding box of the mesh
772+
773+ """
774+ mesh_type = 'hexagonal'
775+
776+ def __init__ (self , uid = None , new = True , index = None ):
777+ super ().__init__ (uid , new , index )
778+
779+ @property
780+ def n_elements (self ):
781+ z_grid , nr , * _ = self ._get_parameters ()
782+ return (z_grid .size - 1 )* (3 * nr * (nr - 1 )+ 1 )
783+
784+ @property
785+ def num_rings (self ):
786+ return self ._get_parameters ()[1 ]
787+
788+ @property
789+ def pitch (self ):
790+ return self ._get_parameters ()[2 ]
791+
792+ @property
793+ def orientation (self ):
794+ return self ._get_parameters ()[4 ]
795+
796+ @property
797+ def origin (self ):
798+ return self ._get_parameters ()[3 ]
799+
800+ @property
801+ def z_grid (self ):
802+ return self ._get_parameters ()[0 ]
803+
804+ def _get_parameters (self ):
805+ gz = POINTER (c_double )()
806+ nz = c_int ()
807+ nr = c_int ()
808+ orig = POINTER (c_double )()
809+ orient = c_char ()
810+ p = c_double ()
811+ # Call C API to get grid parameters
812+ _dll .openmc_hexagonal_mesh_get_grid (self ._index , gz , nz , nr , orig , p , orient )
813+
814+ # Convert grid parameters to Numpy arrays
815+ grid_z = as_array (gz , (nz .value ,))
816+ origin = as_array (orig , (3 ,))
817+
818+ return (grid_z , nr , pitch , origin , orientation .decode ())
819+
730820class UnstructuredMesh (Mesh ):
731821 pass
732822
@@ -736,6 +826,7 @@ class UnstructuredMesh(Mesh):
736826 'rectilinear' : RectilinearMesh ,
737827 'cylindrical' : CylindricalMesh ,
738828 'spherical' : SphericalMesh ,
829+ 'hexagonal' : HexagonalMesh ,
739830 'unstructured' : UnstructuredMesh
740831}
741832
0 commit comments