[petsc-users] petsc4py, plotting DA and writing to file
Lisandro Dalcin
dalcinl at gmail.com
Mon Sep 27 11:27:06 CDT 2010
On 27 September 2010 13:12, Amal Alghamdi <amal.ghamdi at kaust.edu.sa> wrote:
> Dear All,
> I'm using the DA structure in petsc4py. I'd like to know please what is the
> right way to:
> plot the DA vector (the global vector).
> write the global vector to a file.
> Is that each process writes or draws its own part? or I should communicate
> all the data to one process? or none of these?!!
> Thank you very much
> Amal
Use a PETSc.Viewer().createBinary() to save the global vector. Each
process will save its own part.
In order to plot it, I think you should use numpy.fromfile() to load
the data, and then plot the array.
Other way would be to use a PETSc.Scatter.toZero() to get the data at
process 0, and then plot it
scatter, seqvec = PETSc.Scatter.toZero(globalvec)
im = PETSc.InsertMode.INSERT_VALUES
sm = PETSc.ScatterMode.FORWARD
scatter.scatter(globalvec, seqvec, im, sm)
if globalvec.comm.rank == 0:
plot(seqvec.array)
--
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169
More information about the petsc-users
mailing list