Integral in Fenicsx

Can you please decode this to Fenicsx

kernel is defined

kernel = Expression('(i+j)*exp(-x[0]-x[1])', i = 0, j = 0)
Iv = interpolate(kernel, V)

Trying to write Fenicsx code from this

    x_ks = V.tabulate_dof_coordinates()
    m = V.dim()
    d = mesh.geometry().dim()

mesh.geometry is not working in Fenicsx

    x_ks.resize((m, d))

resize is not working in fenicsx

Tabulate dof coordinates is always returning a 3D coordinate:
https://docs.fenicsproject.org/dolfinx/v0.6.0/cpp/fem.html#_CPPv4NK7dolfinx3fem13FunctionSpace24tabulate_dof_coordinatesEb

I am trying to write code in fenicsx for

\int_{\Omega} \int_{\Omega} q(x,y) u(x) v(y) dy dx

where u and v are the trial and test function, respectively. Could you please suggest something.

Is your domain 2D or 3D?

This looks like a standard assembly to me.
Have you read
https://jsdokken.com/dolfinx-tutorial/chapter2/heat_code.html?highlight=assemble_matrix

First I am trying this in 1D then go further
Yes, I have gone through that. I am trying it this way

kernel = fem.Function(V)
kernel.interpolate(lambda x: np.exp(-x[0]) )


import ufl
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

k = fem.Function(V)


# k = (kernel*uD) * ufl.dx
k.interpolate(lambda x:  ( kernel * uD ) * ufl.dx )

a = ufl.dot(ufl.grad(u), ufl.grad(v)) * ufl.dx
L = f * v * ufl.dx + 0.5*(k * v)* ufl.dx

problem = fem.petsc.LinearProblem(a, L, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
uh = problem.solve()

Could you write out the mathematical formulation of this operation ?

Whenever you multiply by ufl.dx it implies that you should do an integral. It is then unclear what the input x should be used for here

u: [0, 1] → R, such that

u(x) - \int_{0}^{1}e^{-y}u(y)dy = f(x) in [0, 1]

Variational formulation

(u,v )- (\int_{0}^{1}e^{-y}u(y)dy,v) = (f,v)

I am just trying to write (\int_{0}^{1}e^{-y}u(y)dy,v) as inner product (e^{-y},u) and again inner product with u

This problem is highly non-linear, and has several non-local couplings (in the y direction, note that u is a function of both x and y), which does not naturally fall under ufl.

What you first need to do is to find a way to linearize the problem (a newton iteration or piccard iteration, i would probably use Piccard on the non-local interaction).

Then secondly, you would have to build up an operation for the lon-local interaction. I would probably make my own quadrature scheme in y direction, and use Implementation — FEniCSx tutorial to make the contributions in y direction.

Okay. Could you please tell me how to assemble a matrix

    a0 = Function(V)
    K = inner(Iu,Iv)*dx
    a0.vector()[:] = assemble(K)

How to write this in fenicsx ?

You have not made an attempt by making a minimal reproducible example, so I don’t have tine to guess what you would like to do.

I just need tyo write this in fenicsx

a0.vector()[:] = assemble(K)