I think what happens on the 1st version is that the input list has len(3), and since the DMDA only has 1 dimension petsc4py throws the first ValueError.
As far as I can tell, the code is expecting a list of lists: ie for each dimension it gets ranges[i] (where i is the index for the dimension) and casts it into an array. So I tried the 2nd version, which fails regardless of whether I use lists or tuples, and I don't understand why. -Chris On Thu, Apr 7, 2016 at 9:00 PM, Matthew Knepley <[email protected]> wrote: > On Thu, Apr 7, 2016 at 1:52 PM, Chris Eldred <[email protected]> wrote: >> >> Hey All, >> >> (I sent this to petsc-users a few days ago and didn't get any replies, >> figured I would try here as well...) >> >> Does anyone know the correct syntax for setting ownership ranges for >> DMDAs in petsc4py? For example, if I have a 1D DMDA with 20 vertices >> and 3 processes, and I want to distribute the vertices as [8,8,4], >> should the correct create call be: >> >> da = >> PETSc.DMDA().create(dim=1,dof=1,sizes=[20,],proc_sizes=[3,],boundary_type=[PETSc.DM.BoundaryType.PERIODIC,], >> stencil_type= PETSc.DMDA.StencilType.BOX, >> stencil_width=1,ownership_ranges=[8,8,4]) >> >> or >> >> da = >> PETSc.DMDA().create(dim=1,dof=1,sizes=[20,],proc_sizes=[3,],boundary_type=[PETSc.DM.BoundaryType.PERIODIC,], >> stencil_type= PETSc.DMDA.StencilType.BOX, >> stencil_width=1,ownership_ranges=[[8,8,4],]) >> >> For me, the 1st version fails with >> ValueError: number of dimensions 1 and number ownership ranges 3 >> (which I expected) >> but the 2nd version also fails with >> TypeError: Expected tuple, got list >> >> I have tried using tuples instead of lists and nothing changes. >> Creating without the ownership_ranges argument works fine as well. Is >> there something else I am missing? > > > Here is the code: > > > https://bitbucket.org/petsc/petsc4py/src/b234a50085607b793fce93d5dc46307c0d9b57c4/src/PETSc/petscdmda.pxi?at=master&fileviewer=file-view-default#petscdmda.pxi-150 > > I do not understand why the 1st version fails. > > Matt > >> >> Thanks in advance for any assistance! >> >> Regards, >> -Chris >> >> >> -- >> Chris Eldred >> Postdoctoral Fellow, LAGA, University of Paris 13 >> PhD, Atmospheric Science, Colorado State University, 2015 >> DOE Computational Science Graduate Fellow (Alumni) >> B.S. Applied Computational Physics, Carnegie Mellon University, 2009 >> [email protected] > > > > > -- > What most experimenters take for granted before they begin their experiments > is infinitely more interesting than any results to which their experiments > lead. > -- Norbert Wiener -- Chris Eldred Postdoctoral Fellow, LAGA, University of Paris 13 PhD, Atmospheric Science, Colorado State University, 2015 DOE Computational Science Graduate Fellow (Alumni) B.S. Applied Computational Physics, Carnegie Mellon University, 2009 [email protected]
