openmc icon indicating copy to clipboard operation
openmc copied to clipboard

bounding_box property on all mesh types

Open shimwell opened this issue 2 years ago • 7 comments

Currently we have a nice RegularMesh.bounding_box property that returns an instance of the BoundingBox class. We should probably have this attribute on all mesh types. RegularMesh was just the easiest option so that I why I did that one first.

Link to RegularMesh.bounding_box https://github.com/openmc-dev/openmc/blob/7479a9022a056d697f79ba2caeccb067eb7aee67/openmc/mesh.py#L426

Discussed with @eepeterson and @pshriwise

  • [x] CylindricalMesh (#2621)
  • [x] SphericalMesh (#2620)
  • [ ] RectilinearMesh
  • [ ] UnstructuredMesh

shimwell avatar Jun 06 '23 18:06 shimwell

If this still something that the collective would like done I'm happy to take it on

caderache2014 avatar Jul 05 '23 13:07 caderache2014

@shimwell was it your intention that we apply some kind of duck typing so the function behaves appropriately regardless of the mesh topology? By the same token.... do you want to extent this attribute to even unstructured meshes? @eepeterson @pshriwise any thoughts?

caderache2014 avatar Jul 17 '23 09:07 caderache2014

Yes Ideally a user would be able to call a bounding_box property on each of the following mesh types. Currently we get an AttributeError as the classes don't have the method. I think unstructured mesh would also be great to include but this could be done in a follow on PR. I think the CylindricalMesh and SphericalMesh would be the first ones to look at

import openmc
surf = openmc.Sphere(r=10)
cell = openmc.Cell(region=-surf)

r_mesh = openmc.RegularMesh().from_domain(cell)
r_mesh.bounding_box
>>> BoundingBox(lower_left=(-10.0, -10.0, -10.0), upper_right=(10.0, 10.0, 10.0))

s_mesh = openmc.SphericalMesh()
s_mesh.bounding_box
>>> AttributeError:

c_mesh = openmc.CylindricalMesh().from_domain(cell)
c_mesh.bounding_box
>>> AttributeError:

shimwell avatar Jul 17 '23 09:07 shimwell

RegularMesh has this property https://github.com/openmc-dev/openmc/blob/3f9cd0d7cb982428295cff25963f4ee2726d34a9/openmc/mesh.py#L661-L665

We would need something similar in the SphericalMesh and the CylindricalMesh class

shimwell avatar Jul 17 '23 09:07 shimwell

So @shimwell you are.... instantiating a spherical mesh object parametrized only by a radius value. You call it 'surf'. Then you cast surf to a cell, and then instantiate the cell to a cylindrical mesh object. So.... would intention to use the sphere-derived cell to define the boundary box on a an cylindrical mesh?

You're not specifying coordinate values on the bounding_box method itself. The 'box' a defined by a 'BoundingBox' object which you've instantiated using what appear to be 3d cartesian coordinates. Do you want to... define a cartesian box and then 'convert' it to a cylindrical or spherical equivalent?

caderache2014 avatar Jul 17 '23 12:07 caderache2014

Actively working on cylindrical mesh. Modifications to spherical mesh test fine,

caderache2014 avatar Jul 17 '23 16:07 caderache2014

https://github.com/caderache2014/openmc/tree/patch-1

caderache2014 avatar Jul 17 '23 16:07 caderache2014