Thank you for your any help !!!
When I set u_D = Expression('pow(x[0], 0.2) * x[1]', degree=5), I got a result.
But when I set u_D = Expression('pow(x[0], -0.2) * x[1]', degree=5), the L2-error become NaN.
Why ??? Is that right using pow(x[0], -0.2) in an Expression() ???
Below is my code:
from fenics import *
# Create mesh and define function space
mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, 'P', 1)
# Define boundary condition
u_D = Expression('pow(x[0],-0.2) * x[1]', degree=5)
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, u_D, boundary)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0)
a = dot(grad(u), grad(v))*dx
L = f*v*dx
# Compute solution
u = Function(V)
solve(a == L, u, bc)
# Plot solution and mesh
plot(u)
# Compute error in L2 norm
error_L2 = errornorm(u_D, u, 'L2')
print('error_L2 =', error_L2)
interactive()