Hi All,
i'm new in using Dolfin and I'm trying to run codes in parallel with MPI.
The code is the following:
from dolfin import *
#Parameters
parameters["mesh_partitioner"] = "SCOTCH" #"ParMETIS"
parameters["linear_algebra_backend"] = "PETSc"
# Load mesh and subdomains
mesh = Mesh("prague30.xml")
sub_domains = MeshFunction("size_t", mesh, "subdomains_praga30.xml")
# Define function spaces
V = VectorFunctionSpace(mesh, "CG", 2)
Q = FunctionSpace(mesh, "CG", 1)
W = V * Q
# No-slip boundary condition for velocity
noslip = Constant((0, 0, 0))
bc0 = DirichletBC(W.sub(0), noslip, sub_domains, 0)
# Inflow boundary condition for pressure
inflow = Expression("9.81*100*x[2]")
bc1 = DirichletBC(W.sub(1), inflow, sub_domains, 1)
# Boundary condition for pressure at outflow
outflow = Expression(("9.81*100*x[2]"))
bc2 = DirichletBC(W.sub(1), outflow, sub_domains, 2)
# Boundary condition for pressure at freesurface
zero = Constant(0)
bc3 = DirichletBC(W.sub(1), zero, sub_domains, 3)
# Collect boundary conditions
bcs = [bc0, bc1, bc2, bc3]
# Define variational problem
(u, p) = TrialFunctions(W)
(v, q) = TestFunctions(W)
f = Constant((0, 0, -9.81))
a = (inner(grad(u), grad(v)) - div(v)*p + q*div(u))*dx
L = inner(f, v)*dx
# Compute solution
w = Function(W)
(A, b) = assemble_system(a, L, bcs)
ww = w.vector()
solve(A, ww, b, "gmres", "ilu")
# Split the mixed solution using deepcopy
# (needed for further computation on coefficient vector)
(u, p) = w.split(True)
print "Norm of velocity coefficient vector: %.15g" % u.vector().norm("l2")
print "Norm of pressure coefficient vector: %.15g" % p.vector().norm("l2")
# Split the mixed solution using a shallow copy
(u, p) = w.split()
# Save solution in VTK format
ufile_pvd = File("velocity.pvd")
ufile_pvd << u
pfile_pvd = File("pressure.pvd")
pfile_pvd << p
# Plot solution
plot(u)
plot(p)
interactive()
The code works properly in serial, but when I ran it with MPI I met the following error:
*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function 'KSPSolve'.
*** Reason: PETSc error code is: 56.
*** Where: This error was encountered inside /build/buildd/dolfin-1.3.0+dfsg/dolfin/la/PETScKrylovSolver.cpp.
*** Process: 1
*** DOLFIN version: 1.3.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------
I use Ubuntu release 13.04.
How can I fix this?
Thank you very much
Lisa