Re: [petsc-users] Matrix-free method in PETSc

2020-02-18 Thread Smith, Barry F. via petsc-users
> On Feb 18, 2020, at 8:26 AM, Yuyun Yang wrote: > > Thanks. Also, when using KSP, would the syntax be KSPSetOperators(ksp,A,A)? > Since you mentioned preconditioners are not generally used for matrix-free > operators, I wasn’t sure whether I should still put “A” in the Pmat field. > > Is i

Re: [petsc-users] Matrix-free method in PETSc

2020-02-18 Thread Yuyun Yang
Thanks a lot for the example! From: "Zhang, Hong" Date: Tuesday, February 18, 2020 at 11:32 PM To: Yuyun Yang Cc: Matthew Knepley , "petsc-users@mcs.anl.gov" Subject: Re: [petsc-users] Matrix-free method in PETSc Here is an TS example using DMDA and matrix-free Jacobians. Though the matrix-f

Re: [petsc-users] Efficiently move matrix from single processor to multiple

2020-02-18 Thread Jed Brown
Hector E Barrios Molano writes: > Dear PETSc Experts! > > Do you know if there is an efficient way to move a matrix from a single > processor (MatCreateSeqBAIJ) to a matrix contained in all processors? How did you create the original SeqBAIJ? Could you just call MatSetValues on a parallel matr

[petsc-users] Efficiently move matrix from single processor to multiple

2020-02-18 Thread Hector E Barrios Molano
Dear PETSc Experts! Do you know if there is an efficient way to move a matrix from a single processor (MatCreateSeqBAIJ) to a matrix contained in all processors? As a little bit of context, I have a code in which only one processor creates a matrix and a vector for a linear system of equation

Re: [petsc-users] BCs for a EPS solver

2020-02-18 Thread Emmanuel Ayala
Thanks for the answer. Finally I generate a submatrix and It worked. Kind regards. El mar., 18 de feb. de 2020 a la(s) 03:51, Jose E. Roman (jro...@dsic.upv.es) escribió: > You put alpha on the diagonal of A and beta on the diagonal of B to get an > eigenvalue lambda=alpha/beta. If you set beta

Re: [petsc-users] SLEPc: The inner product is not well defined

2020-02-18 Thread Emmanuel Ayala
Ok, thank you! Kind regards. El mar., 18 de feb. de 2020 a la(s) 03:17, Jose E. Roman (jro...@dsic.upv.es) escribió: > > > El 17 feb 2020, a las 19:19, Emmanuel Ayala escribió: > > Thank you very much for the answer. > > This error appears when computing the B-norm of a vector x, as >> sqrt(x'*

Re: [petsc-users] Matrix-free method in PETSc

2020-02-18 Thread Zhang, Hong via petsc-users
Here is an TS example using DMDA and matrix-free Jacobians. Though the matrix-free part is faked, it demonstrates the workflow. https://gitlab.com/petsc/petsc/-/blob/hongzh/ts-matshell-example/src/ts/examples/tutorials/advection-diffusion-reaction/ex5_mf.c Hong (Mr.) On Feb 18, 2020, at 8:26 A

Re: [petsc-users] Matrix-free method in PETSc

2020-02-18 Thread Yuyun Yang
Thanks. Also, when using KSP, would the syntax be KSPSetOperators(ksp,A,A)? Since you mentioned preconditioners are not generally used for matrix-free operators, I wasn’t sure whether I should still put “A” in the Pmat field. Is it still possible to use TS in conjunction with the matrix-free ope

Re: [petsc-users] Matrix-free method in PETSc

2020-02-18 Thread Matthew Knepley
On Tue, Feb 18, 2020 at 8:20 AM Yuyun Yang wrote: > Thanks for the clarification. > > Got one more question: if I have variable coefficients, my stencil will be > updated at every time step, so will the coefficients in myMatMult. In that > case, is it necessary to destroy the shell matrix and cre

Re: [petsc-users] Matrix-free method in PETSc

2020-02-18 Thread Yuyun Yang
Thanks for the clarification. Got one more question: if I have variable coefficients, my stencil will be updated at every time step, so will the coefficients in myMatMult. In that case, is it necessary to destroy the shell matrix and create it all over again, or can I use it as it is, only call

Re: [petsc-users] DM_BOUNDARY_GHOSTED

2020-02-18 Thread Matthew Knepley
On Tue, Feb 18, 2020 at 6:03 AM David Scott wrote: > Hello, > > I wish to solve a channel flow problem with different boundary > conditions. In the streamwise direction I may have periodic or > inlet/outlet BCs. I would like to make my code for the two cases as > similar as possible. If I use DM_

[petsc-users] DM_BOUNDARY_GHOSTED

2020-02-18 Thread David Scott
Hello, I wish to solve a channel flow problem with different boundary conditions. In the streamwise direction I may have periodic or inlet/outlet BCs. I would like to make my code for the two cases as similar as possible. If I use DM_BOUNDARY_PERIODIC then when performing a linear solve the ghost

Re: [petsc-users] BCs for a EPS solver

2020-02-18 Thread Jose E. Roman
You put alpha on the diagonal of A and beta on the diagonal of B to get an eigenvalue lambda=alpha/beta. If you set beta=0 then lambda=Inf. The choice depends on where your wanted eigenvalues are and how you are solving the eigenproblem. The choice of lambda=Inf suggested by Jeremy avoids insert

Re: [petsc-users] SLEPc: The inner product is not well defined

2020-02-18 Thread Jose E. Roman
> El 17 feb 2020, a las 19:19, Emmanuel Ayala escribió: > > Thank you very much for the answer. > > This error appears when computing the B-norm of a vector x, as sqrt(x'*B*x). > Probably your B matrix is semi-definite, and due to floating-point error the > value x'*B*x becomes negative for