> On May 7, 2016, at 7:58 PM, Paul Stephen Urbanczyk <[email protected]> wrote:
> 
> Hi Barry and Jed,
> 
> Thank you for responding. I greatly appreciate it. I'm still wrapping my head 
> around the periodic BC case.
> 
> In the meantime, putting the periodic BC case aside, I'm wondering how best 
> to set ghost points outside the computational domain, generally (for example 
> if i need to set values for other types of BCs like 
> inflow/outflow/wall/sponge/etc)?
> 
> In my earlier experiments, scattering the global vector to local vectors, 
> setting the ghost point values using a local array reference to the local 
> vectors, and then scattering the local vectors back to the global vectors 
> didn't seem to work.


  Hmm, generally these ghost values are only put into the "local" 
representation, they are then used in computing the function evaluation but are 
not included in anyway in the global solution (global vector). So what one does 
is scatter the current solution to the local vectors, put whatever is needed in 
the ghost locations and then the function is evaluated putting the results in a 
global vector but using the local vector as the input function. The global 
vector does not have any concept of ghost values nor does it need it; only the 
local vectors sometimes need it. It is easier than you think. If you are still 
having trouble perhaps you could explain a particular type of boundary 
condition you want to do and why what you do fails.

  Barry

> 
> Any help is appreciated.
> 
> Thanks,
> 
> Paul
> ________________________________________
> From: Jed Brown <[email protected]>
> Sent: Friday, May 6, 2016 4:13:20 PM
> To: Barry Smith; Paul Stephen Urbanczyk
> Cc: [email protected]
> Subject: Re: [petsc-users] Structured Finite Difference Method With Periodic  
>   BC Help
> 
> Barry Smith <[email protected]> writes:
> 
>>> On May 6, 2016, at 5:09 PM, Paul Stephen Urbanczyk <[email protected]> 
>>> wrote:
>>> 
>>> However, this raises another question: shouldn't the coordinates behave 
>>> differently than other field variables? In other words, shouldn't the 
>>> periodic ghost points at the left end have coordinates (0-h) and (0-2h), 
>>> rather than (1-h) and (1-2h)? And, at the right side, shouldn't the 
>>> x-coordinates be 1 and 1+h?
>> 
>>   I don't know. But I believe they should not; periodic boundary
>>   conditions can be interpreted as having the domain [0,1) connected
>>   at the two ends so there would never be coordinates less than 0 or
>>   1 or larger. Another way, I think, of saying the same thing is that
>>   if you take a point x in domain and add some positive distance d
>>   then the coordinate of the result is give by fractionalpart(x + d)
>>   something similar can be done for subtracting some distance.
> 
> Additionally, making up coordinates for ghost points is not well-defined
> for non-uniform or distorted grids.
> 

Reply via email to