Find error H10. Pls help me find H10 in that problem


from dolfin import *
import time

L = 4.
H = 1.
Nx = 200
Ny = 50
mesh = RectangleMesh(Point(0., 0.), Point(L, H), Nx, Ny, "crossed")
start = time.time()
def eps(v):
    return sym(grad(v))



E = Constant(1000)
nu = Constant(0.3)
model = "plane_stress"

mu = E/2/(1+nu)
lmbda = E*nu/(1+nu)/(1-2*nu)
if model == "plane_stress":
    lmbda = 2*mu*lmbda/(lmbda+2*mu)

def sigma(v):
    return lmbda*tr(eps(v))*Identity(2) + 2.0*mu*eps(v)


rho_g = 5
f = Constant((0, -rho_g))

V = VectorFunctionSpace(mesh, 'Lagrange', degree=2)
du = TrialFunction(V)
u_ = TestFunction(V)
a = inner(sigma(du), eps(u_))*dx
l = inner(f, u_)*dx



def left(x, on_boundary):
    return near(x[0], 0.)

bc = DirichletBC(V, Constant((0.,0.)), left)

u = Function(V, name="Displacement")
solve(a == l, u, bc)

plot(1e3*u, mode="displacement")


error_L2 = errornorm(Constant((0.,0.)), u, 'L2')
print('error_H10  =',errornorm(V,u, norm_type = "H10"))
print('error_L2  =', error_L2)
print('error_H10  =', uH1_error)
print("Maximal deflection:", -u(L,H/2.)[1])
print("Beam theory deflection:", float(3*rho_g*L**4/2/E/H**3))
print("Running time = %.3f" % float(time.time()-start))


Vsig = TensorFunctionSpace(mesh, "DG", degree=0)
sig = Function(Vsig, name="Stress")
sig.assign(project(sigma(u), Vsig))
print("Stress at (0,H):", sig(0, H))


that is my error :
If not u.ufl_shape ==uh.ufl_shape:
AttributeError: ‘FunctionSpace’ object has no attribute ‘ufl_shape’

Please follow the guidelines in: Read before posting: How do I get my question answered?
and make sure any code posted is properly formatted and encapsulated by 3x`.

1 Like

Sorry sir,
That is my first post and i fixed it

1 Like

The first argument of errornorm I believe should be an analytical Expression and not a FunctionSpace.

1 Like