Repository navigation
Pair periodic surfaces for RectangularParallelepiped #4209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,18 +19,39 @@ | |
| class CompositeSurface(ABC): | ||
| """Multiple primitive surfaces combined into a composite surface""" | ||
|
|
||
| def _periodic_pairs(self): | ||
| """Names of component surfaces that are periodic with each other""" | ||
| components = {id(getattr(self, name)): name | ||
| for name in self._surface_names} | ||
| pairs = [] | ||
| for name in self._surface_names: | ||
| partner = getattr(getattr(self, name), 'periodic_surface', None) | ||
| if partner is not None and id(partner) in components: | ||
| pairs.append((name, components[id(partner)])) | ||
| return pairs | ||
|
|
||
| def _restore_periodic_pairs(self, pairs): | ||
| # Transforming a component can replace it with a new surface (or a | ||
| # copy of its partner), so point each pair back at its new partner. | ||
| for name, partner_name in pairs: | ||
| getattr(self, name).periodic_surface = getattr(self, partner_name) | ||
|
|
||
| def translate(self, vector, inplace=False): | ||
| pairs = self._periodic_pairs() | ||
| surf = self if inplace else copy(self) | ||
| for name in self._surface_names: | ||
| s = getattr(surf, name) | ||
| setattr(surf, name, s.translate(vector, inplace)) | ||
| surf._restore_periodic_pairs(pairs) | ||
| return surf | ||
|
|
||
| def rotate(self, rotation, pivot=(0., 0., 0.), order='xyz', inplace=False): | ||
| pairs = self._periodic_pairs() | ||
| surf = self if inplace else copy(self) | ||
| for name in self._surface_names: | ||
| s = getattr(surf, name) | ||
| setattr(surf, name, s.rotate(rotation, pivot, order, inplace)) | ||
| surf._restore_periodic_pairs(pairs) | ||
| return surf | ||
|
|
||
| @property | ||
|
|
@@ -646,6 +667,19 @@ def __init__(self, xmin, xmax, ymin, ymax, zmin, zmax, **kwargs): | |
| self.ymax = openmc.YPlane(y0=ymax, **kwargs) | ||
| self.zmin = openmc.ZPlane(z0=zmin, **kwargs) | ||
| self.zmax = openmc.ZPlane(z0=zmax, **kwargs) | ||
| if kwargs.get('boundary_type') == 'periodic': | ||
| self.xmin.periodic_surface = self.xmax | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accept axis-aligned planes as periodic partners.
|
||
| self.ymin.periodic_surface = self.ymax | ||
| self.zmin.periodic_surface = self.zmax | ||
|
|
||
| @CompositeSurface.boundary_type.setter | ||
| def boundary_type(self, boundary_type): | ||
| for name in self._surface_names: | ||
| getattr(self, name).boundary_type = boundary_type | ||
| if boundary_type == 'periodic': | ||
| self.xmin.periodic_surface = self.xmax | ||
| self.ymin.periodic_surface = self.ymax | ||
| self.zmin.periodic_surface = self.zmax | ||
|
|
||
| def __neg__(self): | ||
| return -self.xmax & +self.xmin & -self.ymax & +self.ymin & -self.zmax & +self.zmin | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: openmc-dev/openmc
Length of output: 5068
Script executed:
Repository: openmc-dev/openmc
Length of output: 16490
Script executed:
Repository: openmc-dev/openmc
Length of output: 9376
Script executed:
Repository: openmc-dev/openmc
Length of output: 3554
Script executed:
Repository: openmc-dev/openmc
Length of output: 3709
Script executed:
Repository: openmc-dev/openmc
Length of output: 1106
Record only reciprocal periodic pairs.
Surface.boundary_typedoes not clear_periodic_surface. Afterxmaxchanges tovacuumandxmin.periodic_surfaceis set to an external plane,xmax.periodic_surfacestill points toxmin._periodic_pairs()records this one-way link. A latertranslate()orrotate()restores it through the reciprocal setter and replacesxmin's external partner. Zero-vector translation can also modify the original component planes because plane translation returnsself.Suggested fix
Committable suggestion