diff --git a/.github/workflows/ci_docker.yml b/.github/workflows/ci_docker.yml index 70513c8..ae90c28 100644 --- a/.github/workflows/ci_docker.yml +++ b/.github/workflows/ci_docker.yml @@ -20,6 +20,10 @@ jobs: - name: Run tests run: | python3 -m pytest test/ --cov openmc2dolfinx --cov-report xml --cov-report term + + - name: Install curl for codecov + run: | + apt-get update && apt-get install -y curl - name: Upload to codecov uses: codecov/codecov-action@v5 diff --git a/src/openmc2dolfinx/core.py b/src/openmc2dolfinx/core.py index 74aa24f..6faa5bb 100644 --- a/src/openmc2dolfinx/core.py +++ b/src/openmc2dolfinx/core.py @@ -21,12 +21,12 @@ class OpenMC2dolfinx(pyvista.VTKDataSetReader): path: the path to the OpenMC .vtk file Attributes: - data: the mesh and results from the OpenMC .vtk file + _data: the mesh and results from the OpenMC .vtk file connectivity: The OpenMC mesh cell connectivity dolfinx_mesh: the dolfinx mesh """ - data: pyvista.core.pointset.UnstructuredGrid | pyvista.core.pointset.StructuredGrid + _data: pyvista.core.pointset.UnstructuredGrid | pyvista.core.pointset.StructuredGrid connectivity: np.ndarray dolfinx_mesh: dolfinx.mesh.Mesh = None @@ -41,7 +41,7 @@ def create_dolfinx_mesh(self): if not hasattr(self, "cell_type"): raise AttributeError("cell_type must be defined in the child class") - self.data = self.read() + self._data = self.read() if not hasattr(self, "cell_connectivity"): raise AttributeError("cell_connectivity must be defined in the child class") @@ -55,7 +55,10 @@ def create_dolfinx_mesh(self): # Create dolfinx Mesh mesh_ufl = ufl.Mesh(mesh_element) self.dolfinx_mesh = create_mesh( - MPI.COMM_WORLD, self.cell_connectivity, self.data.points, mesh_ufl + comm=MPI.COMM_WORLD, + cells=self.cell_connectivity, + x=self._data.points, + e=mesh_ufl, ) def create_dolfinx_function(self, data: str = "mean") -> dolfinx.fem.Function: @@ -74,7 +77,7 @@ def create_dolfinx_function(self, data: str = "mean") -> dolfinx.fem.Function: function_space = dolfinx.fem.functionspace(self.dolfinx_mesh, ("DG", 0)) u = dolfinx.fem.Function(function_space) - u.x.array[:] = self.data.cell_data[f"{data}"][ + u.x.array[:] = self._data.cell_data[f"{data}"][ self.dolfinx_mesh.topology.original_cell_index ] @@ -101,7 +104,7 @@ class UnstructuredMeshReader(OpenMC2dolfinx): @property def cell_connectivity(self): - return self.data.cells_dict[10] + return self._data.cells_dict[10] class StructuredGridReader(OpenMC2dolfinx): @@ -124,8 +127,8 @@ class StructuredGridReader(OpenMC2dolfinx): _cell_connectivity = None def get_connectivity(self): - num_cells = self.data.GetNumberOfCells() - assert self.data.GetCellType(0) == 12, "Only hexahedron cells are supported" + num_cells = self._data.GetNumberOfCells() + assert self._data.GetCellType(0) == 12, "Only hexahedron cells are supported" # Extract connectivity information ordering = [0, 1, 3, 2, 4, 5, 7, 6] @@ -135,7 +138,7 @@ def get_connectivity(self): # TODO numpify this # Extract all cell connectivity data at once for i in range(num_cells): - cell = self.data.GetCell(i) # Get the i-th cell + cell = self._data.GetCell(i) # Get the i-th cell point_ids = [cell.GetPointId(j) for j in ordering] # Extract connectivity self._cell_connectivity.append(point_ids)