Manuel Valera <[email protected]> writes: > Ok, let me try to clarify a little bit, > > I have a u0 3d array with the mentioned indices (starting from -1), im > creating a dmda with the sizes in the constructor, no problem with that. > > Next, im trying to distribute this u0 array into global and local vectors, > apparently i can do that since no error comes out. > > Now, when i get the array back with VecGetArrayF90(), the indices start now > from 0, is that right? so the whole array have been shifted in its indices.
See FormFunction and FormFunctionLocal. https://www.mcs.anl.gov/petsc/petsc-dev/src/snes/examples/tutorials/ex5f90.F90.html Of course you can just define FormFunctionLocal to use an index range that is shifted from PetscScalar x(user%gxs:user%gxe,user%gys:user%gye) PetscScalar f(user%xs:user%xe,user%ys:user%ye) (this is just Fortran array passing; nothing to do with PETSc). > This changes things for me because my idea was to use the previous serial > code to operate on the arrays, but this is written with indices starting > from -1. There are dozens of arrays with the same structure, but they also > operate with other arrays with indices starting from 1, at the same time, > usually in triple nested loops which code the stencil used within them, to > update and correct the velocities after solving for pressure, per example. > > So it would be much easier to shift the indices of these arrays by one, > rather than changing all the code to match the new indices starting from > zero, Maybe, but note that you need to enforce boundary conditions and different processes will have a different range so preserving the index bounds might cause more confusion than it's worth.
signature.asc
Description: PGP signature
