# ksp ex29.c B.C.s and Forcing terms.

Tahar Amari amari at cpht.polytechnique.fr
Sat Dec 12 14:20:19 CST 2009

```Thanks a lot.

Tahar
Le 12 déc. 09 à 20:57, Barry Smith a écrit :

>
> On Dec 12, 2009, at 12:31 PM, Tahar Amari wrote:
>
>> Hello,
>>
>> SOrry. I took this very interesting discussion a bit late, but one
>> of my major problem is to understand if all this is valid for node
>> centered
>> variables for u or cell centered.
>> Usually the best way of solving Neuwman BC for this equation is
>> having cell centered unknowns to have derivatives
>> given on the domain boundary.
>> This then have some impact on handling ghost values transfer
>> between subdomains with MPI.Is all this transparent for
>> us and PETSC handle it . I guess no, right ?
>
>  If you have only cell centered unknowns the ghost point updates are
> the same. See src/ksp/ksp/examples/tutorials/ex32.c  Having some
> Neuman and some Dirichlet boundary conditions is then trickery with
> cell centered.
>
>   If you have some cell-centered and some vertex centered unknowns
> (staggered grid), DA does not handle this well, you have to "cheat"
> to match up variables on the cells and vertices.
>
>
>   Barry
>
>>
>> Tahar
>>
>>
>> Le 12 déc. 09 à 02:28, Barry Smith a écrit :
>>
>>>
>>> On Dec 11, 2009, at 7:18 PM, Ryan Yan wrote:
>>>
>>>> Hi Matt,
>>>> Thank you very much for the reply.  Now, I got the Neumann part.
>>>> But I am still a bit confused about the Dirichlet part. Please
>>>> see the following quote.
>>>>
>>>> Yan
>>>>
>>>>
>>>> For the Dirichlet B.C.s, I did not understand the coefficients
>>>> given below. Isn't correct to set the v[0]=Hx*Hy here?
>>>> if (i==0 || j==0 || i==mx-1 || j==my-1) {
>>>> if (user->bcType == DIRICHLET) {
>>>> v[0] = 2.0*rho*(HxdHy + HydHx);
>>>> }
>>>> }
>>>>
>>>> This is the proper scaling.
>>>>
>>>> the Dirichlet B.C.s:
>>>> Which  scaling  do you think is proper, "v[0]=Hx*Hy" or
>>>> 2.0*rho*(HxdHy + HydHx)?
>>>> If it is 2.0*rho*(HxdHy + HydHx), can you say a little bit more
>>>> about why is this one? I only see a factor of Hx*Hy when we set
>>>> up the  RHS. Did I miss something?
>>>>
>>> Ryan,
>>>
>>>   You can scale the equations for Dirichlet boundary conditions
>>> anyway you want; you could multiply them by 1,000,000 if you want.
>>> The answer in exact precision with direct solvers will be the
>>> same. The reason we use the given scaling is to make the scaling
>>> work well with multigrid. If you use a different scaling the
>>> Dirichlet boundary conditions on the coarser grid matrices would
>>> have a different scaling then the interior equations and this
>>> would slow down MG's convergence rate. For toy problems people
>>> usually eliminate the Dirichlet boundary conditions, then there is
>>> no scaling issue for multigrid.
>>>
>>>
>>> Barry
>>>
>>>>
>>>> Matt
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> What most experimenters take for granted before they begin their
>>>> experiments is infinitely more interesting than any results to
>>>> -- Norbert Wiener
>>>>
>>
>> --------------------------------------------
>> T. Amari
>> Centre de Physique Theorique
>> Ecole Polytechnique
>> 91128 Palaiseau Cedex France
>> tel : 33 1 69 33 42 52
>> fax: 33 1 69 33 49 49
>> email: <mailto:amari at cpht.polytechnique.fr>
>> URL : http://www.cpht.polytechnique.fr/cpht/amari
>>
>>
>>
>>
>>

--------------------------------------------
T. Amari
Centre de Physique Theorique
Ecole Polytechnique
91128 Palaiseau Cedex France
tel : 33 1 69 33 42 52
fax: 33 1 69 33 49 49
email: <mailto:amari at cpht.polytechnique.fr>
URL : http://www.cpht.polytechnique.fr/cpht/amari

```