mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Merge branch 'develop' into centre_for_cylinder_spherical_meshes
This commit is contained in:
commit
2d573c3fa1
14 changed files with 126 additions and 72 deletions
|
|
@ -10,20 +10,20 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:latest-dagmc-libmesh
|
||||
|
|
|
|||
|
|
@ -10,20 +10,20 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:latest-dagmc
|
||||
|
|
|
|||
8
.github/workflows/dockerhub-publish-dev.yml
vendored
8
.github/workflows/dockerhub-publish-dev.yml
vendored
|
|
@ -10,20 +10,20 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:develop
|
||||
|
|
|
|||
|
|
@ -10,20 +10,20 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:develop-dagmc-libmesh
|
||||
|
|
|
|||
|
|
@ -10,20 +10,20 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:develop-dagmc
|
||||
|
|
|
|||
|
|
@ -10,20 +10,20 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:develop-libmesh
|
||||
|
|
|
|||
|
|
@ -10,20 +10,20 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:latest-libmesh
|
||||
|
|
|
|||
|
|
@ -13,20 +13,20 @@ jobs:
|
|||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:${{ env.RELEASE_VERSION }}-dagmc-libmesh
|
||||
|
|
|
|||
|
|
@ -13,20 +13,20 @@ jobs:
|
|||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:${{ env.RELEASE_VERSION }}-dagmc
|
||||
|
|
|
|||
|
|
@ -13,20 +13,20 @@ jobs:
|
|||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:${{ env.RELEASE_VERSION }}-libmesh
|
||||
|
|
|
|||
|
|
@ -13,20 +13,20 @@ jobs:
|
|||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:${{ env.RELEASE_VERSION }}
|
||||
|
|
|
|||
8
.github/workflows/dockerhub-publish.yml
vendored
8
.github/workflows/dockerhub-publish.yml
vendored
|
|
@ -10,20 +10,20 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: openmc/openmc:latest
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ class StructuredMesh(MeshBase):
|
|||
datasets_out.append(dataset)
|
||||
|
||||
if volume_normalization:
|
||||
dataset /= self.volumes.flatten()
|
||||
dataset /= self.volumes.T.flatten()
|
||||
|
||||
dataset_array = vtk.vtkDoubleArray()
|
||||
dataset_array.SetName(label)
|
||||
|
|
@ -1012,7 +1012,7 @@ class RectilinearMesh(StructuredMesh):
|
|||
the VTK object
|
||||
"""
|
||||
# create points
|
||||
pts_cartesian = np.array([[x, y, z] for z in self.z_grid for y in self.y_grid for x in self.x_grid])
|
||||
pts_cartesian = self.vertices.T.reshape(-1, 3)
|
||||
|
||||
return super().write_data_to_vtk(
|
||||
points=pts_cartesian,
|
||||
|
|
@ -1325,15 +1325,9 @@ class CylindricalMesh(StructuredMesh):
|
|||
the VTK object
|
||||
"""
|
||||
# create points
|
||||
pts_cylindrical = np.array(
|
||||
[
|
||||
[r, phi, z]
|
||||
for z in self.z_grid
|
||||
for phi in self.phi_grid
|
||||
for r in self.r_grid
|
||||
]
|
||||
)
|
||||
pts_cartesian = np.empty_like(pts_cylindrical)
|
||||
pts_cylindrical = self.vertices.T.reshape(-1, 3)
|
||||
pts_cartesian = np.copy(pts_cylindrical)
|
||||
|
||||
r, phi = pts_cylindrical[:, 0], pts_cylindrical[:, 1]
|
||||
pts_cartesian[:, 0] = r * np.cos(phi) + self.origin[0]
|
||||
pts_cartesian[:, 1] = r * np.sin(phi) + self.origin[1]
|
||||
|
|
@ -1579,17 +1573,10 @@ class SphericalMesh(StructuredMesh):
|
|||
vtk.vtkStructuredGrid
|
||||
the VTK object
|
||||
"""
|
||||
|
||||
# create points
|
||||
pts_spherical = np.array(
|
||||
[
|
||||
[r, theta, phi]
|
||||
for phi in self.phi_grid
|
||||
for theta in self.theta_grid
|
||||
for r in self.r_grid
|
||||
]
|
||||
)
|
||||
pts_cartesian = np.empty_like(pts_spherical)
|
||||
pts_spherical = self.vertices.T.reshape(-1, 3)
|
||||
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) + self.origin[0]
|
||||
pts_cartesian[:, 1] = r * np.sin(phi) * np.sin(theta) + self.origin[1]
|
||||
|
|
|
|||
|
|
@ -34,7 +34,11 @@ def test_write_data_to_vtk(mesh, tmpdir):
|
|||
# BUILD
|
||||
filename = Path(tmpdir) / "out.vtk"
|
||||
|
||||
data = np.random.random(mesh.num_mesh_cells)
|
||||
# use mesh element volumes as data to check volume-normalization ordering
|
||||
# kji (i changing fastest) orering is expected for input data
|
||||
# by using the volumes transposed as the data here, we can ensure the
|
||||
# normalization is happening correctly
|
||||
data = mesh.volumes.T
|
||||
|
||||
# RUN
|
||||
mesh.write_data_to_vtk(filename=filename, datasets={"label1": data, "label2": data})
|
||||
|
|
@ -56,8 +60,13 @@ def test_write_data_to_vtk(mesh, tmpdir):
|
|||
assert array2.GetName() == "label2"
|
||||
|
||||
# check size of datasets
|
||||
assert nps.vtk_to_numpy(array1).size == data.size
|
||||
assert nps.vtk_to_numpy(array2).size == data.size
|
||||
data1 = nps.vtk_to_numpy(array1)
|
||||
data2 = nps.vtk_to_numpy(array2)
|
||||
assert data1.size == data.size
|
||||
assert data2.size == data.size
|
||||
|
||||
assert all(data1 == data2)
|
||||
assert all(data1 == 1.0)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mesh", [cylinder_mesh, regular_mesh, rectilinear_mesh, spherical_mesh])
|
||||
|
|
@ -82,3 +91,61 @@ def test_write_data_to_vtk_size_mismatch(mesh):
|
|||
)
|
||||
with pytest.raises(ValueError, match=expected_error_msg):
|
||||
mesh.write_data_to_vtk(filename="out.vtk", datasets={"label": data})
|
||||
|
||||
def test_write_data_to_vtk_round_trip(run_in_tmpdir):
|
||||
cmesh = openmc.CylindricalMesh()
|
||||
cmesh.r_grid = (0.0, 1.0, 2.0)
|
||||
cmesh.z_grid = (0.0, 2.0, 4.0, 5.0)
|
||||
cmesh.phi_grid = (0.0, 3.0, 6.0)
|
||||
|
||||
smesh = openmc.SphericalMesh()
|
||||
smesh.r_grid = (0.0, 1.0, 2.0)
|
||||
smesh.theta_grid = (0.0, 2.0, 4.0, 5.0)
|
||||
smesh.phi_grid = (0.0, 3.0, 6.0)
|
||||
|
||||
rmesh = openmc.RegularMesh()
|
||||
rmesh.lower_left = (0.0, 0.0, 0.0)
|
||||
rmesh.upper_right = (1.0, 3.0, 5.0)
|
||||
rmesh.dimension = (2, 1, 6)
|
||||
|
||||
for mesh in [smesh, cmesh, rmesh]:
|
||||
|
||||
filename = "mesh.vtk"
|
||||
data = np.array([1.0] * 12) # there are 12 voxels in each mesh
|
||||
mesh.write_data_to_vtk(
|
||||
filename=filename,
|
||||
datasets={"normalized": data},
|
||||
volume_normalization=True
|
||||
)
|
||||
|
||||
reader = vtk.vtkStructuredGridReader()
|
||||
reader.SetFileName(filename)
|
||||
reader.ReadAllFieldsOn()
|
||||
reader.Update()
|
||||
|
||||
cell_data = reader.GetOutput().GetCellData()
|
||||
uniform_array = cell_data.GetArray("normalized")
|
||||
num_tuples = uniform_array.GetNumberOfTuples()
|
||||
vtk_values = [uniform_array.GetValue(i) for i in range(num_tuples)]
|
||||
|
||||
# checks that the vtk cell values are equal to the data / mesh volumes
|
||||
assert np.allclose(vtk_values, data / mesh.volumes.T.flatten())
|
||||
|
||||
mesh.write_data_to_vtk(
|
||||
filename=filename,
|
||||
datasets={"not_normalized": data},
|
||||
volume_normalization=False,
|
||||
)
|
||||
|
||||
reader = vtk.vtkStructuredGridReader()
|
||||
reader.SetFileName(filename)
|
||||
reader.ReadAllFieldsOn()
|
||||
reader.Update()
|
||||
|
||||
cell_data = reader.GetOutput().GetCellData()
|
||||
uniform_array = cell_data.GetArray("not_normalized")
|
||||
num_tuples = uniform_array.GetNumberOfTuples()
|
||||
vtk_values = [uniform_array.GetValue(i) for i in range(num_tuples)]
|
||||
|
||||
# checks that the vtk cell values are equal to the data
|
||||
assert np.array_equal(vtk_values, data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue