When I am trying to calculate the difference between two types of error, I’m not receiving numerical results (I’m looking for a number, and getting back math). I’m pretty new to FEniCS, so I don’t know how to get around this.
What I’m looking to obtain are the following:
Where Omega is a unit square.
Here’s my MWE:
def aform(u, v):
return inner(grad(u), grad(v))
def Lform(f, v):
return f*v
f = Expression("32.*x[0]*(1. - x[0])+32.*x[1]*(1. - x[1])", domain=mesh, degree=5)
ue = Expression("16.*x[0]*(1. - x[0])*x[1]*(1. - x[1])", domain=mesh, degree=5)
Qp = FunctionSpace(mesh,'CG',1);
bcp = DirichletBC(Qp, zero, AllBoundary)
u = TrialFunction(Qp);
v = TestFunction(Qp);
ap = aform(u, v)*dx
Lp = Lform(f, v)*dx
U = Function(Qp)
solve(ap == Lp, U, bcp)
Qd = FunctionSpace(mesh, 'CG', 2);
psi = Constant(1.0)
bcd = DirichletBC(Qd, zero, AllBoundary)
w = TestFunction(Qd);
phi = TrialFunction(Qd);
ad = aform(w, phi)*dx
Ld = Lform(psi, w)*dx
phi = Function(Qd)
solve(ad == Ld, phi, bcd)
e1 = ((U - ue)*psi)*dx
e2 = (inner(grad(U), grad(phi)) - f*phi)*dx
print("e1 is: ", e1)
print("e2 is: ", e2)
My output, however, is:
e1 is: { f_599 * (f_583 + -1 * f_579) } * dx(<Mesh #574>[everywhere], {})
e2 is: { -1 * f_578 * f_601 + ((grad(f_583)) : (grad(f_601))) } * dx(<Mesh #574>[everywhere], {})
I’d appreciate any help you can offer.