Bug Summary

File:ksp/pc/impls/hmg/hmg.c
Warning:line 159, column 3
Value stored to 'ierr' is never read

Annotated Source Code

[?] Use j/k keys for keyboard navigation

1#include <petscdm.h>
2#include <petscctable.h>
3#include <petsc/private/matimpl.h>
4#include <petsc/private/pcmgimpl.h>
5#include <petsc/private/pcimpl.h> /*I "petscpc.h" I*/
6
7typedef struct {
8 PC innerpc; /* A MG inner PC (Hypre or PCGAMG) to setup interpolations and coarse operators */
9 char* innerpctype; /* PCGAMG or PCHYPRE */
10 PetscBool reuseinterp; /* A flag indicates if or not to reuse the interpolations */
11 PetscBool subcoarsening;
12 PetscBool usematmaij;
13} PC_HMG;
14
15PetscErrorCode PCSetFromOptions_HMG(PetscOptionItems*,PC);
16PetscErrorCode PCReset_MG(PC);
17
18static PetscErrorCode PCHMGExtractSubMatrix_Private(Mat pmat,Mat *submat,MatReuse reuse,PetscInt blocksize)
19{
20 IS isrow;
21 PetscErrorCode ierr;
22 PetscInt rstart,rend;
23 MPI_Comm comm;
24
25 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 25; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
26 ierr = PetscObjectGetComm((PetscObject)pmat,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),26,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
27 ierr = MatGetOwnershipRange(pmat,&rstart,&rend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),27,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
28 if ((rend-rstart)%blocksize != 0) SETERRQ3(comm,PETSC_ERR_ARG_INCOMP,"Block size %d is inconsisent for [%d, %d) \n",blocksize,rstart,rend)return PetscError(comm,28,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,75,PETSC_ERROR_INITIAL,"Block size %d is inconsisent for [%d, %d) \n"
,blocksize,rstart,rend)
;
29 ierr = ISCreateStride(comm,(rend-rstart)/blocksize,rstart,blocksize,&isrow);
30 ierr = MatCreateSubMatrix(pmat,isrow,isrow,reuse,submat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),30,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
31 ierr = ISDestroy(&isrow);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),31,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
32 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)
;
33}
34
35static PetscErrorCode PCHMGExpandInterpolation_Private(Mat subinterp, Mat *interp, PetscInt blocksize)
36{
37 PetscInt subrstart,subrend,subrowsize,subcolsize,subcstart,subcend,rowsize,colsize;
38 PetscInt subrow,row,nz,*d_nnz,*o_nnz,i,j,dnz,onz,max_nz,*indices;
39 const PetscInt *idx;
40 const PetscScalar *values;
41 PetscErrorCode ierr;
42 MPI_Comm comm;
43
44 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 44; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
45 ierr = PetscObjectGetComm((PetscObject)subinterp,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),45,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
46 ierr = MatGetOwnershipRange(subinterp,&subrstart,&subrend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),46,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
47 subrowsize = subrend-subrstart;
48 rowsize = subrowsize*blocksize;
49 ierr = PetscCalloc2(rowsize,&d_nnz,rowsize,&o_nnz)PetscMallocA(2,PETSC_TRUE,49,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,(size_t)(rowsize)*sizeof(**(&d_nnz)),(&d_nnz),(size_t
)(rowsize)*sizeof(**(&o_nnz)),(&o_nnz))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),49,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
50 ierr = MatGetOwnershipRangeColumn(subinterp,&subcstart,&subcend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),50,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
51 subcolsize = subcend - subcstart;
52 colsize = subcolsize*blocksize;
53 max_nz = 0;
54 for (subrow=subrstart;subrow<subrend;subrow++) {
55 ierr = MatGetRow(subinterp,subrow,&nz,&idx,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),55,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
56 if (max_nz<nz) max_nz = nz;
57 dnz = 0; onz = 0;
58 for (i=0;i<nz;i++) {
59 if(idx[i]>=subcstart && idx[i]<subcend) dnz++;
60 else onz++;
61 }
62 for (i=0;i<blocksize;i++) {
63 d_nnz[(subrow-subrstart)*blocksize+i] = dnz;
64 o_nnz[(subrow-subrstart)*blocksize+i] = onz;
65 }
66 ierr = MatRestoreRow(subinterp,subrow,&nz,&idx,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),66,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
67 }
68 ierr = MatCreateAIJ(comm,rowsize,colsize,PETSC_DETERMINE-1,PETSC_DETERMINE-1,0,d_nnz,0,o_nnz,interp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),68,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
69 ierr = MatSetOption(*interp,MAT_IGNORE_OFF_PROC_ENTRIES,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),69,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
70 ierr = MatSetOption(*interp,MAT_IGNORE_ZERO_ENTRIES,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),70,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
71 ierr = MatSetOption(*interp,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),71,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
72 ierr = MatSetFromOptions(*interp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),72,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
73
74 ierr = MatSetUp(*interp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),74,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
75 ierr = PetscFree2(d_nnz,o_nnz)PetscFreeA(2,75,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,&(d_nnz),&(o_nnz))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),75,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
76 ierr = PetscMalloc1(max_nz,&indices)PetscMallocA(1,PETSC_FALSE,76,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,(size_t)(max_nz)*sizeof(**(&indices)),(&indices))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),76,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
77 for (subrow=subrstart; subrow<subrend; subrow++) {
78 ierr = MatGetRow(subinterp,subrow,&nz,&idx,&values);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),78,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
79 for (i=0;i<blocksize;i++) {
80 row = subrow*blocksize+i;
81 for (j=0;j<nz;j++) {
82 indices[j] = idx[j]*blocksize+i;
83 }
84 ierr = MatSetValues(*interp,1,&row,nz,indices,values,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),84,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
85 }
86 ierr = MatRestoreRow(subinterp,subrow,&nz,&idx,&values);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),86,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
87 }
88 ierr = PetscFree(indices)((*PetscTrFree)((void*)(indices),88,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
) || ((indices) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),88,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
89 ierr = MatAssemblyBegin(*interp,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),89,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
90 ierr = MatAssemblyEnd(*interp,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),90,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
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
94PetscErrorCode PCSetUp_HMG(PC pc)
95{
96 PetscErrorCode ierr;
97 Mat PA, submat;
98 PC_MG *mg = (PC_MG*)pc->data;
99 PC_HMG *hmg = (PC_HMG*) mg->innerctx;
100 MPI_Comm comm;
101 PetscInt level;
102 PetscInt num_levels;
103 Mat *operators,*interpolations;
104 PetscInt blocksize;
105 const char *prefix;
106 PCMGGalerkinType galerkin;
107
108 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 108; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
109 ierr = PetscObjectGetComm((PetscObject)pc,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),109,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
110 if (pc->setupcalled) {
111 if (hmg->reuseinterp) {
112 /* If we did not use Galerkin in the last call or we have a different sparsity pattern now,
113 * we have to build from scratch
114 * */
115 ierr = PCMGGetGalerkin(pc,&galerkin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),115,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
116 if (galerkin == PC_MG_GALERKIN_NONE || pc->flag != SAME_NONZERO_PATTERN) pc->setupcalled = PETSC_FALSE;
117 ierr = PCMGSetGalerkin(pc,PC_MG_GALERKIN_PMAT);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),117,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
118 ierr = PCSetUp_MG(pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),118,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
119 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)
;
120 } else {
121 ierr = PCReset_MG(pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),121,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
122 pc->setupcalled = PETSC_FALSE;
123 }
124 }
125
126 /* Create an inner PC (GAMG or HYPRE) */
127 if (!hmg->innerpc) {
128 ierr = PCCreate(comm,&hmg->innerpc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),128,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
129 /* If users do not set an inner pc type, we need to set a default value */
130 if (!hmg->innerpctype) {
131 /* If hypre is available, use hypre, otherwise, use gamg */
132#if PETSC_HAVE_HYPRE
133 ierr = PetscStrallocpy(PCHYPRE"hypre",&(hmg->innerpctype));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),133,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
134#else
135 ierr = PetscStrallocpy(PCGAMG"gamg",&(hmg->innerpctype));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),135,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
136#endif
137 }
138 ierr = PCSetType(hmg->innerpc,hmg->innerpctype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),138,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
139 }
140 ierr = PCGetOperators(pc,NULL((void*)0),&PA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),140,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
141 /* Users need to correctly set a block size of matrix in order to use subspace coarsening */
142 ierr = MatGetBlockSize(PA,&blocksize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),142,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
143 if (blocksize<=1) hmg->subcoarsening = PETSC_FALSE;
144 /* Extract a submatrix for constructing subinterpolations */
145 if (hmg->subcoarsening) {
146 ierr = PCHMGExtractSubMatrix_Private(PA,&submat,MAT_INITIAL_MATRIX,blocksize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),146,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
147 PA = submat;
148 }
149 ierr = PCSetOperators(hmg->innerpc,PA,PA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),149,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
150 if (hmg->subcoarsening) {
151 ierr = MatDestroy(&PA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),151,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
152 }
153 /* Setup inner PC correctly. During this step, matrix will be coarsened */
154 ierr = PCSetUseAmat(hmg->innerpc,PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),154,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
155 ierr = PetscObjectGetOptionsPrefix((PetscObject)pc,&prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),155,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
156 ierr = PetscObjectSetOptionsPrefix((PetscObject)hmg->innerpc,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),156,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
157 ierr = PetscObjectAppendOptionsPrefix((PetscObject)hmg->innerpc,"hmg_inner_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),157,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
158 ierr = PCSetFromOptions(hmg->innerpc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),158,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
159 ierr = PCSetUp(hmg->innerpc);
Value stored to 'ierr' is never read
160
161 /* Obtain interpolations IN PLACE. For BoomerAMG, (I,J,data) is reused to avoid memory overhead */
162 ierr = PCGetInterpolations(hmg->innerpc,&num_levels,&interpolations);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),162,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
163 /* We can reuse the coarse operators when we do the full space coarsening */
164 if (!hmg->subcoarsening) {
165 ierr = PCGetCoarseOperators(hmg->innerpc,&num_levels,&operators);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),165,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
166 }
167
168 ierr = PCDestroy(&hmg->innerpc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),168,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
169 hmg->innerpc = 0;
170 ierr = PCMGSetLevels_MG(pc,num_levels,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),170,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
171 /* Set coarse matrices and interpolations to PCMG */
172 for (level=num_levels-1; level>0; level--) {
173 Mat P=0, pmat=0;
174 Vec b, x,r;
175 if (hmg->subcoarsening) {
176 if (hmg->usematmaij) {
177 ierr = MatCreateMAIJ(interpolations[level-1],blocksize,&P);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),177,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
178 ierr = MatDestroy(&interpolations[level-1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),178,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
179 } else {
180 /* Grow interpolation. In the future, we should use MAIJ */
181 ierr = PCHMGExpandInterpolation_Private(interpolations[level-1],&P,blocksize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),181,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
182 ierr = MatDestroy(&interpolations[level-1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),182,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
183 }
184 } else {
185 P = interpolations[level-1];
186 }
187 ierr = MatCreateVecs(P,&b,&r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),187,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
188 ierr = PCMGSetInterpolation(pc,level,P);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),188,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
189 ierr = PCMGSetRestriction(pc,level,P);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),189,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
190 ierr = MatDestroy(&P);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),190,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
191 /* We reuse the matrices when we do not do subspace coarsening */
192 if ((level-1)>=0 && !hmg->subcoarsening) {
193 pmat = operators[level-1];
194 ierr = PCMGSetOperators(pc,level-1,pmat,pmat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),194,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
195 ierr = MatDestroy(&pmat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),195,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
196 }
197 ierr = PCMGSetRhs(pc,level-1,b);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),197,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
198
199 ierr = PCMGSetR(pc,level,r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),199,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
200 ierr = VecDestroy(&r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),200,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
201
202 ierr = VecDuplicate(b,&x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),202,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
203 ierr = PCMGSetX(pc,level-1,x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),203,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
204 ierr = VecDestroy(&x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),204,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
205 ierr = VecDestroy(&b);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),205,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
206 }
207 ierr = PetscFree(interpolations)((*PetscTrFree)((void*)(interpolations),207,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
) || ((interpolations) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),207,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
208 if (!hmg->subcoarsening) {
209 ierr = PetscFree(operators)((*PetscTrFree)((void*)(operators),209,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
) || ((operators) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),209,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
210 }
211 /* Turn Galerkin off when we already have coarse operators */
212 ierr = PCMGSetGalerkin(pc,hmg->subcoarsening ? PC_MG_GALERKIN_PMAT:PC_MG_GALERKIN_NONE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),212,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
213 ierr = PCSetDM(pc,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),213,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
214 ierr = PCSetUseAmat(pc,PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),214,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
215 ierr = PetscObjectOptionsBegin((PetscObject)pc)0; do { PetscOptionItems PetscOptionsObjectBase; PetscOptionItems
*PetscOptionsObject = &PetscOptionsObjectBase; PetscOptionsObject
->options = ((PetscObject)(PetscObject)pc)->options; for
(PetscOptionsObject->count=(PetscOptionsPublish?-1:1); PetscOptionsObject
->count<2; PetscOptionsObject->count++) { PetscErrorCode
_5_ierr = PetscObjectOptionsBegin_Private(PetscOptionsObject
,(PetscObject)pc);do {if (__builtin_expect(!!(_5_ierr),0)) return
PetscError(((MPI_Comm)0x44000001),215,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),215,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
216 ierr = PCSetFromOptions_MG(PetscOptionsObject,pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),216,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* should be called in PCSetFromOptions_HMG(), but cannot be called prior to PCMGSetLevels() */
217 ierr = PetscOptionsEnd()_5_ierr = PetscOptionsEnd_Private(PetscOptionsObject);do {if (
__builtin_expect(!!(_5_ierr),0)) return PetscError(((MPI_Comm
)0x44000001),217,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);}} while (0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),217,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
218 ierr = PCSetUp_MG(pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),218,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
219 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)
;
220}
221
222PetscErrorCode PCDestroy_HMG(PC pc)
223{
224 PetscErrorCode ierr;
225 PC_MG *mg = (PC_MG*)pc->data;
226 PC_HMG *hmg = (PC_HMG*) mg->innerctx;
227
228 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 228; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
229 ierr = PCDestroy(&hmg->innerpc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),229,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
230 ierr = PetscFree(hmg->innerpctype)((*PetscTrFree)((void*)(hmg->innerpctype),230,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
) || ((hmg->innerpctype) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),230,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
231 ierr = PetscFree(hmg)((*PetscTrFree)((void*)(hmg),231,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
) || ((hmg) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),231,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
232 ierr = PCDestroy_MG(pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),232,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
233
234 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCHMGSetReuseInterpolation_C",NULL)PetscObjectComposeFunction_Private((PetscObject)pc,"PCHMGSetReuseInterpolation_C"
,(PetscVoidFunction)(((void*)0)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),234,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
235 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCHMGSetUseSubspaceCoarsening_C",NULL)PetscObjectComposeFunction_Private((PetscObject)pc,"PCHMGSetUseSubspaceCoarsening_C"
,(PetscVoidFunction)(((void*)0)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),235,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
236 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCHMGSetInnerPCType_C",NULL)PetscObjectComposeFunction_Private((PetscObject)pc,"PCHMGSetInnerPCType_C"
,(PetscVoidFunction)(((void*)0)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),236,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
237 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)
;
238}
239
240PetscErrorCode PCView_HMG(PC pc,PetscViewer viewer)
241{
242 PC_MG *mg = (PC_MG*)pc->data;
243 PC_HMG *hmg = (PC_HMG*) mg->innerctx;
244 PetscErrorCode ierr;
245 PetscBool iascii;
246
247 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 247; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
248 ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII"ascii",&iascii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),248,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
249 if (iascii) {
250 ierr = PetscViewerASCIIPrintf(viewer," Reuse interpolation: %s\n",hmg->reuseinterp? "true":"false");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),250,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
251 ierr = PetscViewerASCIIPrintf(viewer," Use subspace coarsening: %s\n",hmg->subcoarsening? "true":"false");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),251,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
252 ierr = PetscViewerASCIIPrintf(viewer," Inner PC type: %s \n",hmg->innerpctype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),252,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
253 }
254 ierr = PCView_MG(pc,viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),254,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
255 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)
;
256}
257
258PetscErrorCode PCSetFromOptions_HMG(PetscOptionItems *PetscOptionsObject,PC pc)
259{
260 PetscErrorCode ierr;
261 PC_MG *mg = (PC_MG*)pc->data;
262 PC_HMG *hmg = (PC_HMG*) mg->innerctx;
263
264 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 264; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
265 ierr = PetscOptionsHead(PetscOptionsObject,"HMG");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),265,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
266 ierr = PetscOptionsBool("-pc_hmg_reuse_interpolation","Reuse the interpolation operators when possible (cheaper, weaker when matrix entries change a lot)","None",hmg->reuseinterp,&hmg->reuseinterp,NULL)PetscOptionsBool_Private(PetscOptionsObject,"-pc_hmg_reuse_interpolation"
,"Reuse the interpolation operators when possible (cheaper, weaker when matrix entries change a lot)"
,"None",hmg->reuseinterp,&hmg->reuseinterp,((void*)
0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),266,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
267 ierr = PetscOptionsBool("-pc_hmg_use_subspace_coarsening","Use the subspace coarsening to compute the interpolations","None",hmg->subcoarsening,&hmg->subcoarsening,NULL)PetscOptionsBool_Private(PetscOptionsObject,"-pc_hmg_use_subspace_coarsening"
,"Use the subspace coarsening to compute the interpolations",
"None",hmg->subcoarsening,&hmg->subcoarsening,((void
*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),267,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
268 ierr = PetscOptionsBool("-pc_hmg_use_matmaij","Use MatMAIJ store interpolation for saving memory","None",hmg->usematmaij,&hmg->usematmaij,NULL)PetscOptionsBool_Private(PetscOptionsObject,"-pc_hmg_use_matmaij"
,"Use MatMAIJ store interpolation for saving memory","None",hmg
->usematmaij,&hmg->usematmaij,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),268,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
269 ierr = PetscOptionsTail()0; do {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);} while(0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),269,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
270 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)
;
271}
272
273static PetscErrorCode PCHMGSetReuseInterpolation_HMG(PC pc, PetscBool reuse)
274{
275 PC_MG *mg = (PC_MG*)pc->data;
276 PC_HMG *hmg = (PC_HMG*) mg->innerctx;
277
278 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 278; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
279 hmg->reuseinterp = reuse;
280 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)
;
281}
282
283/*MC
284 PCHMGSetReuseInterpolation - Reuse interpolation matrices in HMG
285
286 Logically Collective on PC
287
288 Input Parameters:
289+ pc - the HMG context
290- reuse - True indicates that HMG will reuse the interpolations
291
292 Options Database Keys:
293+ -pc_hmg_reuse_interpolation <true | false> - Whether or not to reuse the interpolations. If true, it potentially save the compute time.
294
295 Level: beginner
296
297.keywords: HMG, multigrid, interpolation, reuse, set
298
299.seealso: PCHMG
300M*/
301PetscErrorCode PCHMGSetReuseInterpolation(PC pc, PetscBool reuse)
302{
303 PetscErrorCode ierr;
304
305 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 305; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
306 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),306,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",85,PETSC_ERROR_INITIAL
,"Null Object: Parameter # %d",1); if (!PetscCheckPointer(pc,
PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),306,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.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),306,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",64,PETSC_ERROR_INITIAL
,"Object already free: Parameter # %d",1); else return PetscError
(((MPI_Comm)0x44000001),306,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
307 ierr = PetscUseMethod(pc,"PCHMGSetReuseInterpolation_C",(PC,PetscBool),(pc,reuse))0; do { PetscErrorCode (*_7_f)(PC,PetscBool), _7_ierr; _7_ierr
= PetscObjectQueryFunction_Private(((PetscObject)(pc)),("PCHMGSetReuseInterpolation_C"
),(PetscVoidFunction*)(&_7_f));do {if (__builtin_expect(!
!(_7_ierr),0)) return PetscError(((MPI_Comm)0x44000001),307,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",_7_ierr
,PETSC_ERROR_REPEAT," ");} while (0); if (_7_f) {_7_ierr = (*
_7_f)(pc,reuse);do {if (__builtin_expect(!!(_7_ierr),0)) return
PetscError(((MPI_Comm)0x44000001),307,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} else return PetscError
(PetscObjectComm((PetscObject)(pc)),307,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,56,PETSC_ERROR_INITIAL,"Cannot locate function %s in object"
,"PCHMGSetReuseInterpolation_C"); } while(0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),307,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
308 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)
;
309}
310
311static PetscErrorCode PCHMGSetUseSubspaceCoarsening_HMG(PC pc, PetscBool subspace)
312{
313 PC_MG *mg = (PC_MG*)pc->data;
314 PC_HMG *hmg = (PC_HMG*) mg->innerctx;
315
316 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 316; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
317 hmg->subcoarsening = subspace;
318 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)
;
319}
320
321/*MC
322 PCHMGSetUseSubspaceCoarsening - Use subspace coarsening in HMG
323
324 Logically Collective on PC
325
326 Input Parameters:
327+ pc - the HMG context
328- reuse - True indicates that HMG will use the subspace coarsening
329
330 Options Database Keys:
331+ -pc_hmg_use_subspace_coarsening <true | false> - Whether or not to use subspace coarsening (that is, coarsen a submatrix).
332
333 Level: beginner
334
335.keywords: HMG, multigrid, interpolation, subspace, coarsening
336
337.seealso: PCHMG
338M*/
339PetscErrorCode PCHMGSetUseSubspaceCoarsening(PC pc, PetscBool subspace)
340{
341 PetscErrorCode ierr;
342
343 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 343; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
344 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),344,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",85,PETSC_ERROR_INITIAL
,"Null Object: Parameter # %d",1); if (!PetscCheckPointer(pc,
PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),344,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.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),344,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",64,PETSC_ERROR_INITIAL
,"Object already free: Parameter # %d",1); else return PetscError
(((MPI_Comm)0x44000001),344,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
345 ierr = PetscUseMethod(pc,"PCHMGSetUseSubspaceCoarsening_C",(PC,PetscBool),(pc,subspace))0; do { PetscErrorCode (*_7_f)(PC,PetscBool), _7_ierr; _7_ierr
= PetscObjectQueryFunction_Private(((PetscObject)(pc)),("PCHMGSetUseSubspaceCoarsening_C"
),(PetscVoidFunction*)(&_7_f));do {if (__builtin_expect(!
!(_7_ierr),0)) return PetscError(((MPI_Comm)0x44000001),345,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",_7_ierr
,PETSC_ERROR_REPEAT," ");} while (0); if (_7_f) {_7_ierr = (*
_7_f)(pc,subspace);do {if (__builtin_expect(!!(_7_ierr),0)) return
PetscError(((MPI_Comm)0x44000001),345,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} else return PetscError
(PetscObjectComm((PetscObject)(pc)),345,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,56,PETSC_ERROR_INITIAL,"Cannot locate function %s in object"
,"PCHMGSetUseSubspaceCoarsening_C"); } while(0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),345,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
346 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)
;
347}
348
349static PetscErrorCode PCHMGSetInnerPCType_HMG(PC pc, PCType type)
350{
351 PC_MG *mg = (PC_MG*)pc->data;
352 PC_HMG *hmg = (PC_HMG*) mg->innerctx;
353 PetscErrorCode ierr;
354
355 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 355; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
356 ierr = PetscStrallocpy(type,&(hmg->innerpctype));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),356,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
357 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
358}
359
360/*MC
361 PCHMGSetInnerPCType - Set an inner PC type
362
363 Logically Collective on PC
364
365 Input Parameters:
366+ pc - the HMG context
367- type - <hypre, gamg> coarsening algorithm
368
369 Options Database Keys:
370+ -hmg_inner_pc_type <hypre, gamg> - What method is used to coarsen matrix
371
372 Level: beginner
373
374.keywords: HMG, multigrid, interpolation, coarsening
375
376.seealso: PCHMG, PCType
377M*/
378PetscErrorCode PCHMGSetInnerPCType(PC pc, PCType type)
379{
380 PetscErrorCode ierr;
381
382 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 382; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
383 PetscValidHeaderSpecific(pc,PC_CLASSID,1)do { if (!pc) return PetscError(((MPI_Comm)0x44000001),383,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",85,PETSC_ERROR_INITIAL
,"Null Object: Parameter # %d",1); if (!PetscCheckPointer(pc,
PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001),383,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.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),383,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",64,PETSC_ERROR_INITIAL
,"Object already free: Parameter # %d",1); else return PetscError
(((MPI_Comm)0x44000001),383,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
384 ierr = PetscUseMethod(pc,"PCHMGSetInnerPCType_C",(PC,PCType),(pc,type))0; do { PetscErrorCode (*_7_f)(PC,PCType), _7_ierr; _7_ierr =
PetscObjectQueryFunction_Private(((PetscObject)(pc)),("PCHMGSetInnerPCType_C"
),(PetscVoidFunction*)(&_7_f));do {if (__builtin_expect(!
!(_7_ierr),0)) return PetscError(((MPI_Comm)0x44000001),384,__func__
,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c",_7_ierr
,PETSC_ERROR_REPEAT," ");} while (0); if (_7_f) {_7_ierr = (*
_7_f)(pc,type);do {if (__builtin_expect(!!(_7_ierr),0)) return
PetscError(((MPI_Comm)0x44000001),384,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} else return PetscError
(PetscObjectComm((PetscObject)(pc)),384,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,56,PETSC_ERROR_INITIAL,"Cannot locate function %s in object"
,"PCHMGSetInnerPCType_C"); } while(0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),384,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
385 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)
;
386}
387
388/*MC
389 PCHMG - Hybrid of PETSc preconditioners (such as ASM, BJacobi, SOR, etc.) and Hypre BoomerAMG, GAMG or other multilevel methods. BoomerAMG, GAMG
390 or other multilevel methods is used to coarsen matrix and generate a sequence of coarse matrices and interpolations. The matrices and
391 interpolations are employed to construct PCMG, and then any available PETSc preconditioners can be chosen as smoothers and the coarse solver.
392
393 Options Database Keys:
394+ -pc_hmg_reuse_interpolation <true | false> - Whether or not to reuse the interpolations. If true, it potentially save the compute time.
395. -pc_hmg_use_subspace_coarsening <true | false> - Whether or not to use subspace coarsening (that is, coarsen a submatrix).
396. -hmg_inner_pc_type <hypre, gamg, ...> - What method is used to coarsen matrix
397- -pc_hmg_use_matmaij <true | false> - Whether or not to use MatMAIJ for multicomponent problems for saving memory
398
399
400 Notes:
401 For multicomponent problems, we can just coarsen one submatrix associated with one particular component. In this way, the preconditioner setup
402 time is significantly reduced. One typical use case is neutron transport equations. There are many variables on each mesh vertex due to the
403 of angle and energy. Each variable, in fact, corresponds to the same PDEs but with different material properties.
404
405 Level: beginner
406
407 Concepts: Hybrid of ASM and MG, Subspace Coarsening
408
409 References:
410+ 1. - Fande Kong, Yaqi Wang, Derek R Gaston, Cody J Permann, Andrew E Slaughter, Alexander D Lindsay, Richard C Martineau, A highly parallel multilevel
411 Newton-Krylov-Schwarz method with subspace-based coarsening and partition-based balancing for the multigroup neutron transport equations on
412 3D unstructured meshes, arXiv preprint arXiv:1903.03659, 2019
413
414.seealso: PCCreate(), PCSetType(), PCType, PC, PCMG, PCHYPRE, PCHMG, PCGetCoarseOperators(), PCGetInterpolations(), PCHMGSetReuseInterpolation(), PCHMGSetUseSubspaceCoarsening(),
415 PCHMGSetInnerPCType()
416
417M*/
418PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PCCreate_HMG(PC pc)
419{
420 PetscErrorCode ierr;
421 PC_HMG *hmg;
422 PC_MG *mg;
423
424 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"; petscstack
->line[petscstack->currentsize] = 424; petscstack->petscroutine
[petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize
++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE
|| petscstack->hotdepth); } ; } while (0); ; } while (0)
;
425 /* if type was previously mg; must manually destroy it because call to PCSetType(pc,PCMG) will not destroy it */
426 if (pc->ops->destroy) {
427 ierr = (*pc->ops->destroy)(pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),427,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
428 pc->data = 0;
429 }
430 ierr = PetscFree(((PetscObject)pc)->type_name)((*PetscTrFree)((void*)(((PetscObject)pc)->type_name),430,
__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
) || ((((PetscObject)pc)->type_name) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),430,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
431
432 ierr = PCSetType(pc,PCMG"mg");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),432,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
433 ierr = PetscObjectChangeTypeName((PetscObject)pc, PCHMG"hmg");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),433,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
434 ierr = PetscNew(&hmg)PetscMallocA(1,PETSC_TRUE,434,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,(size_t)(1)*sizeof(**((&hmg))),((&hmg)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),434,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
435
436 mg = (PC_MG*) pc->data;
437 mg->innerctx = hmg;
438 hmg->reuseinterp = PETSC_FALSE;
439 hmg->subcoarsening = PETSC_FALSE;
440 hmg->usematmaij = PETSC_TRUE;
441 hmg->innerpc = NULL((void*)0);
442
443 pc->ops->setfromoptions = PCSetFromOptions_HMG;
444 pc->ops->view = PCView_HMG;
445 pc->ops->destroy = PCDestroy_HMG;
446 pc->ops->setup = PCSetUp_HMG;
447
448 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCHMGSetReuseInterpolation_C",PCHMGSetReuseInterpolation_HMG)PetscObjectComposeFunction_Private((PetscObject)pc,"PCHMGSetReuseInterpolation_C"
,(PetscVoidFunction)(PCHMGSetReuseInterpolation_HMG))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),448,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
449 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCHMGSetUseSubspaceCoarsening_C",PCHMGSetUseSubspaceCoarsening_HMG)PetscObjectComposeFunction_Private((PetscObject)pc,"PCHMGSetUseSubspaceCoarsening_C"
,(PetscVoidFunction)(PCHMGSetUseSubspaceCoarsening_HMG))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),449,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
450 ierr = PetscObjectComposeFunction((PetscObject)pc,"PCHMGSetInnerPCType_C",PCHMGSetInnerPCType_HMG)PetscObjectComposeFunction_Private((PetscObject)pc,"PCHMGSetInnerPCType_C"
,(PetscVoidFunction)(PCHMGSetInnerPCType_HMG))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),450,__func__,"/sandbox/petsc/petsc.next/src/ksp/pc/impls/hmg/hmg.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
451 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)
;
452}