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

2022-09-13 Thread Tu, Jiannan
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
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 with

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
ested. > > 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-user

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

2022-09-12 Thread Tu, Jiannan
: [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 structured

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,,nv,col,vals,INSERT_VALUES); > } > } > } > } > > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Sunday, September 11, 2022 12:10 PM > To: Tu, Jiannan mailto:jiannan..

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

2022-09-11 Thread Tu, Jiannan
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 create

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

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
iannan...@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 matrix

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

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

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

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

2022-08-21 Thread Tu, Jiannan
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 network. I

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

2022-08-19 Thread Tu, Jiannan
. 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 CAUTION

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

2022-08-19 Thread Barry Smith
y, 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. > >

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

2022-08-18 Thread Tu, Jiannan
: 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 matrix

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

2022-08-18 Thread Barry Smith
t; KSPSetFromOptions(ksp); > > PC pc; > KSPGetPC(ksp, ); > PCSetFromOptions(pc); > > From: Barry Smith mailto:bsm...@petsc.dev>> > Sent: Thursday, August 18, 2022 12:59 PM > To: Tu, Jiannan mailto:jiannan...@uml.edu>> > Cc: petsc-users@mcs.anl.gov &l

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

2022-08-18 Thread Tu, Jiannan
etsc-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 only job is to gather the preallocation information On Au

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 b

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
sers@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. I don't fully understand your question so I will answer questions that I do know t

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
sc.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 from outsid

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

2022-08-17 Thread Tu, Jiannan
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 stored to

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 email

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

2022-08-16 Thread Barry Smith
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>> > Cc: petsc-users@mcs.anl.gov &l

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

2022-08-16 Thread Tu, Jiannan
iannan mailto:jiannan...@uml.edu>> Sent: Wednesday, July 6, 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: [pet

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

2022-08-16 Thread Barry Smith
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
; 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 VecScatterC

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 VecScatte

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 eith

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

2022-07-06 Thread Tu, Jiannan
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 LocalToGlobal

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

2022-07-06 Thread Jed Brown
; 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/docs/manualp

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
ays 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

[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