> On Jun 27, 2015, at 1:25 PM, Gianluca Meneghello <[email protected]> wrote: > > Dear Matthew, Berry and Dave, > > Thanks for your reply. I will do as you suggest: only two more questions: > > - is the beginning of formFunction the right place to set up the coordinates? > As far as I understand I do not have access to the refined DM before running > the code with -snes_grid_sequence. > > - if so, what should I check in order to avoid to recompute the coordinates > at each formFunction call? e.g., what does DMGetCoordinates return NULL as > the coordinate vector (or something else) if called when the coordinates have > not yet been set up?
Yes it returns NULL so you can use that as your check. > > Thanks again > > Gianluca > > > > On Fri, Jun 26, 2015 at 11:28 AM, Dave May <[email protected]> wrote: > Also note that if you go and modify the global coordinate vector after > calling DMDASetUniformCoordinates, you will need to explicitly call the > vecscatter yourself to update the local coordinates. > > > > On Friday, 26 June 2015, Barry Smith <[email protected]> wrote: > > > On Jun 26, 2015, at 12:27 PM, Gianluca Meneghello <[email protected]> > > wrote: > > > > Dear all, > > > > I would like to solve a PDE discretized on a nonuniform --- but rectangular > > --- grid and I wanted to use the DM coordinates vector to compute the > > metric terms by finite difference. The only alternative I see is to > > recompute the coordinates (and then the metric terms) at every function and > > jacobian evaluation call. > > > > My question is what is the best (or even correct) way to provide the > > coordinates to the newly created da objects. Is there anything like a > > DMDASetNonUniformCoordinates to which to pass a function computing the > > coordinates? As far as I can tell the fine grid coordinates are currently > > linearly interpolated from the coarse grid ones. > > Call DMDASetUniformCoordinates() on each level then call > DMGetCoordinates() and put the coordinate values you want in. You can call > DMGetCoordinateDM(dm, &dmcoor) to get the DM that goes with the coordinate > vector and use DMDAVecGetArray(dmcoor,coor,&array) to give easy access to the > entries. > > > > > Please also let me thank you for your great work: it has been and it > > currently is of enormous help. > > > > Best > > > > Gianluca > >
