mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Add length_multiplier to python API. Refs #1872
This commit is contained in:
parent
1650dab5b0
commit
95c1143cfc
2 changed files with 29 additions and 1 deletions
|
|
@ -318,6 +318,10 @@ attributes/sub-elements:
|
|||
:dimension:
|
||||
The number of mesh cells in each direction. (For regular mesh only.)
|
||||
|
||||
:length_multiplier:
|
||||
A multiplicative factor to apply to the mesh coordinates in all directions.
|
||||
(For unstructured mesh only.)
|
||||
|
||||
:lower_left:
|
||||
The lower-left corner of the structured mesh. If only two coordinates are
|
||||
given, it is assumed that the mesh is an x-y mesh. (For regular mesh only.)
|
||||
|
|
|
|||
|
|
@ -611,6 +611,8 @@ class UnstructuredMesh(MeshBase):
|
|||
----------
|
||||
filename : str
|
||||
Location of the unstructured mesh file
|
||||
length_multiplier: float
|
||||
Constant multiplier to apply to mesh coordinates
|
||||
mesh_id : int
|
||||
Unique identifier for the mesh
|
||||
name : str
|
||||
|
|
@ -626,11 +628,16 @@ class UnstructuredMesh(MeshBase):
|
|||
Name of the mesh
|
||||
filename : str
|
||||
Name of the file containing the unstructured mesh
|
||||
length_multiplier: float
|
||||
Multiplicative factor to apply to mesh coordinates
|
||||
library : str
|
||||
Mesh library used for the unstructured mesh tally
|
||||
output : bool
|
||||
Indicates whether or not automatic tally output should
|
||||
be generated for this mesh
|
||||
specified_length_multiplier: bool
|
||||
Indicates whether a non-unity length multiplier has been
|
||||
applied to this mesh
|
||||
volumes : Iterable of float
|
||||
Volumes of the unstructured mesh elements
|
||||
total_volume : float
|
||||
|
|
@ -639,13 +646,15 @@ class UnstructuredMesh(MeshBase):
|
|||
An iterable of element centroid coordinates, e.g. [(0.0, 0.0, 0.0),
|
||||
(1.0, 1.0, 1.0), ...]
|
||||
"""
|
||||
def __init__(self, filename, library, mesh_id=None, name=''):
|
||||
def __init__(self, filename, library, mesh_id=None, name='', length_multiplier=1.0):
|
||||
super().__init__(mesh_id, name)
|
||||
self.filename = filename
|
||||
self._volumes = None
|
||||
self._centroids = None
|
||||
self.library = library
|
||||
self._output = True
|
||||
self._specified_length_multiplier = False
|
||||
self.length_multiplier = length_multiplier
|
||||
|
||||
@property
|
||||
def filename(self):
|
||||
|
|
@ -713,6 +722,18 @@ class UnstructuredMesh(MeshBase):
|
|||
Iterable, Real)
|
||||
self._centroids = centroids
|
||||
|
||||
@property
|
||||
def length_multiplier(self):
|
||||
return self._length_multiplier
|
||||
|
||||
@length_multiplier.setter
|
||||
def length_multiplier(self, length_multiplier):
|
||||
cv.check_type("Unstructured mesh length multiplier", length_multiplier, Real)
|
||||
self._length_multiplier = length_multiplier
|
||||
|
||||
if (self._length_multiplier != 1.0):
|
||||
self._specified_length_multiplier = True
|
||||
|
||||
def __repr__(self):
|
||||
string = super().__repr__()
|
||||
string += '{: <16}=\t{}\n'.format('\tFilename', self.filename)
|
||||
|
|
@ -836,6 +857,9 @@ class UnstructuredMesh(MeshBase):
|
|||
subelement = ET.SubElement(element, "filename")
|
||||
subelement.text = self.filename
|
||||
|
||||
if (self._specified_length_multiplier):
|
||||
element.set("length_multiplier", str(self.length_multiplier))
|
||||
|
||||
return element
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue