[petsc-users] Does petsc4py support matrix-free iterative solvers?

Jose E. Roman jroman at dsic.upv.es
Tue Mar 14 11:49:51 CDT 2023


Have a look at ex100.c ex100.py:
https://gitlab.com/petsc/petsc/-/blob/c28a890633c5a91613f1645670105409b4ba3c14/src/ksp/ksp/tutorials/ex100.c
https://gitlab.com/petsc/petsc/-/blob/c28a890633c5a91613f1645670105409b4ba3c14/src/ksp/ksp/tutorials/ex100.py

Jose


> El 14 mar 2023, a las 17:45, Eric Hester <eric.w.hester at icloud.com> escribió:
> 
> Is there a similar example of how to create shell preconditioners using petsc4py?
> 
> Thanks,
> Eric
> 
>> On Mar 13, 2023, at 09:37, Eric Hester <eric.w.hester at icloud.com> wrote:
>> 
>> Ah ok. I see how the poisson2d example works. Thanks for the quick reply.
>> 
>> Eric
>> 
>>> On Mar 13, 2023, at 08:10, Jose E. Roman <jroman at dsic.upv.es> wrote:
>>> 
>>> Both ode/vanderpol.py and poisson2d/poisson2d.py use shell matrices via a mult(self,mat,X,Y) function defined in the python side. Another example is ex3.py in slepc4py.
>>> 
>>> Jose
>>> 
>>> 
>>> 
>>>> El 13 mar 2023, a las 15:58, Eric Hester via petsc-users <petsc-users at mcs.anl.gov> escribió:
>>>> 
>>>> Hello everyone,
>>>> 
>>>> Does petsc4py support matrix-free iterative solvers (as for Matrix-Free matrices in petsc)?
>>>> 
>>>> For context, I have a distributed matrix problem to solve. It comes from a Fourier-Chebyshev Galerkin discretisation. The corresponding matrix is dense, but it is fast to evaluate using fftw. It is also distributed in memory.
>>>> 
>>>> While I’ve found some petsc4py tutorial examples in "/petsc/src/binding/petsc4py/demo/“, they don’t seem to show a matrix free example. And I don’t see a reference to a matrix shell create method in the petsc4py api.
>>>> 
>>>> If petsc4py does support matrix free iterative solvers, it would be really helpful if someone could provide even a toy example of that. Serial would work, though a parallelised one would be better.
>>>> 
>>>> Thanks,
>>>> Eric
>>>> 
>>>> 
>>> 
>> 
> 



More information about the petsc-users mailing list