[petsc-users] [petsc4py] dm/examples/tutorials/ex2 in python

Francesco Caimmi francesco.caimmi at polimi.it
Wed Jun 3 09:37:04 CDT 2015


Thank you all for your suggestions! 

It looks like I will have to re-read the initial parts of the manual to better 
understand the assembly operations.

However I am still a bit puzzled by the fact that doing 

####
start, end = global_vec.getOwnershipRange()

with global_vec as v:
        for i in xrange(end-start):
            v[i] = 5.0*rank

viewer = PETSc.Viewer.DRAW(global_vec.comm)
global_vec.view(viewer)
####

or  doing 

####
start, end = global_vec.getOwnershipRange()

for i in xrange(start,end):
        global_vec[i] = 5.0*rank

viewer = PETSc.Viewer.DRAW(global_vec.comm)
global_vec.view(viewer)
####

actually I get the _same_ output, which, btw, is the intended output, as far as I 
can tell from the output of ex2.c (after compiling it). This is true regardless of the 
number of processors (up to three).
Based on what you said I expected the second piece of code to fail. Have I 
misunderstood something?


-- 
Francesco Caimmi
 
Laboratorio di Ingegneria dei Polimeri
http://www.chem.polimi.it/polyenglab/

Politecnico di Milano - Dipartimento di Chimica,
Materiali e Ingegneria Chimica “Giulio Natta”

P.zza Leonardo da Vinci, 32
I-20133 Milano
Tel. +39.02.2399.4711
Fax +39.02.7063.8173

francesco.caimmi at polimi.it
Skype: fmglcaimmi (please arrange meetings by e-mail)
GPG Public Key : http://goo.gl/64dDo
On Tuesday June 2 2015 at 18:49 Jed Brown wrote:

> Matthew Knepley <knepley at gmail.com> writes:
> >> for i in xrange(start,end):
> >>         global_vec[i] = 5.0*rank
> > 
> > No, you would need xrange(end-start):
> Specifically, Python made a decision about indexing semantics that,
> while not irrational, really sucks for distributed array computing.  I'm
> not aware of a clean way to give you nice syntax.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150603/e39cfa5a/attachment-0001.html>


More information about the petsc-users mailing list