File: | snes/utils/convest.c |
Warning: | line 415, column 12 2nd function call argument is an uninitialized value |
[?] Use j/k keys for keyboard navigation
1 | #include <petscconvest.h> /*I "petscconvest.h" I*/ | |||
2 | #include <petscdmplex.h> | |||
3 | #include <petscds.h> | |||
4 | #include <petscblaslapack.h> | |||
5 | ||||
6 | #include <petsc/private/petscconvestimpl.h> | |||
7 | ||||
8 | static PetscErrorCode zero_private(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) | |||
9 | { | |||
10 | PetscInt c; | |||
11 | for (c = 0; c < Nc; ++c) u[c] = 0.0; | |||
12 | return 0; | |||
13 | } | |||
14 | ||||
15 | ||||
16 | /*@ | |||
17 | PetscConvEstCreate - Create a PetscConvEst object | |||
18 | ||||
19 | Collective on MPI_Comm | |||
20 | ||||
21 | Input Parameter: | |||
22 | . comm - The communicator for the PetscConvEst object | |||
23 | ||||
24 | Output Parameter: | |||
25 | . ce - The PetscConvEst object | |||
26 | ||||
27 | Level: beginner | |||
28 | ||||
29 | .keywords: PetscConvEst, convergence, create | |||
30 | .seealso: PetscConvEstDestroy(), PetscConvEstGetConvRate() | |||
31 | @*/ | |||
32 | PetscErrorCode PetscConvEstCreate(MPI_Comm comm, PetscConvEst *ce) | |||
33 | { | |||
34 | PetscErrorCode ierr; | |||
35 | ||||
36 | 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] = 36; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
37 | PetscValidPointer(ce, 2)do { if (!ce) return PetscError(((MPI_Comm)0x44000001),37,__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),37, __func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
38 | ierr = PetscSysInitializePackage();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),38,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
39 | ierr = PetscHeaderCreate(*ce, PETSC_OBJECT_CLASSID, "PetscConvEst", "ConvergenceEstimator", "SNES", comm, PetscConvEstDestroy, PetscConvEstView)(PetscMallocA(1,PETSC_TRUE,39,__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),39,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
40 | (*ce)->monitor = PETSC_FALSE; | |||
41 | (*ce)->Nr = 4; | |||
42 | 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); | |||
43 | } | |||
44 | ||||
45 | /*@ | |||
46 | PetscConvEstDestroy - Destroys a PetscConvEst object | |||
47 | ||||
48 | Collective on PetscConvEst | |||
49 | ||||
50 | Input Parameter: | |||
51 | . ce - The PetscConvEst object | |||
52 | ||||
53 | Level: beginner | |||
54 | ||||
55 | .keywords: PetscConvEst, convergence, destroy | |||
56 | .seealso: PetscConvEstCreate(), PetscConvEstGetConvRate() | |||
57 | @*/ | |||
58 | PetscErrorCode PetscConvEstDestroy(PetscConvEst *ce) | |||
59 | { | |||
60 | PetscErrorCode ierr; | |||
61 | ||||
62 | 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] = 62; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
63 | 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); | |||
64 | PetscValidHeaderSpecific((*ce),PETSC_OBJECT_CLASSID,1)do { if (!(*ce)) return PetscError(((MPI_Comm)0x44000001),64, __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),64,__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),64,__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),64,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1) ; } } while (0); | |||
65 | if (--((PetscObject)(*ce))->refct > 0) { | |||
66 | *ce = NULL((void*)0); | |||
67 | 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); | |||
68 | } | |||
69 | ierr = PetscFree2((*ce)->initGuess, (*ce)->exactSol)PetscFreeA(2,69,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,&((*ce)->initGuess),&((*ce)->exactSol));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),69,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
70 | ierr = PetscFree((*ce)->errors)((*PetscTrFree)((void*)((*ce)->errors),70,__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),70,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
71 | ierr = PetscHeaderDestroy(ce)(PetscHeaderDestroy_Private((PetscObject)(*ce)) || ((*PetscTrFree )((void*)(*ce),71,__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),71,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
72 | 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); | |||
73 | } | |||
74 | ||||
75 | /*@ | |||
76 | PetscConvEstSetFromOptions - Sets a PetscConvEst object from options | |||
77 | ||||
78 | Collective on PetscConvEst | |||
79 | ||||
80 | Input Parameters: | |||
81 | . ce - The PetscConvEst object | |||
82 | ||||
83 | Level: beginner | |||
84 | ||||
85 | .keywords: PetscConvEst, convergence, options | |||
86 | .seealso: PetscConvEstCreate(), PetscConvEstGetConvRate() | |||
87 | @*/ | |||
88 | PetscErrorCode PetscConvEstSetFromOptions(PetscConvEst ce) | |||
89 | { | |||
90 | PetscErrorCode ierr; | |||
91 | ||||
92 | 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] = 92; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
93 | 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),93,__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),93,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
94 | 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),94,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
95 | 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),95,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
96 | ierr = PetscOptionsEnd()_5_ierr = PetscOptionsEnd_Private(PetscOptionsObject);do {if ( __builtin_expect(!!(_5_ierr),0)) return PetscError(((MPI_Comm )0x44000001),96,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);}} while (0); | |||
97 | 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); | |||
98 | } | |||
99 | ||||
100 | /*@ | |||
101 | PetscConvEstView - Views a PetscConvEst object | |||
102 | ||||
103 | Collective on PetscConvEst | |||
104 | ||||
105 | Input Parameters: | |||
106 | + ce - The PetscConvEst object | |||
107 | - viewer - The PetscViewer object | |||
108 | ||||
109 | Level: beginner | |||
110 | ||||
111 | .keywords: PetscConvEst, convergence, view | |||
112 | .seealso: PetscConvEstCreate(), PetscConvEstGetConvRate() | |||
113 | @*/ | |||
114 | PetscErrorCode PetscConvEstView(PetscConvEst ce, PetscViewer viewer) | |||
115 | { | |||
116 | PetscErrorCode ierr; | |||
117 | ||||
118 | 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] = 118; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
119 | ierr = PetscObjectPrintClassNamePrefixType((PetscObject) ce, viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),119,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
120 | ierr = PetscViewerASCIIPrintf(viewer, "ConvEst with %D levels\n", ce->Nr+1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),120,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
121 | 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); | |||
122 | } | |||
123 | ||||
124 | /*@ | |||
125 | PetscConvEstGetSolver - Gets the solver used to produce discrete solutions | |||
126 | ||||
127 | Not collective | |||
128 | ||||
129 | Input Parameter: | |||
130 | . ce - The PetscConvEst object | |||
131 | ||||
132 | Output Parameter: | |||
133 | . snes - The solver | |||
134 | ||||
135 | Level: intermediate | |||
136 | ||||
137 | .keywords: PetscConvEst, convergence | |||
138 | .seealso: PetscConvEstSetSolver(), PetscConvEstCreate(), PetscConvEstGetConvRate() | |||
139 | @*/ | |||
140 | PetscErrorCode PetscConvEstGetSolver(PetscConvEst ce, SNES *snes) | |||
141 | { | |||
142 | 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] = 142; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
143 | PetscValidHeaderSpecific(ce, PETSC_OBJECT_CLASSID, 1)do { if (!ce) return PetscError(((MPI_Comm)0x44000001),143,__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),143 ,__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),143,__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),143,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1) ; } } while (0); | |||
144 | PetscValidPointer(snes, 2)do { if (!snes) return PetscError(((MPI_Comm)0x44000001),144, __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),144,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
145 | *snes = ce->snes; | |||
146 | 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); | |||
147 | } | |||
148 | ||||
149 | /*@ | |||
150 | PetscConvEstSetSolver - Sets the solver used to produce discrete solutions | |||
151 | ||||
152 | Not collective | |||
153 | ||||
154 | Input Parameters: | |||
155 | + ce - The PetscConvEst object | |||
156 | - snes - The solver | |||
157 | ||||
158 | Level: intermediate | |||
159 | ||||
160 | Note: The solver MUST have an attached DM/DS, so that we know the exact solution | |||
161 | ||||
162 | .keywords: PetscConvEst, convergence | |||
163 | .seealso: PetscConvEstGetSolver(), PetscConvEstCreate(), PetscConvEstGetConvRate() | |||
164 | @*/ | |||
165 | PetscErrorCode PetscConvEstSetSolver(PetscConvEst ce, SNES snes) | |||
166 | { | |||
167 | PetscErrorCode ierr; | |||
168 | ||||
169 | 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] = 169; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
170 | PetscValidHeaderSpecific(ce, PETSC_OBJECT_CLASSID, 1)do { if (!ce) return PetscError(((MPI_Comm)0x44000001),170,__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),170 ,__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),170,__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),170,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1) ; } } while (0); | |||
171 | PetscValidHeaderSpecific(snes, SNES_CLASSID, 2)do { if (!snes) return PetscError(((MPI_Comm)0x44000001),171, __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),171,__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),171,__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),171,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c",62, PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",2) ; } } while (0); | |||
172 | ce->snes = snes; | |||
173 | ierr = SNESGetDM(ce->snes, &ce->idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),173,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
174 | 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); | |||
175 | } | |||
176 | ||||
177 | /*@ | |||
178 | PetscConvEstSetUp - After the solver is specified, we create structures for estimating convergence | |||
179 | ||||
180 | Collective on PetscConvEst | |||
181 | ||||
182 | Input Parameters: | |||
183 | . ce - The PetscConvEst object | |||
184 | ||||
185 | Level: beginner | |||
186 | ||||
187 | .keywords: PetscConvEst, convergence, setup | |||
188 | .seealso: PetscConvEstCreate(), PetscConvEstGetConvRate() | |||
189 | @*/ | |||
190 | PetscErrorCode PetscConvEstSetUp(PetscConvEst ce) | |||
191 | { | |||
192 | PetscDS prob; | |||
193 | PetscInt f; | |||
194 | PetscErrorCode ierr; | |||
195 | ||||
196 | 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] = 196; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
197 | ierr = DMGetDS(ce->idm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),197,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
198 | ierr = PetscDSGetNumFields(prob, &ce->Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),198,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
199 | ierr = PetscMalloc1((ce->Nr+1)*ce->Nf, &ce->errors)PetscMallocA(1,PETSC_FALSE,199,__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),199,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
200 | ierr = PetscMalloc2(ce->Nf, &ce->initGuess, ce->Nf, &ce->exactSol)PetscMallocA(2,PETSC_FALSE,200,__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));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),200,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
201 | for (f = 0; f < ce->Nf; ++f) ce->initGuess[f] = zero_private; | |||
202 | for (f = 0; f < ce->Nf; ++f) { | |||
203 | ierr = PetscDSGetExactSolution(prob, f, &ce->exactSol[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),203,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
204 | 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),204,__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); | |||
205 | } | |||
206 | 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); | |||
207 | } | |||
208 | ||||
209 | static PetscErrorCode PetscConvEstLinearRegression_Private(PetscConvEst ce, PetscInt n, const PetscReal x[], const PetscReal y[], PetscReal *slope, PetscReal *intercept) | |||
210 | { | |||
211 | PetscScalar H[4]; | |||
212 | PetscReal *X, *Y, beta[2]; | |||
213 | PetscInt i, j, k; | |||
214 | PetscErrorCode ierr; | |||
215 | ||||
216 | 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] = 216; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
217 | *slope = *intercept = 0.0; | |||
218 | ierr = PetscMalloc2(n*2, &X, n*2, &Y)PetscMallocA(2,PETSC_FALSE,218,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,(size_t)(n*2)*sizeof(**(&X)),(&X),(size_t)(n*2)*sizeof (**(&Y)),(&Y));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),218,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
219 | for (k = 0; k < n; ++k) { | |||
220 | /* X[n,2] = [1, x] */ | |||
221 | X[k*2+0] = 1.0; | |||
222 | X[k*2+1] = x[k]; | |||
223 | } | |||
224 | /* H = X^T X */ | |||
225 | for (i = 0; i < 2; ++i) { | |||
226 | for (j = 0; j < 2; ++j) { | |||
227 | H[i*2+j] = 0.0; | |||
228 | for (k = 0; k < n; ++k) { | |||
229 | H[i*2+j] += X[k*2+i] * X[k*2+j]; | |||
230 | } | |||
231 | } | |||
232 | } | |||
233 | /* H = (X^T X)^{-1} */ | |||
234 | { | |||
235 | PetscBLASInt two = 2, ipiv[2], info; | |||
236 | PetscScalar work[2]; | |||
237 | ||||
238 | ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),238,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
239 | PetscStackCallBLAS("LAPACKgetrf", LAPACKgetrf_(&two, &two, H, &two, ipiv, &info))do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = "LAPACKgetrf"; petscstack->file[petscstack->currentsize ] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack->line[petscstack->currentsize] = 239; petscstack ->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); dgetrf_(&two, &two, H, &two, ipiv, &info); do { do {PetscErrorCode _7_ierr = PetscMallocValidate(239,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c");do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError(((MPI_Comm )0x44000001),239,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} while(0); 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); } while (0); } while(0); | |||
240 | PetscStackCallBLAS("LAPACKgetri", LAPACKgetri_(&two, H, &two, ipiv, work, &two, &info))do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = "LAPACKgetri"; petscstack->file[petscstack->currentsize ] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c"; petscstack->line[petscstack->currentsize] = 240; petscstack ->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); dgetri_(&two, H, &two, ipiv, work, &two, &info ); do { do {PetscErrorCode _7_ierr = PetscMallocValidate(240, __func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" );do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError( ((MPI_Comm)0x44000001),240,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} while(0); 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); } while (0); } while(0); | |||
241 | ierr = PetscFPTrapPop();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 | } | |||
243 | /* Y = H X^T */ | |||
244 | for (i = 0; i < 2; ++i) { | |||
245 | for (k = 0; k < n; ++k) { | |||
246 | Y[i*n+k] = 0.0; | |||
247 | for (j = 0; j < 2; ++j) { | |||
248 | Y[i*n+k] += PetscRealPart(H[i*2+j])(H[i*2+j]) * X[k*2+j]; | |||
249 | } | |||
250 | } | |||
251 | } | |||
252 | /* beta = Y error = [y-intercept, slope] */ | |||
253 | for (i = 0; i < 2; ++i) { | |||
254 | beta[i] = 0.0; | |||
255 | for (k = 0; k < n; ++k) { | |||
256 | beta[i] += Y[i*n+k] * y[k]; | |||
257 | } | |||
258 | } | |||
259 | ierr = PetscFree2(X, Y)PetscFreeA(2,259,__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),259,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
260 | *intercept = beta[0]; | |||
261 | *slope = beta[1]; | |||
262 | 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); | |||
263 | } | |||
264 | ||||
265 | /*@ | |||
266 | PetscConvEstGetConvRate - Returns an estimate of the convergence rate for the discretization | |||
267 | ||||
268 | Not collective | |||
269 | ||||
270 | Input Parameter: | |||
271 | . ce - The PetscConvEst object | |||
272 | ||||
273 | Output Parameter: | |||
274 | . alpha - The convergence rate for each field | |||
275 | ||||
276 | Note: The convergence rate alpha is defined by | |||
277 | $ || u_h - u_exact || < C h^alpha | |||
278 | where u_h is the discrete solution, and h is a measure of the discretization size. | |||
279 | ||||
280 | We solve a series of problems on refined meshes, calculate an error based upon the exact solution in the DS, | |||
281 | and then fit the result to our model above using linear regression. | |||
282 | ||||
283 | Options database keys: | |||
284 | . -snes_convergence_estimate : Execute convergence estimation and print out the rate | |||
285 | ||||
286 | Level: intermediate | |||
287 | ||||
288 | .keywords: PetscConvEst, convergence | |||
289 | .seealso: PetscConvEstSetSolver(), PetscConvEstCreate(), PetscConvEstGetConvRate() | |||
290 | @*/ | |||
291 | PetscErrorCode PetscConvEstGetConvRate(PetscConvEst ce, PetscReal alpha[]) | |||
292 | { | |||
293 | DM *dm; | |||
294 | PetscObject disc; | |||
295 | MPI_Comm comm; | |||
296 | const char *uname, *dmname; | |||
297 | void *ctx; | |||
298 | Vec u; | |||
299 | PetscReal t = 0.0, *x, *y, slope, intercept; | |||
300 | PetscInt *dof, dim, Nr = ce->Nr, r, f, oldlevel, oldnlev; | |||
| ||||
301 | PetscLogEvent event; | |||
302 | PetscErrorCode ierr; | |||
303 | ||||
304 | 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] = 304; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
305 | ierr = PetscObjectGetComm((PetscObject) ce, &comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),305,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
306 | ierr = DMGetDimension(ce->idm, &dim);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 | ierr = DMGetApplicationContext(ce->idm, &ctx);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 | ierr = DMPlexSetRefinementUniform(ce->idm, PETSC_TRUE);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 | ierr = DMGetRefineLevel(ce->idm, &oldlevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),309,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
310 | ierr = PetscMalloc2((Nr+1), &dm, (Nr+1)*ce->Nf, &dof)PetscMallocA(2,PETSC_FALSE,310,__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),310,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
311 | dm[0] = ce->idm; | |||
312 | for (f = 0; f < ce->Nf; ++f) alpha[f] = 0.0; | |||
313 | /* Loop over meshes */ | |||
314 | ierr = PetscLogEventRegister("ConvEst Error", PETSC_OBJECT_CLASSID, &event);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),314,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
315 | for (r = 0; r <= Nr; ++r) { | |||
316 | PetscLogStage stage; | |||
317 | char stageName[PETSC_MAX_PATH_LEN4096]; | |||
318 | ||||
319 | 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),319,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
320 | ierr = PetscLogStageRegister(stageName, &stage);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 | ierr = PetscLogStagePush(stage);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),321,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
322 | if (r > 0) { | |||
323 | 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),323,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
324 | ierr = DMSetCoarseDM(dm[r], dm[r-1]);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 | ierr = DMCopyDisc(ce->idm, dm[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),325,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
326 | ierr = PetscObjectGetName((PetscObject) dm[r-1], &dmname);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),326,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
327 | ierr = PetscObjectSetName((PetscObject) dm[r], dmname);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 | for (f = 0; f <= ce->Nf; ++f) { | |||
329 | PetscErrorCode (*nspconstr)(DM, PetscInt, MatNullSpace *); | |||
330 | ierr = DMGetNullSpaceConstructor(dm[r-1], f, &nspconstr);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 | ierr = DMSetNullSpaceConstructor(dm[r], f, nspconstr);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),331,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
332 | } | |||
333 | } | |||
334 | ierr = DMViewFromOptions(dm[r], NULL((void*)0), "-conv_dm_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),334,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
335 | /* Create solution */ | |||
336 | ierr = DMCreateGlobalVector(dm[r], &u);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 | ierr = DMGetField(dm[r], 0, NULL((void*)0), &disc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),337,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
338 | ierr = PetscObjectGetName(disc, &uname);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),338,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
339 | ierr = PetscObjectSetName((PetscObject) u, uname);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),339,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
340 | /* Setup solver */ | |||
341 | ierr = SNESReset(ce->snes);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 | ierr = SNESSetDM(ce->snes, dm[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),342,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
343 | ierr = DMPlexSetSNESLocalFEM(dm[r], ctx, ctx, ctx);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 | ierr = SNESSetFromOptions(ce->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),344,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
345 | /* Create initial guess */ | |||
346 | ierr = DMProjectFunction(dm[r], t, ce->initGuess, NULL((void*)0), INSERT_VALUES, u);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),346,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
347 | ierr = SNESSolve(ce->snes, NULL((void*)0), u);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),347,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
348 | 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),348,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
349 | ierr = DMComputeL2FieldDiff(dm[r], t, ce->exactSol, NULL((void*)0), u, &ce->errors[r*ce->Nf]);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 = 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),350,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
351 | for (f = 0; f < ce->Nf; ++f) { | |||
352 | PetscSection s, fs; | |||
353 | PetscInt lsize; | |||
354 | ||||
355 | /* Could use DMGetOutputDM() to add in Dirichlet dofs */ | |||
356 | ierr = DMGetSection(dm[r], &s);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 | ierr = PetscSectionGetField(s, f, &fs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),357,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
358 | ierr = PetscSectionGetConstrainedStorageSize(fs, &lsize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),358,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
359 | 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),359,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
360 | ierr = PetscLogEventSetDof(event, f, dof[r*ce->Nf+f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),360,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
361 | ierr = PetscLogEventSetError(event, f, ce->errors[r*ce->Nf+f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),361,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
362 | } | |||
363 | /* Monitor */ | |||
364 | if (ce->monitor) { | |||
365 | PetscReal *errors = &ce->errors[r*ce->Nf]; | |||
366 | ||||
367 | ierr = PetscPrintf(comm, "L_2 Error: ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),367,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
368 | if (ce->Nf > 1) {ierr = PetscPrintf(comm, "[");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),368,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
369 | for (f = 0; f < ce->Nf; ++f) { | |||
370 | if (f > 0) {ierr = PetscPrintf(comm, ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),370,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
371 | if (errors[f] < 1.0e-11) {ierr = PetscPrintf(comm, "< 1e-11");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),371,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
372 | else {ierr = PetscPrintf(comm, "%g", (double)errors[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),372,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
373 | } | |||
374 | if (ce->Nf > 1) {ierr = PetscPrintf(comm, "]");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),374,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
375 | ierr = PetscPrintf(comm, "\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),375,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
376 | } | |||
377 | if (!r) { | |||
378 | /* PCReset() does not wipe out the level structure */ | |||
379 | KSP ksp; | |||
380 | PC pc; | |||
381 | ||||
382 | ierr = SNESGetKSP(ce->snes, &ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),382,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
383 | ierr = KSPGetPC(ksp, &pc);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 | ierr = PCMGGetLevels(pc, &oldnlev);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),384,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
385 | } | |||
386 | /* Cleanup */ | |||
387 | ierr = VecDestroy(&u);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),387,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
388 | ierr = PetscLogStagePop();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 | } | |||
390 | for (r = 1; r <= Nr; ++r) { | |||
391 | ierr = DMDestroy(&dm[r]);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 | } | |||
393 | /* Fit convergence rate */ | |||
394 | ierr = PetscMalloc2(Nr+1, &x, Nr+1, &y)PetscMallocA(2,PETSC_FALSE,394,__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),394,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
395 | for (f = 0; f < ce->Nf; ++f) { | |||
396 | for (r = 0; r <= Nr; ++r) { | |||
397 | x[r] = PetscLog10Real(dof[r*ce->Nf+f])log10(dof[r*ce->Nf+f]); | |||
398 | y[r] = PetscLog10Real(ce->errors[r*ce->Nf+f])log10(ce->errors[r*ce->Nf+f]); | |||
399 | } | |||
400 | ierr = PetscConvEstLinearRegression_Private(ce, Nr+1, x, y, &slope, &intercept);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),400,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
401 | /* Since h^{-dim} = N, lg err = s lg N + b = -s dim lg h + b */ | |||
402 | alpha[f] = -slope * dim; | |||
403 | } | |||
404 | ierr = PetscFree2(x, y)PetscFreeA(2,404,__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),404,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
405 | ierr = PetscFree2(dm, dof)PetscFreeA(2,405,__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),405,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
406 | /* Restore solver */ | |||
407 | ierr = SNESReset(ce->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),407,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
408 | { | |||
409 | /* PCReset() does not wipe out the level structure */ | |||
410 | KSP ksp; | |||
411 | PC pc; | |||
412 | ||||
413 | ierr = SNESGetKSP(ce->snes, &ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),413,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
414 | ierr = KSPGetPC(ksp, &pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),414,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
415 | ierr = PCMGSetLevels(pc, oldnlev, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),415,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
| ||||
416 | ierr = DMSetRefineLevel(ce->idm, oldlevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),416,__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 */ | |||
417 | } | |||
418 | ierr = SNESSetDM(ce->snes, ce->idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),418,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
419 | ierr = DMPlexSetSNESLocalFEM(ce->idm, ctx, ctx, ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),419,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
420 | ierr = SNESSetFromOptions(ce->snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),420,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
421 | 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); | |||
422 | } | |||
423 | ||||
424 | /*@ | |||
425 | PetscConvEstRateView - Displays the convergence rate to a viewer | |||
426 | ||||
427 | Collective on SNES | |||
428 | ||||
429 | Parameter: | |||
430 | + snes - iterative context obtained from SNESCreate() | |||
431 | . alpha - the convergence rate for each field | |||
432 | - viewer - the viewer to display the reason | |||
433 | ||||
434 | Options Database Keys: | |||
435 | . -snes_convergence_estimate - print the convergence rate | |||
436 | ||||
437 | Level: developer | |||
438 | ||||
439 | .seealso: PetscConvEstGetRate() | |||
440 | @*/ | |||
441 | PetscErrorCode PetscConvEstRateView(PetscConvEst ce, const PetscReal alpha[], PetscViewer viewer) | |||
442 | { | |||
443 | PetscBool isAscii; | |||
444 | PetscErrorCode ierr; | |||
445 | ||||
446 | 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] = 446; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
447 | ierr = PetscObjectTypeCompare((PetscObject) viewer, PETSCVIEWERASCII"ascii", &isAscii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
448 | if (isAscii) { | |||
449 | DM dm; | |||
450 | PetscInt Nf, f; | |||
451 | ||||
452 | ierr = SNESGetDM(ce->snes, &dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),452,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
453 | ierr = DMGetNumFields(dm, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),453,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
454 | ierr = PetscViewerASCIIAddTab(viewer, ((PetscObject) ce)->tablevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),454,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
455 | ierr = PetscViewerASCIIPrintf(viewer, "L_2 convergence rate: ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),455,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
456 | if (Nf > 1) {ierr = PetscViewerASCIIPrintf(viewer, "[");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),456,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
457 | for (f = 0; f < Nf; ++f) { | |||
458 | if (f > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),458,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
459 | ierr = PetscViewerASCIIPrintf(viewer, "%#.2g", (double) alpha[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),459,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
460 | } | |||
461 | if (Nf > 1) {ierr = PetscViewerASCIIPrintf(viewer, "]");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),461,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
462 | ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),462,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
463 | ierr = PetscViewerASCIISubtractTab(viewer, ((PetscObject) ce)->tablevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),463,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/convest.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
464 | } | |||
465 | 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); | |||
466 | } |