On 27 September 2010 13:33, Barry Smith <bsmith at mcs.anl.gov> wrote: > > ?Lisandro > > ? ?In C he could do VecView(vec,PETSC_VIEWER_DRAW_WORLD); can he not do the > equivalent in Python? > What syntax would he use?
viewer = PETSc.Viewer.DRAW(globalvec.comm) globalvec.view(viewer) # or viewer(globalvec) > > Perhaps the 2d bratu python example could demonstrate this since it is simple > and there is no monkeying with copying to one process etc. > Well, that example does not even use a DA, the plot is going to be a bit ugly. > ? Barry > > On Sep 27, 2010, at 11:27 AM, Lisandro Dalcin wrote: > >> 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 > > -- 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