Re: [petsc-users] Using matrix-free with KSP

2022-09-13 Thread Tu, Jiannan
Barry Smith Sent: Tuesday, September 13, 2022 11:53 AM To: Tu, Jiannan Cc: petsc-users Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. This is becoming a nightmare. You pointed out something I had not thought about

Re: [petsc-users] Using matrix-free with KSP

2022-09-13 Thread Barry Smith
Thank you, > Jiannan > > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Monday, September 12, 2022 4:18 PM > To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Cc: petsc-users mailto:petsc-users@mcs.anl.gov>> > Subject: Re: [petsc-users] Using matrix-free wit

Re: [petsc-users] Using matrix-free with KSP

2022-09-12 Thread Tu, Jiannan
ess probably due to wrong column locations of those Jacobian elements. Thank you, Jiannan From: Barry Smith Sent: Monday, September 12, 2022 4:18 PM To: Tu, Jiannan Cc: petsc-users Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Low

Re: [petsc-users] Using matrix-free with KSP

2022-09-12 Thread Barry Smith
suggested. > > Thank you very much. > Jiannan > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Monday, September 12, 2022 9:31 AM > To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Cc: petsc-users mailto:petsc-users@mcs.anl.gov>> > Subject: Re: [petsc

Re: [petsc-users] Using matrix-free with KSP

2022-09-12 Thread Tu, Jiannan
t: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. I am not able to visualize the pattern you refer to but I am pretty sure it is not a type of connectivity that DMDA handles by default since DMDA is for relatively simply struc

Re: [petsc-users] Using matrix-free with KSP

2022-09-12 Thread Barry Smith
Barry Smith mailto:bsm...@petsc.dev>> > Sent: Sunday, September 11, 2022 12:10 PM > To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Cc: petsc-users mailto:petsc-users@mcs.anl.gov>> > Subject: Re: [petsc-users] Using matrix-free with KSP > > CAUTION: This email w

Re: [petsc-users] Using matrix-free with KSP

2022-09-11 Thread Tu, Jiannan
ting appropriate BC there and inserting at that location without wrapping. Jiannan From: Barry Smith Sent: Sunday, September 11, 2022 12:10 PM To: Tu, Jiannan Cc: petsc-users Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network.

Re: [petsc-users] Using matrix-free with KSP

2022-09-11 Thread Barry Smith
> MatSetValuesStencil(Jac,1,&row,nv,col,vals,INSERT_VALUES); > } > } > } > } > > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Sunday, September 11, 2022 12:10 PM > To: Tu, Jiannan mailto:jiann

Re: [petsc-users] Using matrix-free with KSP

2022-09-11 Thread Tu, Jiannan
12:10 PM To: Tu, Jiannan Cc: petsc-users Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. On Sep 11, 2022, at 9:56 AM, Tu, Jiannan mailto:jiannan...@uml.edu>> wrote: Barry, Thank you. Yes, the DMDA is created

Re: [petsc-users] Using matrix-free with KSP

2022-09-11 Thread Barry Smith
.dev>> > Sent: Sunday, September 11, 2022 12:10 AM > To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Cc: petsc-users mailto:petsc-users@mcs.anl.gov>> > Subject: Re: [petsc-users] Using matrix-free with KSP > > CAUTION: This email was sent from outside the

Re: [petsc-users] Using matrix-free with KSP

2022-09-11 Thread Tu, Jiannan
range" error or code stuck at inserting values if MatSetOption() is called. Jiannan From: Barry Smith Sent: Sunday, September 11, 2022 12:10 AM To: Tu, Jiannan Cc: petsc-users Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowe

Re: [petsc-users] Using matrix-free with KSP

2022-09-10 Thread Barry Smith
Jiannan > > > > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Saturday, September 10, 2022 1:10 PM > To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Cc: petsc-users mailto:petsc-users@mcs.anl.gov>> > Subject: Re: [petsc-users] Using matrix-free with

Re: [petsc-users] Using matrix-free with KSP

2022-09-10 Thread Tu, Jiannan
Smith mailto:bsm...@petsc.dev>> Sent: Thursday, September 8, 2022 9:53 PM To: Tu, Jiannan mailto:jiannan...@uml.edu>> Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. On Sep 8, 2022, at 8:34 PM, Tu, Jianna

Re: [petsc-users] Using matrix-free with KSP

2022-09-10 Thread Barry Smith
To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Subject: Re: [petsc-users] Using matrix-free with KSP > > CAUTION: This email was sent from outside the UMass Lowell network. > > > > > On Sep 8, 2022, at 8:34 PM, Tu, Jiannan <mailto:jiannan...@uml.edu>>

Re: [petsc-users] Using matrix-free with KSP

2022-09-08 Thread Barry Smith
; Jiannan > > > > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows > > From: Barry Smith <mailto:bsm...@petsc.dev> > Sent: Wednesday, September 7, 2022 11:53 AM > To: Tu, Jiannan <mailto:jiannan...@uml.edu> > Cc: petsc-users@mcs.anl.go

Re: [petsc-users] Using matrix-free with KSP

2022-09-08 Thread Tu, Jiannan
Smith<mailto:bsm...@petsc.dev> Sent: Wednesday, September 7, 2022 11:53 AM To: Tu, Jiannan<mailto:jiannan...@uml.edu> Cc: petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside

Re: [petsc-users] Using matrix-free with KSP

2022-09-07 Thread Barry Smith
lto:jiannan...@uml.edu>> > Cc: petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> > mailto:petsc-users@mcs.anl.gov>> > Subject: Re: [petsc-users] Using matrix-free with KSP > > CAUTION: This email was sent from outside the UMass Lowell network. > >

Re: [petsc-users] Using matrix-free with KSP

2022-09-07 Thread Tu, Jiannan
row. I'll try DMDASetBlockFills() or DMDASetBlockFillsSparse() and see how they can reduce the memory usage. Jiannan From: Barry Smith Sent: Tuesday, September 6, 2022 11:33 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using m

Re: [petsc-users] Using matrix-free with KSP

2022-09-06 Thread Barry Smith
> On Sep 6, 2022, at 11:00 PM, Tu, Jiannan wrote: > > I am using TS IMEX to solve a large DAE system. The DAE is obtained by > applying finite FV method to 3-D multi-specie ion/neutral fluids equations > with magnetic induction equation. The Jacobian for stiff part is formed by > using MatSe

Re: [petsc-users] Using matrix-free with KSP

2022-09-06 Thread Zhang, Hong via petsc-users
You can refer to the example src/ts/tutorials/advection-diffusion-reaction/ex5adj_mf.c which uses a matrix-free approach for a 2D multi-component reaction-diffusion PDE. In particular, you only need to look at MyIMatMult() and ignore the transposed version which is intended for adjoint calculati

Re: [petsc-users] Using matrix-free with KSP

2022-09-06 Thread Tu, Jiannan
I am using TS IMEX to solve a large DAE system. The DAE is obtained by applying finite FV method to 3-D multi-specie ion/neutral fluids equations with magnetic induction equation. The Jacobian for stiff part is formed by using MatSetValuesStencil(). The Jacobian matrix is very sparse, no more th

Re: [petsc-users] Using matrix-free with KSP

2022-08-21 Thread Tu, Jiannan
r Mat assembly doesn't support shell matrix either. Thank you, Jiannan From: Barry Smith Sent: Friday, August 19, 2022 4:02 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell netw

Re: [petsc-users] Using matrix-free with KSP

2022-08-19 Thread Tu, Jiannan
converge. The question then becomes how to link A to matrix-free matrix-vector multiplication. And where to put MatShell? Thank you, Jiannan From: Barry Smith Sent: Friday, August 19, 2022 10:27 AM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP

Re: [petsc-users] Using matrix-free with KSP

2022-08-19 Thread Barry Smith
ursday, August 18, 2022 7:44 PM > To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Cc: petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> > Subject: Re: [petsc-users] Using matrix-free with KSP > > CAUTION: This email was sent from outside the UMass Lowell network. > &g

Re: [petsc-users] Using matrix-free with KSP

2022-08-18 Thread Tu, Jiannan
n Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. Is it in the first iteration of the first KSPSolve that you get this message? Or in the second call to KSPSolve? The error comes from a m

Re: [petsc-users] Using matrix-free with KSP

2022-08-18 Thread Barry Smith
KSPSetOperators(ksp, A, B); > KSPSetFromOptions(ksp); > > PC pc; > KSPGetPC(ksp, &pc); > PCSetFromOptions(pc); > > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Thursday, August 18, 2022 12:59 PM > To: Tu, Jiannan mailto:jiannan...@uml

Re: [petsc-users] Using matrix-free with KSP

2022-08-18 Thread Tu, Jiannan
ugust 18, 2022 12:59 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. Yes, once you have preallocated the real matrix you can destroy the preallocation matrix whose

Re: [petsc-users] Using matrix-free with KSP

2022-08-18 Thread Barry Smith
nan...@uml.edu>> > Cc: petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> > Subject: Re: [petsc-users] Using matrix-free with KSP > > CAUTION: This email was sent from outside the UMass Lowell network. > > >The preallocator MatType matrix cannot be pa

Re: [petsc-users] Using matrix-free with KSP

2022-08-18 Thread Tu, Jiannan
: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. The preallocator MatType matrix cannot be passed to the KSPSetOperators(), you need to create an actual matrix, for example MATAIJ and use the preallocator to set its preallocation

Re: [petsc-users] Using matrix-free with KSP

2022-08-18 Thread Tu, Jiannan
August 16, 2022 2:00 PM To: Tu, Jiannan mailto:jiannan...@uml.edu>> Cc: petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. Create another matrix B that contain

Re: [petsc-users] Using matrix-free with KSP

2022-08-18 Thread Barry Smith
jiannantu/petsc-3.16.6/src/ksp/ksp/interface/itfunc.c:914 > [0]PETSC ERROR: #8 KSPSolve() at > /home/jiannantu/petsc-3.16.6/src/ksp/ksp/interface/itfunc.c:1086 > > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Thursday, August 18, 2022 8:35 AM > To: Tu, Jiannan mailt

Re: [petsc-users] Using matrix-free with KSP

2022-08-18 Thread Barry Smith
ilto:bsm...@petsc.dev>> > Sent: Tuesday, August 16, 2022 2:00 PM > To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Cc: petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> > Subject: Re: [petsc-users] Using matrix-free with KSP > > CAUTION: This email was sent fro

Re: [petsc-users] Using matrix-free with KSP

2022-08-17 Thread Tu, Jiannan
ugust 16, 2022 2:00 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. Create another matrix B that contains "Selected parts of the matrix can be pre-calculated and store

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Tu, Jiannan
Barry, Thank you so much. I'll try these options and see how they work. Jiannan From: Barry Smith Sent: Tuesday, August 16, 2022 1:59 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This emai

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Barry Smith
(ksp,&pc); > PCSetType(pc,PCSHELL); > PCShellSetApply(pc,MatrixFreePreconditioner); > > Thank you, > Jiannan > > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Tuesday, August 16, 2022 10:10 AM > To: Tu, Jiannan mailto:jiannan...@uml.edu>

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Tu, Jiannan
s.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was sent from outside the UMass Lowell network. I don't fully understand your question so I will answer questions that I do know the answer to :-) The function you provide to PCShellSetApply() applies the p

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Barry Smith
2022 2:34 PM > To: Barry Smith mailto:bsm...@petsc.dev>> > Cc: Jed Brown mailto:j...@jedbrown.org>>; > petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> > mailto:petsc-users@mcs.anl.gov>> > Subject: Re: [petsc-users] Using matrix-free with KSP

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Tu, Jiannan
Brown ; petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP So your operator is a "dense" operator in that its matrix representation would be essentially dense. In that case, you can use specialized routines to do this efficiently. You can use VecScatterCr

Re: [petsc-users] Using matrix-free with KSP

2022-07-06 Thread Tu, Jiannan
Subject: Re: [petsc-users] Using matrix-free with KSP So your operator is a "dense" operator in that its matrix representation would be essentially dense. In that case, you can use specialized routines to do this efficiently. You can use VecScatterCreateToAll() and then VecScatterBe

Re: [petsc-users] Using matrix-free with KSP

2022-07-06 Thread Barry Smith
;> > Cc: petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> > mailto:petsc-users@mcs.anl.gov>> > Subject: Re: [petsc-users] Using matrix-free with KSP > > You'll usually have a GlobalToLocal operation for each rank to get the halo > data it needs, then eit

Re: [petsc-users] Using matrix-free with KSP

2022-07-06 Thread Tu, Jiannan
annan From: Jed Brown Sent: Wednesday, July 6, 2022 10:09 AM To: Tu, Jiannan ; Barry Smith Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP You'll usually have a GlobalToLocal operation for each rank to get the halo data it needs, then either a LocalT

Re: [petsc-users] Using matrix-free with KSP

2022-07-06 Thread Jed Brown
:12 PM > To: Tu, Jiannan > Cc: petsc-users@mcs.anl.gov > Subject: Re: [petsc-users] Using matrix-free with KSP > > This e-mail originated from outside the UMass Lowell network. > > >You can use MatCreateMFFD > https://petsc.org/main/do

Re: [petsc-users] Using matrix-free with KSP

2022-07-06 Thread Tu, Jiannan
From: Barry Smith Sent: Tuesday, May 24, 2022 2:12 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP This e-mail originated from outside the UMass Lowell network. You can use

Re: [petsc-users] Using matrix-free with KSP

2022-05-30 Thread Tu, Jiannan
Barry, thanks for the clarification. Jiannan From: Barry Smith Sent: Monday, May 30, 2022 7:49 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP This e-mail originated from outside the UMass Lowell network

Re: [petsc-users] Using matrix-free with KSP

2022-05-30 Thread Barry Smith
t;> > Cc: petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> > Subject: Re: [petsc-users] Using matrix-free with KSP > > This e-mail originated from outside the UMass Lowell network. > >You can use MatCreateMFFD > https://petsc.org/main/docs/manualpages/M

Re: [petsc-users] Using matrix-free with KSP

2022-05-30 Thread Tu, Jiannan
around it? Thank you, Jiannan From: Barry Smith Sent: Tuesday, May 24, 2022 2:13 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP This e-mail originated from outside the UMass Lowell network. You can use Mat

Re: [petsc-users] Using matrix-free with KSP

2022-05-24 Thread Barry Smith
You can use MatCreateMFFD https://petsc.org/main/docs/manualpages/Mat/MatCreateMFFD/ MatMFFDSetFunction MatSetFromOptions MatMFFDSetBase and provide the matrix to KSP. Note you will need to use -pc_type none or provide your own cu

[petsc-users] Using matrix-free with KSP

2022-05-24 Thread Tu, Jiannan
I want to use a matrix-free matrix to solve a large linear equation system because the matrix is too large to be stored. Petsc user manual describes matrix-free method for SNES with examples. The matrix-free matrices section explains how to set up such a matrix, but I can't find any example of