In a time-dependent mixed function space problem, I wanna to compare the calculated solution with analytical solution, but haven't got the right way.
I know for a one unknown problem, we use a script like this one:
u_exact = interpolate(g, V)
maxdiff = numpy.abs(u_exact.vector().array() - u.vector().array()).max()
print 'Max error, t=%.2f: %-10.3f' % (t, maxdiff)
What if it becomes a mixed function space? How to compare each of them? How to interpolate the analytical solution?
In my problem, the mixed function space is:
Q = FunctionSpace(mesh, "CG", 2)
S = FunctionSpace(mesh, "CG", 1)
W = Q*S
and the function w is split into two parts as
w = Function(W)
(p,s) = split(w) # current solution
and the while loop for time stepping is like:
while t <= T:
print t
solve(F == 0, w, bc)
w0.vector()[:] = w.vector()
t += float(dt)