New class method, Mesh.fromRectLattice()

This commit is contained in:
tjlaboss 2018-05-21 17:13:37 -04:00
parent e3f0bff0f0
commit a47f3abbde

View file

@ -182,6 +182,40 @@ class Mesh(IDManagerMixin):
return mesh
@classmethod
def fromRectLattice(cls, lattice, division=1, mesh_id=None, name=''):
"""Create mesh from an existing rectangular lattice
Parameters
----------
lattice : openmc.RectLattice
Rectangular lattice used as a template for this mesh
division : int, optional
Number of mesh cells per lattice cell.
If not specified, there will be 1 mesh cell per lattice cell.
mesh_id : int, optional
Unique identifier for the mesh
name : str, optional
Name of the mesh
Returns
-------
openmc.Mesh
Mesh instance
"""
cv.check_type('rectangular lattice', lattice, openmc.RectLattice)
shape = np.array(lattice.shape)
width = lattice.pitch*shape
mesh = cls(mesh_id, name)
mesh.lower_left = lattice.lower_left
mesh.upper_right = lattice.lower_left + width
mesh.dimension = shape*division
return mesh
def to_xml_element(self):
"""Return XML representation of the mesh