Hello all,
Here is MWE for calculating the minimum element length, which works smoothly on 0.8.0, but on the latest docker nightly installation of dolfinx 0.9.0.0, it results an error.
# Scaled variable
import dolfinx
from mpi4py import MPI
from dolfinx import mesh, fem, plot, io, default_scalar_type
from petsc4py import PETSc
import numpy as np
def mpi_print(s):
print(f"Rank {comm.rank}: {s}")
dtype = PETSc.ScalarType # type: ignore
comm = MPI.COMM_WORLD
rank = comm.rank
# prints dolfinx version
mpi_print(f"DOLFINx version: {dolfinx.__version__}")
domain = mesh.create_box(MPI.COMM_WORLD, [[0.0, 0.0, 0.0], [1, 1, 1]], [3, 2, 1], mesh.CellType.hexahedron)
# Assuming `mesh` is the mesh created in the code
num_elements = domain.topology.index_map(3).size_local
num_nodes = domain.topology.index_map(0).size_local
# Summing up the counts from all processes in MPI_COMM_WORLD
num_elements_global = MPI.COMM_WORLD.allreduce(num_elements, op=MPI.SUM)
num_nodes_global = MPI.COMM_WORLD.allreduce(num_nodes, op=MPI.SUM)
mpi_print(f"Number of elements: {num_elements_global}")
mpi_print(f"Number of nodes: {num_nodes_global}")
# filter and projection parameters
tdim = domain.topology.dim
num_cells = domain.topology.index_map(tdim).size_local + domain.topology.index_map(tdim).num_ghosts
h = domain.h(tdim-2, np.arange(num_cells))
hmax = max(h)
hmin = min(h)
mpi_print(f"Max Element Size: {hmax}")
mpi_print(f"Min Element Size: {hmin}")
Output on Dolfinx 0.8.0
Rank 0: DOLFINx version: 0.8.0
Rank 0: Number of elements: 6
Rank 0: Number of nodes: 24
Rank 0: Max Element Size: 1.0
Rank 0: Min Element Size: 0.3333333333333333
Output on docker nightly Dolfinx 0.9.0.0
Rank 0: DOLFINx version: 0.9.0.0
Rank 0: Number of elements: 6
Rank 0: Number of nodes: 24
Traceback (most recent call last):
File "/home/versiontest/vertest2.py", line 32, in <module>
h = domain.h(tdim-2, np.arange(num_cells))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/dolfinx-real/lib/python3.12/dist-packages/dolfinx/mesh.py", line 346, in h
return _cpp.mesh.h(self._cpp_object, dim, entities)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Entity-to-cell connectivity has not been computed. Missing dims 1->3
Can anyone please let me know the changes I require on the latest version?
Thanks.