Bug Summary

File:ksp/pc/impls/telescope/telescope_coarsedm.c
Warning:line 286, column 89
Array access (from variable 'sub_vecs') results in a null pointer dereference

Annotated Source Code

[?] Use j/k keys for keyboard navigation

1
2#include <petsc/private/matimpl.h>
3#include <petsc/private/pcimpl.h>
4#include <petsc/private/dmimpl.h>
5#include <petscksp.h> /*I "petscksp.h" I*/
6#include <petscdm.h>
7#include <petscdmda.h>
8#include <petscdmshell.h>
9
10#include "../src/ksp/pc/impls/telescope/telescope.h"
11
12static PetscBool cited = PETSC_FALSE;
13static const char citation[] =
14"@inproceedings{MaySananRuppKnepleySmith2016,\n"
15" title = {Extreme-Scale Multigrid Components within PETSc},\n"
16" author = {Dave A. May and Patrick Sanan and Karl Rupp and Matthew G. Knepley and Barry F. Smith},\n"
17" booktitle = {Proceedings of the Platform for Advanced Scientific Computing Conference},\n"
18" series = {PASC '16},\n"
19" isbn = {978-1-4503-4126-4},\n"
20" location = {Lausanne, Switzerland},\n"
21" pages = {5:1--5:12},\n"
22" articleno = {5},\n"
23" numpages = {12},\n"
24" url = {http://doi.acm.org/10.1145/2929908.2929913},\n"
25" doi = {10.1145/2929908.2929913},\n"
26" acmid = {2929913},\n"
27" publisher = {ACM},\n"
28" address = {New York, NY, USA},\n"
29" keywords = {GPU, HPC, agglomeration, coarse-level solver, multigrid, parallel computing, preconditioning},\n"
30" year = {2016}\n"
31"}\n";
32
33typedef struct {
34 DM dm_fine,dm_coarse; /* these DM's should be topologically identical but use different communicators */
35 Mat permutation;
36 Vec xp;
37 PetscErrorCode (*fp_dm_field_scatter)(DM,Vec,ScatterMode,DM,Vec);
38 PetscErrorCode (*fp_dm_state_scatter)(DM,ScatterMode,DM);
39 void *dmksp_context_determined;
40 void *dmksp_context_user;
41} PC_Telescope_CoarseDMCtx;
42
43
44PetscErrorCode PCTelescopeSetUp_scatters_CoarseDM(PC pc,PC_Telescope sred,PC_Telescope_CoarseDMCtx *ctx)
45{
46 PetscErrorCode ierr;
47 Vec xred,yred,xtmp,x,xp;
48 VecScatter scatter;
49 IS isin;
50 Mat B;
51 PetscInt m,bs,st,ed;
52 MPI_Comm comm;
53
54 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
; petscstack->line[petscstack->currentsize] = 54; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
55 ierr = PetscObjectGetComm((PetscObject)pc,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),55,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
56 ierr = PCGetOperators(pc,NULL((void*)0),&B);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),56,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
57 ierr = MatCreateVecs(B,&x,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),57,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
58 ierr = MatGetBlockSize(B,&bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),58,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
59 ierr = VecDuplicate(x,&xp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),59,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
60 m = 0;
61 xred = NULL((void*)0);
62 yred = NULL((void*)0);
63 if (PCTelescope_isActiveRank(sred)) {
64 ierr = DMCreateGlobalVector(ctx->dm_coarse,&xred);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),64,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
65 ierr = VecDuplicate(xred,&yred);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),65,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
66 ierr = VecGetOwnershipRange(xred,&st,&ed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),66,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
67 ierr = ISCreateStride(comm,ed-st,st,1,&isin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),67,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
68 ierr = VecGetLocalSize(xred,&m);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),68,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
69 } else {
70 ierr = VecGetOwnershipRange(x,&st,&ed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),70,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
71 ierr = ISCreateStride(comm,0,st,1,&isin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),71,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
72 }
73 ierr = ISSetBlockSize(isin,bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),73,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
74 ierr = VecCreate(comm,&xtmp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),74,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
75 ierr = VecSetSizes(xtmp,m,PETSC_DECIDE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),75,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
76 ierr = VecSetBlockSize(xtmp,bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),76,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
77 ierr = VecSetType(xtmp,((PetscObject)x)->type_name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),77,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
78 ierr = VecScatterCreate(x,isin,xtmp,NULL((void*)0),&scatter);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),78,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
79 sred->xred = xred;
80 sred->yred = yred;
81 sred->isin = isin;
82 sred->scatter = scatter;
83 sred->xtmp = xtmp;
84 ctx->xp = xp;
85 ierr = VecDestroy(&x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),85,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
86 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)
;
87}
88
89PetscErrorCode PCTelescopeSetUp_CoarseDM(PC pc,PC_Telescope sred)
90{
91 PC_Telescope_CoarseDMCtx *ctx;
92 DM dm,dm_coarse = NULL((void*)0);
93 MPI_Comm comm;
94 PetscBool has_perm,has_kspcomputeoperators,using_kspcomputeoperators;
95 PetscErrorCode ierr;
96
97 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
; petscstack->line[petscstack->currentsize] = 97; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
98 ierr = PetscInfo(pc,"PCTelescope: setup (CoarseDM)\n")PetscInfo_Private(__func__,pc,"PCTelescope: setup (CoarseDM)\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),98,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
99 ierr = PetscMalloc1(1,&ctx)PetscMallocA(1,PETSC_FALSE,99,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,(size_t)(1)*sizeof(**(&ctx)),(&ctx))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),99,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
100 ierr = PetscMemzero(ctx,sizeof(PC_Telescope_CoarseDMCtx));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),100,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
101 sred->dm_ctx = (void*)ctx;
102
103 ierr = PetscObjectGetComm((PetscObject)pc,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),103,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
104 ierr = PCGetDM(pc,&dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),104,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
105 ierr = DMGetCoarseDM(dm,&dm_coarse);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),105,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
106 ctx->dm_fine = dm;
107 ctx->dm_coarse = dm_coarse;
108
109 /* attach coarse dm to ksp on sub communicator */
110 if (PCTelescope_isActiveRank(sred)) {
111 ierr = KSPSetDM(sred->ksp,ctx->dm_coarse);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),111,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
112 if (sred->ignore_kspcomputeoperators) {
113 ierr = KSPSetDMActive(sred->ksp,PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),113,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
114 }
115 }
116
117 /* check if there is a method to provide a permutation */
118 has_perm = PETSC_FALSE;
119 has_kspcomputeoperators = PETSC_FALSE;
120 using_kspcomputeoperators = PETSC_FALSE;
121
122 /* if no permutation is provided, we must rely on KSPSetComputeOperators */
123 {
124 PetscErrorCode (*dmfine_kspfunc)(KSP,Mat,Mat,void*) = NULL((void*)0);
125 void *dmfine_kspctx = NULL((void*)0),*dmcoarse_kspctx = NULL((void*)0);
126 void *dmfine_appctx = NULL((void*)0),*dmcoarse_appctx = NULL((void*)0);
127 void *dmfine_shellctx = NULL((void*)0),*dmcoarse_shellctx = NULL((void*)0);
128
129 ierr = DMKSPGetComputeOperators(dm,&dmfine_kspfunc,&dmfine_kspctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),129,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
130 if (dmfine_kspfunc) { has_kspcomputeoperators = PETSC_TRUE; }
131
132 ierr = DMGetApplicationContext(ctx->dm_fine,&dmfine_appctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),132,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
133 ierr = DMShellGetContext(ctx->dm_fine,&dmfine_shellctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),133,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
134
135 /* need to define dmcoarse_kspctx */
136 if (dmfine_kspfunc && !sred->ignore_kspcomputeoperators) {
137
138 ierr = PetscInfo(pc,"PCTelescope: KSPSetComputeOperators fetched from parent DM\n")PetscInfo_Private(__func__,pc,"PCTelescope: KSPSetComputeOperators fetched from parent DM\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),138,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
139 if (PCTelescope_isActiveRank(sred)) {
140 ierr = DMGetApplicationContext(ctx->dm_coarse,&dmcoarse_appctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),140,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
141 ierr = DMShellGetContext(ctx->dm_coarse,&dmcoarse_shellctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),141,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
142 }
143
144 /* Assume that if the fine operator didn't require any context, neither will the coarse */
145 if (!dmfine_kspctx) {
146 dmcoarse_kspctx = NULL((void*)0);
147 ierr = PetscInfo(pc,"PCTelescope: KSPSetComputeOperators using NULL context\n")PetscInfo_Private(__func__,pc,"PCTelescope: KSPSetComputeOperators using NULL context\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),147,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
148 } else {
149
150 ierr = PetscInfo(pc,"PCTelescope: KSPSetComputeOperators detected non-NULL context from parent DM \n")PetscInfo_Private(__func__,pc,"PCTelescope: KSPSetComputeOperators detected non-NULL context from parent DM \n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),150,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
151 if (PCTelescope_isActiveRank(sred)) {
152
153 if (dmfine_kspctx == dmfine_appctx) {
154 dmcoarse_kspctx = dmcoarse_appctx;
155 ierr = PetscInfo(pc,"PCTelescope: KSPSetComputeOperators using context from DM->ApplicationContext\n")PetscInfo_Private(__func__,pc,"PCTelescope: KSPSetComputeOperators using context from DM->ApplicationContext\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),155,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
156 if (!dmcoarse_kspctx) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_USER,"Non NULL dmfine->kspctx == dmfine->appctx. NULL dmcoarse->appctx found. Likely this is an error")return PetscError(((MPI_Comm)0x44000001),156,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,83,PETSC_ERROR_INITIAL,"Non NULL dmfine->kspctx == dmfine->appctx. NULL dmcoarse->appctx found. Likely this is an error"
)
;
157 } else if (dmfine_kspctx == dmfine_shellctx) {
158 dmcoarse_kspctx = dmcoarse_shellctx;
159 ierr = PetscInfo(pc,"PCTelescope: KSPSetComputeOperators using context from DMShell->Context\n")PetscInfo_Private(__func__,pc,"PCTelescope: KSPSetComputeOperators using context from DMShell->Context\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),159,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
160 if (!dmcoarse_kspctx) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_USER,"Non NULL dmfine->kspctx == dmfine.shell->ctx. NULL dmcoarse.shell->ctx found. Likely this is an error")return PetscError(((MPI_Comm)0x44000001),160,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,83,PETSC_ERROR_INITIAL,"Non NULL dmfine->kspctx == dmfine.shell->ctx. NULL dmcoarse.shell->ctx found. Likely this is an error"
)
;
161 }
162 ctx->dmksp_context_determined = dmcoarse_kspctx;
163
164 /* look for user provided method to fetch the context */
165 {
166 PetscErrorCode (*fp_get_coarsedm_context)(DM,void**) = NULL((void*)0);
167 void *dmcoarse_context_user = NULL((void*)0);
168 char dmcoarse_method[PETSC_MAX_PATH_LEN4096];
169
170 ierr = PetscSNPrintf(dmcoarse_method,sizeof(dmcoarse_method),"PCTelescopeGetCoarseDMKSPContext");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),170,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
171 ierr = PetscObjectQueryFunction((PetscObject)ctx->dm_coarse,dmcoarse_method,&fp_get_coarsedm_context)PetscObjectQueryFunction_Private(((PetscObject)ctx->dm_coarse
),(dmcoarse_method),(PetscVoidFunction*)(&fp_get_coarsedm_context
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),171,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
172 if (fp_get_coarsedm_context) {
173 ierr = PetscInfo(pc,"PCTelescope: Found composed method PCTelescopeGetCoarseDMKSPContext from coarse DM\n")PetscInfo_Private(__func__,pc,"PCTelescope: Found composed method PCTelescopeGetCoarseDMKSPContext from coarse DM\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),173,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
174 ierr = fp_get_coarsedm_context(ctx->dm_coarse,&dmcoarse_context_user);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),174,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
175 ctx->dmksp_context_user = dmcoarse_context_user;
176 dmcoarse_kspctx = dmcoarse_context_user;
177 } else {
178 ierr = PetscInfo(pc,"PCTelescope: Failed to find composed method PCTelescopeGetCoarseDMKSPContext from coarse DM\n")PetscInfo_Private(__func__,pc,"PCTelescope: Failed to find composed method PCTelescopeGetCoarseDMKSPContext from coarse DM\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),178,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
179 }
180 }
181
182 if (!dmcoarse_kspctx) {
183 ierr = PetscInfo(pc,"PCTelescope: KSPSetComputeOperators failed to determine the context to use on sub-communicator\n")PetscInfo_Private(__func__,pc,"PCTelescope: KSPSetComputeOperators failed to determine the context to use on sub-communicator\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),183,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
184 SETERRQ(PETSC_COMM_SELF,PETSC_ERR_USER,"Cannot determine which context with use for KSPSetComputeOperators() on sub-communicator")return PetscError(((MPI_Comm)0x44000001),184,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,83,PETSC_ERROR_INITIAL,"Cannot determine which context with use for KSPSetComputeOperators() on sub-communicator"
)
;
185 }
186 }
187 }
188 }
189
190 if (dmfine_kspfunc && !sred->ignore_kspcomputeoperators) {
191 using_kspcomputeoperators = PETSC_TRUE;
192
193 if (PCTelescope_isActiveRank(sred)) {
194 /* sub ksp inherits dmksp_func and context provided by user */
195 ierr = KSPSetComputeOperators(sred->ksp,dmfine_kspfunc,dmcoarse_kspctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),195,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
196 /*ierr = PetscObjectCopyFortranFunctionPointers((PetscObject)dm,(PetscObject)ctx->dmrepart);CHKERRQ(ierr);*/
197 ierr = KSPSetDMActive(sred->ksp,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),197,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
198 }
199 }
200 }
201
202 if (!has_perm && has_kspcomputeoperators && !using_kspcomputeoperators) SETERRQ(comm,PETSC_ERR_SUP,"No method to permute an operator was found on the parent DM. A method for KSPSetComputeOperators() was provided but it was requested to be ignored. Telescope setup cannot proceed")return PetscError(comm,202,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,56,PETSC_ERROR_INITIAL,"No method to permute an operator was found on the parent DM. A method for KSPSetComputeOperators() was provided but it was requested to be ignored. Telescope setup cannot proceed"
)
;
203 if (!has_perm && !has_kspcomputeoperators) SETERRQ(comm,PETSC_ERR_SUP,"No method to permute an operator was found on the parent DM. No method for KSPSetComputeOperators() was provided. Telescope setup cannot proceed")return PetscError(comm,203,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,56,PETSC_ERROR_INITIAL,"No method to permute an operator was found on the parent DM. No method for KSPSetComputeOperators() was provided. Telescope setup cannot proceed"
)
;
204
205 {
206 char dmfine_method[PETSC_MAX_PATH_LEN4096];
207
208 ierr = PetscSNPrintf(dmfine_method,sizeof(dmfine_method),"PCTelescopeFieldScatter");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),208,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
209 ierr = PetscObjectQueryFunction((PetscObject)ctx->dm_fine,dmfine_method,&ctx->fp_dm_field_scatter)PetscObjectQueryFunction_Private(((PetscObject)ctx->dm_fine
),(dmfine_method),(PetscVoidFunction*)(&ctx->fp_dm_field_scatter
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),209,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
210
211 ierr = PetscSNPrintf(dmfine_method,sizeof(dmfine_method),"PCTelescopeStateScatter");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),211,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
212 ierr = PetscObjectQueryFunction((PetscObject)ctx->dm_fine,dmfine_method,&ctx->fp_dm_state_scatter)PetscObjectQueryFunction_Private(((PetscObject)ctx->dm_fine
),(dmfine_method),(PetscVoidFunction*)(&ctx->fp_dm_state_scatter
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),212,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
213 }
214
215 if (ctx->fp_dm_state_scatter) {
216 ierr = PetscInfo(pc,"PCTelescope: Found composed method PCTelescopeStateScatter from parent DM\n")PetscInfo_Private(__func__,pc,"PCTelescope: Found composed method PCTelescopeStateScatter from parent DM\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),216,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
217 } else {
218 ierr = PetscInfo(pc,"PCTelescope: Failed to find composed method PCTelescopeStateScatter from parent DM\n")PetscInfo_Private(__func__,pc,"PCTelescope: Failed to find composed method PCTelescopeStateScatter from parent DM\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),218,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
219 }
220
221 if (ctx->fp_dm_field_scatter) {
222 ierr = PetscInfo(pc,"PCTelescope: Found composed method PCTelescopeFieldScatter from parent DM\n")PetscInfo_Private(__func__,pc,"PCTelescope: Found composed method PCTelescopeFieldScatter from parent DM\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),222,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
223 } else {
224 ierr = PetscInfo(pc,"PCTelescope: Failed to find composed method PCTelescopeFieldScatter from parent DM\n")PetscInfo_Private(__func__,pc,"PCTelescope: Failed to find composed method PCTelescopeFieldScatter from parent DM\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),224,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
225 SETERRQ(comm,PETSC_ERR_SUP,"No method to scatter fields between the parent DM and coarse DM was found. Must call PetscObjectComposeFunction() with the parent DM. Telescope setup cannot proceed")return PetscError(comm,225,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,56,PETSC_ERROR_INITIAL,"No method to scatter fields between the parent DM and coarse DM was found. Must call PetscObjectComposeFunction() with the parent DM. Telescope setup cannot proceed"
)
;
226 }
227
228 /*ierr = PCTelescopeSetUp_permutation_CoarseDM(pc,sred,ctx);CHKERRQ(ierr);*/
229 ierr = PCTelescopeSetUp_scatters_CoarseDM(pc,sred,ctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),229,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
230 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)
;
231}
232
233PetscErrorCode PCApply_Telescope_CoarseDM(PC pc,Vec x,Vec y)
234{
235 PC_Telescope sred = (PC_Telescope)pc->data;
236 PetscErrorCode ierr;
237 Vec xred,yred;
238 PC_Telescope_CoarseDMCtx *ctx;
239
240 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
; petscstack->line[petscstack->currentsize] = 240; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
241 ctx = (PC_Telescope_CoarseDMCtx*)sred->dm_ctx;
242 xred = sred->xred;
243 yred = sred->yred;
244
245 ierr = PetscCitationsRegister(citation,&cited);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),245,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
246
247 if (ctx->fp_dm_state_scatter) {
248 ierr = ctx->fp_dm_state_scatter(ctx->dm_fine,SCATTER_FORWARD,ctx->dm_coarse);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),248,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
249 }
250
251 ierr = ctx->fp_dm_field_scatter(ctx->dm_fine,x,SCATTER_FORWARD,ctx->dm_coarse,xred);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),251,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
252
253 /* solve */
254 if (PCTelescope_isActiveRank(sred)) {
255 ierr = KSPSolve(sred->ksp,xred,yred);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),255,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
256 }
257
258 ierr = ctx->fp_dm_field_scatter(ctx->dm_fine,y,SCATTER_REVERSE,ctx->dm_coarse,yred);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),258,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
259 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)
;
260}
261
262PetscErrorCode PCTelescopeSubNullSpaceCreate_CoarseDM(PC pc,PC_Telescope sred,MatNullSpace nullspace,MatNullSpace *sub_nullspace)
263{
264 PetscErrorCode ierr;
265 PetscBool has_const;
266 PetscInt k,n = 0;
267 const Vec *vecs;
268 Vec *sub_vecs = NULL((void*)0);
6
'sub_vecs' initialized to a null pointer value
269 MPI_Comm subcomm;
270 PC_Telescope_CoarseDMCtx *ctx;
271
272 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
; petscstack->line[petscstack->currentsize] = 272; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
273 ctx = (PC_Telescope_CoarseDMCtx*)sred->dm_ctx;
274 subcomm = sred->subcomm;
275 ierr = MatNullSpaceGetVecs(nullspace,&has_const,&n,&vecs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),275,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
276
277 if (PCTelescope_isActiveRank(sred)) {
7
Taking false branch
278 /* create new vectors */
279 if (n) {
280 ierr = VecDuplicateVecs(sred->xred,n,&sub_vecs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),280,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
281 }
282 }
283
284 /* copy entries */
285 for (k=0; k<n; k++) {
8
Assuming 'k' is < 'n'
9
Loop condition is true. Entering loop body
286 ierr = ctx->fp_dm_field_scatter(ctx->dm_fine,vecs[k],SCATTER_FORWARD,ctx->dm_coarse,sub_vecs[k]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),286,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
10
Array access (from variable 'sub_vecs') results in a null pointer dereference
287 }
288
289 if (PCTelescope_isActiveRank(sred)) {
290 /* create new (near) nullspace for redundant object */
291 ierr = MatNullSpaceCreate(subcomm,has_const,n,sub_vecs,sub_nullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),291,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
292 ierr = VecDestroyVecs(n,&sub_vecs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),292,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
293 }
294 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)
;
295}
296
297PetscErrorCode PCTelescopeMatNullSpaceCreate_CoarseDM(PC pc,PC_Telescope sred,Mat sub_mat)
298{
299 PetscErrorCode ierr;
300 Mat B;
301 PC_Telescope_CoarseDMCtx *ctx;
302
303 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
; petscstack->line[petscstack->currentsize] = 303; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
304 ctx = (PC_Telescope_CoarseDMCtx*)sred->dm_ctx;
305 ierr = PCGetOperators(pc,NULL((void*)0),&B);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),305,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
306 {
307 MatNullSpace nullspace,sub_nullspace;
308 ierr = MatGetNullSpace(B,&nullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),308,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
309 if (nullspace) {
1
Assuming 'nullspace' is null
2
Taking false branch
310 ierr = PetscInfo(pc,"PCTelescope: generating nullspace (CoarseDM)\n")PetscInfo_Private(__func__,pc,"PCTelescope: generating nullspace (CoarseDM)\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),310,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
311 ierr = PCTelescopeSubNullSpaceCreate_CoarseDM(pc,sred,nullspace,&sub_nullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),311,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
312
313 /* attach any user nullspace removal methods and contexts */
314 if (PCTelescope_isActiveRank(sred)) {
315 void *context = NULL((void*)0);
316 if (nullspace->remove && !nullspace->rmctx){
317 ierr = MatNullSpaceSetFunction(sub_nullspace,nullspace->remove,context);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),317,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
318 } else if (nullspace->remove && nullspace->rmctx) {
319 char dmcoarse_method[PETSC_MAX_PATH_LEN4096];
320 PetscErrorCode (*fp_get_coarsedm_context)(DM,void**) = NULL((void*)0);
321
322 ierr = PetscSNPrintf(dmcoarse_method,sizeof(dmcoarse_method),"PCTelescopeGetCoarseDMNullSpaceUserContext");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),322,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
323 ierr = PetscObjectQueryFunction((PetscObject)ctx->dm_coarse,dmcoarse_method,&fp_get_coarsedm_context)PetscObjectQueryFunction_Private(((PetscObject)ctx->dm_coarse
),(dmcoarse_method),(PetscVoidFunction*)(&fp_get_coarsedm_context
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),323,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
324 if (!context) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Propagation of user null-space removal method with non-NULL context requires the coarse DM be composed with a function named \"%s\"",dmcoarse_method)return PetscError(((MPI_Comm)0x44000001),324,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,56,PETSC_ERROR_INITIAL,"Propagation of user null-space removal method with non-NULL context requires the coarse DM be composed with a function named \"%s\""
,dmcoarse_method)
;
325 ierr = MatNullSpaceSetFunction(sub_nullspace,nullspace->remove,context);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),325,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
326 }
327 }
328
329 if (PCTelescope_isActiveRank(sred)) {
330 ierr = MatSetNullSpace(sub_mat,sub_nullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),330,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
331 ierr = MatNullSpaceDestroy(&sub_nullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),331,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
332 }
333 }
334 }
335 {
336 MatNullSpace nearnullspace,sub_nearnullspace;
337 ierr = MatGetNearNullSpace(B,&nearnullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),337,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
338 if (nearnullspace) {
3
Assuming 'nearnullspace' is non-null
4
Taking true branch
339 ierr = PetscInfo(pc,"PCTelescope: generating near nullspace (CoarseDM)\n")PetscInfo_Private(__func__,pc,"PCTelescope: generating near nullspace (CoarseDM)\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),339,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
340 ierr = PCTelescopeSubNullSpaceCreate_CoarseDM(pc,sred,nearnullspace,&sub_nearnullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),340,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
5
Calling 'PCTelescopeSubNullSpaceCreate_CoarseDM'
341
342 /* attach any user nullspace removal methods and contexts */
343 if (PCTelescope_isActiveRank(sred)) {
344 void *context = NULL((void*)0);
345 if (nearnullspace->remove && !nearnullspace->rmctx){
346 ierr = MatNullSpaceSetFunction(sub_nearnullspace,nearnullspace->remove,context);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),346,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
347 } else if (nearnullspace->remove && nearnullspace->rmctx) {
348 char dmcoarse_method[PETSC_MAX_PATH_LEN4096];
349 PetscErrorCode (*fp_get_coarsedm_context)(DM,void**) = NULL((void*)0);
350
351 ierr = PetscSNPrintf(dmcoarse_method,sizeof(dmcoarse_method),"PCTelescopeGetCoarseDMNearNullSpaceUserContext");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),351,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
352 ierr = PetscObjectQueryFunction((PetscObject)ctx->dm_coarse,dmcoarse_method,&fp_get_coarsedm_context)PetscObjectQueryFunction_Private(((PetscObject)ctx->dm_coarse
),(dmcoarse_method),(PetscVoidFunction*)(&fp_get_coarsedm_context
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),352,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
353 if (!context) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Propagation of user near null-space removal method with non-NULL context requires the coarse DM be composed with a function named \"%s\"",dmcoarse_method)return PetscError(((MPI_Comm)0x44000001),353,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,56,PETSC_ERROR_INITIAL,"Propagation of user near null-space removal method with non-NULL context requires the coarse DM be composed with a function named \"%s\""
,dmcoarse_method)
;
354 ierr = MatNullSpaceSetFunction(sub_nearnullspace,nearnullspace->remove,context);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),354,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
355 }
356 }
357
358 if (PCTelescope_isActiveRank(sred)) {
359 ierr = MatSetNearNullSpace(sub_mat,sub_nearnullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),359,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
360 ierr = MatNullSpaceDestroy(&sub_nearnullspace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),360,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
361 }
362 }
363 }
364 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)
;
365}
366
367PetscErrorCode PCReset_Telescope_CoarseDM(PC pc)
368{
369 PetscErrorCode ierr;
370 PC_Telescope sred = (PC_Telescope)pc->data;
371 PC_Telescope_CoarseDMCtx *ctx;
372
373 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
; petscstack->line[petscstack->currentsize] = 373; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
374 ctx = (PC_Telescope_CoarseDMCtx*)sred->dm_ctx;
375 ctx->dm_fine = NULL((void*)0); /* since I did not increment the ref counter we set these to NULL */
376 ctx->dm_coarse = NULL((void*)0); /* since I did not increment the ref counter we set these to NULL */
377 ctx->permutation = NULL((void*)0); /* this will be fetched from the dm so no need to call destroy */
378 ierr = VecDestroy(&ctx->xp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),378,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
379 ctx->fp_dm_field_scatter = NULL((void*)0);
380 ctx->fp_dm_state_scatter = NULL((void*)0);
381 ctx->dmksp_context_determined = NULL((void*)0);
382 ctx->dmksp_context_user = NULL((void*)0);
383 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)
;
384}
385
386PetscErrorCode PCApplyRichardson_Telescope_CoarseDM(PC pc,Vec x,Vec y,Vec w,PetscReal rtol,PetscReal abstol,PetscReal dtol,PetscInt its,PetscBool zeroguess,PetscInt *outits,PCRichardsonConvergedReason *reason)
387{
388 PC_Telescope sred = (PC_Telescope)pc->data;
389 PetscErrorCode ierr;
390 Vec yred = NULL((void*)0);
391 PetscBool default_init_guess_value = PETSC_FALSE;
392 PC_Telescope_CoarseDMCtx *ctx;
393
394 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
; petscstack->line[petscstack->currentsize] = 394; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
395 ctx = (PC_Telescope_CoarseDMCtx*)sred->dm_ctx;
396 yred = sred->yred;
397
398 if (its > 1) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_SUP,"PCApplyRichardson_Telescope_CoarseDM only supports max_it = 1")return PetscError(PetscObjectComm((PetscObject)pc),398,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,56,PETSC_ERROR_INITIAL,"PCApplyRichardson_Telescope_CoarseDM only supports max_it = 1"
)
;
399 *reason = (PCRichardsonConvergedReason)0;
400
401 if (!zeroguess) {
402 ierr = PetscInfo(pc,"PCTelescopeCoarseDM: Scattering y for non-zero-initial guess\n")PetscInfo_Private(__func__,pc,"PCTelescopeCoarseDM: Scattering y for non-zero-initial guess\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),402,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
403
404 ierr = ctx->fp_dm_field_scatter(ctx->dm_fine,y,SCATTER_FORWARD,ctx->dm_coarse,yred);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),404,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
405 }
406
407 if (PCTelescope_isActiveRank(sred)) {
408 ierr = KSPGetInitialGuessNonzero(sred->ksp,&default_init_guess_value);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),408,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
409 if (!zeroguess) ierr = KSPSetInitialGuessNonzero(sred->ksp,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),409,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
410 }
411
412 ierr = PCApply_Telescope_CoarseDM(pc,x,y);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),412,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
413
414 if (PCTelescope_isActiveRank(sred)) {
415 ierr = KSPSetInitialGuessNonzero(sred->ksp,default_init_guess_value);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),415,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/telescope/telescope_coarsedm.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
416 }
417
418 if (!*reason) *reason = PCRICHARDSON_CONVERGED_ITS;
419 *outits = 1;
420 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)
;
421}