Dear all, I have a vector say sol which is a vector created from a dmda with dof = 3. Now I need to provide an interface to the part of my code which does not use petsc but needs access to the values of sol.
I was thinking of providing an interface such as: double solver::getSolutionAtPosition(int x, int y, int z, int field); which should return a value of the vector sol at the grid position (x,y,z) and dof = field. I know how to get the array and loop through all the values such as: DMDALocalInfo info; ierr = DMDAGetLocalInfo(da,&info);CHKERRQ(ierr); Field ***sol; ierr = DMDAVecGetArray(da,b,&rhs);CHKERRQ(ierr); for (PetscInt k = info.zs; k<info.zs+info.zm; ++k) { for (PetscInt j = info.ys; j < info.ys+info.ym; ++j) { for (PetscInt i = info.xs; i < info.xs+info.xm; ++i) { //access sol[k][j][i].vx or sol[k][j][i].vy or sol[k][j][i].vz depending on field } } } But if I have a particular (x,y,z) based on global co-ordinate system, how do I get the value for the given field ? Thanks, Bishesh