Integration within the variational form

Hello everyone
I was using FEniCS to solve a 1D peridynamics problem. The exact problem statement is as follows-
A rod extends from (alpha = 0) to (beta = 1m) and is subjected to body force (b(x)) of 1N/m and the equation is solved for displacement with BCs as u(0) = 0 and u(1) = 0 and delta is a parameter. The variational form for the same is :
$$\frac{1}{\delta^2}$$ $$ \int_{\alpha}^{\beta}v(x) \int_{x - \delta}^{x + \delta} \frac{u(x) - u(x’)}{|x-x’|} dx’ dx = \int_{\alpha}^{\beta}v(x) b(x) dx $$
with v being the weight function
Within the outside integral of variational form, we have another inner integral for a dummy variable x’.
How is that to be coded in FEniCS?
My sample code looks like this:

from fenics import *
import sympy as sy
alpha,beta,delta = 0,1,0.3
no_elem,degree = 2,1
mesh = IntervalMesh(no_elem, alpha, beta)
def boundary_1(x,on_boundary):
    return on_boundary and near(x[0],0,DOLFIN_EPS)
def boundary_2(x,on_boundary):
    return on_boundary and near(x[0],1,DOLFIN_EPS)
V = FunctionSpace(mesh, "CG", degree)
u = TrialFunction(V)
v = TestFunction(V)
body_force = Constant(1.0)
y1 = sy.Symbol('y1')
i = Expression(' (u(x[0]) - u(y1)) / abs (x[0] - y1) ', degree = 2)
a = v*Expression('(sy.integrate(i,(y1,x[0] - delta, x[0] + delta))/delta**2)', degree = 2)
L = body_force*v*dx
u = Function(V)
bcs = [DirichletBC(V, Constant(0.0), boundary_1), DirichletBC(V, Constant(0.0), boundary_1)]
solve(a == L, u, bcs)

The error message I get is -

The version I m using is dolfin 2019.2.0 (developed version) in Spyder3 notebook in a Linux Subsystem on Windows
PS : My apologies for posting the error as an image, but for some reason Spyder won’t allow me to copy and paste the error here or anywhere else. (I had to write the code manually)

Any lead and help is in formulation of the weak form is highly appreciated. Thanks in advance!

This is the variational form I’m trying to code in FEniCS

I am not sure FEniCS is the best tool to handle such integral-type kernel.

1 Like

Thank for replying bleyerj. I see. Could you provide a few lines of code on how to write that weak form in FEniCS so that I could give it a shot. I’m not sure on how to code it.

See perhaps here. The principle is similar. These types of formulations are an absolute pain because the discretisation is dense.

Thanks a lot Nate for replying! I have a few questions for you (some of them may be quite naive) -

  1. In the example which you have cited, the expression for the integral - type kernel is already known, whereas in my case, it is a function of u which we have to find out, so how do we proceed there?
  2. I’m unable to write the bilinear form i.e. the LHS of the variational form and get the stiffness matrix. If you could help me to code it, that would solve my issue completely.
  3. This variational form is a 1D. Would the complexity increase if we were to go to 2D and what are the alternatives for FEniCS that could be used to solve these?