# [petsc-users] Dirichlet boundary condition for a nonlinear system

Sanjay Govindjee s_g at berkeley.edu
Tue Feb 18 23:26:14 CST 2014

```Yes that is exactly what we do.  In fact it is a bit better than your
typical continuation/homotopy methods
since the solutions along the way are physically meaningful and also
often of interest.

In our FEA+PETSc code we do this but we only call PETSc for the linear
solves.
We handle all the Newton stuff within our own code.  For us this was an
easier route
to a fully working non-linear FEA code since we started with a fully
working non-linear
serial FEA code.

-sg

On 2/18/14 8:38 PM, Barry Smith wrote:
>    So you could solve a sequence of problems where you move the boundary condition from being “easy” to the final value you want as a kind of continuation method?
>
>      Hmm, wonder how you would do that cleanly in PETSc.
>
>    Barry
>
> On Feb 18, 2014, at 10:31 PM, Sanjay Govindjee <s_g at berkeley.edu> wrote:
>
>> One alternate to this is that on the first step the initial value of X_B is not
>> taken as the know value but rather some prior known value.  Then for the first
>> iteration Y_B turns out to be the known increment; in subsequent iterations it
>> is take as 0.  This can sometimes be helpful with convergence in tough problems.
>>
>> -sg
>>
>>
>> On 2/18/14 5:56 PM, Barry Smith wrote:
>>> On Feb 18, 2014, at 5:39 PM, Fande Kong <fd.kong at siat.ac.cn> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I am just trying to solve a nonlinear system resulted from discretizating a hyperelasticity problem by finite element method. When I solve a linear PDE, I never put boundary solution either in a solution vector or a matrix, but instead, I put boundary condition to the right hand size (load).
>>>      You adjust the right hand side to have zero as the boundary conditions. This can be written as
>>>
>>>        (A_II   A_IB ) ( X_I )       (F_I)
>>>        (A_BI  A_BB)(X_B)   =   (F_B)
>>>
>>>      Which is equivalent to
>>>
>>>        (A_I  A_B) (X_I)         (F_I) - (A_B)*(X_B)
>>>                          (0)       =
>>>
>>>        A_I X_I  = F_I - A_B*X_B
>>>
>>>      In the nonlinear case you have
>>>
>>>        F_I(X_I,X_B)    = ( 0 )
>>>        F_B(X_I,X_B)      ( 0)
>>>
>>>       where you know X_B  with Jacobian
>>>
>>>         (J_II  J_IB)
>>>         (J_BI J_BB)
>>>          Newtons’ method on all variables gives
>>>
>>>        (X_I)^{n+1}     =  (X_I)^{n}     +  (Y_I)
>>>        (X_B)                  (X_B)              (Y_B)
>>>
>>>      where   JY = F which written out in terms of I and B is
>>>
>>>          (J_II  J_IB)   (Y_I)      =   F_I( X_I,X_B)
>>>         (J_BI J_BB)   (Y_B)         F_B(X_I,X_B)
>>>
>>>      Now since X_B is the solution on the boundary the updates on the boundary at zero so Y_B is zero so this system reduces to
>>>
>>>          J_II   Y_I     = F_I(X_I,X_B) so Newton reduces to just the interior with
>>>
>>>      (X_I)^{n+1}     =  (X_I)^{n}     +  J_II^{-1} F_I(X_I,X_B)
>>>
>>>      Another way to look at it is you are simply solving F_I(X_I,X_B) = 0 with given X_B so Newton’s method only uses the Jacobian of F_I with respect to X_I
>>>
>>>     Barry
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> How can I do a similar thing when solving a nonlinear system using a newton method?
>>>>
>>>> Thanks,
>>>>
>>>> Fande,

```