Hello everyone,
I am using the Fenics-Dolfin 2019.1.0 version and trying to implement the LUSolver for solving the parabolic PDE. Following in my code and the error.
from fenics import *
from matplotlib import pyplot as plt
from mshr import *
# parameters, function spaces, initial data
n_steps = 20
tau = 5e-4
t = 0.0
#mesh = RectangleMesh(Point(0,0),Point(1,1),128,128)
domain = Circle(Point(0, 0), 1)
mesh = generate_mesh(domain, 64)
U = FunctionSpace(mesh,'CG',1)
old_u = interpolate(Expression("2*(float)(rand())-1 + tanh(100*(x[0]-0.5))",degree=2),U)
u = Function(U)
v = TestFunction(U)
Res = (u-old_u)*v*dx + tau*inner(grad(u),grad(v))*dx
a = lhs(Res)
A = assemble(a)
solver = LUSolver(A)
solver.parameters['reuse_factorization'] = True
L = rhs(Res)
u.assign(old_u)
# main loop and plot solution each step
for i in range(1,n_steps+1):
plt.figure()
plot(old_u)
t = t + tau
b = assemble(L)
solver.solve(u.vector(),b)
print(et-st)
old_u.assign(u)
The error I receive:
Form has no parts with arity 2.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-21-b018cbdfd804> in <module>
21 a = lhs(Res)
22 A = assemble(a)
---> 23 solver = LUSolver(A)
24 solver.parameters['reuse_factorization'] = True
25 L = rhs(Res)
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. dolfin.cpp.la.LUSolver()
2. dolfin.cpp.la.LUSolver(arg0: str)
3. dolfin.cpp.la.LUSolver(A: dolfin.cpp.la.GenericLinearOperator, method: str = 'default')
4. dolfin.cpp.la.LUSolver(comm: MPICommWrapper, A: dolfin.cpp.la.GenericLinearOperator, method: str = 'default')
Invoked with: 0.0
However, when I run the code on for advection-diffusion on the Fenics Bitbucket repsoitory(link to the respository) it runs without any error (contains a similar syntax for invoking the LUSolver).
I am very new to Fenics and I could be completely missing out on something, so any help would be greatly appreciated.