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

parallel block in a serial code ?

+1 vote

In my serial script there is a part that solves a big linear system. I would like to use Fenics to solve my linear system in parallel, but keep the rest serial.
For now, I have been able to use the Fenics library to solve my linear system, and I do not know how to make only the solve block run in parallel.

here is my code:

from petsc4py import PETSc
from dolfin import *
def solve_parallel(scipyMat, numpRHS, nx,ny):

    petscMat = PETScMatrix(PETSc.Mat().createAIJ(size=scipyMat.shape,csr=scipyMat.indptr,scipyMat.indices,scipyMat.data)))
    x = PETScVector()
    b = PETScVector(PETSc.Vec().createWithArray(numpRHS))

    solver = LUSolver(petscMat, "mumps")
    solver.solve(petscMat,x,b)

    return x.array()

How can I switch to parallel in the 'solve_parallel()' function ?

asked Oct 4, 2016 by martinpauthenet FEniCS Novice (220 points)
retagged Oct 4, 2016 by martinpauthenet

1 Answer

+1 vote
 
Best answer

This will not work with FEniCS. You have to distribute your matrix and vector with mpi.

answered Oct 4, 2016 by chris_richardson FEniCS Expert (31,740 points)
selected Oct 22, 2016 by martinpauthenet

Thanks for the hint. I used mpi4py and petsc4py and it works !
Thanks again.

...