Post processing scalar solution components as vector

In solving for magnetic potential for a cylinder, we need to solve a Poisson Equation for each component.Suppose the results are Ax, Ay and Az.How can we combine them as a vector.I have used

# Plotting
Vp = VectorFunctionSpace(mesh_tot,'P',1)
A_tot = project(as_vector(Ax,Ay,Az),Vp)
vtkfile = File('Vectorpotential.pvd')
vtkfile << A_tot

But this gives the following error:

Expecting a single Index object.
Traceback (most recent call last):
File “/home/fenics/shared/Cylinder/cylinder_dokken.py”, line 80, in
A_tot = project(as_vector((Ax,Ay,Az),Vp))
File “/usr/local/lib/python3.6/dist-packages/ufl/tensors.py”, line 318, in as_vector
error(“Expecting a single Index object.”)
File “/usr/local/lib/python3.6/dist-packages/ufl/log.py”, line 172, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Expecting a single Index object

Can someone point me towards a better way of doing it?

You are not using as vector correctly, it should be

as_vector((Ax,Ay,Az))

I corrected that.

# Plotting
Vp = VectorFunctionSpace(mesh_tot,'P',1)
A_tot = Function(Vp)
A_tot = project(as_vector(Ax,Ay,Az),Vp)
vtkfile = File('Vectorpotential.pvd')
vtkfile << A_tot

This gives the following error :

Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.

UMFPACK V5.7.1 (Oct 10, 2014): ERROR: out of memory

Traceback (most recent call last):
File “/home/fenics/shared/Cylinder/cylinder_dokken.py”, line 81, in
A_tot = project(as_vector((Ax,Ay,Az)),Vp)
File “/usr/local/lib/python3.6/dist-packages/dolfin/fem/projection.py”, line 138, in project
cpp.la.solve(A, function.vector(), b, solver_type, preconditioner_type)
RuntimeError:

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at


*** fenics-support@googlegroups.com


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function ‘KSPSolve’.
*** Reason: PETSc error code is: 76 (Error in external library).
*** Where: This error was encountered inside /tmp/dolfin/dolfin/la/PETScKrylovSolver.cpp.
*** Process: 0


*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------

The error message is quite clear, you do not have enough memory to do this projection. Consider setting sover_type in projection, see Out of memory error - #4 by dokken