Locating dofs for Nedelec order 2


I’m using dolfinx 0.6.0 in a docker with windows.
I want to solve a 2D vector valued dirichlet problem. As function space I used Nedelec functions of order 2. How to locate the dofs on the boundary?

I tried fem.locate_dofs_geometrical, but thats not suported with Nedelec functions. Is there a simple way to locate them geomatrically?

Is there also a way to define g below as a vector to use ufl.inner(g,v) in the weak form?

import dolfinx as dox
import ufl
from mpi4py import MPI
import numpy as np

domain=dox.mesh.create_rectangle(MPI.COMM_WORLD, [np.array([0, 0]), np.array([1, 0.7])],[3, 2],    dox.mesh.CellType.triangle)

x = ufl.SpatialCoordinate(domain)  
alpha = 1 + x[0]**2
beta = x[0]**2*x[1]
g = np.array( [x[1] , x[0]**2*x[1]] )

# function space
V = dox.fem.FunctionSpace(domain, ("Nedelec 1st kind H(curl)", order))

dofs = dox.fem.locate_dofs_geometrical(V, lambda X : np.isclose(X[0],0,atol=tol) | (X[0]>1-tol) | (X[1]>0.7-tol) | (X[1]<tol)  )
print("dofs : ",dofs)

# AD interpolation
AD = dox.fem.Function(V)
def func(x):
    values = np.empty( (2, x.shape[1]) )
    values[0] = 1+x[0]+x[1]**2
    values[1] = 2+x[0]*x[1]
    return values
print("\n interpolation: ",AD.x.array )

# weak form
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)
K=alpha*ufl.inner(ufl.rot(u),ufl.rot(v))*ufl.dx + beta*ufl.inner(u,v)*ufl.dx

# dirichlet boundary condition
bc = dox.fem.dirichletbc(AD,dofs)
problem = dox.fem.petsc.LinearProblem(K, D, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu"})

Apot = problem.solve()
print("\nsolution ",Apot.x.array)

Nedelec function space have dofs associated with facets, not a given coordinate, so you have to use locate dofs topological, using locate entities first

thanks, so that would be

mkr=dox.mesh.locate_entities_boundary(domain, 1 , lambda x: x[0] > -0.001  )

Do you have a suggestion about defining g to write inner(g,v) ?

Look into ufl.as_vector