Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check_formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
ruff format --check .

- name: Mypy check
run: python3 -m mypy -v
run: python3 -m mypy
4 changes: 3 additions & 1 deletion src/io4dolfinx/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ufl
from packaging.version import Version

from . import compat
from .backends import FileMode, ReadMode, get_backend
from .comm_helpers import (
send_and_recv_cell_perm,
Expand Down Expand Up @@ -157,7 +158,8 @@ def write_meshtags(
local_start = mesh.comm.exscan(num_saved_tag_entities, op=MPI.SUM)
local_start = local_start if mesh.comm.rank != 0 else 0
global_num_tag_entities = mesh.comm.allreduce(num_saved_tag_entities, op=MPI.SUM)
dof_layout = mesh.geometry.cmap.create_dof_layout()

dof_layout = compat.cmap(mesh).create_dof_layout()
if hasattr(dof_layout, "num_entity_closure_dofs"):
num_dofs_per_entity = dof_layout.num_entity_closure_dofs(dim)
else:
Expand Down
9 changes: 9 additions & 0 deletions src/io4dolfinx/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import dolfinx.mesh


def cmap(mesh) -> dolfinx.fem.element.CoordinateElement:
# Due to https://github.com/FEniCS/dolfinx/pull/4169
try:
return mesh.geometry.cmap()
except TypeError:
return mesh.geometry.cmap
Comment thread
jorgensd marked this conversation as resolved.
Outdated
3 changes: 2 additions & 1 deletion src/io4dolfinx/original_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import dolfinx
import numpy as np

from . import compat
from .backends import FileMode, get_backend
from .comm_helpers import numpy_to_mpi
from .structures import FunctionData, MeshData
Expand Down Expand Up @@ -178,7 +179,7 @@ def create_original_mesh_data(mesh: dolfinx.mesh.Mesh) -> MeshData:
del _geometry, recv_nodes

assert local_node_range[1] - local_node_range[0] == geometry.shape[0]
cmap = mesh.geometry.cmap
cmap = compat.cmap(mesh)

cell_to_output_comm.Free()
geometry_to_owner_comm.Free()
Expand Down
8 changes: 5 additions & 3 deletions src/io4dolfinx/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy as np
from packaging.version import Version

from . import compat
from .backends import FileMode, get_backend
from .structures import FunctionData, MeshData

Expand Down Expand Up @@ -40,7 +41,8 @@ def prepare_meshdata_for_storage(mesh: dolfinx.mesh.Mesh, store_partition_info:
num_cells_local = mesh.topology.index_map(mesh.topology.dim).size_local
num_cells_global = mesh.topology.index_map(mesh.topology.dim).size_global
cell_range = mesh.topology.index_map(mesh.topology.dim).local_range
cmap = mesh.geometry.cmap
cmap = compat.cmap(mesh)

geom_layout = cmap.create_dof_layout()
if hasattr(geom_layout, "num_entity_closure_dofs"):
num_dofs_per_cell = geom_layout.num_entity_closure_dofs(mesh.topology.dim)
Expand Down Expand Up @@ -94,8 +96,8 @@ def prepare_meshdata_for_storage(mesh: dolfinx.mesh.Mesh, store_partition_info:
local_topology_pos=cell_range,
num_cells_global=num_cells_global,
cell_type=mesh.topology.cell_name(),
degree=mesh.geometry.cmap.degree,
lagrange_variant=mesh.geometry.cmap.variant,
degree=cmap.degree,
lagrange_variant=cmap.variant,
store_partition=store_partition_info,
partition_processes=partition_processes,
ownership_array=ownership_array,
Expand Down