[petsc-users] Near null space for a fieldsplit in petsc4py

Pierre Jolivet pierre.jolivet at lip6.fr
Wed Jul 12 12:52:21 CDT 2023

> On 12 Jul 2023, at 6:04 PM, TARDIEU Nicolas via petsc-users <petsc-users at mcs.anl.gov> wrote:
> Dear PETSc team,
> In the attached example, I set up a block pc for a saddle-point problem in petsc4py. The IS define the unknowns, namely some physical quantity (phys) and a Lagrange multiplier (lags).
> I would like to attach a near null space to the physical block, in order to get the best performance from an AMG pc. 
> I have been trying hard, attaching it to the initial block, to the IS but no matter what I am doing, when it comes to "ksp_view", no near null space is attached to the matrix.
> Could you please help me figure out what I am doing wrong ?

Are you using a double-precision 32-bit integers real build of PETSc?
Is it --with-debugging=0?
Because with my debug build, I get the following error (thus explaining why it’s not attached to the KSP).
Traceback (most recent call last):
  File "/Volumes/Data/Downloads/test/test_NullSpace.py", line 35, in <module>
    ns = NullSpace().create(True, [v], comm=comm)
  File "petsc4py/PETSc/Mat.pyx", line 5611, in petsc4py.PETSc.NullSpace.create
petsc4py.PETSc.Error: error code 62
[0] MatNullSpaceCreate() at /Volumes/Data/repositories/petsc/src/mat/interface/matnull.c:249
[0] Invalid argument
[0] Vector 0 must have 2-norm of 1.0, it is 22.3159

Furthermore, if you set yourself the constant vector in the near null-space, then the first argument of create() must be False, otherwise, you’ll have twice the same vector, and you’ll end up with another error (the vectors in the near null-space must be orthonormal).
If things still don’t work after those couple of fixes, please feel free to send an up-to-date reproducer.


> Thanks,
> Nicolas
> Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme à sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse.
> Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez reçu ce Message par erreur, merci de le supprimer de votre système, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions également d'en avertir immédiatement l'expéditeur par retour du message.
> Il est impossible de garantir que les communications par messagerie électronique arrivent en temps utile, sont sécurisées ou dénuées de toute erreur ou virus.
> ____________________________________________________
> This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval.
> If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message.
> E-mail communication cannot be guaranteed to be timely secure, error or virus-free.
> <test.tgz>

More information about the petsc-users mailing list