Bug Summary

File:ksp/pc/impls/gamg/agg.c
Warning:line 1069, column 12
6th function call argument is an uninitialized value

Annotated Source Code

[?] Use j/k keys for keyboard navigation

1/*
2 GAMG geometric-algebric multigrid PC - Mark Adams 2011
3 */
4
5#include <../src/ksp/pc/impls/gamg/gamg.h> /*I "petscpc.h" I*/
6/* Next line needed to deactivate KSP_Solve logging */
7#include <petsc/private/kspimpl.h>
8#include <petscblaslapack.h>
9#include <petscdm.h>
10
11typedef struct {
12 PetscInt nsmooths;
13 PetscBool sym_graph;
14 PetscInt square_graph;
15} PC_GAMG_AGG;
16
17/*@
18 PCGAMGSetNSmooths - Set number of smoothing steps (1 is typical)
19
20 Not Collective on PC
21
22 Input Parameters:
23. pc - the preconditioner context
24
25 Options Database Key:
26. -pc_gamg_agg_nsmooths <nsmooth, default=1> - number of smoothing steps to use with smooth aggregation
27
28 Level: intermediate
29
30 Concepts: Aggregation AMG preconditioner
31
32.seealso: ()
33@*/
34PetscErrorCode PCGAMGSetNSmooths(PC pc, PetscInt n)
35{
36 PetscErrorCode ierr;
37
38 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 38; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
39 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),39,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(pc,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),39,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(pc))->classid != PC_CLASSID) { if (
((PetscObject)(pc))->classid == -1) return PetscError(((MPI_Comm
)0x44000001),39,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),39,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
40 ierr = PetscTryMethod(pc,"PCGAMGSetNSmooths_C",(PC,PetscInt),(pc,n))0;{ PetscErrorCode (*f)(PC,PetscInt), __ierr; __ierr = PetscObjectQueryFunction_Private
(((PetscObject)pc),("PCGAMGSetNSmooths_C"),(PetscVoidFunction
*)(&f));do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),40,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (f) {__ierr =
(*f)(pc,n);do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),40,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0);} }
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),40,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
41 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)
;
42}
43
44static PetscErrorCode PCGAMGSetNSmooths_AGG(PC pc, PetscInt n)
45{
46 PC_MG *mg = (PC_MG*)pc->data;
47 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
48 PC_GAMG_AGG *pc_gamg_agg = (PC_GAMG_AGG*)pc_gamg->subctx;
49
50 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 50; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
51 pc_gamg_agg->nsmooths = n;
52 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)
;
53}
54
55/*@
56 PCGAMGSetSymGraph - Symmetrize the graph before computing the aggregation. Some algorithms require the graph be symmetric
57
58 Not Collective on PC
59
60 Input Parameters:
61+ pc - the preconditioner context
62. n - PETSC_TRUE or PETSC_FALSE
63
64 Options Database Key:
65. -pc_gamg_sym_graph <true,default=false> - symmetrize the graph before computing the aggregation
66
67 Level: intermediate
68
69 Concepts: Aggregation AMG preconditioner
70
71.seealso: PCGAMGSetSquareGraph()
72@*/
73PetscErrorCode PCGAMGSetSymGraph(PC pc, PetscBool n)
74{
75 PetscErrorCode ierr;
76
77 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 77; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
78 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),78,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(pc,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),78,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(pc))->classid != PC_CLASSID) { if (
((PetscObject)(pc))->classid == -1) return PetscError(((MPI_Comm
)0x44000001),78,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),78,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
79 ierr = PetscTryMethod(pc,"PCGAMGSetSymGraph_C",(PC,PetscBool),(pc,n))0;{ PetscErrorCode (*f)(PC,PetscBool), __ierr; __ierr = PetscObjectQueryFunction_Private
(((PetscObject)pc),("PCGAMGSetSymGraph_C"),(PetscVoidFunction
*)(&f));do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),79,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (f) {__ierr =
(*f)(pc,n);do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),79,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0);} }
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),79,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
80 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)
;
81}
82
83static PetscErrorCode PCGAMGSetSymGraph_AGG(PC pc, PetscBool n)
84{
85 PC_MG *mg = (PC_MG*)pc->data;
86 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
87 PC_GAMG_AGG *pc_gamg_agg = (PC_GAMG_AGG*)pc_gamg->subctx;
88
89 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 89; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
90 pc_gamg_agg->sym_graph = n;
91 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)
;
92}
93
94/*@
95 PCGAMGSetSquareGraph - Square the graph, ie. compute A'*A before aggregating it
96
97 Not Collective on PC
98
99 Input Parameters:
100+ pc - the preconditioner context
101- n - PETSC_TRUE or PETSC_FALSE
102
103 Options Database Key:
104. -pc_gamg_square_graph <n,default = 1> - number of levels to square the graph on before aggregating it
105
106 Notes:
107 Squaring the graph increases the rate of coarsening (aggressive coarsening) and thereby reduces the complexity of the coarse grids, and generally results in slower solver converge rates. Reducing coarse grid complexity reduced the complexity of Galerkin coarse grid construction considerably.
108
109 Level: intermediate
110
111 Concepts: Aggregation AMG preconditioner
112
113.seealso: PCGAMGSetSymGraph(), PCGAMGSetThreshold()
114@*/
115PetscErrorCode PCGAMGSetSquareGraph(PC pc, PetscInt n)
116{
117 PetscErrorCode ierr;
118
119 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 119; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
120 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),120,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(pc,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),120,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(pc))->classid != PC_CLASSID) { if (
((PetscObject)(pc))->classid == -1) return PetscError(((MPI_Comm
)0x44000001),120,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),120,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
121 ierr = PetscTryMethod(pc,"PCGAMGSetSquareGraph_C",(PC,PetscInt),(pc,n))0;{ PetscErrorCode (*f)(PC,PetscInt), __ierr; __ierr = PetscObjectQueryFunction_Private
(((PetscObject)pc),("PCGAMGSetSquareGraph_C"),(PetscVoidFunction
*)(&f));do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),121,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0); if (f) {__ierr =
(*f)(pc,n);do {if (__builtin_expect(!!(__ierr),0)) return PetscError
(((MPI_Comm)0x44000001),121,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,__ierr,PETSC_ERROR_REPEAT," ");} while (0);} }
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),121,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
122 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)
;
123}
124
125static PetscErrorCode PCGAMGSetSquareGraph_AGG(PC pc, PetscInt n)
126{
127 PC_MG *mg = (PC_MG*)pc->data;
128 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
129 PC_GAMG_AGG *pc_gamg_agg = (PC_GAMG_AGG*)pc_gamg->subctx;
130
131 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 131; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
132 pc_gamg_agg->square_graph = n;
133 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)
;
134}
135
136static PetscErrorCode PCSetFromOptions_GAMG_AGG(PetscOptionItems *PetscOptionsObject,PC pc)
137{
138 PetscErrorCode ierr;
139 PC_MG *mg = (PC_MG*)pc->data;
140 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
141 PC_GAMG_AGG *pc_gamg_agg = (PC_GAMG_AGG*)pc_gamg->subctx;
142
143 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 143; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
144 ierr = PetscOptionsHead(PetscOptionsObject,"GAMG-AGG options");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),144,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
145 {
146 ierr = PetscOptionsInt("-pc_gamg_agg_nsmooths","smoothing steps for smoothed aggregation, usually 1","PCGAMGSetNSmooths",pc_gamg_agg->nsmooths,&pc_gamg_agg->nsmooths,NULL)PetscOptionsInt_Private(PetscOptionsObject,"-pc_gamg_agg_nsmooths"
,"smoothing steps for smoothed aggregation, usually 1","PCGAMGSetNSmooths"
,pc_gamg_agg->nsmooths,&pc_gamg_agg->nsmooths,((void
*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),146,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
147 ierr = PetscOptionsBool("-pc_gamg_sym_graph","Set for asymmetric matrices","PCGAMGSetSymGraph",pc_gamg_agg->sym_graph,&pc_gamg_agg->sym_graph,NULL)PetscOptionsBool_Private(PetscOptionsObject,"-pc_gamg_sym_graph"
,"Set for asymmetric matrices","PCGAMGSetSymGraph",pc_gamg_agg
->sym_graph,&pc_gamg_agg->sym_graph,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),147,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
148 ierr = PetscOptionsInt("-pc_gamg_square_graph","Number of levels to square graph for faster coarsening and lower coarse grid complexity","PCGAMGSetSquareGraph",pc_gamg_agg->square_graph,&pc_gamg_agg->square_graph,NULL)PetscOptionsInt_Private(PetscOptionsObject,"-pc_gamg_square_graph"
,"Number of levels to square graph for faster coarsening and lower coarse grid complexity"
,"PCGAMGSetSquareGraph",pc_gamg_agg->square_graph,&pc_gamg_agg
->square_graph,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
149 }
150 ierr = PetscOptionsTail()0; {if (PetscOptionsObject->count != 1) 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);}
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),150,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
151 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)
;
152}
153
154/* -------------------------------------------------------------------------- */
155static PetscErrorCode PCDestroy_GAMG_AGG(PC pc)
156{
157 PetscErrorCode ierr;
158 PC_MG *mg = (PC_MG*)pc->data;
159 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
160
161 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 161; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
162 ierr = PetscFree(pc_gamg->subctx)((*PetscTrFree)((void*)(pc_gamg->subctx),162,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((pc_gamg->subctx) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),162,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
163 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCSetCoordinates_C",NULL)PetscObjectComposeFunction_Private((PetscObject)pc,"PCSetCoordinates_C"
,(PetscVoidFunction)(((void*)0)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),163,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
164 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)
;
165}
166
167/* -------------------------------------------------------------------------- */
168/*
169 PCSetCoordinates_AGG
170 - collective
171
172 Input Parameter:
173 . pc - the preconditioner context
174 . ndm - dimesion of data (used for dof/vertex for Stokes)
175 . a_nloc - number of vertices local
176 . coords - [a_nloc][ndm] - interleaved coordinate data: {x_0, y_0, z_0, x_1, y_1, ...}
177*/
178
179static PetscErrorCode PCSetCoordinates_AGG(PC pc, PetscInt ndm, PetscInt a_nloc, PetscReal *coords)
180{
181 PC_MG *mg = (PC_MG*)pc->data;
182 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
183 PetscErrorCode ierr;
184 PetscInt arrsz,kk,ii,jj,nloc,ndatarows,ndf;
185 Mat mat = pc->pmat;
186
187 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 187; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
188 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),188,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(pc,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),188,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(pc))->classid != PC_CLASSID) { if (
((PetscObject)(pc))->classid == -1) return PetscError(((MPI_Comm
)0x44000001),188,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),188,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
189 PetscValidHeaderSpecific(mat,MAT_CLASSID,1)do { if (!mat) return PetscError(((MPI_Comm)0x44000001),189,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(mat,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(mat))->classid != MAT_CLASSID) { if
(((PetscObject)(mat))->classid == -1) return PetscError((
(MPI_Comm)0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),189,__func__
,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c",
62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
190 nloc = a_nloc;
191
192 /* SA: null space vectors */
193 ierr = MatGetBlockSize(mat, &ndf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),193,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* this does not work for Stokes */
194 if (coords && ndf==1) pc_gamg->data_cell_cols = 1; /* scalar w/ coords and SA (not needed) */
195 else if (coords) {
196 if (ndm > ndf) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"degrees of motion %D > block size %D",ndm,ndf)return PetscError(((MPI_Comm)0x44000001),196,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"degrees of motion %D > block size %D"
,ndm,ndf)
;
197 pc_gamg->data_cell_cols = (ndm==2 ? 3 : 6); /* displacement elasticity */
198 if (ndm != ndf) {
199 if (pc_gamg->data_cell_cols != ndf) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Don't know how to create null space for ndm=%D, ndf=%D. Use MatSetNearNullSpace.",ndm,ndf)return PetscError(((MPI_Comm)0x44000001),199,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"Don't know how to create null space for ndm=%D, ndf=%D. Use MatSetNearNullSpace."
,ndm,ndf)
;
200 }
201 } else pc_gamg->data_cell_cols = ndf; /* no data, force SA with constant null space vectors */
202 pc_gamg->data_cell_rows = ndatarows = ndf;
203 if (pc_gamg->data_cell_cols <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"pc_gamg->data_cell_cols %D <= 0",pc_gamg->data_cell_cols)return PetscError(((MPI_Comm)0x44000001),203,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"pc_gamg->data_cell_cols %D <= 0"
,pc_gamg->data_cell_cols)
;
204 arrsz = nloc*pc_gamg->data_cell_rows*pc_gamg->data_cell_cols;
205
206 /* create data - syntactic sugar that should be refactored at some point */
207 if (!pc_gamg->data || (pc_gamg->data_sz != arrsz)) {
208 ierr = PetscFree(pc_gamg->data)((*PetscTrFree)((void*)(pc_gamg->data),208,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((pc_gamg->data) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),208,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
209 ierr = PetscMalloc1(arrsz+1, &pc_gamg->data)PetscMallocA(1,PETSC_FALSE,209,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(arrsz+1)*sizeof(**(&pc_gamg->data)),(&pc_gamg
->data))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),209,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
210 }
211 /* copy data in - column oriented */
212 for (kk=0; kk<nloc; kk++) {
213 const PetscInt M = nloc*pc_gamg->data_cell_rows; /* stride into data */
214 PetscReal *data = &pc_gamg->data[kk*ndatarows]; /* start of cell */
215 if (pc_gamg->data_cell_cols==1) *data = 1.0;
216 else {
217 /* translational modes */
218 for (ii=0;ii<ndatarows;ii++) {
219 for (jj=0;jj<ndatarows;jj++) {
220 if (ii==jj)data[ii*M + jj] = 1.0;
221 else data[ii*M + jj] = 0.0;
222 }
223 }
224
225 /* rotational modes */
226 if (coords) {
227 if (ndm == 2) {
228 data += 2*M;
229 data[0] = -coords[2*kk+1];
230 data[1] = coords[2*kk];
231 } else {
232 data += 3*M;
233 data[0] = 0.0; data[M+0] = coords[3*kk+2]; data[2*M+0] = -coords[3*kk+1];
234 data[1] = -coords[3*kk+2]; data[M+1] = 0.0; data[2*M+1] = coords[3*kk];
235 data[2] = coords[3*kk+1]; data[M+2] = -coords[3*kk]; data[2*M+2] = 0.0;
236 }
237 }
238 }
239 }
240
241 pc_gamg->data_sz = arrsz;
242 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)
;
243}
244
245typedef PetscInt NState;
246static const NState NOT_DONE=-2;
247static const NState DELETED =-1;
248static const NState REMOVED =-3;
249#define IS_SELECTED(s)(s!=DELETED && s!=NOT_DONE && s!=REMOVED) (s!=DELETED && s!=NOT_DONE && s!=REMOVED)
250
251/* -------------------------------------------------------------------------- */
252/*
253 smoothAggs - greedy grab of with G1 (unsquared graph) -- AIJ specific
254 - AGG-MG specific: clears singletons out of 'selected_2'
255
256 Input Parameter:
257 . Gmat_2 - glabal matrix of graph (data not defined) base (squared) graph
258 . Gmat_1 - base graph to grab with base graph
259 Input/Output Parameter:
260 . aggs_2 - linked list of aggs with gids)
261*/
262static PetscErrorCode smoothAggs(PC pc,Mat Gmat_2, Mat Gmat_1,PetscCoarsenData *aggs_2)
263{
264 PetscErrorCode ierr;
265 PetscBool isMPI;
266 Mat_SeqAIJ *matA_1, *matB_1=0;
267 MPI_Comm comm;
268 PetscInt lid,*ii,*idx,ix,Iend,my0,kk,n,j;
269 Mat_MPIAIJ *mpimat_2 = 0, *mpimat_1=0;
270 const PetscInt nloc = Gmat_2->rmap->n;
271 PetscScalar *cpcol_1_state,*cpcol_2_state,*cpcol_2_par_orig,*lid_parent_gid;
272 PetscInt *lid_cprowID_1;
273 NState *lid_state;
274 Vec ghost_par_orig2;
275
276 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 276; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
277 ierr = PetscObjectGetComm((PetscObject)Gmat_2,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),277,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
278 ierr = MatGetOwnershipRange(Gmat_1,&my0,&Iend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),278,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
279
280 /* get submatrices */
281 ierr = PetscStrbeginswith(((PetscObject)Gmat_1)->type_name,MATMPIAIJ"mpiaij",&isMPI);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),281,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
282 if (isMPI) {
283 /* grab matrix objects */
284 mpimat_2 = (Mat_MPIAIJ*)Gmat_2->data;
285 mpimat_1 = (Mat_MPIAIJ*)Gmat_1->data;
286 matA_1 = (Mat_SeqAIJ*)mpimat_1->A->data;
287 matB_1 = (Mat_SeqAIJ*)mpimat_1->B->data;
288
289 /* force compressed row storage for B matrix in AuxMat */
290 ierr = MatCheckCompressedRow(mpimat_1->B,matB_1->nonzerorowcnt,&matB_1->compressedrow,matB_1->i,Gmat_1->rmap->n,-1.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),290,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
291
292 ierr = PetscMalloc1(nloc, &lid_cprowID_1)PetscMallocA(1,PETSC_FALSE,292,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(nloc)*sizeof(**(&lid_cprowID_1)),(&lid_cprowID_1
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),292,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
293 for (lid = 0; lid < nloc; lid++) lid_cprowID_1[lid] = -1;
294 for (ix=0; ix<matB_1->compressedrow.nrows; ix++) {
295 PetscInt lid = matB_1->compressedrow.rindex[ix];
296 lid_cprowID_1[lid] = ix;
297 }
298 } else {
299 PetscBool isAIJ;
300 ierr = PetscStrbeginswith(((PetscObject)Gmat_1)->type_name,MATSEQAIJ"seqaij",&isAIJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),300,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
301 if (!isAIJ) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_USER,"Require AIJ matrix.")return PetscError(((MPI_Comm)0x44000001),301,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,83,PETSC_ERROR_INITIAL,"Require AIJ matrix.")
;
302 matA_1 = (Mat_SeqAIJ*)Gmat_1->data;
303 lid_cprowID_1 = NULL((void*)0);
304 }
305 if (nloc>0) {
306 if (matB_1 && !matB_1->compressedrow.use) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"matB_1 && !matB_1->compressedrow.use: PETSc bug???")return PetscError(((MPI_Comm)0x44000001),306,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"matB_1 && !matB_1->compressedrow.use: PETSc bug???"
)
;
307 }
308 /* get state of locals and selected gid for deleted */
309 ierr = PetscMalloc2(nloc, &lid_state,nloc, &lid_parent_gid)PetscMallocA(2,PETSC_FALSE,309,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(nloc)*sizeof(**(&lid_state)),(&lid_state),(
size_t)(nloc)*sizeof(**(&lid_parent_gid)),(&lid_parent_gid
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),309,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
310 for (lid = 0; lid < nloc; lid++) {
311 lid_parent_gid[lid] = -1.0;
312 lid_state[lid] = DELETED;
313 }
314
315 /* set lid_state */
316 for (lid = 0; lid < nloc; lid++) {
317 PetscCDIntNd *pos;
318 ierr = PetscCDGetHeadPos(aggs_2,lid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),318,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
319 if (pos) {
320 PetscInt gid1;
321
322 ierr = PetscCDIntNdGetID(pos, &gid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),322,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
323 if (gid1 != lid+my0) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_PLIB,"gid1 %D != lid %D + my0 %D",gid1,lid,my0)return PetscError(((MPI_Comm)0x44000001),323,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"gid1 %D != lid %D + my0 %D",gid1,lid
,my0)
;
324 lid_state[lid] = gid1;
325 }
326 }
327
328 /* map local to selected local, DELETED means a ghost owns it */
329 for (lid=kk=0; lid<nloc; lid++) {
330 NState state = lid_state[lid];
331 if (IS_SELECTED(state)(state!=DELETED && state!=NOT_DONE && state!=
REMOVED)
) {
332 PetscCDIntNd *pos;
333 ierr = PetscCDGetHeadPos(aggs_2,lid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),333,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
334 while (pos) {
335 PetscInt gid1;
336 ierr = PetscCDIntNdGetID(pos, &gid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),336,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
337 ierr = PetscCDGetNextPos(aggs_2,lid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),337,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
338
339 if (gid1 >= my0 && gid1 < Iend) lid_parent_gid[gid1-my0] = (PetscScalar)(lid + my0);
340 }
341 }
342 }
343 /* get 'cpcol_1/2_state' & cpcol_2_par_orig - uses mpimat_1/2->lvec for temp space */
344 if (isMPI) {
345 Vec tempVec;
346 /* get 'cpcol_1_state' */
347 ierr = MatCreateVecs(Gmat_1, &tempVec, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),347,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
348 for (kk=0,j=my0; kk<nloc; kk++,j++) {
349 PetscScalar v = (PetscScalar)lid_state[kk];
350 ierr = VecSetValues(tempVec, 1, &j, &v, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),350,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
351 }
352 ierr = VecAssemblyBegin(tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),352,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
353 ierr = VecAssemblyEnd(tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),353,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
354 ierr = VecScatterBegin(mpimat_1->Mvctx,tempVec, mpimat_1->lvec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),354,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
355 ierr = VecScatterEnd(mpimat_1->Mvctx,tempVec, mpimat_1->lvec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),355,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
356 ierr = VecGetArray(mpimat_1->lvec, &cpcol_1_state);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),356,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
357 /* get 'cpcol_2_state' */
358 ierr = VecScatterBegin(mpimat_2->Mvctx,tempVec, mpimat_2->lvec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),358,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
359 ierr = VecScatterEnd(mpimat_2->Mvctx,tempVec, mpimat_2->lvec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),359,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
360 ierr = VecGetArray(mpimat_2->lvec, &cpcol_2_state);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),360,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
361 /* get 'cpcol_2_par_orig' */
362 for (kk=0,j=my0; kk<nloc; kk++,j++) {
363 PetscScalar v = (PetscScalar)lid_parent_gid[kk];
364 ierr = VecSetValues(tempVec, 1, &j, &v, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),364,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
365 }
366 ierr = VecAssemblyBegin(tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),366,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
367 ierr = VecAssemblyEnd(tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),367,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
368 ierr = VecDuplicate(mpimat_2->lvec, &ghost_par_orig2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),368,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
369 ierr = VecScatterBegin(mpimat_2->Mvctx,tempVec, ghost_par_orig2,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),369,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
370 ierr = VecScatterEnd(mpimat_2->Mvctx,tempVec, ghost_par_orig2,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),370,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
371 ierr = VecGetArray(ghost_par_orig2, &cpcol_2_par_orig);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),371,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
372
373 ierr = VecDestroy(&tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),373,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
374 } /* ismpi */
375
376 /* doit */
377 for (lid=0; lid<nloc; lid++) {
378 NState state = lid_state[lid];
379 if (IS_SELECTED(state)(state!=DELETED && state!=NOT_DONE && state!=
REMOVED)
) {
380 /* steal locals */
381 ii = matA_1->i; n = ii[lid+1] - ii[lid];
382 idx = matA_1->j + ii[lid];
383 for (j=0; j<n; j++) {
384 PetscInt lidj = idx[j], sgid;
385 NState statej = lid_state[lidj];
386 if (statej==DELETED && (sgid=(PetscInt)PetscRealPart(lid_parent_gid[lidj])(lid_parent_gid[lidj])) != lid+my0) { /* steal local */
387 lid_parent_gid[lidj] = (PetscScalar)(lid+my0); /* send this if sgid is not local */
388 if (sgid >= my0 && sgid < Iend) { /* I'm stealing this local from a local sgid */
389 PetscInt hav=0,slid=sgid-my0,gidj=lidj+my0;
390 PetscCDIntNd *pos,*last=NULL((void*)0);
391 /* looking for local from local so id_llist_2 works */
392 ierr = PetscCDGetHeadPos(aggs_2,slid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),392,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
393 while (pos) {
394 PetscInt gid;
395 ierr = PetscCDIntNdGetID(pos, &gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),395,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
396 if (gid == gidj) {
397 if (!last) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"last cannot be null")return PetscError(((MPI_Comm)0x44000001),397,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"last cannot be null")
;
398 ierr = PetscCDRemoveNextNode(aggs_2, slid, last);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),398,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
399 ierr = PetscCDAppendNode(aggs_2, lid, pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),399,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
400 hav = 1;
401 break;
402 } else last = pos;
403
404 ierr = PetscCDGetNextPos(aggs_2,slid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),404,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
405 }
406 if (hav!=1) {
407 if (!hav) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"failed to find adj in 'selected' lists - structurally unsymmetric matrix")return PetscError(((MPI_Comm)0x44000001),407,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"failed to find adj in 'selected' lists - structurally unsymmetric matrix"
)
;
408 SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"found node %D times???",hav)return PetscError(((MPI_Comm)0x44000001),408,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"found node %D times???",hav)
;
409 }
410 } else { /* I'm stealing this local, owned by a ghost */
411 if (sgid != -1) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Have un-symmetric graph (apparently). Use '-%spc_gamg_sym_graph true' to symetrize the graph or '-%spc_gamg_threshold -1' if the matrix is structurally symmetric.",((PetscObject)pc)->prefix,((PetscObject)pc)->prefix)return PetscError(((MPI_Comm)0x44000001),411,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"Have un-symmetric graph (apparently). Use '-%spc_gamg_sym_graph true' to symetrize the graph or '-%spc_gamg_threshold -1' if the matrix is structurally symmetric."
,((PetscObject)pc)->prefix,((PetscObject)pc)->prefix)
;
412 ierr = PetscCDAppendID(aggs_2, lid, lidj+my0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),412,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
413 }
414 }
415 } /* local neighbors */
416 } else if (state == DELETED && lid_cprowID_1) {
417 PetscInt sgidold = (PetscInt)PetscRealPart(lid_parent_gid[lid])(lid_parent_gid[lid]);
418 /* see if I have a selected ghost neighbor that will steal me */
419 if ((ix=lid_cprowID_1[lid]) != -1) {
420 ii = matB_1->compressedrow.i; n = ii[ix+1] - ii[ix];
421 idx = matB_1->j + ii[ix];
422 for (j=0; j<n; j++) {
423 PetscInt cpid = idx[j];
424 NState statej = (NState)PetscRealPart(cpcol_1_state[cpid])(cpcol_1_state[cpid]);
425 if (IS_SELECTED(statej)(statej!=DELETED && statej!=NOT_DONE && statej
!=REMOVED)
&& sgidold != (PetscInt)statej) { /* ghost will steal this, remove from my list */
426 lid_parent_gid[lid] = (PetscScalar)statej; /* send who selected */
427 if (sgidold>=my0 && sgidold<Iend) { /* this was mine */
428 PetscInt hav=0,oldslidj=sgidold-my0;
429 PetscCDIntNd *pos,*last=NULL((void*)0);
430 /* remove from 'oldslidj' list */
431 ierr = PetscCDGetHeadPos(aggs_2,oldslidj,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),431,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
432 while (pos) {
433 PetscInt gid;
434 ierr = PetscCDIntNdGetID(pos, &gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),434,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
435 if (lid+my0 == gid) {
436 /* id_llist_2[lastid] = id_llist_2[flid]; /\* remove lid from oldslidj list *\/ */
437 if (!last) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"last cannot be null")return PetscError(((MPI_Comm)0x44000001),437,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"last cannot be null")
;
438 ierr = PetscCDRemoveNextNode(aggs_2, oldslidj, last);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),438,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
439 /* ghost (PetscScalar)statej will add this later */
440 hav = 1;
441 break;
442 } else last = pos;
443
444 ierr = PetscCDGetNextPos(aggs_2,oldslidj,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),444,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
445 }
446 if (hav!=1) {
447 if (!hav) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"failed to find adj in 'selected' lists - structurally unsymmetric matrix")return PetscError(((MPI_Comm)0x44000001),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"failed to find adj in 'selected' lists - structurally unsymmetric matrix"
)
;
448 SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"found node %D times???",hav)return PetscError(((MPI_Comm)0x44000001),448,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"found node %D times???",hav)
;
449 }
450 } else {
451 /* ghosts remove this later */
452 }
453 }
454 }
455 }
456 } /* selected/deleted */
457 } /* node loop */
458
459 if (isMPI) {
460 PetscScalar *cpcol_2_parent,*cpcol_2_gid;
461 Vec tempVec,ghostgids2,ghostparents2;
462 PetscInt cpid,nghost_2;
463 PCGAMGHashTable gid_cpid;
464
465 ierr = VecGetSize(mpimat_2->lvec, &nghost_2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),465,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
466 ierr = MatCreateVecs(Gmat_2, &tempVec, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),466,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
467
468 /* get 'cpcol_2_parent' */
469 for (kk=0,j=my0; kk<nloc; kk++,j++) {
470 ierr = VecSetValues(tempVec, 1, &j, &lid_parent_gid[kk], INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),470,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
471 }
472 ierr = VecAssemblyBegin(tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),472,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
473 ierr = VecAssemblyEnd(tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),473,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
474 ierr = VecDuplicate(mpimat_2->lvec, &ghostparents2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),474,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
475 ierr = VecScatterBegin(mpimat_2->Mvctx,tempVec, ghostparents2,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),475,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
476 ierr = VecScatterEnd(mpimat_2->Mvctx,tempVec, ghostparents2,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),476,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
477 ierr = VecGetArray(ghostparents2, &cpcol_2_parent);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),477,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
478
479 /* get 'cpcol_2_gid' */
480 for (kk=0,j=my0; kk<nloc; kk++,j++) {
481 PetscScalar v = (PetscScalar)j;
482 ierr = VecSetValues(tempVec, 1, &j, &v, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),482,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
483 }
484 ierr = VecAssemblyBegin(tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),484,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
485 ierr = VecAssemblyEnd(tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),485,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
486 ierr = VecDuplicate(mpimat_2->lvec, &ghostgids2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),486,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
487 ierr = VecScatterBegin(mpimat_2->Mvctx,tempVec, ghostgids2,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),487,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
488 ierr = VecScatterEnd(mpimat_2->Mvctx,tempVec, ghostgids2,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),488,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
489 ierr = VecGetArray(ghostgids2, &cpcol_2_gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),489,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
490 ierr = VecDestroy(&tempVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),490,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
491
492 /* look for deleted ghosts and add to table */
493 ierr = PCGAMGHashTableCreate(2*nghost_2+1, &gid_cpid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),493,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
494 for (cpid = 0; cpid < nghost_2; cpid++) {
495 NState state = (NState)PetscRealPart(cpcol_2_state[cpid])(cpcol_2_state[cpid]);
496 if (state==DELETED) {
497 PetscInt sgid_new = (PetscInt)PetscRealPart(cpcol_2_parent[cpid])(cpcol_2_parent[cpid]);
498 PetscInt sgid_old = (PetscInt)PetscRealPart(cpcol_2_par_orig[cpid])(cpcol_2_par_orig[cpid]);
499 if (sgid_old == -1 && sgid_new != -1) {
500 PetscInt gid = (PetscInt)PetscRealPart(cpcol_2_gid[cpid])(cpcol_2_gid[cpid]);
501 ierr = PCGAMGHashTableAdd(&gid_cpid, gid, cpid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),501,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
502 }
503 }
504 }
505
506 /* look for deleted ghosts and see if they moved - remove it */
507 for (lid=0; lid<nloc; lid++) {
508 NState state = lid_state[lid];
509 if (IS_SELECTED(state)(state!=DELETED && state!=NOT_DONE && state!=
REMOVED)
) {
510 PetscCDIntNd *pos,*last=NULL((void*)0);
511 /* look for deleted ghosts and see if they moved */
512 ierr = PetscCDGetHeadPos(aggs_2,lid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),512,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
513 while (pos) {
514 PetscInt gid;
515 ierr = PetscCDIntNdGetID(pos, &gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),515,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
516
517 if (gid < my0 || gid >= Iend) {
518 ierr = PCGAMGHashTableFind(&gid_cpid, gid, &cpid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),518,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
519 if (cpid != -1) {
520 /* a moved ghost - */
521 /* id_llist_2[lastid] = id_llist_2[flid]; /\* remove 'flid' from list *\/ */
522 ierr = PetscCDRemoveNextNode(aggs_2, lid, last);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),522,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
523 } else last = pos;
524 } else last = pos;
525
526 ierr = PetscCDGetNextPos(aggs_2,lid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),526,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
527 } /* loop over list of deleted */
528 } /* selected */
529 }
530 ierr = PCGAMGHashTableDestroy(&gid_cpid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),530,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
531
532 /* look at ghosts, see if they changed - and it */
533 for (cpid = 0; cpid < nghost_2; cpid++) {
534 PetscInt sgid_new = (PetscInt)PetscRealPart(cpcol_2_parent[cpid])(cpcol_2_parent[cpid]);
535 if (sgid_new >= my0 && sgid_new < Iend) { /* this is mine */
536 PetscInt gid = (PetscInt)PetscRealPart(cpcol_2_gid[cpid])(cpcol_2_gid[cpid]);
537 PetscInt slid_new=sgid_new-my0,hav=0;
538 PetscCDIntNd *pos;
539
540 /* search for this gid to see if I have it */
541 ierr = PetscCDGetHeadPos(aggs_2,slid_new,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),541,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
542 while (pos) {
543 PetscInt gidj;
544 ierr = PetscCDIntNdGetID(pos, &gidj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),544,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
545 ierr = PetscCDGetNextPos(aggs_2,slid_new,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),545,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
546
547 if (gidj == gid) { hav = 1; break; }
548 }
549 if (hav != 1) {
550 /* insert 'flidj' into head of llist */
551 ierr = PetscCDAppendID(aggs_2, slid_new, gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),551,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
552 }
553 }
554 }
555
556 ierr = VecRestoreArray(mpimat_1->lvec, &cpcol_1_state);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),556,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
557 ierr = VecRestoreArray(mpimat_2->lvec, &cpcol_2_state);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),557,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
558 ierr = VecRestoreArray(ghostparents2, &cpcol_2_parent);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),558,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
559 ierr = VecRestoreArray(ghostgids2, &cpcol_2_gid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),559,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
560 ierr = PetscFree(lid_cprowID_1)((*PetscTrFree)((void*)(lid_cprowID_1),560,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((lid_cprowID_1) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),560,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
561 ierr = VecDestroy(&ghostgids2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),561,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
562 ierr = VecDestroy(&ghostparents2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),562,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
563 ierr = VecDestroy(&ghost_par_orig2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),563,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
564 }
565
566 ierr = PetscFree2(lid_state,lid_parent_gid)PetscFreeA(2,566,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,&(lid_state),&(lid_parent_gid))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),566,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
567 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)
;
568}
569
570/* -------------------------------------------------------------------------- */
571/*
572 PCSetData_AGG - called if data is not set with PCSetCoordinates.
573 Looks in Mat for near null space.
574 Does not work for Stokes
575
576 Input Parameter:
577 . pc -
578 . a_A - matrix to get (near) null space out of.
579*/
580static PetscErrorCode PCSetData_AGG(PC pc, Mat a_A)
581{
582 PetscErrorCode ierr;
583 PC_MG *mg = (PC_MG*)pc->data;
584 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
585 MatNullSpace mnull;
586
587 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 587; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
588 ierr = MatGetNearNullSpace(a_A, &mnull);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),588,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
589 if (!mnull) {
590 DM dm;
591 ierr = PCGetDM(pc, &dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),591,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
592 if (!dm) {
593 ierr = MatGetDM(a_A, &dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),593,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
594 }
595 if (dm) {
596 PetscObject deformation;
597 PetscInt Nf;
598
599 ierr = DMGetNumFields(dm, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),599,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
600 if (Nf) {
601 ierr = DMGetField(dm, 0, NULL((void*)0), &deformation);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),601,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
602 ierr = PetscObjectQuery((PetscObject)deformation,"nearnullspace",(PetscObject*)&mnull);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),602,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
603 if (!mnull) {
604 ierr = PetscObjectQuery((PetscObject)deformation,"nullspace",(PetscObject*)&mnull);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),604,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
605 }
606 }
607 }
608 }
609
610 if (!mnull) {
611 PetscInt bs,NN,MM;
612 ierr = MatGetBlockSize(a_A, &bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),612,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
613 ierr = MatGetLocalSize(a_A, &MM, &NN);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),613,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
614 if (MM % bs) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"MM %D must be divisible by bs %D",MM,bs)return PetscError(((MPI_Comm)0x44000001),614,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"MM %D must be divisible by bs %D",MM
,bs)
;
615 ierr = PCSetCoordinates_AGG(pc, bs, MM/bs, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),615,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
616 } else {
617 PetscReal *nullvec;
618 PetscBool has_const;
619 PetscInt i,j,mlocal,nvec,bs;
620 const Vec *vecs; const PetscScalar *v;
621
622 ierr = MatGetLocalSize(a_A,&mlocal,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),622,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
623 ierr = MatNullSpaceGetVecs(mnull, &has_const, &nvec, &vecs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),623,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
624 pc_gamg->data_sz = (nvec+!!has_const)*mlocal;
625 ierr = PetscMalloc1((nvec+!!has_const)*mlocal,&nullvec)PetscMallocA(1,PETSC_FALSE,625,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)((nvec+!!has_const)*mlocal)*sizeof(**(&nullvec))
,(&nullvec))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),625,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
626 if (has_const) for (i=0; i<mlocal; i++) nullvec[i] = 1.0;
627 for (i=0; i<nvec; i++) {
628 ierr = VecGetArrayRead(vecs[i],&v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),628,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
629 for (j=0; j<mlocal; j++) nullvec[(i+!!has_const)*mlocal + j] = PetscRealPart(v[j])(v[j]);
630 ierr = VecRestoreArrayRead(vecs[i],&v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),630,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
631 }
632 pc_gamg->data = nullvec;
633 pc_gamg->data_cell_cols = (nvec+!!has_const);
634 ierr = MatGetBlockSize(a_A, &bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),634,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
635 pc_gamg->data_cell_rows = bs;
636 }
637 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)
;
638}
639
640/* -------------------------------------------------------------------------- */
641/*
642 formProl0
643
644 Input Parameter:
645 . agg_llists - list of arrays with aggregates -- list from selected vertices of aggregate unselected vertices
646 . bs - row block size
647 . nSAvec - column bs of new P
648 . my0crs - global index of start of locals
649 . data_stride - bs*(nloc nodes + ghost nodes) [data_stride][nSAvec]
650 . data_in[data_stride*nSAvec] - local data on fine grid
651 . flid_fgid[data_stride/bs] - make local to global IDs, includes ghosts in 'locals_llist'
652 Output Parameter:
653 . a_data_out - in with fine grid data (w/ghosts), out with coarse grid data
654 . a_Prol - prolongation operator
655*/
656static PetscErrorCode formProl0(PetscCoarsenData *agg_llists,PetscInt bs,PetscInt nSAvec,PetscInt my0crs,PetscInt data_stride,PetscReal data_in[],const PetscInt flid_fgid[],PetscReal **a_data_out,Mat a_Prol)
657{
658 PetscErrorCode ierr;
659 PetscInt Istart,my0,Iend,nloc,clid,flid = 0,aggID,kk,jj,ii,mm,ndone,nSelected,minsz,nghosts,out_data_stride;
660 MPI_Comm comm;
661 PetscMPIInt rank;
662 PetscReal *out_data;
663 PetscCDIntNd *pos;
664 PCGAMGHashTable fgid_flid;
665
666 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 666; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
667 ierr = PetscObjectGetComm((PetscObject)a_Prol,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),667,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
668 ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),668,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
669 ierr = MatGetOwnershipRange(a_Prol, &Istart, &Iend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),669,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
670 nloc = (Iend-Istart)/bs; my0 = Istart/bs;
671 if ((Iend-Istart) % bs) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Iend %D - Istart %D must be divisible by bs %D",Iend,Istart,bs)return PetscError(((MPI_Comm)0x44000001),671,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"Iend %D - Istart %D must be divisible by bs %D"
,Iend,Istart,bs)
;
672 Iend /= bs;
673 nghosts = data_stride/bs - nloc;
674
675 ierr = PCGAMGHashTableCreate(2*nghosts+1, &fgid_flid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),675,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
676 for (kk=0; kk<nghosts; kk++) {
677 ierr = PCGAMGHashTableAdd(&fgid_flid, flid_fgid[nloc+kk], nloc+kk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),677,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
678 }
679
680 /* count selected -- same as number of cols of P */
681 for (nSelected=mm=0; mm<nloc; mm++) {
682 PetscBool ise;
683 ierr = PetscCDEmptyAt(agg_llists, mm, &ise);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),683,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
684 if (!ise) nSelected++;
685 }
686 ierr = MatGetOwnershipRangeColumn(a_Prol, &ii, &jj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),686,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
687 if ((ii/nSAvec) != my0crs) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_PLIB,"ii %D /nSAvec %D != my0crs %D",ii,nSAvec,my0crs)return PetscError(((MPI_Comm)0x44000001),687,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"ii %D /nSAvec %D != my0crs %D",ii,nSAvec
,my0crs)
;
688 if (nSelected != (jj-ii)/nSAvec) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_PLIB,"nSelected %D != (jj %D - ii %D)/nSAvec %D",nSelected,jj,ii,nSAvec)return PetscError(((MPI_Comm)0x44000001),688,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"nSelected %D != (jj %D - ii %D)/nSAvec %D"
,nSelected,jj,ii,nSAvec)
;
689
690 /* aloc space for coarse point data (output) */
691 out_data_stride = nSelected*nSAvec;
692
693 ierr = PetscMalloc1(out_data_stride*nSAvec, &out_data)PetscMallocA(1,PETSC_FALSE,693,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(out_data_stride*nSAvec)*sizeof(**(&out_data)),(
&out_data))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),693,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
694 for (ii=0;ii<out_data_stride*nSAvec;ii++) out_data[ii]=PETSC_MAX_REAL1.7976931348623157e+308;
695 *a_data_out = out_data; /* output - stride nSelected*nSAvec */
696
697 /* find points and set prolongation */
698 minsz = 100;
699 ndone = 0;
700 for (mm = clid = 0; mm < nloc; mm++) {
701 ierr = PetscCDSizeAt(agg_llists, mm, &jj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),701,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
702 if (jj > 0) {
703 const PetscInt lid = mm, cgid = my0crs + clid;
704 PetscInt cids[100]; /* max bs */
705 PetscBLASInt asz =jj,M=asz*bs,N=nSAvec,INFO;
706 PetscBLASInt Mdata=M+((N-M>0) ? N-M : 0),LDA=Mdata,LWORK=N*bs;
707 PetscScalar *qqc,*qqr,*TAU,*WORK;
708 PetscInt *fids;
709 PetscReal *data;
710
711 /* count agg */
712 if (asz<minsz) minsz = asz;
713
714 /* get block */
715 ierr = PetscMalloc5(Mdata*N, &qqc,M*N, &qqr,N, &TAU,LWORK, &WORK,M, &fids)PetscMallocA(5,PETSC_FALSE,715,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(Mdata*N)*sizeof(**(&qqc)),(&qqc),(size_t)(M
*N)*sizeof(**(&qqr)),(&qqr),(size_t)(N)*sizeof(**(&
TAU)),(&TAU),(size_t)(LWORK)*sizeof(**(&WORK)),(&
WORK),(size_t)(M)*sizeof(**(&fids)),(&fids))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),715,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
716
717 aggID = 0;
718 ierr = PetscCDGetHeadPos(agg_llists,lid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),718,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
719 while (pos) {
720 PetscInt gid1;
721 ierr = PetscCDIntNdGetID(pos, &gid1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),721,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
722 ierr = PetscCDGetNextPos(agg_llists,lid,&pos);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),722,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
723
724 if (gid1 >= my0 && gid1 < Iend) flid = gid1 - my0;
725 else {
726 ierr = PCGAMGHashTableFind(&fgid_flid, gid1, &flid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),726,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
727 if (flid < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Cannot find gid1 in table")return PetscError(((MPI_Comm)0x44000001),727,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"Cannot find gid1 in table")
;
728 }
729 /* copy in B_i matrix - column oriented */
730 data = &data_in[flid*bs];
731 for (ii = 0; ii < bs; ii++) {
732 for (jj = 0; jj < N; jj++) {
733 PetscReal d = data[jj*data_stride + ii];
734 qqc[jj*Mdata + aggID*bs + ii] = d;
735 }
736 }
737 /* set fine IDs */
738 for (kk=0; kk<bs; kk++) fids[aggID*bs + kk] = flid_fgid[flid]*bs + kk;
739 aggID++;
740 }
741
742 /* pad with zeros */
743 for (ii = asz*bs; ii < Mdata; ii++) {
744 for (jj = 0; jj < N; jj++, kk++) {
745 qqc[jj*Mdata + ii] = .0;
746 }
747 }
748
749 ndone += aggID;
750 /* QR */
751 ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),751,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
752 PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&Mdata, &N, qqc, &LDA, TAU, WORK, &LWORK, &INFO))do { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = "LAPACKgeqrf"; petscstack->file[petscstack->currentsize
] = "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 752; petscstack
->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
dgeqrf_(&Mdata, &N, qqc, &LDA, TAU, WORK, &LWORK
, &INFO); do { do {PetscErrorCode _7_ierr = PetscMallocValidate
(752,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
);do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError(
((MPI_Comm)0x44000001),752,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.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)
;
753 ierr = PetscFPTrapPop();CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),753,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
754 if (INFO != 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"xGEQRF error")return PetscError(((MPI_Comm)0x44000001),754,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"xGEQRF error")
;
755 /* get R - column oriented - output B_{i+1} */
756 {
757 PetscReal *data = &out_data[clid*nSAvec];
758 for (jj = 0; jj < nSAvec; jj++) {
759 for (ii = 0; ii < nSAvec; ii++) {
760 if (data[jj*out_data_stride + ii] != PETSC_MAX_REAL1.7976931348623157e+308) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"data[jj*out_data_stride + ii] != %e",PETSC_MAX_REAL)return PetscError(((MPI_Comm)0x44000001),760,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"data[jj*out_data_stride + ii] != %e"
,1.7976931348623157e+308)
;
761 if (ii <= jj) data[jj*out_data_stride + ii] = PetscRealPart(qqc[jj*Mdata + ii])(qqc[jj*Mdata + ii]);
762 else data[jj*out_data_stride + ii] = 0.;
763 }
764 }
765 }
766
767 /* get Q - row oriented */
768 PetscStackCallBLAS("LAPACKorgqr",LAPACKorgqr_(&Mdata, &N, &N, qqc, &LDA, TAU, WORK, &LWORK, &INFO))do { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = "LAPACKorgqr"; petscstack->file[petscstack->currentsize
] = "/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 768; petscstack
->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
dorgqr_(&Mdata, &N, &N, qqc, &LDA, TAU, WORK
, &LWORK, &INFO); do { do {PetscErrorCode _7_ierr = PetscMallocValidate
(768,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
);do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError(
((MPI_Comm)0x44000001),768,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.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)
;
769 if (INFO != 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"xORGQR error arg %d",-INFO)return PetscError(((MPI_Comm)0x44000001),769,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"xORGQR error arg %d",-INFO)
;
770
771 for (ii = 0; ii < M; ii++) {
772 for (jj = 0; jj < N; jj++) {
773 qqr[N*ii + jj] = qqc[jj*Mdata + ii];
774 }
775 }
776
777 /* add diagonal block of P0 */
778 for (kk=0; kk<N; kk++) {
779 cids[kk] = N*cgid + kk; /* global col IDs in P0 */
780 }
781 ierr = MatSetValues(a_Prol,M,fids,N,cids,qqr,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),781,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
782 ierr = PetscFree5(qqc,qqr,TAU,WORK,fids)PetscFreeA(5,782,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,&(qqc),&(qqr),&(TAU),&(WORK),&(fids))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),782,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
783 clid++;
784 } /* coarse agg */
785 } /* for all fine nodes */
786 ierr = MatAssemblyBegin(a_Prol,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),786,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
787 ierr = MatAssemblyEnd(a_Prol,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),787,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
788 ierr = PCGAMGHashTableDestroy(&fgid_flid);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),788,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
789 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)
;
790}
791
792static PetscErrorCode PCView_GAMG_AGG(PC pc,PetscViewer viewer)
793{
794 PetscErrorCode ierr;
795 PC_MG *mg = (PC_MG*)pc->data;
796 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
797 PC_GAMG_AGG *pc_gamg_agg = (PC_GAMG_AGG*)pc_gamg->subctx;
798
799 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 799; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
800 ierr = PetscViewerASCIIPrintf(viewer," AGG specific options\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),800,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
801 ierr = PetscViewerASCIIPrintf(viewer," Symmetric graph %s\n",pc_gamg_agg->sym_graph ? "true" : "false");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),801,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
802 ierr = PetscViewerASCIIPrintf(viewer," Number of levels to square graph %D\n",pc_gamg_agg->square_graph);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),802,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
803 ierr = PetscViewerASCIIPrintf(viewer," Number smoothing steps %D\n",pc_gamg_agg->nsmooths);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),803,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
804 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)
;
805}
806
807/* -------------------------------------------------------------------------- */
808/*
809 PCGAMGGraph_AGG
810
811 Input Parameter:
812 . pc - this
813 . Amat - matrix on this fine level
814 Output Parameter:
815 . a_Gmat -
816*/
817static PetscErrorCode PCGAMGGraph_AGG(PC pc,Mat Amat,Mat *a_Gmat)
818{
819 PetscErrorCode ierr;
820 PC_MG *mg = (PC_MG*)pc->data;
821 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
822 const PetscReal vfilter = pc_gamg->threshold[pc_gamg->current_level];
823 PC_GAMG_AGG *pc_gamg_agg = (PC_GAMG_AGG*)pc_gamg->subctx;
824 Mat Gmat;
825 MPI_Comm comm;
826 PetscBool /* set,flg , */ symm;
827
828 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 828; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
829 ierr = PetscObjectGetComm((PetscObject)Amat,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),829,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
830 ierr = PetscLogEventBegin(PC_GAMGGraph_AGG,0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGGraph_AGG].active) ? (*PetscLogPLB)((PC_GAMGGraph_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),830,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
831
832 /* ierr = MatIsSymmetricKnown(Amat, &set, &flg);CHKERRQ(ierr); || !(set && flg) -- this causes lot of symm calls */
833 symm = (PetscBool)(pc_gamg_agg->sym_graph); /* && !pc_gamg_agg->square_graph; */
834
835 ierr = PCGAMGCreateGraph(Amat, &Gmat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),835,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
836 ierr = PCGAMGFilterGraph(&Gmat, vfilter, symm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),836,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
837 *a_Gmat = Gmat;
838 ierr = PetscLogEventEnd(PC_GAMGGraph_AGG,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGGraph_AGG].active) ? (*PetscLogPLE)((PC_GAMGGraph_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),838,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
839 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)
;
840}
841
842/* -------------------------------------------------------------------------- */
843/*
844 PCGAMGCoarsen_AGG
845
846 Input Parameter:
847 . a_pc - this
848 Input/Output Parameter:
849 . a_Gmat1 - graph on this fine level - coarsening can change this (squares it)
850 Output Parameter:
851 . agg_lists - list of aggregates
852*/
853static PetscErrorCode PCGAMGCoarsen_AGG(PC a_pc,Mat *a_Gmat1,PetscCoarsenData **agg_lists)
854{
855 PetscErrorCode ierr;
856 PC_MG *mg = (PC_MG*)a_pc->data;
857 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
858 PC_GAMG_AGG *pc_gamg_agg = (PC_GAMG_AGG*)pc_gamg->subctx;
859 Mat mat,Gmat2, Gmat1 = *a_Gmat1; /* squared graph */
860 IS perm;
861 PetscInt Istart,Iend,Ii,nloc,bs,n,m;
862 PetscInt *permute;
863 PetscBool *bIndexSet;
864 MatCoarsen crs;
865 MPI_Comm comm;
866 PetscMPIInt rank;
867 PetscReal hashfact;
868 PetscInt iSwapIndex;
869 PetscRandom random;
870
871 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 871; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
872 ierr = PetscLogEventBegin(PC_GAMGCoarsen_AGG,0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGCoarsen_AGG].active) ? (*PetscLogPLB)((PC_GAMGCoarsen_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),872,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
873 ierr = PetscObjectGetComm((PetscObject)Gmat1,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),873,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
874 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),874,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
875 ierr = MatGetLocalSize(Gmat1, &n, &m);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),875,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
876 ierr = MatGetBlockSize(Gmat1, &bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),876,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
877 if (bs != 1) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"bs %D must be 1",bs)return PetscError(((MPI_Comm)0x44000001),877,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"bs %D must be 1",bs)
;
878 nloc = n/bs;
879
880 if (pc_gamg->current_level < pc_gamg_agg->square_graph) {
881 ierr = PetscInfo2(a_pc,"Square Graph on level %D of %D to square\n",pc_gamg->current_level+1,pc_gamg_agg->square_graph)PetscInfo_Private(__func__,a_pc,"Square Graph on level %D of %D to square\n"
,pc_gamg->current_level+1,pc_gamg_agg->square_graph)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),881,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
882 ierr = MatTransposeMatMult(Gmat1, Gmat1, MAT_INITIAL_MATRIX, PETSC_DEFAULT-2, &Gmat2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),882,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
883 } else Gmat2 = Gmat1;
884
885 /* get MIS aggs - randomize */
886 ierr = PetscMalloc1(nloc, &permute)PetscMallocA(1,PETSC_FALSE,886,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(nloc)*sizeof(**(&permute)),(&permute))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),886,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
887 ierr = PetscCalloc1(nloc, &bIndexSet)PetscMallocA(1,PETSC_TRUE,887,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(nloc)*sizeof(**(&bIndexSet)),(&bIndexSet))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),887,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
888 for (Ii = 0; Ii < nloc; Ii++) {
889 permute[Ii] = Ii;
890 }
891 ierr = PetscRandomCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001),&random);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),891,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
892 ierr = MatGetOwnershipRange(Gmat1, &Istart, &Iend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),892,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
893 for (Ii = 0; Ii < nloc; Ii++) {
894 ierr = PetscRandomGetValueReal(random,&hashfact);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),894,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
895 iSwapIndex = (PetscInt) (hashfact*nloc)%nloc;
896 if (!bIndexSet[iSwapIndex] && iSwapIndex != Ii) {
897 PetscInt iTemp = permute[iSwapIndex];
898 permute[iSwapIndex] = permute[Ii];
899 permute[Ii] = iTemp;
900 bIndexSet[iSwapIndex] = PETSC_TRUE;
901 }
902 }
903 ierr = PetscFree(bIndexSet)((*PetscTrFree)((void*)(bIndexSet),903,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((bIndexSet) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),903,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
904 ierr = PetscRandomDestroy(&random);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),904,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
905 ierr = ISCreateGeneral(PETSC_COMM_SELF((MPI_Comm)0x44000001), nloc, permute, PETSC_USE_POINTER, &perm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),905,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
906#if defined PETSC_GAMG_USE_LOG
907 ierr = PetscLogEventBegin(petsc_gamg_setup_events[SET4],0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[petsc_gamg_setup_events[SET4]].active) ? (*PetscLogPLB)((petsc_gamg_setup_events
[SET4]),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),
(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),907,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
908#endif
909 ierr = MatCoarsenCreate(comm, &crs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),909,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
910 ierr = MatCoarsenSetFromOptions(crs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),910,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
911 ierr = MatCoarsenSetGreedyOrdering(crs, perm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),911,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
912 ierr = MatCoarsenSetAdjacency(crs, Gmat2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),912,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
913 ierr = MatCoarsenSetStrictAggs(crs, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),913,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
914 ierr = MatCoarsenApply(crs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),914,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
915 ierr = MatCoarsenGetData(crs, agg_lists);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),915,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* output */
916 ierr = MatCoarsenDestroy(&crs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),916,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
917
918 ierr = ISDestroy(&perm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),918,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
919 ierr = PetscFree(permute)((*PetscTrFree)((void*)(permute),919,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((permute) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),919,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
920#if defined PETSC_GAMG_USE_LOG
921 ierr = PetscLogEventEnd(petsc_gamg_setup_events[SET4],0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[petsc_gamg_setup_events[SET4]].active) ? (*PetscLogPLE)((petsc_gamg_setup_events
[SET4]),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),
(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),921,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
922#endif
923
924 /* smooth aggs */
925 if (Gmat2 != Gmat1) {
926 const PetscCoarsenData *llist = *agg_lists;
927 ierr = smoothAggs(a_pc,Gmat2, Gmat1, *agg_lists);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),927,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
928 ierr = MatDestroy(&Gmat1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),928,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
929 *a_Gmat1 = Gmat2; /* output */
930 ierr = PetscCDGetMat(llist, &mat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),930,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
931 if (mat) SETERRQ(comm,PETSC_ERR_ARG_WRONG, "Auxilary matrix with squared graph????")return PetscError(comm,931,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,62,PETSC_ERROR_INITIAL,"Auxilary matrix with squared graph????"
)
;
932 } else {
933 const PetscCoarsenData *llist = *agg_lists;
934 /* see if we have a matrix that takes precedence (returned from MatCoarsenApply) */
935 ierr = PetscCDGetMat(llist, &mat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),935,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
936 if (mat) {
937 ierr = MatDestroy(&Gmat1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),937,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
938 *a_Gmat1 = mat; /* output */
939 }
940 }
941 ierr = PetscLogEventEnd(PC_GAMGCoarsen_AGG,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGCoarsen_AGG].active) ? (*PetscLogPLE)((PC_GAMGCoarsen_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),941,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
942 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)
;
943}
944
945/* -------------------------------------------------------------------------- */
946/*
947 PCGAMGProlongator_AGG
948
949 Input Parameter:
950 . pc - this
951 . Amat - matrix on this fine level
952 . Graph - used to get ghost data for nodes in
953 . agg_lists - list of aggregates
954 Output Parameter:
955 . a_P_out - prolongation operator to the next level
956 */
957static PetscErrorCode PCGAMGProlongator_AGG(PC pc,Mat Amat,Mat Gmat,PetscCoarsenData *agg_lists,Mat *a_P_out)
958{
959 PC_MG *mg = (PC_MG*)pc->data;
960 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
961 const PetscInt col_bs = pc_gamg->data_cell_cols;
962 PetscErrorCode ierr;
963 PetscInt Istart,Iend,nloc,ii,jj,kk,my0,nLocalSelected,bs;
964 Mat Prol;
965 PetscMPIInt rank, size;
966 MPI_Comm comm;
967 PetscReal *data_w_ghost;
1
'data_w_ghost' declared without an initial value
968 PetscInt myCrs0, nbnodes=0, *flid_fgid;
969 MatType mtype;
970
971 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 971; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
972 ierr = PetscObjectGetComm((PetscObject)Amat,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),972,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
973 if (col_bs < 1) SETERRQ(comm,PETSC_ERR_PLIB,"Column bs cannot be less than 1")return PetscError(comm,973,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"Column bs cannot be less than 1")
;
2
Assuming 'col_bs' is >= 1
3
Taking false branch
974 ierr = PetscLogEventBegin(PC_GAMGProlongator_AGG,0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGProlongator_AGG].active) ? (*PetscLogPLB)((PC_GAMGProlongator_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),974,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
975 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),975,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
976 ierr = MPI_Comm_size(comm, &size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),976,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
977 ierr = MatGetOwnershipRange(Amat, &Istart, &Iend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),977,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
978 ierr = MatGetBlockSize(Amat, &bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),978,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
979 nloc = (Iend-Istart)/bs; my0 = Istart/bs;
980 if ((Iend-Istart) % bs) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_PLIB,"(Iend %D - Istart %D) not divisible by bs %D",Iend,Istart,bs)return PetscError(((MPI_Comm)0x44000001),980,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"(Iend %D - Istart %D) not divisible by bs %D"
,Iend,Istart,bs)
;
4
Taking false branch
981
982 /* get 'nLocalSelected' */
983 for (ii=0, nLocalSelected = 0; ii < nloc; ii++) {
5
Assuming 'ii' is >= 'nloc'
6
Loop condition is false. Execution continues on line 991
984 PetscBool ise;
985 /* filter out singletons 0 or 1? */
986 ierr = PetscCDEmptyAt(agg_lists, ii, &ise);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),986,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
987 if (!ise) nLocalSelected++;
988 }
989
990 /* create prolongator, create P matrix */
991 ierr = MatGetType(Amat,&mtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),991,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
992 ierr = MatCreate(comm, &Prol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),992,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
993 ierr = MatSetSizes(Prol,nloc*bs,nLocalSelected*col_bs,PETSC_DETERMINE-1,PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),993,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
994 ierr = MatSetBlockSizes(Prol, bs, col_bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),994,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
995 ierr = MatSetType(Prol, mtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),995,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
996 ierr = MatSeqAIJSetPreallocation(Prol, col_bs, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),996,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
997 ierr = MatMPIAIJSetPreallocation(Prol,col_bs, NULL((void*)0),col_bs, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),997,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
998
999 /* can get all points "removed" */
1000 ierr = MatGetSize(Prol, &kk, &ii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1000,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1001 if (!ii) {
7
Assuming 'ii' is not equal to 0
8
Taking false branch
1002 ierr = PetscInfo(pc,"No selected points on coarse grid\n")PetscInfo_Private(__func__,pc,"No selected points on coarse grid\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1002,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1003 ierr = MatDestroy(&Prol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1003,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1004 *a_P_out = NULL((void*)0); /* out */
1005 ierr = PetscLogEventEnd(PC_GAMGProlongator_AGG,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGProlongator_AGG].active) ? (*PetscLogPLE)((PC_GAMGProlongator_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1005,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1006 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)
;
1007 }
1008 ierr = PetscInfo1(pc,"New grid %D nodes\n",ii/col_bs)PetscInfo_Private(__func__,pc,"New grid %D nodes\n",ii/col_bs
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1008,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1009 ierr = MatGetOwnershipRangeColumn(Prol, &myCrs0, &kk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1009,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1010
1011 if ((kk-myCrs0) % col_bs) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_PLIB,"(kk %D -myCrs0 %D) not divisible by col_bs %D",kk,myCrs0,col_bs)return PetscError(((MPI_Comm)0x44000001),1011,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"(kk %D -myCrs0 %D) not divisible by col_bs %D"
,kk,myCrs0,col_bs)
;
9
Taking false branch
1012 myCrs0 = myCrs0/col_bs;
1013 if ((kk/col_bs-myCrs0) != nLocalSelected) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_PLIB,"(kk %D/col_bs %D - myCrs0 %D) != nLocalSelected %D)",kk,col_bs,myCrs0,nLocalSelected)return PetscError(((MPI_Comm)0x44000001),1013,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"(kk %D/col_bs %D - myCrs0 %D) != nLocalSelected %D)"
,kk,col_bs,myCrs0,nLocalSelected)
;
10
Taking false branch
1014
1015 /* create global vector of data in 'data_w_ghost' */
1016#if defined PETSC_GAMG_USE_LOG
1017 ierr = PetscLogEventBegin(petsc_gamg_setup_events[SET7],0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[petsc_gamg_setup_events[SET7]].active) ? (*PetscLogPLB)((petsc_gamg_setup_events
[SET7]),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),
(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1017,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1018#endif
1019 if (size > 1) { /* */
11
Assuming 'size' is > 1
12
Taking true branch
1020 PetscReal *tmp_gdata,*tmp_ldata,*tp2;
1021 ierr = PetscMalloc1(nloc, &tmp_ldata)PetscMallocA(1,PETSC_FALSE,1021,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(nloc)*sizeof(**(&tmp_ldata)),(&tmp_ldata))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1021,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1022 for (jj = 0; jj < col_bs; jj++) {
13
Loop condition is true. Entering loop body
16
Assuming 'jj' is >= 'col_bs'
17
Loop condition is false. Execution continues on line 1039
1023 for (kk = 0; kk < bs; kk++) {
14
Assuming 'kk' is >= 'bs'
15
Loop condition is false. Execution continues on line 1022
1024 PetscInt ii,stride;
1025 const PetscReal *tp = pc_gamg->data + jj*bs*nloc + kk;
1026 for (ii = 0; ii < nloc; ii++, tp += bs) tmp_ldata[ii] = *tp;
1027
1028 ierr = PCGAMGGetDataWithGhosts(Gmat, 1, tmp_ldata, &stride, &tmp_gdata);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1028,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1029
1030 if (!jj && !kk) { /* now I know how many todal nodes - allocate */
1031 ierr = PetscMalloc1(stride*bs*col_bs, &data_w_ghost)PetscMallocA(1,PETSC_FALSE,1031,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(stride*bs*col_bs)*sizeof(**(&data_w_ghost)),(&
data_w_ghost))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1031,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1032 nbnodes = bs*stride;
1033 }
1034 tp2 = data_w_ghost + jj*bs*stride + kk;
1035 for (ii = 0; ii < stride; ii++, tp2 += bs) *tp2 = tmp_gdata[ii];
1036 ierr = PetscFree(tmp_gdata)((*PetscTrFree)((void*)(tmp_gdata),1036,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((tmp_gdata) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1036,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1037 }
1038 }
1039 ierr = PetscFree(tmp_ldata)((*PetscTrFree)((void*)(tmp_ldata),1039,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((tmp_ldata) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1039,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1040 } else {
1041 nbnodes = bs*nloc;
1042 data_w_ghost = (PetscReal*)pc_gamg->data;
1043 }
1044
1045 /* get P0 */
1046 if (size > 1) {
18
Taking true branch
1047 PetscReal *fid_glid_loc,*fiddata;
1048 PetscInt stride;
1049
1050 ierr = PetscMalloc1(nloc, &fid_glid_loc)PetscMallocA(1,PETSC_FALSE,1050,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(nloc)*sizeof(**(&fid_glid_loc)),(&fid_glid_loc
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1050,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1051 for (kk=0; kk<nloc; kk++) fid_glid_loc[kk] = (PetscReal)(my0+kk);
19
Loop condition is false. Execution continues on line 1052
1052 ierr = PCGAMGGetDataWithGhosts(Gmat, 1, fid_glid_loc, &stride, &fiddata);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1052,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1053 ierr = PetscMalloc1(stride, &flid_fgid)PetscMallocA(1,PETSC_FALSE,1053,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(stride)*sizeof(**(&flid_fgid)),(&flid_fgid)
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1053,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1054 for (kk=0; kk<stride; kk++) flid_fgid[kk] = (PetscInt)fiddata[kk];
20
Assuming 'kk' is >= 'stride'
21
Loop condition is false. Execution continues on line 1055
1055 ierr = PetscFree(fiddata)((*PetscTrFree)((void*)(fiddata),1055,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((fiddata) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1055,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1056
1057 if (stride != nbnodes/bs) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_PLIB,"stride %D != nbnodes %D/bs %D",stride,nbnodes,bs)return PetscError(((MPI_Comm)0x44000001),1057,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,77,PETSC_ERROR_INITIAL,"stride %D != nbnodes %D/bs %D",stride
,nbnodes,bs)
;
22
Taking false branch
1058 ierr = PetscFree(fid_glid_loc)((*PetscTrFree)((void*)(fid_glid_loc),1058,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((fid_glid_loc) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1058,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1059 } else {
1060 ierr = PetscMalloc1(nloc, &flid_fgid)PetscMallocA(1,PETSC_FALSE,1060,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(nloc)*sizeof(**(&flid_fgid)),(&flid_fgid))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1060,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1061 for (kk=0; kk<nloc; kk++) flid_fgid[kk] = my0 + kk;
1062 }
1063#if defined PETSC_GAMG_USE_LOG
1064 ierr = PetscLogEventEnd(petsc_gamg_setup_events[SET7],0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[petsc_gamg_setup_events[SET7]].active) ? (*PetscLogPLE)((petsc_gamg_setup_events
[SET7]),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),
(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1064,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1065 ierr = PetscLogEventBegin(petsc_gamg_setup_events[SET8],0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[petsc_gamg_setup_events[SET8]].active) ? (*PetscLogPLB)((petsc_gamg_setup_events
[SET8]),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),
(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1065,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1066#endif
1067 {
1068 PetscReal *data_out = NULL((void*)0);
1069 ierr = formProl0(agg_lists, bs, col_bs, myCrs0, nbnodes,data_w_ghost, flid_fgid, &data_out, Prol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1069,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
23
6th function call argument is an uninitialized value
1070 ierr = PetscFree(pc_gamg->data)((*PetscTrFree)((void*)(pc_gamg->data),1070,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((pc_gamg->data) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1070,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1071
1072 pc_gamg->data = data_out;
1073 pc_gamg->data_cell_rows = col_bs;
1074 pc_gamg->data_sz = col_bs*col_bs*nLocalSelected;
1075 }
1076#if defined PETSC_GAMG_USE_LOG
1077 ierr = PetscLogEventEnd(petsc_gamg_setup_events[SET8],0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[petsc_gamg_setup_events[SET8]].active) ? (*PetscLogPLE)((petsc_gamg_setup_events
[SET8]),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),
(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1077,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1078#endif
1079 if (size > 1) {ierr = PetscFree(data_w_ghost)((*PetscTrFree)((void*)(data_w_ghost),1079,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((data_w_ghost) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1079,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1080 ierr = PetscFree(flid_fgid)((*PetscTrFree)((void*)(flid_fgid),1080,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
) || ((flid_fgid) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1080,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1081
1082 *a_P_out = Prol; /* out */
1083
1084 ierr = PetscLogEventEnd(PC_GAMGProlongator_AGG,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGProlongator_AGG].active) ? (*PetscLogPLE)((PC_GAMGProlongator_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1084,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1085 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)
;
1086}
1087
1088/* -------------------------------------------------------------------------- */
1089/*
1090 PCGAMGOptProlongator_AGG
1091
1092 Input Parameter:
1093 . pc - this
1094 . Amat - matrix on this fine level
1095 In/Output Parameter:
1096 . a_P - prolongation operator to the next level
1097*/
1098static PetscErrorCode PCGAMGOptProlongator_AGG(PC pc,Mat Amat,Mat *a_P)
1099{
1100 PetscErrorCode ierr;
1101 PC_MG *mg = (PC_MG*)pc->data;
1102 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
1103 PC_GAMG_AGG *pc_gamg_agg = (PC_GAMG_AGG*)pc_gamg->subctx;
1104 PetscInt jj;
1105 Mat Prol = *a_P;
1106 MPI_Comm comm;
1107 KSP eksp;
1108 Vec bb, xx;
1109 PC epc;
1110 PetscReal alpha, emax, emin;
1111 PetscRandom random;
1112
1113 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 1113; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1114 ierr = PetscObjectGetComm((PetscObject)Amat,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1114,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1115 ierr = PetscLogEventBegin(PC_GAMGOptProlongator_AGG,0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGOptProlongator_AGG].active) ? (*PetscLogPLB)((PC_GAMGOptProlongator_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1115,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1116
1117 /* compute maximum value of operator to be used in smoother */
1118 if (0 < pc_gamg_agg->nsmooths) {
1119 ierr = MatCreateVecs(Amat, &bb, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1119,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1120 ierr = MatCreateVecs(Amat, &xx, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1120,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1121 ierr = PetscRandomCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001),&random);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1121,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1122 ierr = VecSetRandom(bb,random);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1122,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1123 ierr = PetscRandomDestroy(&random);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1123,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1124
1125 ierr = KSPCreate(comm,&eksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1125,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1126 ierr = KSPSetErrorIfNotConverged(eksp,pc->erroriffailure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1126,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1127 ierr = KSPSetTolerances(eksp,PETSC_DEFAULT-2,PETSC_DEFAULT-2,PETSC_DEFAULT-2,10);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1127,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1128 ierr = KSPSetNormType(eksp, KSP_NORM_NONE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1128,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1129
1130 ierr = KSPSetInitialGuessNonzero(eksp, PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1130,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1131 ierr = KSPSetOperators(eksp, Amat, Amat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1131,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1132 ierr = KSPSetComputeSingularValues(eksp,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1132,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1133
1134 ierr = KSPGetPC(eksp, &epc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1134,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1135 ierr = PCSetType(epc, PCJACOBI"jacobi");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1135,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* smoother in smoothed agg. */
1136
1137 ierr = KSPSetOptionsPrefix(eksp,((PetscObject)pc)->prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1137,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1138 ierr = KSPAppendOptionsPrefix(eksp, "gamg_est_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1138,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1139 ierr = KSPSetFromOptions(eksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1139,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1140
1141 /* solve - keep stuff out of logging */
1142 ierr = PetscLogEventDeactivate(KSP_Solve);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1142,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1143 ierr = PetscLogEventDeactivate(PC_Apply);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1143,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1144 ierr = KSPSolve(eksp, bb, xx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1144,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1145 ierr = KSPCheckSolve(eksp,pc,xx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1145,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1146 ierr = PetscLogEventActivate(KSP_Solve);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1146,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1147 ierr = PetscLogEventActivate(PC_Apply);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1147,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1148
1149 ierr = KSPComputeExtremeSingularValues(eksp, &emax, &emin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1149,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1150 ierr = PetscInfo3(pc,"Smooth P0: max eigen=%e min=%e PC=%s\n",emax,emin,PCJACOBI)PetscInfo_Private(__func__,pc,"Smooth P0: max eigen=%e min=%e PC=%s\n"
,emax,emin,"jacobi")
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1150,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1151 ierr = VecDestroy(&xx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1151,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1152 ierr = VecDestroy(&bb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1152,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1153 ierr = KSPDestroy(&eksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1153,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1154 }
1155
1156 /* smooth P0 */
1157 for (jj = 0; jj < pc_gamg_agg->nsmooths; jj++) {
1158 Mat tMat;
1159 Vec diag;
1160
1161#if defined PETSC_GAMG_USE_LOG
1162 ierr = PetscLogEventBegin(petsc_gamg_setup_events[SET9],0,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[petsc_gamg_setup_events[SET9]].active) ? (*PetscLogPLB)((petsc_gamg_setup_events
[SET9]),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),
(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1162,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1163#endif
1164
1165 /* smooth P1 := (I - omega/lam D^{-1}A)P0 */
1166 ierr = MatMatMult(Amat, Prol, MAT_INITIAL_MATRIX, PETSC_DEFAULT-2, &tMat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1166,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1167 ierr = MatCreateVecs(Amat, &diag, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1167,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1168 ierr = MatGetDiagonal(Amat, diag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1168,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* effectively PCJACOBI */
1169 ierr = VecReciprocal(diag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1169,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1170 ierr = MatDiagonalScale(tMat, diag, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1170,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1171 ierr = VecDestroy(&diag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1171,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1172 alpha = -1.4/emax;
1173 ierr = MatAYPX(tMat, alpha, Prol, SUBSET_NONZERO_PATTERN);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1173,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1174 ierr = MatDestroy(&Prol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1174,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1175 Prol = tMat;
1176#if defined PETSC_GAMG_USE_LOG
1177 ierr = PetscLogEventEnd(petsc_gamg_setup_events[SET9],0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[petsc_gamg_setup_events[SET9]].active) ? (*PetscLogPLE)((petsc_gamg_setup_events
[SET9]),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),
(PetscObject)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1177,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1178#endif
1179 }
1180 ierr = PetscLogEventEnd(PC_GAMGOptProlongator_AGG,0,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog
->curStage].perfInfo.active && petsc_stageLog->
stageInfo[petsc_stageLog->curStage].eventLog->eventInfo
[PC_GAMGOptProlongator_AGG].active) ? (*PetscLogPLE)((PC_GAMGOptProlongator_AGG
),0,(PetscObject)(0),(PetscObject)(0),(PetscObject)(0),(PetscObject
)(0)) : 0 ))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1180,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1181 *a_P = Prol;
1182 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)
;
1183}
1184
1185/* -------------------------------------------------------------------------- */
1186/*
1187 PCCreateGAMG_AGG
1188
1189 Input Parameter:
1190 . pc -
1191*/
1192PetscErrorCode PCCreateGAMG_AGG(PC pc)
1193{
1194 PetscErrorCode ierr;
1195 PC_MG *mg = (PC_MG*)pc->data;
1196 PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
1197 PC_GAMG_AGG *pc_gamg_agg;
1198
1199 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/gamg/agg.c"
; petscstack->line[petscstack->currentsize] = 1199; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1200 /* create sub context for SA */
1201 ierr = PetscNewLog(pc,&pc_gamg_agg)(PetscMallocA(1,PETSC_TRUE,1201,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,(size_t)(1)*sizeof(**(((&pc_gamg_agg)))),(((&pc_gamg_agg
)))) || PetscLogObjectMemory((PetscObject)pc,sizeof(**(&pc_gamg_agg
))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1201,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1202 pc_gamg->subctx = pc_gamg_agg;
1203
1204 pc_gamg->ops->setfromoptions = PCSetFromOptions_GAMG_AGG;
1205 pc_gamg->ops->destroy = PCDestroy_GAMG_AGG;
1206 /* reset does not do anything; setup not virtual */
1207
1208 /* set internal function pointers */
1209 pc_gamg->ops->graph = PCGAMGGraph_AGG;
1210 pc_gamg->ops->coarsen = PCGAMGCoarsen_AGG;
1211 pc_gamg->ops->prolongator = PCGAMGProlongator_AGG;
1212 pc_gamg->ops->optprolongator = PCGAMGOptProlongator_AGG;
1213 pc_gamg->ops->createdefaultdata = PCSetData_AGG;
1214 pc_gamg->ops->view = PCView_GAMG_AGG;
1215
1216 pc_gamg_agg->square_graph = 1;
1217 pc_gamg_agg->sym_graph = PETSC_FALSE;
1218 pc_gamg_agg->nsmooths = 1;
1219
1220 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCGAMGSetNSmooths_C",PCGAMGSetNSmooths_AGG)PetscObjectComposeFunction_Private((PetscObject)pc,"PCGAMGSetNSmooths_C"
,(PetscVoidFunction)(PCGAMGSetNSmooths_AGG))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1220,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1221 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCGAMGSetSymGraph_C",PCGAMGSetSymGraph_AGG)PetscObjectComposeFunction_Private((PetscObject)pc,"PCGAMGSetSymGraph_C"
,(PetscVoidFunction)(PCGAMGSetSymGraph_AGG))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1221,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1222 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCGAMGSetSquareGraph_C",PCGAMGSetSquareGraph_AGG)PetscObjectComposeFunction_Private((PetscObject)pc,"PCGAMGSetSquareGraph_C"
,(PetscVoidFunction)(PCGAMGSetSquareGraph_AGG))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1222,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1223 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCSetCoordinates_C",PCSetCoordinates_AGG)PetscObjectComposeFunction_Private((PetscObject)pc,"PCSetCoordinates_C"
,(PetscVoidFunction)(PCSetCoordinates_AGG))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1223,__func__,"/sandbox/petsc/petsc.next-tmp/src/ksp/pc/impls/gamg/agg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1224 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)
;
1225}