Thank you, I have got this working now. I’ve left my implementation below if anyone is else is needing to do this.
import numpy as np
import dolfin as fe
def ChebyshevMesh(Lx, Ly, Nx, Ny, refinement = 'xy'):
# Generate DOLFINx mesh
mesh = fe.UnitSquareMesh(Nx, Ny)
coords = mesh.coordinates()
# Generate Chebyshev nodes
x = np.cos (np.pi * np.arange(Nx + 1) / Nx)
y = np.cos (np.pi * np.arange(Ny + 1) / Ny)
# Scale to the domain
x = 0.5 * (x + 1) * Lx
y = 0.5 * (y + 1) * Ly
# Generate meshgrid
xx, yy = np.meshgrid(x, y)
# Apply to DOLFINx mesh
if 'x' in refinement:
coords[:,0] = xx.flatten()
else:
coords[:,0] *= Lx
if 'y' in refinement:
coords[:,1] = yy.flatten()
else:
coords[:,1] *= Ly
return mesh