[petsc-users] DM_BOUNDARY_GHOSTED

Barry Smith bsmith at petsc.dev
Thu Jul 9 11:19:50 CDT 2020


  David,

    I don't think you can do it directly, you need to know how to adjust the matrix entry and make the entry. The reason is that when you put a value in the ghost location nothing knows that you have done this and thus nothing has the information to help with the Jacobian. 

   Here is how you can do it with a contrived example


   Ghost location        First location           second location

         NULL                       x_0                           x_1

          .2*x_0                     x_0                           x_1

                                     f(ghost,x_0)                f(x_0,x_1)

        Now the derivative of f() with respect to x_0 is partial f/partial ghost * partial ghost /partial x_0   + partial f /partial x_0

partial f/partial ghost * .2  + partial f /partial x_0


   Barry


> On Jul 9, 2020, at 10:53 AM, David Scott <d.scott at epcc.ed.ac.uk> wrote:
> 
> Hello Matt,
> 
> I am sorry that I have not replied before now.
> 
> I think that the reason you did not understand the question was that the question was silly but I'll try to explain my thought process anyway.
> 
> If you have a periodic boundary condition then when you construct a matrix to be used by a KSP it can address the ghost points corresponding to the periodic boundaries. So, I wondered if when you have ghosted boundary conditions you could refer to those ghosted points too when constructing the matrix. This led on to the question of how those values would be obtained when the linear solver came to be executed.
> 
> At this point I expect you are asking why on earth I would want to do that and I do not have an adequate response.
> 
> I am sorry I wasted your time and thanks for your help,
> 
> David
> 
> On 18/02/2020 20:23, Matthew Knepley wrote:
>> On Tue, Feb 18, 2020 at 10:23 AM SCOTT David <d.scott at epcc.ed.ac.uk <mailto:d.scott at epcc.ed.ac.uk>> wrote:
>> Hello Matt,
>> 
>> Thanks for the quick response.
>> 
>> Sorry to be dense but I want the ghost(ed) values to be used by KSPSolve where the KSP has an associated DM. I can, of course create a local vector using DMGetLocalVector and then populate the ghosted locations but I do not know how to get the KSPSolve to use these values in the way that automatically generated periodic, ghost values would be.
>> 
>> Let me try and understand. We normally distinguish between global vectors and local vectors. Global vectors, used in the solver, describe the entire space. Local vectors, used in assembly, describe overlapping patches of the space. The ghost values would only be used in assembly, not in the solver, since they help make the correct value, but have no equation associated with themselves. Am I misunderstanding something?
>> 
>>   Thanks,
>> 
>>     Matt
>>  
>> Thanks,
>> 
>> David
>> 
>> On 18/02/2020 12:42, Matthew Knepley wrote:
>>> On Tue, Feb 18, 2020 at 6:03 AM David Scott <d.scott at epcc.ed.ac.uk <mailto:d.scott at epcc.ed.ac.uk>> wrote:
>>> Hello,
>>> 
>>> I wish to solve a channel flow problem with different boundary
>>> conditions. In the streamwise direction I may have periodic or
>>> inlet/outlet BCs. I would like to make my code for the two cases as
>>> similar as possible. If I use DM_BOUNDARY_PERIODIC then when performing
>>> a linear solve the ghost values will be set automatically. For the
>>> inlet/outlet case can I use DM_BOUNDARY_GHOSTED instead and somehow
>>> arrange for values that I specify to be placed in the ghost locations?
>>> 
>>> Yes, that is the intent.
>>> 
>>>   Thanks,
>>> 
>>>      Matt
>>>  
>>> Thanks,
>>> 
>>> David
>>> 
>>> The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
>>> 
>>> 
>>> -- 
>>> 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/>
>> 
>> 
>> 
>> -- 
>> 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/>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200709/9ed3ab4d/attachment-0001.html>


More information about the petsc-users mailing list