Dear FEniCS community.
I’m trying to use the refine_plaza function in order to consider a criterium for refinement.
I have followed Mesh refinement in dolfinx - #2 by dokken and considered the following MWE.
import dolfinx
from mpi4py import MPI
import numpy as np
def cell_criterion(x):
"""Given mesh coordinates, return if each point
satisfies x[0]<0.3 or x[1]>0.4
:param x: Input coordinates, shape (num_points, 3)
:returns: Boolean array of shape (num_points, )
"""
return (x[0] < 0.3) | (x[1] > 0.4)
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 4, 4)
# Compute midpoints for all cells on process
cells_local = np.arange(mesh.topology.index_map(
mesh.topology.dim).size_local, dtype=np.int32)
midpoints = dolfinx.mesh.compute_midpoints(
mesh, mesh.topology.dim, cells_local).T
# Check midpoint criterion and find edges connected to cells
should_refine = np.flatnonzero(cell_criterion(midpoints)).astype(np.int32)
mesh.topology.create_entities(1)
local_edges = dolfinx.mesh.compute_incident_entities(
mesh.topology, should_refine, mesh.topology.dim, 1)
fine_mesh, parent_cell, parent_facet = dolfinx.mesh.refine_plaza(
mesh, local_edges, False, dolfinx.mesh.RefinementOption.parent_cell_and_facet)
But I get the error on the refine_plaza
function
TypeError: refine_plaza(): incompatible function arguments. The following argument types are supported:
1. (mesh: dolfinx.cpp.mesh.Mesh_float32, redistribute: bool, option: dolfinx.cpp.refinement.RefinementOption) -> Tuple[dolfinx.cpp.mesh.Mesh_float32, numpy.ndarray[numpy.int32], numpy.ndarray[numpy.int8]]
2. (mesh: dolfinx.cpp.mesh.Mesh_float64, redistribute: bool, option: dolfinx.cpp.refinement.RefinementOption) -> Tuple[dolfinx.cpp.mesh.Mesh_float64, numpy.ndarray[numpy.int32], numpy.ndarray[numpy.int8]]
3. (mesh: dolfinx.cpp.mesh.Mesh_float32, edges: numpy.ndarray[numpy.int32], redistribute: bool, option: dolfinx.cpp.refinement.RefinementOption) -> Tuple[dolfinx.cpp.mesh.Mesh_float32, numpy.ndarray[numpy.int32], numpy.ndarray[numpy.int8]]
4. (mesh: dolfinx.cpp.mesh.Mesh_float64, edges: numpy.ndarray[numpy.int32], redistribute: bool, option: dolfinx.cpp.refinement.RefinementOption) -> Tuple[dolfinx.cpp.mesh.Mesh_float64, numpy.ndarray[numpy.int32], numpy.ndarray[numpy.int8]]
Invoked with: <dolfinx.cpp.mesh.Mesh_float64 object at 0x7fa3de0b5df0>, array([ 8, 10, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 49, 50, 51, 52, 53, 54, 55], dtype=int32), False
If I remove local_edges
the code runs but using uniform refinements.
Any help is appreciated.