snesut.c (35d705712e4e30cc2db45fcc137e266709f373c9) snesut.c (e37c518b3c178882b922d1d3faeb3ee252cb498a)
1
2#include <petsc/private/snesimpl.h> /*I "petsc/private/snesimpl.h" I*/
3#include <petscdm.h>
4#include <petscblaslapack.h>
5
6#undef __FUNCT__
7#define __FUNCT__ "SNESMonitorSolution"
8/*@C

--- 647 unchanged lines hidden (view full) ---

656 PetscFunctionBegin;
657 PetscValidHeaderSpecific(snes,SNES_CLASSID,1);
658 PetscValidPointer(reason,6);
659
660 *reason = SNES_CONVERGED_ITERATING;
661
662 if (!it) {
663 /* set parameter for default relative tolerance convergence test */
1
2#include <petsc/private/snesimpl.h> /*I "petsc/private/snesimpl.h" I*/
3#include <petscdm.h>
4#include <petscblaslapack.h>
5
6#undef __FUNCT__
7#define __FUNCT__ "SNESMonitorSolution"
8/*@C

--- 647 unchanged lines hidden (view full) ---

656 PetscFunctionBegin;
657 PetscValidHeaderSpecific(snes,SNES_CLASSID,1);
658 PetscValidPointer(reason,6);
659
660 *reason = SNES_CONVERGED_ITERATING;
661
662 if (!it) {
663 /* set parameter for default relative tolerance convergence test */
664 snes->ttol = fnorm*snes->rtol;
664 snes->ttol = fnorm*snes->rtol;
665 snes->rnorm0 = fnorm;
665 }
666 if (PetscIsInfOrNanReal(fnorm)) {
667 ierr = PetscInfo(snes,"Failed to converged, function norm is NaN\n");CHKERRQ(ierr);
668 *reason = SNES_DIVERGED_FNORM_NAN;
669 } else if (fnorm < snes->abstol) {
670 ierr = PetscInfo2(snes,"Converged due to function norm %14.12e < %14.12e\n",(double)fnorm,(double)snes->abstol);CHKERRQ(ierr);
671 *reason = SNES_CONVERGED_FNORM_ABS;
672 } else if (snes->nfuncs >= snes->max_funcs) {
673 ierr = PetscInfo2(snes,"Exceeded maximum number of function evaluations: %D > %D\n",snes->nfuncs,snes->max_funcs);CHKERRQ(ierr);
674 *reason = SNES_DIVERGED_FUNCTION_COUNT;
675 }
676
677 if (it && !*reason) {
678 if (fnorm <= snes->ttol) {
679 ierr = PetscInfo2(snes,"Converged due to function norm %14.12e < %14.12e (relative tolerance)\n",(double)fnorm,(double)snes->ttol);CHKERRQ(ierr);
680 *reason = SNES_CONVERGED_FNORM_RELATIVE;
681 } else if (snorm < snes->stol*xnorm) {
682 ierr = PetscInfo3(snes,"Converged due to small update length: %14.12e < %14.12e * %14.12e\n",(double)snorm,(double)snes->stol,(double)xnorm);CHKERRQ(ierr);
683 *reason = SNES_CONVERGED_SNORM_RELATIVE;
666 }
667 if (PetscIsInfOrNanReal(fnorm)) {
668 ierr = PetscInfo(snes,"Failed to converged, function norm is NaN\n");CHKERRQ(ierr);
669 *reason = SNES_DIVERGED_FNORM_NAN;
670 } else if (fnorm < snes->abstol) {
671 ierr = PetscInfo2(snes,"Converged due to function norm %14.12e < %14.12e\n",(double)fnorm,(double)snes->abstol);CHKERRQ(ierr);
672 *reason = SNES_CONVERGED_FNORM_ABS;
673 } else if (snes->nfuncs >= snes->max_funcs) {
674 ierr = PetscInfo2(snes,"Exceeded maximum number of function evaluations: %D > %D\n",snes->nfuncs,snes->max_funcs);CHKERRQ(ierr);
675 *reason = SNES_DIVERGED_FUNCTION_COUNT;
676 }
677
678 if (it && !*reason) {
679 if (fnorm <= snes->ttol) {
680 ierr = PetscInfo2(snes,"Converged due to function norm %14.12e < %14.12e (relative tolerance)\n",(double)fnorm,(double)snes->ttol);CHKERRQ(ierr);
681 *reason = SNES_CONVERGED_FNORM_RELATIVE;
682 } else if (snorm < snes->stol*xnorm) {
683 ierr = PetscInfo3(snes,"Converged due to small update length: %14.12e < %14.12e * %14.12e\n",(double)snorm,(double)snes->stol,(double)xnorm);CHKERRQ(ierr);
684 *reason = SNES_CONVERGED_SNORM_RELATIVE;
685 } else if (fnorm > snes->divtol*snes->rnorm0) {
686 ierr = PetscInfo3(snes,"Diverged due to increase in function norm: %14.12e > %14.12e * %14.12e\n",(double)fnorm,(double)snes->divtol,(double)snes->rnorm0);CHKERRQ(ierr);
687 *reason = SNES_DIVERGED_DTOL;
684 }
688 }
689
685 }
686 PetscFunctionReturn(0);
687}
688
689#undef __FUNCT__
690#define __FUNCT__ "SNESConvergedSkip"
691/*@C
692 SNESConvergedSkip - Convergence test for SNES that NEVER returns as

--- 74 unchanged lines hidden ---
690 }
691 PetscFunctionReturn(0);
692}
693
694#undef __FUNCT__
695#define __FUNCT__ "SNESConvergedSkip"
696/*@C
697 SNESConvergedSkip - Convergence test for SNES that NEVER returns as

--- 74 unchanged lines hidden ---