This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Using manufactured solutions to verify the accuracy of a mixed function space problem

+2 votes

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)
asked Aug 20, 2014 by Chao Zhang FEniCS User (1,180 points)
edited Aug 20, 2014 by Chao Zhang

2 Answers

+2 votes
 
Best answer

See here for an answer on how to interpolate in mixed function spaces.

For mixed FEM for Navier-Stokes equations I have an example in this preprint (Section 4).

Btw., I prefer python's scipy module to construct analytical solutions and corresponding source terms, while others stick to UFL, see this post.

answered Aug 20, 2014 by Jan FEniCS User (8,290 points)
selected Aug 21, 2014 by Chao Zhang
What could be wrong if a problem doesn't converge?

Thanks, Jan. It solves my problem.

+2 votes

You can use SymPy to construct a right-hand side matching any solution that you choose, and then use Dolfin's Expressions to translate the SymPy solution into something that you can use in Dolfin.

See Maelstrom's testing suite for an example.

answered Aug 20, 2014 by nschloe FEniCS User (7,120 points)
...