Residual() function not defined error (Conda fenics version 2018.1.0)

Hi, I’m reading some other ppl’s code and there was a function residual(A, x, b) which computes the residual value. But I got the error of residual not defined. Is there any alternative for that?

Some update, I thought the residual function was depreciated, but seems like it is not as it still works in 2019 version. So it should be my conda installation problem or version problem?

The following code snippet works fine for me, using FEniCS 2019.1.0:

from dolfin import *

mesh = UnitIntervalMesh(1)
V = FunctionSpace(mesh,"CG",1)
A = assemble(TrialFunction(V)*TestFunction(V)*dx)
b = assemble(TestFunction(V)*dx)
x = Function(V).vector()

print(residual(A,x,b))
print(norm(A*x-b))

Hi, Kamensky,

Thanks for your reply. But the same script will output an error “residual not defined.”
I’m using the conda version of FEnics. Checked the version is 2018.1.0. But I think I’ve got the latest conda package.

Latest conda version should be 2019.1.0

Hi, Dokken,

I am not sure how can I get the latest version with conda. I just followed the installation guidance and installed with
conda install -c conda-forge fenics

but after installation, I get fenics-version 2018.1.0

I installed docker-version 2019.1.0. Problem resolved.