Re: [petsc-users] snes matrix-free jacobian fails with preconditioner shape mismatch

2024-03-14 Thread Yi Hu
have > 27 values in this case and you use it for local operations only (its communicator is PETSC_COMM_SELF). Hope this helps, Mark On Mon, Mar 11, 2024 at 4:48 AM Yi Hu wrote: Dear Barry, Thanks for your response. Now I am doing simple debugging for my customized mat_mult_op of

Re: [petsc-users] snes matrix-free jacobian fails with preconditioner shape mismatch

2024-03-11 Thread Yi Hu
: Sunday, March 10, 2024 6:45 PM To: Yi Hu Cc: Mark Adams ; petsc-users Subject: Re: [petsc-users] snes matrix-free jacobian fails with preconditioner shape mismatch On Mar 10, 2024, at 10:16 AM, Yi Hu wrote: This Message Is From an External Sender This message came from outside your

Re: [petsc-users] snes matrix-free jacobian fails with preconditioner shape mismatch

2024-03-10 Thread Yi Hu
, 2024 at 7:21 AM Yi Hu wrote: Dear petsc team, I implemented a matrix-free jacobian, and it can run sequentially. But running parallel I got the pc error like this (running with mpirun -np 2, only error from rank1 is presented here) [1]PETSC ERROR

[petsc-users] snes matrix-free jacobian fails with preconditioner shape mismatch

2024-03-10 Thread Yi Hu
Dear petsc team, I implemented a matrix-free jacobian, and it can run sequentially. But running parallel I got the pc error like this (running with mpirun -np 2, only error from rank1 is presented here) [1]PETSC ERROR: - ZjQcmQRYFpfptBannerStart

Re: [petsc-users] how to check state of form residual of snes, for solving ksp or line search?

2024-02-24 Thread Yi Hu
:29, Barry Smith wrote: > >> On Feb 24, 2024, at 10:50 AM, Yi Hu wrote: >> >> Dear Barry, >> >> Thanks for the hint. >> >> This works for my purpose. I did not need to access my form function value, so I did not call SNESGetFunction() in my callback funct

Re: [petsc-users] how to check state of form residual of snes, for solving ksp or line search?

2024-02-24 Thread Yi Hu
y immediately before each linear solve. Inside your callback use SNESGetFunction(snes,f,NULL,NULL); to access the last computed value of your function, from this you can update your global variable. > > Barry > > >> On Feb 14, 2024, at 4:28 PM, Yi Hu wrote: >> >> Dear P

[petsc-users] how to check state of form residual of snes, for solving ksp or line search?

2024-02-14 Thread Yi Hu
Dear PETSc team, I am using a newtonls snes solver. I know that form residual is invoked at several locations of the algorithm, first evaluated for the rhs of ksp solver, then several times for obtaining the optimal step of line search. In my problem I have a global variable that is updated

Re: [petsc-users] KSP has an extra iteration when use shell matrix

2024-02-06 Thread Yi Hu
FormJacobShell(). Like   TYPE(MatCtx),POINTER :: ctxF_pt    MatShellGetContext(jac,ctxF_ptr,ierr)    ctxF_pt%Xbase = X The reason this works is because ctxF_pt%Xbase = X copies the value of X (the PETSc vector) to Xbase, not the address of X.   Barry On Feb 5, 2024, at 4:18 PM, Yi Hu

Re: [petsc-users] KSP has an extra iteration when use shell matrix

2024-02-05 Thread Yi Hu
:   Send the entire code. On Feb 4, 2024, at 4:43 PM, Yi Hu wrote: Thanks for your response. You are correct. I overlooked this step. Now I am trying to correct my "shell matrix approach" for ex1f.F90 of snes solver (https://github.com/hyharry/small_petsc_test/blob/master/test_shell_ja

Re: [petsc-users] KSP has an extra iteration when use shell matrix

2024-02-04 Thread Yi Hu
Newton step results in sufficient decrease of the function value.   Barry On Jan 30, 2024, at 3:19 PM, Yi Hu wrote: Hello Barry, Thanks for your reply. The monitor options are fine. I actually meant my modification of snes tutorial ex1f.F90 does not work and has some unexpected behavior. I basically

Re: [petsc-users] KSP has an extra iteration when use shell matrix

2024-01-30 Thread Yi Hu
0 KSP Residual norm 1.267482220786e-01 >1 KSP Residual norm 1.498679601680e-17 > Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1 >   8 SNES Function norm 3.468150619264e-02 >0 KSP Residual norm 3.468150619264e-02 >1 KSP Residual norm 5.944160522951e-18 > Li

[petsc-users] KSP has an extra iteration when use shell matrix

2024-01-30 Thread Yi Hu
Dear PETSc team, I am still trying to sort out my previous thread https://lists.mcs.anl.gov/pipermail/petsc-users/2024-January/050079.html using a minimal working example. However, I encountered another problem. Basically I combined the basic usage of SNES solver and shell matrix and tried to

Re: [petsc-users] SNES seems not use my matrix-free operation

2024-01-16 Thread Yi Hu
  end interface MatShellSetContext   interface MatShellGetContext     subroutine MatShellGetContext(mat,ctx_F_base,ierr)   use petscmat   Mat :: mat   Vec :: ctx_F_base   PetscErrorCode :: ierr     end subroutine MatShellGetContext   end interface MatShellGetContext From: Yi Hu

Re: [petsc-users] SNES seems not use my matrix-free operation

2024-01-16 Thread Yi Hu
a valid formJacobian() can lead to a write to the matrix. My formJacobian maybe not valid (because the output not gives me print), so the Jac_PETSc is never written for the SNES. Maybe I am wrong about it.   Best wishes, Yi From: Barry Smith Sent: Thursday, January 11, 2024 4:47 PM To: Yi Hu

Re: [petsc-users] SNES seems not use my matrix-free operation

2024-01-11 Thread Yi Hu
be the same as my shell matrix. Yi From: Barry Smith Sent: Wednesday, January 10, 2024 4:27 PM To: Yi Hu Cc: petsc-users Subject: Re: [petsc-users] SNES seems not use my matrix-free operation By default if SNESSetJacobian() is not called with a function pointer PETSc attempts to compute

Re: [petsc-users] SNES seems not use my matrix-free operation

2024-01-10 Thread Yi Hu
shes, Yi From: Barry Smith Sent: Tuesday, January 9, 2024 4:49 PM To: Yi Hu Cc: petsc-users Subject: Re: [petsc-users] SNES seems not use my matrix-free operation However, my GK_op (which is the reloaded MATOP_MULT) gives me some problem. It is entered but then crashed with Segmentation V

[petsc-users] SNES seems not use my matrix-free operation

2024-01-08 Thread Yi Hu
Dear PETSc Experts, I am implementing a matrix-free jacobian for my SNES solver in Fortran. (command line option -snes_type newtonls -ksp_type gmres) In the main program, I define my residual and jacobian and matrix-free jacobian like the following, … call DMDASNESSetFunctionLocal(DM_mech,

Re: [petsc-users] fortran interface to snes matrix-free jacobian

2023-12-20 Thread Yi Hu
Dear Jed, Thanks for your reply. I have an analytical one to implement. Best, Yi -Original Message- From: Jed Brown Sent: Wednesday, December 20, 2023 5:40 PM To: Yi Hu ; petsc-users@mcs.anl.gov Subject: Re: [petsc-users] fortran interface to snes matrix-free jacobian Are you wanting

[petsc-users] fortran interface to snes matrix-free jacobian

2023-12-20 Thread Yi Hu
Dear PETSc team, My  solution scheme relies on a matrix-free jacobian in the SNES solver. I saw the useful C interface like MatCreateSNESMF(), DMSNESCreateJacobianMF(). I am wondering if you have the fortran equivalence? I think for my problem in the main program I need to do