Merge pull request #2417 from pshriwise/spherical-mesh-fixes

Spherical to Cartesian coordinate conversion correction for VTK files
This commit is contained in:
Paul Romano 2023-03-21 22:27:53 -05:00 committed by GitHub
commit 341cb9eb11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 141 additions and 17 deletions

View file

@ -446,7 +446,7 @@ class RegularMesh(StructuredMesh):
if self._width is not None:
self._width = None
warnings.warn("Unsetting width attribute.")
if self.lower_left is not None and any(np.isclose(self.lower_left, upper_right)):
raise ValueError("Mesh cannot have zero thickness in any dimension")
@ -1533,9 +1533,9 @@ class SphericalMesh(StructuredMesh):
pts_cartesian = np.copy(pts_spherical)
r, theta, phi = pts_spherical[:, 0], pts_spherical[:, 1], pts_spherical[:, 2]
pts_cartesian[:, 0] = r * np.sin(phi) * np.cos(theta)
pts_cartesian[:, 1] = r * np.sin(phi) * np.sin(theta)
pts_cartesian[:, 2] = r * np.cos(phi)
pts_cartesian[:, 0] = r * np.sin(theta) * np.cos(phi)
pts_cartesian[:, 1] = r * np.sin(theta) * np.sin(phi)
pts_cartesian[:, 2] = r * np.cos(theta)
return super().write_data_to_vtk(
points=pts_cartesian,