I do not know if the scaling of the BC equations could affect the norms of 
the nonlinear residual in your situation. I suggest you look at which 
coefficients of the residual are blowing up in the first step to see if you can 
understand why they get increased.

  Barry


> On Nov 17, 2021, at 12:15 PM, Francesc Levrero-Florencio 
> <f.levrero-floren...@onscale.com> wrote:
> 
> Hi Barry,
> 
> I believe that what you are referring to is what Jed is referring to in this 
> thread, am I right?
> https://scicomp.stackexchange.com/questions/3298/appropriate-space-for-weak-solutions-to-an-elliptical-pde-with-mixed-inhomogeneo/3300#3300
>  
> <https://scicomp.stackexchange.com/questions/3298/appropriate-space-for-weak-solutions-to-an-elliptical-pde-with-mixed-inhomogeneo/3300#3300>
> 
> We do set the rows/cols of the Jacobian to zero except the diagonal component 
> which is set to one, as you mention. I understand that in the case of only 
> homogeneous Dirichlet BCs it is generally a good idea to scale that diagonal 
> component so that the condition number of the Jacobian improves. I assume 
> that what Jed mentions is the inhomogeneous Dirichlet BC version of this 
> scaling, which also acts on the corresponding indices of the residual, not 
> just the Jacobian. My question is the following, since the case we are 
> encountering problems with is a system with only homogeneous Dirichlet BCs, 
> how does it apply? Also, would this scaling affect the convergence of the 
> NEWTONLS with "bt" line-search? Without any scaling we can solve this example 
> with "basic" (with a very reasonable convergence rate), but not with "bt" 
> line-search.
> 
> Regards,
> Francesc.
> 
> On Tue, Nov 16, 2021 at 6:55 PM Barry Smith <bsm...@petsc.dev 
> <mailto:bsm...@petsc.dev>> wrote:
> 
>    By "scaling" I mean you may need to rescale the residual terms from the 
> Dirichlet boundary conditions to be the same  order  (in terms of the 
> characteristic size  of the elements) as they are for the other residuals.
> 
>   It seems in your formulation the Jacobian entries of the residual for 
> Dirichlet boundary conditions are 1 on the diagonal while the Jacobian 
> entries of the residual for the PDE entries will have a scaling related to 
> the finite element method you are using, for example in 3d with an operator 
> grad dot grad the Jacobian entry will be order dx = (dx)^3 * (1/dx)^2. Thus 
> you should scale the Dirichlet boundary condition residuals by dx to get the 
> same scaling.
> 
>   Barry
> 
> 
>> On Nov 16, 2021, at 1:37 PM, Francesc Levrero-Florencio 
>> <f.levrero-floren...@onscale.com <mailto:f.levrero-floren...@onscale.com>> 
>> wrote:
>> 
>> Hi Barry,
>> 
>> Thanks for the quick reply. I am not sure what you meant by "scaling". In 
>> our code, every time our residual is called we do the following in this 
>> order:
>> - Apply updated Dirichlet BCs in order to assemble the internal forces, and 
>> add them to the residual.
>> - Assemble the external forces, and subtract them from the residual.
>> - Update the residual to take into account Dirichet BCs, so we set the 
>> corresponding indices of the residual to - (dirichlet_bc_value - 
>> solution_value), the latter obtained directly from the solution vector of 
>> PETSc. However, note that in this case all Dirichlet BCs are homogeneous, so 
>> this value would be just "solution_value", or 0 throughout the simulation. 
>> This ensures that the solution vector coming from PETSc has the Dirichlet 
>> BCs applied.
>> 
>> This is basically what we do in the residual. If I am not mistaken, the 
>> lambda scaling factor from the line-search would scale the factor 
>> "jacobian^{-1} * residual", so it would scale equally both internal and 
>> external forces.
>> 
>> Regards,
>> Francesc.
>> 
>> On Tue, Nov 16, 2021 at 5:38 PM Barry Smith <bsm...@petsc.dev 
>> <mailto:bsm...@petsc.dev>> wrote:
>> 
>>   Perhaps this behavior is the result of a "scaling" issue in how various 
>> terms affect the residual? In particular perhaps the terms for enforcing 
>> boundary conditions are scaled differently than terms for the PDE 
>> enforcement?
>> 
>> 
>> 
>> > On Nov 16, 2021, at 11:19 AM, Francesc Levrero-Florencio 
>> > <f.levrero-floren...@onscale.com <mailto:f.levrero-floren...@onscale.com>> 
>> > wrote:
>> > 
>> > Dear PETSc team and users,
>> > 
>> > We are running a simple cantilever beam bending, where the profile of the 
>> > beam is I-shaped, where we apply a bending force on one end and fully 
>> > constrained displacements on the other end. The formulation is a large 
>> > strain formulation in Total Lagrangian form, where the material of the 
>> > beam is a Saint Venant-Kirchhoff hyperelastic material that uses the same 
>> > constants as steel (200E9 GPa Young’s modulus and 0.3 Poisson’s ratio).
>> > 
>> > The simulation finishes in the requested number of time steps by using the 
>> > “basic” type of line-search in the SNES (i.e. traditional Newton method 
>> > without line-search) in a reasonable number of Newton iterations per time 
>> > step (3 or 4 iterations). However, when using the “bt” (or “l2”, and in 
>> > fact no type of line-search ends up yielding convergence) line-search 
>> > type, the convergence never happens within the SNES default maximum number 
>> > of iterations of 50.
>> > 
>> > During solving with traditional Newton, the general behaviour of each time 
>> > step is that the norm of the residual increases on the second call to the 
>> > residual function, but then hugely decreases in the following one or two, 
>> > up to the point where convergence is achieved. Using “bt” line-search, the 
>> > line-search discards the step at lambda=1 immediately because the norm of 
>> > the residual is higher than that produced in the first call to the 
>> > residual function, cutting down the value of lambda to a value 
>> > significantly lower than 1. The simulation then progresses in following 
>> > Newton iterations in a similar fashion, the line-search step at lambda=1 
>> > is always discarded, and then smaller steps are taken but convergence 
>> > never occurs, for even the first time step.
>> > 
>> > Here are a few values of the relevant norms (using traditional Newton) in 
>> > the first time step:
>> > 
>> > BASIC NEWTON LS
>> > Norm of the internal forces is 0
>> > Norm of the external forces is 1374.49
>> > Norm of the residual is 1374.49
>> > Norm of the solution with Dirichlet BCs is 0
>> > Number of SNES iteration is 0
>> > ---------------------------------------------------------------------
>> > Norm of the internal forces is 113498
>> > Norm of the external forces is 1374.49
>> > Norm of the residual is 105053
>> > Norm of the solution with Dirichlet BCs is 0.441466
>> > Number of SNES iteration is 0
>> > ---------------------------------------------------------------------
>> > Norm of the internal forces is 42953.5
>> > Norm of the external forces is 1374.49
>> > Norm of the residual is 11.3734
>> > Norm of the solution with Dirichlet BCs is 0.441438
>> > Number of SNES iteration is 1
>> > 
>> > Here are a few values of the relevant norms (using “bt” line-search) in 
>> > the first time step:
>> > 
>> > BT NEWTONLS
>> > Norm of the internal forces is 0
>> > Norm of the external forces is 1374.49
>> > Norm of the residual is 1374.49
>> > Norm of the solution with Dirichlet BCs is 0
>> > Number of SNES iteration is 0
>> > ---------------------------------------------------------------------
>> > Norm of the internal forces is 113498
>> > Norm of the external forces is 1374.49
>> > Norm of the residual is 105053
>> > Norm of the solution with Dirichlet BCs is 0.441466
>> > Number of SNES iteration is 0
>> > (I assume this is the first try at lambda=1)
>> > ---------------------------------------------------------------------
>> > Norm of the internal forces is 4422.12
>> > Norm of the external forces is 1374.49
>> > Norm of the residual is 1622.74
>> > Norm of the solution with Dirichlet BCs is 0.0441466
>> > Number of SNES iteration is 0
>> > Line search: gnorm after quadratic fit 1.622742343614e+03
>> > (I assume that in this line-search iteration 0.05 < lambda < 1, but the 
>> > corresponding residual is not smaller than the one in the first call, 1622 
>> > > 1374)
>> > ---------------------------------------------------------------------
>> > Norm of the internal forces is 2163.76
>> > Norm of the external forces is 1374.49
>> > Norm of the residual is 1331.88
>> > Norm of the solution with Dirichlet BCs is 0.0220733
>> > Number of SNES iteration is 0
>> > Line search: Cubically determined step, current gnorm 1.331884625811e+03 
>> > lambda=5.0000000000000003e-02
>> > (This is the accepted lambda for the current Newton iteration)
>> > ---------------------------------------------------------------------
>> > Norm of the internal forces is 104020
>> > Norm of the external forces is 1374.49
>> > Norm of the residual is 94739
>> > Norm of the solution with Dirichlet BCs is 0.441323
>> > Number of SNES iteration is 1
>> > 
>> > My question would be, any idea on how to deal with this situation? I would 
>> > imagine a “hack” would be to bypass the first residual norm, and have the 
>> > line-search use the following one as the “base norm” to check its 
>> > reduction in further iterations, but we are open to any ideas.
>> > 
>> > Thanks for your help in advance and please keep up the good work!
>> > 
>> > Regards,
>> > Francesc.
>> 
> 

Reply via email to