Re: [petsc-users] FW: 'Preconditioning' with lower-order method

2024-03-03 Thread Zou, Ling via petsc-users


From: Jed Brown 
Date: Sunday, March 3, 2024 at 9:24 PM
To: Zou, Ling , petsc-users@mcs.anl.gov 
Subject: Re: [petsc-users] FW: 'Preconditioning' with lower-order method
One option is to form the preconditioner using the FV1 method, which is sparser 
and satisfies h-ellipticity, while using FV2 for the residual and (optionally) 
for matrix-free operator application. FV1 is a highly diffusive method so in a 
sense,
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.

ZjQcmQRYFpfptBannerEnd

One option is to form the preconditioner using the FV1 method, which is sparser 
and satisfies h-ellipticity, while using FV2 for the residual and (optionally) 
for matrix-free operator application.



<<< In terms of code implementation, this seems a bit tricky to me. Looks to me 
that I have to know exactly who is calling the residual function, if its MF 
operation, using FV2, while if finite-differencing for Jacobian, using FV1. 
Currently, I don’t know how to do it.

Another thing I’d like to mention is that the linear solver has never really 
been an issue. While the non-linear solver for the FV2 scheme often ‘stagnant’ 
at the first a couple of non-linear iteration [see the other email reply to 
Barry]. Seems to me, the additional nonlinearity from the TVD limiter causing 
difficulty to PETSc to find the attraction zone.



FV1 is a highly diffusive method so in a sense, it's much less faithful to the 
physics and (say, in the case of fluids) similar to a much lower-Reynolds 
number (if you use a modified equation analysis to work out the effective 
Reynolds number in the presence of the numerical diffusion).



It's good to put some thought into your choice of limiter. Note that 
intersection of second order and TVD methods leads to mandatory nonsmoothness 
(discontinuous derivatives).



<<< Yeah… I am afraid that the TVD limiter is the issue, so that’s the reason 
I’d try to use FV1 to bring the solution (hopefully) closer to the real 
solution so the non-linear solver has an easy job to do.



"Zou, Ling via petsc-users"  writes:



> Original email may have been sent to the incorrect place.

> See below.

>

> -Ling

>

> From: Zou, Ling 

> Date: Sunday, March 3, 2024 at 10:34 AM

> To: petsc-users 

> Subject: 'Preconditioning' with lower-order method

> Hi all,

>

> I am solving a PDE system over a spatial domain. Numerical methods are:

>

>   *   Finite volume method (both 1st and 2nd order implemented)

>   *   BDF1 and BDF2 for time integration.

> What I have noticed is that 1st order FVM converges much faster than 2nd 
> order FVM, regardless the time integration scheme. Well, not surprising since 
> 2nd order FVM introduces additional non-linearity.

>

> I’m thinking about two possible ways to speed up 2nd order FVM, and would 
> like to get some thoughts or community knowledge before jumping into code 
> implementation.

>

> Say, let the 2nd order FVM residual function be F2(x) = 0; and the 1st order 
> FVM residual function be F1(x) = 0.

>

>   1.  Option – 1, multi-step for each time step

> Step 1: solving F1(x) = 0 to obtain a temporary solution x1

> Step 2: feed x1 as an initial guess to solve F2(x) = 0 to obtain the final 
> solution.

> [Not sure if gain any saving at all]

>

>

>   1.  Option -2, dynamically changing residual function F(x)

>

> In pseudo code, would be something like.

>

>

>

> snesFormFunction(SNES snes, Vec u, Vec f, void *)

>

> {

>

>   if (snes.nl_it_no < 4) // 4 being arbitrary here

>

> f = F1(u);

>

>   else

>

> f = F2(u);

>

> }

>

>

>

> I know this might be a bit crazy since it may crash after switching residual 
> function, still, any thoughts?

>

> Best,

>

> -Ling


Re: [petsc-users] FW: 'Preconditioning' with lower-order method

2024-03-03 Thread Jed Brown




 One option is to form the preconditioner using the FV1 method, which is sparser and satisfies h-ellipticity, while using FV2 for the residual and (optionally) for matrix-free operator application. FV1 is a highly diffusive method so in a sense,




ZjQcmQRYFpfptBannerStart




  

  
	This Message Is From an External Sender
  
  
This message came from outside your organization.
  



 
  


ZjQcmQRYFpfptBannerEnd




One option is to form the preconditioner using the FV1 method, which is sparser and satisfies h-ellipticity, while using FV2 for the residual and (optionally) for matrix-free operator application.

FV1 is a highly diffusive method so in a sense, it's much less faithful to the physics and (say, in the case of fluids) similar to a much lower-Reynolds number (if you use a modified equation analysis to work out the effective Reynolds number in the presence of the numerical diffusion).

It's good to put some thought into your choice of limiter. Note that intersection of second order and TVD methods leads to mandatory nonsmoothness (discontinuous derivatives). 

"Zou, Ling via petsc-users"  writes:

> Original email may have been sent to the incorrect place.
> See below.
>
> -Ling
>
> From: Zou, Ling 
> Date: Sunday, March 3, 2024 at 10:34 AM
> To: petsc-users 
> Subject: 'Preconditioning' with lower-order method
> Hi all,
>
> I am solving a PDE system over a spatial domain. Numerical methods are:
>
>   *   Finite volume method (both 1st and 2nd order implemented)
>   *   BDF1 and BDF2 for time integration.
> What I have noticed is that 1st order FVM converges much faster than 2nd order FVM, regardless the time integration scheme. Well, not surprising since 2nd order FVM introduces additional non-linearity.
>
> I’m thinking about two possible ways to speed up 2nd order FVM, and would like to get some thoughts or community knowledge before jumping into code implementation.
>
> Say, let the 2nd order FVM residual function be F2(x) = 0; and the 1st order FVM residual function be F1(x) = 0.
>
>   1.  Option – 1, multi-step for each time step
> Step 1: solving F1(x) = 0 to obtain a temporary solution x1
> Step 2: feed x1 as an initial guess to solve F2(x) = 0 to obtain the final solution.
> [Not sure if gain any saving at all]
>
>
>   1.  Option -2, dynamically changing residual function F(x)
>
> In pseudo code, would be something like.
>
>
>
> snesFormFunction(SNES snes, Vec u, Vec f, void *)
>
> {
>
>   if (snes.nl_it_no < 4) // 4 being arbitrary here
>
> f = F1(u);
>
>   else
>
> f = F2(u);
>
> }
>
>
>
> I know this might be a bit crazy since it may crash after switching residual function, still, any thoughts?
>
> Best,
>
> -Ling



Re: [petsc-users] FW: 'Preconditioning' with lower-order method

2024-03-03 Thread Zou, Ling via petsc-users
Thank you, Mark. This is encouraging!
I will give it a try and report back.

-Ling

From: Mark Adams 
Date: Sunday, March 3, 2024 at 11:10 AM
To: Zou, Ling 
Cc: petsc-users@mcs.anl.gov 
Subject: Re: [petsc-users] FW: 'Preconditioning' with lower-order method
On Sun, Mar 3, 2024 at 11: 42 AM Zou, Ling via petsc-users  wrote: Original email may have been sent to the incorrect place. See 
below. -Ling From: Zou, Ling  Date: Sunday, March 3, 2024 at
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.

ZjQcmQRYFpfptBannerEnd


On Sun, Mar 3, 2024 at 11:42 AM Zou, Ling via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:
Original email may have been sent to the incorrect place.
See below.

-Ling

From: Zou, Ling mailto:l...@anl.gov>>
Date: Sunday, March 3, 2024 at 10:34 AM
To: petsc-users 
mailto:petsc-users-boun...@mcs.anl.gov>>
Subject: 'Preconditioning' with lower-order method
Hi all,

I am solving a PDE system over a spatial domain. Numerical methods are:

  *   Finite volume method (both 1st and 2nd order implemented)
  *   BDF1 and BDF2 for time integration.
What I have noticed is that 1st order FVM converges much faster than 2nd order 
FVM, regardless the time integration scheme. Well, not surprising since 2nd 
order FVM introduces additional non-linearity.

I’m thinking about two possible ways to speed up 2nd order FVM, and would like 
to get some thoughts or community knowledge before jumping into code 
implementation.

Say, let the 2nd order FVM residual function be F2(x) = 0; and the 1st order 
FVM residual function be F1(x) = 0.

  1.  Option – 1, multi-step for each time step
Step 1: solving F1(x) = 0 to obtain a temporary solution x1
Step 2: feed x1 as an initial guess to solve F2(x) = 0 to obtain the final 
solution.
[Not sure if gain any saving at all]


  1.  Option -2, dynamically changing residual function F(x)

In pseudo code, would be something like.


You can try it. I would doubt the linear version (1) would help. This is 
similar to "defect correction" but not the same.

The nonlinear version (2) is something you could try.
I've seen people switch nonlinear solvers like this but not operators.
You could try it.

Mark

snesFormFunction(SNES snes, Vec u, Vec f, void *)

{

  if (snes.nl_it_no < 4) // 4 being arbitrary here

f = F1(u);

  else

f = F2(u);

}



I know this might be a bit crazy since it may crash after switching residual 
function, still, any thoughts?

Best,

-Ling


Re: [petsc-users] FW: 'Preconditioning' with lower-order method

2024-03-03 Thread Mark Adams
On Sun, Mar 3, 2024 at 11:42 AM Zou, Ling via petsc-users <
petsc-users@mcs.anl.gov> wrote:

> Original email may have been sent to the incorrect place.
>
> See below.
>
>
>
> -Ling
>
>
>
> *From: *Zou, Ling 
> *Date: *Sunday, March 3, 2024 at 10:34 AM
> *To: *petsc-users 
> *Subject: *'Preconditioning' with lower-order method
>
> Hi all,
>
>
>
> I am solving a PDE system over a spatial domain. Numerical methods are:
>
>- Finite volume method (both 1st and 2nd order implemented)
>- BDF1 and BDF2 for time integration.
>
> What I have noticed is that 1st order FVM converges much faster than 2nd
> order FVM, regardless the time integration scheme. Well, not surprising
> since 2nd order FVM introduces additional non-linearity.
>
>
>
> I’m thinking about two possible ways to speed up 2nd order FVM, and would
> like to get some thoughts or community knowledge before jumping into code
> implementation.
>
>
>
> Say, let the 2nd order FVM residual function be *F*2(*x*) = 0; and the 1st
> order FVM residual function be *F*1(*x*) = 0.
>
>1. Option – 1, multi-step for each time step
>
> Step 1: solving *F*1(*x*) = 0 to obtain a temporary solution * x*1
>
> Step 2: feed *x*1 as an initial guess to solve *F*2(*x*) = 0 to obtain
> the final solution.
>
> [Not sure if gain any saving at all]
>
>
>

>1. Option -2, dynamically changing residual function F(x)
>
> In pseudo code, would be something like.
>
>
>
You can try it. I would doubt the linear version (1) would help. This is
similar to "defect correction" but not the same.

The nonlinear version (2) is something you could try.
I've seen people switch nonlinear solvers like this but not operators.
You could try it.

Mark

> snesFormFunction(SNES snes, Vec u, Vec f, void *)
>
> {
>
>   if (snes.nl_it_no < 4) // 4 being arbitrary here
>
> f = F1(u);
>
>   else
>
> f = F2(u);
>
> }
>
>
>
> I know this might be a bit crazy since it may crash after switching
> residual function, still, any thoughts?
>
>
>
> Best,
>
>
>
> -Ling
>


[petsc-users] FW: 'Preconditioning' with lower-order method

2024-03-03 Thread Zou, Ling via petsc-users
Original email may have been sent to the incorrect place.
See below.

-Ling

From: Zou, Ling 
Date: Sunday, March 3, 2024 at 10:34 AM
To: petsc-users 
Subject: 'Preconditioning' with lower-order method
Hi all,

I am solving a PDE system over a spatial domain. Numerical methods are:

  *   Finite volume method (both 1st and 2nd order implemented)
  *   BDF1 and BDF2 for time integration.
What I have noticed is that 1st order FVM converges much faster than 2nd order 
FVM, regardless the time integration scheme. Well, not surprising since 2nd 
order FVM introduces additional non-linearity.

I’m thinking about two possible ways to speed up 2nd order FVM, and would like 
to get some thoughts or community knowledge before jumping into code 
implementation.

Say, let the 2nd order FVM residual function be F2(x) = 0; and the 1st order 
FVM residual function be F1(x) = 0.

  1.  Option – 1, multi-step for each time step
Step 1: solving F1(x) = 0 to obtain a temporary solution x1
Step 2: feed x1 as an initial guess to solve F2(x) = 0 to obtain the final 
solution.
[Not sure if gain any saving at all]


  1.  Option -2, dynamically changing residual function F(x)

In pseudo code, would be something like.



snesFormFunction(SNES snes, Vec u, Vec f, void *)

{

  if (snes.nl_it_no < 4) // 4 being arbitrary here

f = F1(u);

  else

f = F2(u);

}



I know this might be a bit crazy since it may crash after switching residual 
function, still, any thoughts?

Best,

-Ling