Skip to main content
`Ctrl`+`K`

# SNESConvergedCorrectPressure

The regular `SNES` convergence test that, up on convergence, adds a vector in the nullspace to make the continuum integral of the pressure field equal to zero.

## Synopsis

    #include "petscdmplex.h"
    #include "petscsnes.h"
    PetscErrorCode SNESConvergedCorrectPressure(SNES snes, PetscInt it, PetscReal xnorm, PetscReal gnorm, PetscReal f, SNESConvergedReason *reason, void *ctx)

Logically Collective

## Input Parameters

- snes - the `SNES` context

- it - the iteration (0 indicates before any Newton steps)

- xnorm - 2-norm of current iterate

- gnorm - 2-norm of current step

- f - 2-norm of function at current iterate

- ctx - Optional user context

## Output Parameter

- reason - `SNES_CONVERGED_ITERATING`, `SNES_CONVERGED_ITS`, or `SNES_DIVERGED_FNORM_NAN`

## Options Database Key

- -snes_convergence_test correct_pressure - see `SNESSetFromOptions()`

## Notes

In order to use this convergence test, you must set up several PETSc structures. First fields must be added to the `DM`, and a `PetscDS` must be created with discretizations of those fields. We currently assume that the pressure field has index 1. The pressure field must have a nullspace, likely created using the `DMSetNullSpaceConstructor()` interface. Last we must be able to integrate the pressure over the domain, so the `DM` attached to the SNES `must` be a `DMPLEX` at this time.

## Developer Note

This is a total misuse of the `SNES` convergence test handling system. It should be removed. Perhaps a `SNESSetPostSolve()` could be constructed to handle this process.

## See Also

SNES: Nonlinear Solvers, `SNES`, `DM`, `SNESConvergedDefault()`, `SNESSetConvergenceTest()`, `DMSetNullSpaceConstructor()`

## Level

advanced

## Location

src/snes/utils/dmplexsnes.c

Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages