Bug Summary

File:snes/utils/convest.c
Warning:line 351, column 12
2nd function call argument is an uninitialized value

Annotated Source Code

[?] Use j/k keys for keyboard navigation

1#include <petscconvest.h> /*I "petscconvest.h" I*/
2#include <petscdmplex.h>
3#include <petscds.h>
4
5#include <petsc/private/petscconvestimpl.h>
6
7static PetscErrorCode zero_private(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
8{
9 PetscInt c;
10 for (c = 0; c < Nc; ++c) u[c] = 0.0;
11 return 0;
12}
13
14
15/*@
16 PetscConvEstCreate - Create a PetscConvEst object
17
18 Collective
19
20 Input Parameter:
21. comm - The communicator for the PetscConvEst object
22
23 Output Parameter:
24. ce - The PetscConvEst object
25
26 Level: beginner
27
28.seealso: PetscConvEstDestroy(), PetscConvEstGetConvRate()
29@*/
30PetscErrorCode PetscConvEstCreate(MPI_Comm comm, PetscConvEst *ce)
31{
32 PetscErrorCode ierr;
33
34 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 34; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
35 PetscValidPointer(ce, 2)do { if (!ce) return PetscError(((MPI_Comm)0x44000001),35,__func__
,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",85,
PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer
(ce,PETSC_CHAR)) return PetscError(((MPI_Comm)0x44000001),35,
__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
36 ierr = PetscSysInitializePackage();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),36,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
37 ierr = PetscHeaderCreate(*ce, PETSC_OBJECT_CLASSID, "PetscConvEst", "ConvergenceEstimator", "SNES", comm, PetscConvEstDestroy, PetscConvEstView)(PetscMallocA(1,PETSC_TRUE,37,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,(size_t)(1)*sizeof(**((&(*ce)))),((&(*ce)))) || PetscHeaderCreate_Private
((PetscObject)*ce,PETSC_OBJECT_CLASSID,"PetscConvEst","ConvergenceEstimator"
,"SNES",comm,(PetscObjectDestroyFunction)PetscConvEstDestroy,
(PetscObjectViewFunction)PetscConvEstView) || ((PetscLogPHC) ?
(*PetscLogPHC)((PetscObject)(*ce)) : 0) || PetscLogObjectMemory
((PetscObject)*ce,sizeof(*(*ce))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),37,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
38 (*ce)->monitor = PETSC_FALSE;
39 (*ce)->Nr = 4;
40 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
41}
42
43/*@
44 PetscConvEstDestroy - Destroys a PetscConvEst object
45
46 Collective on PetscConvEst
47
48 Input Parameter:
49. ce - The PetscConvEst object
50
51 Level: beginner
52
53.seealso: PetscConvEstCreate(), PetscConvEstGetConvRate()
54@*/
55PetscErrorCode PetscConvEstDestroy(PetscConvEst *ce)
56{
57 PetscErrorCode ierr;
58
59 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 59; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
60 if (!*ce) PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
61 PetscValidHeaderSpecific((*ce),PETSC_OBJECT_CLASSID,1)do { if (!(*ce)) return PetscError(((MPI_Comm)0x44000001),61,
__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer((*ce),PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),61,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)((*ce)))->classid != PETSC_OBJECT_CLASSID
) { if (((PetscObject)((*ce)))->classid == -1) return PetscError
(((MPI_Comm)0x44000001),61,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),61,__func__
,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62,
PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1)
; } } while (0)
;
62 if (--((PetscObject)(*ce))->refct > 0) {
63 *ce = NULL((void*)0);
64 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
65 }
66 ierr = PetscFree3((*ce)->initGuess, (*ce)->exactSol, (*ce)->ctxs)PetscFreeA(3,66,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,&((*ce)->initGuess),&((*ce)->exactSol),&((
*ce)->ctxs))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),66,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
67 ierr = PetscFree((*ce)->errors)((*PetscTrFree)((void*)((*ce)->errors),67,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
) || (((*ce)->errors) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),67,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
68 ierr = PetscHeaderDestroy(ce)(PetscHeaderDestroy_Private((PetscObject)(*ce)) || ((*PetscTrFree
)((void*)(*ce),68,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
) || ((*ce) = 0,0)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),68,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
69 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
70}
71
72/*@
73 PetscConvEstSetFromOptions - Sets a PetscConvEst object from options
74
75 Collective on PetscConvEst
76
77 Input Parameters:
78. ce - The PetscConvEst object
79
80 Level: beginner
81
82.seealso: PetscConvEstCreate(), PetscConvEstGetConvRate()
83@*/
84PetscErrorCode PetscConvEstSetFromOptions(PetscConvEst ce)
85{
86 PetscErrorCode ierr;
87
88 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 88; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
89 ierr = PetscOptionsBegin(PetscObjectComm((PetscObject) ce), "", "Convergence Estimator Options", "PetscConvEst")0; do { PetscOptionItems PetscOptionsObjectBase; PetscOptionItems
*PetscOptionsObject = &PetscOptionsObjectBase; PetscMemzero
(PetscOptionsObject,sizeof(PetscOptionItems)); for (PetscOptionsObject
->count=(PetscOptionsPublish?-1:1); PetscOptionsObject->
count<2; PetscOptionsObject->count++) { PetscErrorCode _5_ierr
= PetscOptionsBegin_Private(PetscOptionsObject,PetscObjectComm
((PetscObject) ce),"","Convergence Estimator Options","PetscConvEst"
);do {if (__builtin_expect(!!(_5_ierr),0)) return PetscError(
((MPI_Comm)0x44000001),89,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),89,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
90 ierr = PetscOptionsInt("-convest_num_refine", "The number of refinements for the convergence check", "PetscConvEst", ce->Nr, &ce->Nr, NULL)PetscOptionsInt_Private(PetscOptionsObject,"-convest_num_refine"
,"The number of refinements for the convergence check","PetscConvEst"
,ce->Nr,&ce->Nr,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),90,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
91 ierr = PetscOptionsBool("-convest_monitor", "Monitor the error for each convergence check", "PetscConvEst", ce->monitor, &ce->monitor, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-convest_monitor"
,"Monitor the error for each convergence check","PetscConvEst"
,ce->monitor,&ce->monitor,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),91,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
92 ierr = PetscOptionsEnd()_5_ierr = PetscOptionsEnd_Private(PetscOptionsObject);do {if (
__builtin_expect(!!(_5_ierr),0)) return PetscError(((MPI_Comm
)0x44000001),92,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);}} while (0)
;
93 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
94}
95
96/*@
97 PetscConvEstView - Views a PetscConvEst object
98
99 Collective on PetscConvEst
100
101 Input Parameters:
102+ ce - The PetscConvEst object
103- viewer - The PetscViewer object
104
105 Level: beginner
106
107.seealso: PetscConvEstCreate(), PetscConvEstGetConvRate()
108@*/
109PetscErrorCode PetscConvEstView(PetscConvEst ce, PetscViewer viewer)
110{
111 PetscErrorCode ierr;
112
113 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 113; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
114 ierr = PetscObjectPrintClassNamePrefixType((PetscObject) ce, viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),114,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
115 ierr = PetscViewerASCIIPrintf(viewer, "ConvEst with %D levels\n", ce->Nr+1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),115,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
116 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
117}
118
119/*@
120 PetscConvEstGetSolver - Gets the solver used to produce discrete solutions
121
122 Not collective
123
124 Input Parameter:
125. ce - The PetscConvEst object
126
127 Output Parameter:
128. snes - The solver
129
130 Level: intermediate
131
132.seealso: PetscConvEstSetSolver(), PetscConvEstCreate(), PetscConvEstGetConvRate()
133@*/
134PetscErrorCode PetscConvEstGetSolver(PetscConvEst ce, SNES *snes)
135{
136 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 136; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
137 PetscValidHeaderSpecific(ce, PETSC_OBJECT_CLASSID, 1)do { if (!ce) return PetscError(((MPI_Comm)0x44000001),137,__func__
,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",85,
PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (!PetscCheckPointer
(ce,PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),137
,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(ce))->classid != PETSC_OBJECT_CLASSID
) { if (((PetscObject)(ce))->classid == -1) return PetscError
(((MPI_Comm)0x44000001),137,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),137,__func__
,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62,
PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1)
; } } while (0)
;
138 PetscValidPointer(snes, 2)do { if (!snes) return PetscError(((MPI_Comm)0x44000001),138,
__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(snes,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),138,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
139 *snes = ce->snes;
140 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
141}
142
143/*@
144 PetscConvEstSetSolver - Sets the solver used to produce discrete solutions
145
146 Not collective
147
148 Input Parameters:
149+ ce - The PetscConvEst object
150- snes - The solver
151
152 Level: intermediate
153
154 Note: The solver MUST have an attached DM/DS, so that we know the exact solution
155
156.seealso: PetscConvEstGetSolver(), PetscConvEstCreate(), PetscConvEstGetConvRate()
157@*/
158PetscErrorCode PetscConvEstSetSolver(PetscConvEst ce, SNES snes)
159{
160 PetscErrorCode ierr;
161
162 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 162; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
163 PetscValidHeaderSpecific(ce, PETSC_OBJECT_CLASSID, 1)do { if (!ce) return PetscError(((MPI_Comm)0x44000001),163,__func__
,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",85,
PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (!PetscCheckPointer
(ce,PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),163
,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(ce))->classid != PETSC_OBJECT_CLASSID
) { if (((PetscObject)(ce))->classid == -1) return PetscError
(((MPI_Comm)0x44000001),163,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),163,__func__
,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62,
PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1)
; } } while (0)
;
164 PetscValidHeaderSpecific(snes, SNES_CLASSID, 2)do { if (!snes) return PetscError(((MPI_Comm)0x44000001),164,
__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",2); if (
!PetscCheckPointer(snes,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),164,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,2); if (((PetscObject)(snes))->classid != SNES_CLASSID) {
if (((PetscObject)(snes))->classid == -1) return PetscError
(((MPI_Comm)0x44000001),164,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,2); else return PetscError(((MPI_Comm)0x44000001),164,__func__
,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62,
PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",2)
; } } while (0)
;
165 ce->snes = snes;
166 ierr = SNESGetDM(ce->snes, &ce->idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),166,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
167 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
168}
169
170/*@
171 PetscConvEstSetUp - After the solver is specified, we create structures for estimating convergence
172
173 Collective on PetscConvEst
174
175 Input Parameters:
176. ce - The PetscConvEst object
177
178 Level: beginner
179
180.seealso: PetscConvEstCreate(), PetscConvEstGetConvRate()
181@*/
182PetscErrorCode PetscConvEstSetUp(PetscConvEst ce)
183{
184 PetscDS prob;
185 PetscInt f;
186 PetscErrorCode ierr;
187
188 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 188; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
189 ierr = DMGetDS(ce->idm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
190 ierr = PetscDSGetNumFields(prob, &ce->Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),190,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
191 ierr = PetscMalloc1((ce->Nr+1)*ce->Nf, &ce->errors)PetscMallocA(1,PETSC_FALSE,191,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,(size_t)((ce->Nr+1)*ce->Nf)*sizeof(**(&ce->errors
)),(&ce->errors))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),191,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
192 ierr = PetscMalloc3(ce->Nf, &ce->initGuess, ce->Nf, &ce->exactSol, ce->Nf, &ce->ctxs)PetscMallocA(3,PETSC_FALSE,192,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,(size_t)(ce->Nf)*sizeof(**(&ce->initGuess)),(&
ce->initGuess),(size_t)(ce->Nf)*sizeof(**(&ce->exactSol
)),(&ce->exactSol),(size_t)(ce->Nf)*sizeof(**(&
ce->ctxs)),(&ce->ctxs))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),192,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
193 for (f = 0; f < ce->Nf; ++f) ce->initGuess[f] = zero_private;
194 for (f = 0; f < ce->Nf; ++f) {
195 ierr = PetscDSGetExactSolution(prob, f, &ce->exactSol[f], &ce->ctxs[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),195,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
196 if (!ce->exactSol[f]) SETERRQ1(PetscObjectComm((PetscObject) ce), PETSC_ERR_ARG_WRONG, "DS must contain exact solution functions in order to estimate convergence, missing for field %D", f)return PetscError(PetscObjectComm((PetscObject) ce),196,__func__
,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62,
PETSC_ERROR_INITIAL,"DS must contain exact solution functions in order to estimate convergence, missing for field %D"
,f)
;
197 }
198 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
199}
200
201/*@
202 PetscConvEstGetConvRate - Returns an estimate of the convergence rate for the discretization
203
204 Not collective
205
206 Input Parameter:
207. ce - The PetscConvEst object
208
209 Output Parameter:
210. alpha - The convergence rate for each field
211
212 Note: The convergence rate alpha is defined by
213$ || u_h - u_exact || < C h^alpha
214where u_h is the discrete solution, and h is a measure of the discretization size.
215
216We solve a series of problems on refined meshes, calculate an error based upon the exact solution in the DS,
217and then fit the result to our model above using linear regression.
218
219 Options database keys:
220. -snes_convergence_estimate : Execute convergence estimation and print out the rate
221
222 Level: intermediate
223
224.seealso: PetscConvEstSetSolver(), PetscConvEstCreate(), PetscConvEstGetConvRate()
225@*/
226PetscErrorCode PetscConvEstGetConvRate(PetscConvEst ce, PetscReal alpha[])
227{
228 DM *dm;
229 PetscObject disc;
230 MPI_Comm comm;
231 const char *uname, *dmname;
232 void *ctx;
233 Vec u;
234 PetscReal t = 0.0, *x, *y, slope, intercept;
235 PetscInt *dof, dim, Nr = ce->Nr, r, f, oldlevel, oldnlev;
1
'oldnlev' declared without an initial value
236 PetscLogEvent event;
237 PetscErrorCode ierr;
238
239 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 239; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
240 ierr = PetscObjectGetComm((PetscObject) ce, &comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),240,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
241 ierr = DMGetDimension(ce->idm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),241,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
242 ierr = DMGetApplicationContext(ce->idm, &ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),242,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
243 ierr = DMPlexSetRefinementUniform(ce->idm, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),243,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
244 ierr = DMGetRefineLevel(ce->idm, &oldlevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),244,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
245 ierr = PetscMalloc2((Nr+1), &dm, (Nr+1)*ce->Nf, &dof)PetscMallocA(2,PETSC_FALSE,245,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,(size_t)((Nr+1))*sizeof(**(&dm)),(&dm),(size_t)((Nr+
1)*ce->Nf)*sizeof(**(&dof)),(&dof))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),245,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
246 dm[0] = ce->idm;
247 for (f = 0; f < ce->Nf; ++f) alpha[f] = 0.0;
2
Assuming the condition is false
3
Loop condition is false. Execution continues on line 249
248 /* Loop over meshes */
249 ierr = PetscLogEventRegister("ConvEst Error", PETSC_OBJECT_CLASSID, &event);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),249,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
250 for (r = 0; r <= Nr; ++r) {
4
Assuming 'r' is > 'Nr'
5
Loop condition is false. Execution continues on line 326
251 PetscLogStage stage;
252 char stageName[PETSC_MAX_PATH_LEN4096];
253
254 ierr = PetscSNPrintf(stageName, PETSC_MAX_PATH_LEN4096-1, "ConvEst Refinement Level %D", r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),254,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
255 ierr = PetscLogStageRegister(stageName, &stage);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),255,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
256 ierr = PetscLogStagePush(stage);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),256,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
257 if (r > 0) {
258 ierr = DMRefine(dm[r-1], MPI_COMM_NULL((MPI_Comm)0x04000000), &dm[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),258,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
259 ierr = DMSetCoarseDM(dm[r], dm[r-1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),259,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
260 ierr = DMCopyDisc(ce->idm, dm[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),260,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
261 ierr = DMCopyTransform(ce->idm, dm[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),261,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
262 ierr = PetscObjectGetName((PetscObject) dm[r-1], &dmname);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),262,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
263 ierr = PetscObjectSetName((PetscObject) dm[r], dmname);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),263,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
264 for (f = 0; f <= ce->Nf; ++f) {
265 PetscErrorCode (*nspconstr)(DM, PetscInt, MatNullSpace *);
266 ierr = DMGetNullSpaceConstructor(dm[r-1], f, &nspconstr);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),266,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
267 ierr = DMSetNullSpaceConstructor(dm[r], f, nspconstr);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),267,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
268 }
269 }
270 ierr = DMViewFromOptions(dm[r], NULL((void*)0), "-conv_dm_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),270,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
271 /* Create solution */
272 ierr = DMCreateGlobalVector(dm[r], &u);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),272,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
273 ierr = DMGetField(dm[r], 0, NULL((void*)0), &disc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),273,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
274 ierr = PetscObjectGetName(disc, &uname);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),274,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
275 ierr = PetscObjectSetName((PetscObject) u, uname);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),275,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
276 /* Setup solver */
277 ierr = SNESReset(ce->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),277,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
278 ierr = SNESSetDM(ce->snes, dm[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),278,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
279 ierr = DMPlexSetSNESLocalFEM(dm[r], ctx, ctx, ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),279,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
280 ierr = SNESSetFromOptions(ce->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),280,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
281 /* Create initial guess */
282 ierr = DMProjectFunction(dm[r], t, ce->initGuess, ce->ctxs, INSERT_VALUES, u);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),282,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
283 ierr = SNESSolve(ce->snes, NULL((void*)0), u);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),283,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
284 ierr = PetscLogEventBegin(event, ce, 0, 0, 0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[event].active) ? (*PetscLogPLB)((event),0,(PetscObject)(ce),
(PetscObject)(0),(PetscObject)(0),(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),284,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
285 ierr = DMComputeL2FieldDiff(dm[r], t, ce->exactSol, ce->ctxs, u, &ce->errors[r*ce->Nf]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),285,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
286 ierr = PetscLogEventEnd(event, ce, 0, 0, 0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[event].active) ? (*PetscLogPLE)((event),0,(PetscObject)(ce),
(PetscObject)(0),(PetscObject)(0),(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),286,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
287 for (f = 0; f < ce->Nf; ++f) {
288 PetscSection s, fs;
289 PetscInt lsize;
290
291 /* Could use DMGetOutputDM() to add in Dirichlet dofs */
292 ierr = DMGetSection(dm[r], &s);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),292,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
293 ierr = PetscSectionGetField(s, f, &fs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),293,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
294 ierr = PetscSectionGetConstrainedStorageSize(fs, &lsize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),294,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
295 ierr = MPI_Allreduce(&lsize, &dof[r*ce->Nf+f], 1, MPIU_INT, MPI_SUM, PetscObjectComm((PetscObject) ce->snes))((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm
((PetscObject) ce->snes))),0) || MPI_Allreduce((&lsize
),(&dof[r*ce->Nf+f]),(1),(((MPI_Datatype)0x4c000405)),
((MPI_Op)(0x58000003)),(PetscObjectComm((PetscObject) ce->
snes))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),295,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
296 ierr = PetscLogEventSetDof(event, f, dof[r*ce->Nf+f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),296,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
297 ierr = PetscLogEventSetError(event, f, ce->errors[r*ce->Nf+f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),297,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
298 }
299 /* Monitor */
300 if (ce->monitor) {
301 PetscReal *errors = &ce->errors[r*ce->Nf];
302
303 ierr = PetscPrintf(comm, "L_2 Error: ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),303,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
304 if (ce->Nf > 1) {ierr = PetscPrintf(comm, "[");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),304,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
305 for (f = 0; f < ce->Nf; ++f) {
306 if (f > 0) {ierr = PetscPrintf(comm, ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),306,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
307 if (errors[f] < 1.0e-11) {ierr = PetscPrintf(comm, "< 1e-11");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),307,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
308 else {ierr = PetscPrintf(comm, "%g", (double)errors[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),308,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
309 }
310 if (ce->Nf > 1) {ierr = PetscPrintf(comm, "]");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),310,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
311 ierr = PetscPrintf(comm, "\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),311,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
312 }
313 if (!r) {
314 /* PCReset() does not wipe out the level structure */
315 KSP ksp;
316 PC pc;
317
318 ierr = SNESGetKSP(ce->snes, &ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),318,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
319 ierr = KSPGetPC(ksp, &pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),319,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
320 ierr = PCMGGetLevels(pc, &oldnlev);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),320,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
321 }
322 /* Cleanup */
323 ierr = VecDestroy(&u);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),323,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
324 ierr = PetscLogStagePop();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),324,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
325 }
326 for (r = 1; r <= Nr; ++r) {
6
Loop condition is false. Execution continues on line 330
327 ierr = DMDestroy(&dm[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),327,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
328 }
329 /* Fit convergence rate */
330 ierr = PetscMalloc2(Nr+1, &x, Nr+1, &y)PetscMallocA(2,PETSC_FALSE,330,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,(size_t)(Nr+1)*sizeof(**(&x)),(&x),(size_t)(Nr+1)*sizeof
(**(&y)),(&y))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),330,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
331 for (f = 0; f < ce->Nf; ++f) {
7
Loop condition is false. Execution continues on line 340
332 for (r = 0; r <= Nr; ++r) {
333 x[r] = PetscLog10Real(dof[r*ce->Nf+f])log10(dof[r*ce->Nf+f]);
334 y[r] = PetscLog10Real(ce->errors[r*ce->Nf+f])log10(ce->errors[r*ce->Nf+f]);
335 }
336 ierr = PetscLinearRegression(Nr+1, x, y, &slope, &intercept);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),336,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
337 /* Since h^{-dim} = N, lg err = s lg N + b = -s dim lg h + b */
338 alpha[f] = -slope * dim;
339 }
340 ierr = PetscFree2(x, y)PetscFreeA(2,340,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,&(x),&(y))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),340,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
341 ierr = PetscFree2(dm, dof)PetscFreeA(2,341,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,&(dm),&(dof))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),341,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
342 /* Restore solver */
343 ierr = SNESReset(ce->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),343,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
344 {
345 /* PCReset() does not wipe out the level structure */
346 KSP ksp;
347 PC pc;
348
349 ierr = SNESGetKSP(ce->snes, &ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),349,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
350 ierr = KSPGetPC(ksp, &pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),350,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
351 ierr = PCMGSetLevels(pc, oldnlev, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),351,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
8
2nd function call argument is an uninitialized value
352 ierr = DMSetRefineLevel(ce->idm, oldlevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),352,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* The damn DMCoarsen() calls in PCMG can reset this */
353 }
354 ierr = SNESSetDM(ce->snes, ce->idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),354,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
355 ierr = DMPlexSetSNESLocalFEM(ce->idm, ctx, ctx, ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),355,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
356 ierr = SNESSetFromOptions(ce->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),356,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
357 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
358}
359
360/*@
361 PetscConvEstRateView - Displays the convergence rate to a viewer
362
363 Collective on SNES
364
365 Parameter:
366+ snes - iterative context obtained from SNESCreate()
367. alpha - the convergence rate for each field
368- viewer - the viewer to display the reason
369
370 Options Database Keys:
371. -snes_convergence_estimate - print the convergence rate
372
373 Level: developer
374
375.seealso: PetscConvEstGetRate()
376@*/
377PetscErrorCode PetscConvEstRateView(PetscConvEst ce, const PetscReal alpha[], PetscViewer viewer)
378{
379 PetscBool isAscii;
380 PetscErrorCode ierr;
381
382 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack
->line[petscstack->currentsize] = 382; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
383 ierr = PetscObjectTypeCompare((PetscObject) viewer, PETSCVIEWERASCII"ascii", &isAscii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),383,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
384 if (isAscii) {
385 DM dm;
386 PetscInt Nf, f;
387
388 ierr = SNESGetDM(ce->snes, &dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),388,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
389 ierr = DMGetNumFields(dm, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),389,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
390 ierr = PetscViewerASCIIAddTab(viewer, ((PetscObject) ce)->tablevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),390,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
391 ierr = PetscViewerASCIIPrintf(viewer, "L_2 convergence rate: ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),391,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
392 if (Nf > 1) {ierr = PetscViewerASCIIPrintf(viewer, "[");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),392,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
393 for (f = 0; f < Nf; ++f) {
394 if (f > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),394,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
395 ierr = PetscViewerASCIIPrintf(viewer, "%#.2g", (double) alpha[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),395,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
396 }
397 if (Nf > 1) {ierr = PetscViewerASCIIPrintf(viewer, "]");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),397,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
398 ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),398,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
399 ierr = PetscViewerASCIISubtractTab(viewer, ((PetscObject) ce)->tablevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),399,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
400 }
401 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
402}