Open
Description
When using a Firedrake install with 64-bit integers (i.e. when Firedrake is installed with flag --petsc-int-type int64
), curved mesh generation fails. For example, consider the curved mesh Netgen demo code
from firedrake import *
from netgen.occ import WorkPlane, OCCGeometry
import netgen
from mpi4py import MPI
wp = WorkPlane()
if COMM_WORLD.rank == 0:
for i in range(6):
wp.Line(0.6).Arc(0.4, 60)
shape = wp.Face()
ngmesh = OCCGeometry(shape,dim=2).GenerateMesh(maxh=1.)
else:
ngmesh = netgen.libngpy._meshing.Mesh(2)
mesh = Mesh(Mesh(ngmesh, comm=COMM_WORLD).curve_field(4))
VTKFile("output/MeshExample5.pvd").write(mesh)
Running this yields an error message
File "/scratch/baierreinio/test.py", line 14, in <module>
mesh = Mesh(Mesh(ngmesh, comm=COMM_WORLD).curve_field(4))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/scratch/baierreinio/firedrake_aaron/firedrake/lib/python3.12/site-packages/ngsPETSc/utils/firedrake/meshes.py", line 185, in curveField
ng_index = [*map(lambda x: self.locate_cell(x, tolerance=location_tol), barycentres)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_aaron/firedrake/lib/python3.12/site-packages/ngsPETSc/utils/firedrake/meshes.py", line 185, in <lambda>
ng_index = [*map(lambda x: self.locate_cell(x, tolerance=location_tol), barycentres)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/scratch/baierreinio/firedrake_aaron/firedrake/src/firedrake/firedrake/mesh.py", line 2549, in locate_cell
return self.locate_cell_and_reference_coordinate(x, tolerance=tolerance, cell_ignore=cell_ignore)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_aaron/firedrake/src/firedrake/firedrake/mesh.py", line 2584, in locate_cell_and_reference_coordinate
cells, ref_coords, _ = self.locate_cells_ref_coords_and_dists(x, tolerance=tolerance, cells_ignore=[[cell_ignore]])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_aaron/firedrake/src/firedrake/firedrake/mesh.py", line 2633, in locate_cells_ref_coords_and_dists
self._c_locator(tolerance=tolerance)(self.coordinates._ctypes,
ctypes.ArgumentError: argument 8: TypeError: array must have data type int32
I believe the culprit is that commit ec0329f is using int32
's in some situations where it should be using the Firedrake int type.