Hi Matt, Thanks for your helps. I have another question, but I think I should ask the question in a new subject.
leejearl > > Hi, Matt > > > > > > Hi, all Petscer: > > > > I am very sorry for disturbing you for my questions. > > > > > > > > > I like your questions. > > > > > > > > > > I have a > > > > problems as follow. > > > > 1. A DMPlex object dm is created. > > > > 2. A global vector and a local vector are created using the > > > following > > > > routines DMCreateGlobalVector and DMCreateLocalVector. > > > > 3. I have initialed global Vector. Because the local vector > have > > > some > > > > overlap cells, I want to scatter the data from global to local. > > > > 4. If I don't use the routines > > > > DMGlobaltoLocalBegin/DMGlobaltoLocalEnd, how can I scatter it? > > > > > > > > > To understand the question better, why would you not use > > > DMGlobalToLocal()? > > I have create a PetscSection for the dm object. The section is used > to > > store the macroscopic variables $\rho$, u, v, $\rho$E. A pair of > > global and local vector are created using DMCreateGlobalVector and > > DMCreateLocalVector. > > > > I also needed a vector to store the derivatives of the macroscopic > > variables, but I have the difficulty to set two PetscSection to a > dm > > object. > > > You are right. You can't use 2 Sections for 1 DM. However, this one > is easy. > Use DMClone() to get another DM. They will share the expensive > topology > information, but the new one can have the different Section. Then all > the > GlobalToLocal will be created automatically. > > Thanks, > > Matt > > > > The first section has four variables on the cell point, and the > > variable number of second section is not the same as the first > > section. I have no > > idea about this problem, and I think that whether I can scatter it > by > > myself without using DMGlobalToLocal()? > > > > Can you point me out how can I creat two PetscSection whin a dmplex > > object, and how can I using DMGlobalToLocal() for the two pair of > > vectors whin a dmplex object? > > > > > > > I have > > > > scatter the vectors using VecScatterBegin and VecScatterEnd, > and > > > the IS > > > > is created using the localId and the glolbalId (Obtained by > > > > DMPlexGetCellNumbering). I got a wrong result. > > > > > > > > > > DMPlexGetCellNumbering() gives you are _arbitrary_ numbering of > the > > > cells, > > > not the > > > global numbering of unknowns. > > > > > > > > > > Can anyone give me some advices, and does it have some to do > with > > > the > > > > natural ids? > > > > > > > > > > 1) You can get the local ids from the local Section > (DMGetSection), > > > and the > > > global ids > > > from the global Section (DMGetGlobalSection). You loop over all > the > > > points > > > in the mesh > > > and get the offset/size pairs. However, this is error-prone > (since > > > you can > > > have constraints) > > > and probably unnecessary. > > > > > > 2) If you look at the code for DMGlobalToLocalBegin(): > > > > > > > > > > > https://bitbucket.org/petsc/petsc/src/650136806607101f8eb495880e9efa33f2f75729/src/dm/interface/dm.c#lines-2201 > > > > > > you see it just call PetscSFBcastBegin(), and there is a similar > > > BcastEnd() > > > in GlobalToLocalEnd(). Thus all > > > we are doing is using the SF directly. That is the same as using > a > > > Scatter. > > > > > > Thanks, > > > > > > Matt > > Thank you very much. I have do it yestoday following the code for > > DMGlobalToLocalBegin(). > > > > > > > Any helps are approciated. Thanks. > > > > > > > > leejearl > > > > > > > > > > > > > > -- > > > 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 > > > > > > https://www.cse.buffalo.edu/~knepley/ < > > > http://www.cse.buffalo.edu/~knepley/>; > > > > > > > > > > > > >