Locating dofs for Nedelec order 2

Hi,

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
order=2
V = dox.fem.FunctionSpace(domain, ("Nedelec 1st kind H(curl)", order))

# SELECTION NOT WORKING 
tol=1e-15
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
AD.interpolate(func)
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
D=(g[0]*v[0]+g[1]*v[1])*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  )
dofs=dox.fem.locate_dofs_topological(V,1,mkr)

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

Look into ufl.as_vector
https://fenics.readthedocs.io/projects/ufl/en/latest/manual/form_language.html#making-tensors-from-components