This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

in 'assemble': integrating over one dimension in a two-dimensional problem with varying limits

0 votes

I have a very long problem in which there is a nonlinear part in the form of an integral of itself (implicit) where the limits from 0 to one of the spatial variables only over one dimension.

I've tried to write a test code in which I am solving something similar and it doesn't seem to be working.

I am trying to solve for u, where u=u(x,z), and
partial_du/partial_dx = exp(- int_0^x {c*z} dx),
with u(x=0,z) = 0 for all z, where c is a constant.

Then the exact solution is known as u(x,z) = 1/(cx) - 1/cx * exp(-cxz).

I am getting the error: "All terms in form must have same rank", in the assemble part in the minimal working code below. Here, f2 is my integral int_0^x {c*z} dx

I've tried a few things like assembling the integral for a intervalmesh and using dx, which does not work. I have also tried the whole thing without z in the integrand, which works, but only with intervalmesh and dx.

from dolfin import *

mesh = RectangleMesh(0,0,10,10,20,20)

c=Constant(5.0)

class f2(Expression):
    def eval(self,values,x):
        if x[0] == 0:
            values[0] = 0.0
        else:
            values[0] = assemble(c*x[1]*dx(0), mesh=RectangleMesh(0,0,x[0],10,20,20) )

F2 = f2()

def boundary(x,on_boundary):
    return on_boundary and abs(x[0] - 0) < 1E-14

V = FunctionSpace(mesh,'Lagrange' ,1)
u2 = TrialFunction(V)
w = TestFunction(V)

bc = DirichletBC(V, Constant(0.0), boundary)

a2 = Dx(u2,0)*w*dx 
L = exp(-F2)*w*dx

u2 = Function(V)
solve(a2==L,u2,bc)
plot(u2, interactive=True)
asked Dec 7, 2015 by jel2278 FEniCS Novice (220 points)
...