Mesh refine in quad element

Hello everyone,
I am very much new to this community. I have a mesh with quadrilateral elements but I wanted in that mesh to have only a particular region to get fine meshed. Is that even possible in Fenicsx. Because I went through some previous discussions like Mesh.refine errror: Refinement only defined for simplices, but I found that there is no refinement in quad element meshes.

Could anyone tell me a way in handling this which is very thankful. Thanks all in advance. My code that I initially tried was,

import numpy as np
from dolfinx.mesh import  create_rectangle, locate_entities, refine
from mpi4py import MPI
from dolfinx.io import XDMFFile
from mpi4py import MPI
from dolfinx import mesh

#Creating mesh
msh = mesh.create_rectangle (comm=MPI.COMM_WORLD, points=((0.0, 0.0), (6.0,1.0)), n=(12,2), cell_type=mesh.CellType.quadrilateral)


def top_data(x):
    return np.logical_and(np.isclose(x[1], 1), np.logical_and(x[0] >= 2.5, x[0] <= 3)) 


dim = msh.topology.dim
edges =  locate_entities(msh, dim-1, top_data)
msh.topology.create_entities(1)
msh = refine(msh, edges, redistribute=True)


# Output file
file = XDMFFile(MPI.COMM_WORLD, "new_mesh.xdmf", "w")
file.write_mesh(msh)

This code I tried to imitate from existing example but went in vain. So could anyone help in doing this small fine refinement in the particular region. Thanks in advance once again. Any hints on handling the code is very much helpful.

Please clarify what happens with the code you wrote: is there an error? does it run, and if so what does it do?

Thanks for your response. Actually the code showing error stating refinement possible only with simplex.

But actually I need like inside one quad element in top middle region to get more finer, like within the quad element with further divisions. So will that option possible for a quad elements??

Thanks for your help and considerations.

It would have been best to include the error in the first post then. It seems then that the situation is unchanged from the one you saw in the other post in March 2022. It is not implemented, and there is no ETA on any future implementation.

If you know a priori which regions you want to refine, you may trying generating your own mesh (rather than using the builtin create_rectangle), for instance using gmsh. If you never used it, there are several resources on this forum (starting from the pinned post) to help you get started with it. You’ll need to look up in its documentation how to generate a mesh with quads, since by default triangles are used.