Actual source code: ex76.c

  1: #include <petscksp.h>
  2: #include "petsc/private/petscimpl.h"

  4: static char help[] = "Solves a linear system using PCHPDDM.\n\n";

  6: int main(int argc, char **args)
  7: {
  8:   Vec             b;            /* computed solution and RHS */
  9:   Mat             A, aux, X, B; /* linear system matrix */
 10:   KSP             ksp;          /* linear solver context */
 11:   PC              pc;
 12:   IS              is, sizes;
 13:   const PetscInt *idx;
 14:   PetscMPIInt     rank, size;
 15:   PetscInt        m, N = 1;
 16:   PetscViewer     viewer;
 17:   char            dir[PETSC_MAX_PATH_LEN], name[PETSC_MAX_PATH_LEN], type[256];
 18:   PetscBool3      share = PETSC_BOOL3_UNKNOWN;
 19:   PetscBool       flg, set;

 21:   PetscFunctionBeginUser;
 22:   PetscCall(PetscInitialize(&argc, &args, NULL, help));
 23:   PetscCall(PetscLogDefaultBegin());
 24:   PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
 25:   PetscCheck(size == 4, PETSC_COMM_WORLD, PETSC_ERR_USER, "This example requires 4 processes");
 26:   PetscCall(PetscOptionsGetInt(NULL, NULL, "-rhs", &N, NULL));
 27:   PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
 28:   PetscCall(MatCreate(PETSC_COMM_WORLD, &A));
 29:   PetscCall(MatCreate(PETSC_COMM_SELF, &aux));
 30:   PetscCall(ISCreate(PETSC_COMM_SELF, &is));
 31:   PetscCall(PetscStrncpy(dir, ".", sizeof(dir)));
 32:   PetscCall(PetscOptionsGetString(NULL, NULL, "-load_dir", dir, sizeof(dir), NULL));
 33:   /* loading matrices */
 34:   PetscCall(PetscSNPrintf(name, sizeof(name), "%s/sizes_%d_%d.dat", dir, rank, size));
 35:   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_SELF, name, FILE_MODE_READ, &viewer));
 36:   PetscCall(ISCreate(PETSC_COMM_SELF, &sizes));
 37:   PetscCall(ISLoad(sizes, viewer));
 38:   PetscCall(ISGetIndices(sizes, &idx));
 39:   PetscCall(MatSetSizes(A, idx[0], idx[1], idx[2], idx[3]));
 40:   PetscCall(MatSetUp(A));
 41:   PetscCall(ISRestoreIndices(sizes, &idx));
 42:   PetscCall(ISDestroy(&sizes));
 43:   PetscCall(PetscViewerDestroy(&viewer));
 44:   PetscCall(PetscSNPrintf(name, sizeof(name), "%s/A.dat", dir));
 45:   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD, name, FILE_MODE_READ, &viewer));
 46:   PetscCall(MatLoad(A, viewer));
 47:   PetscCall(PetscViewerDestroy(&viewer));
 48:   PetscCall(PetscSNPrintf(name, sizeof(name), "%s/is_%d_%d.dat", dir, rank, size));
 49:   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_SELF, name, FILE_MODE_READ, &viewer));
 50:   PetscCall(ISLoad(is, viewer));
 51:   PetscCall(ISSetBlockSize(is, 2));
 52:   PetscCall(PetscViewerDestroy(&viewer));
 53:   PetscCall(PetscSNPrintf(name, sizeof(name), "%s/Neumann_%d_%d.dat", dir, rank, size));
 54:   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_SELF, name, FILE_MODE_READ, &viewer));
 55:   PetscCall(MatLoad(aux, viewer));
 56:   PetscCall(PetscViewerDestroy(&viewer));
 57:   flg = PETSC_FALSE;
 58:   PetscCall(PetscOptionsGetBool(NULL, NULL, "-pc_hpddm_levels_1_st_share_sub_ksp", &flg, &set));
 59:   if (flg) { /* PETSc LU/Cholesky is struggling numerically for bs > 1          */
 60:              /* only set the proper bs for the geneo_share_* tests, 1 otherwise */
 61:     PetscCall(MatSetBlockSizesFromMats(aux, A, A));
 62:     share = PETSC_BOOL3_TRUE;
 63:   } else if (set) share = PETSC_BOOL3_FALSE;
 64:   PetscCall(MatSetOption(A, MAT_SYMMETRIC, PETSC_TRUE));
 65:   PetscCall(MatSetOption(aux, MAT_SYMMETRIC, PETSC_TRUE));
 66:   /* ready for testing */
 67:   PetscOptionsBegin(PETSC_COMM_WORLD, "", "", "");
 68:   PetscCall(PetscStrncpy(type, MATAIJ, sizeof(type)));
 69:   PetscCall(PetscOptionsFList("-mat_type", "Matrix type", "MatSetType", MatList, type, type, 256, &flg));
 70:   PetscOptionsEnd();
 71:   PetscCall(MatConvert(A, type, MAT_INPLACE_MATRIX, &A));
 72:   PetscCall(MatConvert(aux, type, MAT_INPLACE_MATRIX, &aux));
 73:   PetscCall(KSPCreate(PETSC_COMM_WORLD, &ksp));
 74:   PetscCall(KSPSetOperators(ksp, A, A));
 75:   PetscCall(KSPGetPC(ksp, &pc));
 76:   PetscCall(PCSetType(pc, PCHPDDM));
 77: #if defined(PETSC_HAVE_HPDDM) && defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES)
 78:   flg = PETSC_FALSE;
 79:   PetscCall(PetscOptionsGetBool(NULL, NULL, "-reset", &flg, NULL));
 80:   if (flg) {
 81:     PetscCall(PetscOptionsSetValue(NULL, "-pc_hpddm_block_splitting", "true"));
 82:     PetscCall(PCSetFromOptions(pc));
 83:     PetscCall(PCSetUp(pc));
 84:     PetscCall(PetscOptionsClearValue(NULL, "-pc_hpddm_block_splitting"));
 85:   }
 86:   PetscCall(PCHPDDMSetAuxiliaryMat(pc, is, aux, NULL, NULL));
 87:   PetscCall(PCHPDDMHasNeumannMat(pc, PETSC_FALSE)); /* PETSC_TRUE is fine as well, just testing */
 88:   if (share == PETSC_BOOL3_UNKNOWN) PetscCall(PCHPDDMSetSTShareSubKSP(pc, PetscBool3ToBool(share)));
 89:   flg = PETSC_FALSE;
 90:   PetscCall(PetscOptionsGetBool(NULL, NULL, "-set_rhs", &flg, NULL));
 91:   if (flg) {          /* user-provided RHS for concurrent generalized eigenvalue problems                          */
 92:     Mat      a, c, P; /* usually assembled automatically in PCHPDDM, this is solely for testing PCHPDDMSetRHSMat() */
 93:     PetscInt rstart, rend, location;
 94:     PetscCall(MatDuplicate(aux, MAT_DO_NOT_COPY_VALUES, &B)); /* duplicate so that MatStructure is SAME_NONZERO_PATTERN */
 95:     PetscCall(MatGetDiagonalBlock(A, &a));
 96:     PetscCall(MatGetOwnershipRange(A, &rstart, &rend));
 97:     PetscCall(ISGetLocalSize(is, &m));
 98:     PetscCall(MatCreateSeqAIJ(PETSC_COMM_SELF, rend - rstart, m, 1, NULL, &P));
 99:     for (m = rstart; m < rend; ++m) {
100:       PetscCall(ISLocate(is, m, &location));
101:       PetscCheck(location >= 0, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "IS of the auxiliary Mat does not include all local rows of A");
102:       PetscCall(MatSetValue(P, m - rstart, location, 1.0, INSERT_VALUES));
103:     }
104:     PetscCall(MatAssemblyBegin(P, MAT_FINAL_ASSEMBLY));
105:     PetscCall(MatAssemblyEnd(P, MAT_FINAL_ASSEMBLY));
106:     PetscCall(PetscObjectTypeCompare((PetscObject)a, MATSEQAIJ, &flg));
107:     if (flg) PetscCall(MatPtAP(a, P, MAT_INITIAL_MATRIX, 1.0, &X)); /* MatPtAP() is used to extend diagonal blocks with zeros on the overlap */
108:     else { /* workaround for MatPtAP() limitations with some types */ PetscCall(MatConvert(a, MATSEQAIJ, MAT_INITIAL_MATRIX, &c));
109:       PetscCall(MatPtAP(c, P, MAT_INITIAL_MATRIX, 1.0, &X));
110:       PetscCall(MatDestroy(&c));
111:     }
112:     PetscCall(MatDestroy(&P));
113:     PetscCall(MatAXPY(B, 1.0, X, SUBSET_NONZERO_PATTERN));
114:     PetscCall(MatDestroy(&X));
115:     PetscCall(MatSetOption(B, MAT_SYMMETRIC, PETSC_TRUE));
116:     PetscCall(PCHPDDMSetRHSMat(pc, B));
117:     PetscCall(MatDestroy(&B));
118:   }
119: #else
120:   (void)share;
121: #endif
122:   PetscCall(MatDestroy(&aux));
123:   PetscCall(KSPSetFromOptions(ksp));
124:   PetscCall(PetscObjectTypeCompare((PetscObject)pc, PCASM, &flg));
125:   if (flg) {
126:     flg = PETSC_FALSE;
127:     PetscCall(PetscOptionsGetBool(NULL, NULL, "-pc_hpddm_define_subdomains", &flg, NULL));
128:     if (flg) {
129:       IS rows;
130:       PetscCall(MatGetOwnershipIS(A, &rows, NULL));
131:       PetscCall(PCASMSetLocalSubdomains(pc, 1, &is, &rows));
132:       PetscCall(ISDestroy(&rows));
133:     }
134:   }
135:   PetscCall(ISDestroy(&is));
136:   PetscCall(MatCreateVecs(A, NULL, &b));
137:   PetscCall(VecSet(b, 1.0));
138:   PetscCall(KSPSolve(ksp, b, b));
139:   PetscCall(VecGetLocalSize(b, &m));
140:   PetscCall(VecDestroy(&b));
141:   if (N > 1) {
142:     KSPType type;
143:     PetscCall(PetscOptionsClearValue(NULL, "-ksp_converged_reason"));
144:     PetscCall(KSPSetFromOptions(ksp));
145:     PetscCall(MatCreateDense(PETSC_COMM_WORLD, m, PETSC_DECIDE, PETSC_DECIDE, N, NULL, &B));
146:     PetscCall(MatCreateDense(PETSC_COMM_WORLD, m, PETSC_DECIDE, PETSC_DECIDE, N, NULL, &X));
147:     PetscCall(MatSetRandom(B, NULL));
148:     /* this is algorithmically optimal in the sense that blocks of vectors are coarsened or interpolated using matrix--matrix operations */
149:     /* PCHPDDM however heavily relies on MPI[S]BAIJ format for which there is no efficient MatProduct implementation */
150:     PetscCall(KSPMatSolve(ksp, B, X));
151:     PetscCall(KSPGetType(ksp, &type));
152:     PetscCall(PetscStrcmp(type, KSPHPDDM, &flg));
153: #if defined(PETSC_HAVE_HPDDM)
154:     if (flg) {
155:       PetscReal    norm;
156:       KSPHPDDMType type;
157:       PetscCall(KSPHPDDMGetType(ksp, &type));
158:       if (type == KSP_HPDDM_TYPE_PREONLY || type == KSP_HPDDM_TYPE_CG || type == KSP_HPDDM_TYPE_GMRES || type == KSP_HPDDM_TYPE_GCRODR) {
159:         Mat C;
160:         PetscCall(MatDuplicate(X, MAT_DO_NOT_COPY_VALUES, &C));
161:         PetscCall(KSPSetMatSolveBatchSize(ksp, 1));
162:         PetscCall(KSPMatSolve(ksp, B, C));
163:         PetscCall(MatAYPX(C, -1.0, X, SAME_NONZERO_PATTERN));
164:         PetscCall(MatNorm(C, NORM_INFINITY, &norm));
165:         PetscCall(MatDestroy(&C));
166:         PetscCheck(norm <= 100 * PETSC_MACHINE_EPSILON, PetscObjectComm((PetscObject)pc), PETSC_ERR_PLIB, "KSPMatSolve() and KSPSolve() difference has nonzero norm %g with pseudo-block KSPHPDDMType %s", (double)norm, KSPHPDDMTypes[type]);
167:       }
168:     }
169: #endif
170:     PetscCall(MatDestroy(&X));
171:     PetscCall(MatDestroy(&B));
172:   }
173:   PetscCall(PetscObjectTypeCompare((PetscObject)pc, PCHPDDM, &flg));
174: #if defined(PETSC_HAVE_HPDDM) && defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES)
175:   if (flg) PetscCall(PCHPDDMGetSTShareSubKSP(pc, &flg));
176: #endif
177:   if (flg && PetscDefined(USE_LOG)) {
178:     PetscCall(PetscOptionsHasName(NULL, NULL, "-pc_hpddm_harmonic_overlap", &flg));
179:     if (!flg) {
180:       PetscLogEvent      event;
181:       PetscEventPerfInfo info1, info2;

183:       PetscCall(PetscLogEventRegister("MatLUFactorSym", PC_CLASSID, &event));
184:       PetscCall(PetscLogEventGetPerfInfo(PETSC_DETERMINE, event, &info1));
185:       PetscCall(PetscLogEventRegister("MatLUFactorNum", PC_CLASSID, &event));
186:       PetscCall(PetscLogEventGetPerfInfo(PETSC_DETERMINE, event, &info2));
187:       if (!info1.count && !info2.count) {
188:         PetscCall(PetscLogEventRegister("MatCholFctrSym", PC_CLASSID, &event));
189:         PetscCall(PetscLogEventGetPerfInfo(PETSC_DETERMINE, event, &info1));
190:         PetscCall(PetscLogEventRegister("MatCholFctrNum", PC_CLASSID, &event));
191:         PetscCall(PetscLogEventGetPerfInfo(PETSC_DETERMINE, event, &info2));
192:         PetscCheck(info2.count > info1.count, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Cholesky numerical factorization (%d) not called more times than Cholesky symbolic factorization (%d), broken -pc_hpddm_levels_1_st_share_sub_ksp", info2.count, info1.count);
193:       } else PetscCheck(info2.count > info1.count, PETSC_COMM_SELF, PETSC_ERR_PLIB, "LU numerical factorization (%d) not called more times than LU symbolic factorization (%d), broken -pc_hpddm_levels_1_st_share_sub_ksp", info2.count, info1.count);
194:     }
195:   }
196: #if defined(PETSC_HAVE_HPDDM) && defined(PETSC_HAVE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES)
197:   if (N == 1) {
198:     flg = PETSC_FALSE;
199:     PetscCall(PetscOptionsGetBool(NULL, NULL, "-successive_solves", &flg, NULL));
200:     if (flg) {
201:       KSPConvergedReason reason[2];
202:       PetscInt           iterations[3];
203:       PetscCall(KSPGetConvergedReason(ksp, reason));
204:       PetscCall(KSPGetTotalIterations(ksp, iterations));
205:       PetscCall(PetscOptionsClearValue(NULL, "-ksp_converged_reason"));
206:       flg = PETSC_FALSE;
207:       PetscCall(PetscOptionsGetBool(NULL, NULL, "-pc_hpddm_block_splitting", &flg, NULL));
208:       if (!flg) {
209:         PetscCall(MatCreate(PETSC_COMM_SELF, &aux));
210:         PetscCall(ISCreate(PETSC_COMM_SELF, &is));
211:         PetscCall(PetscSNPrintf(name, sizeof(name), "%s/is_%d_%d.dat", dir, rank, size));
212:         PetscCall(PetscViewerBinaryOpen(PETSC_COMM_SELF, name, FILE_MODE_READ, &viewer));
213:         PetscCall(ISLoad(is, viewer));
214:         PetscCall(ISSetBlockSize(is, 2));
215:         PetscCall(PetscViewerDestroy(&viewer));
216:         PetscCall(PetscSNPrintf(name, sizeof(name), "%s/Neumann_%d_%d.dat", dir, rank, size));
217:         PetscCall(PetscViewerBinaryOpen(PETSC_COMM_SELF, name, FILE_MODE_READ, &viewer));
218:         PetscCall(MatLoad(aux, viewer));
219:         PetscCall(PetscViewerDestroy(&viewer));
220:         PetscCall(MatSetBlockSizesFromMats(aux, A, A));
221:         PetscCall(MatSetOption(aux, MAT_SYMMETRIC, PETSC_TRUE));
222:         PetscCall(MatConvert(aux, type, MAT_INPLACE_MATRIX, &aux));
223:       }
224:       PetscCall(MatCreateVecs(A, NULL, &b));
225:       PetscCall(PetscObjectStateIncrease((PetscObject)A));
226:       if (!flg) PetscCall(PCHPDDMSetAuxiliaryMat(pc, NULL, aux, NULL, NULL));
227:       PetscCall(VecSet(b, 1.0));
228:       PetscCall(KSPSolve(ksp, b, b));
229:       PetscCall(KSPGetConvergedReason(ksp, reason + 1));
230:       PetscCall(KSPGetTotalIterations(ksp, iterations + 1));
231:       iterations[1] -= iterations[0];
232:       PetscCheck(reason[0] == reason[1] && PetscAbs(iterations[0] - iterations[1]) <= 3, PetscObjectComm((PetscObject)ksp), PETSC_ERR_PLIB, "Successive calls to KSPSolve() did not converge for the same reason (%s v. %s) or with the same number of iterations (+/- 3, %" PetscInt_FMT " v. %" PetscInt_FMT ")", KSPConvergedReasons[reason[0]], KSPConvergedReasons[reason[1]], iterations[0], iterations[1]);
233:       PetscCall(PetscObjectStateIncrease((PetscObject)A));
234:       if (!flg) PetscCall(PCHPDDMSetAuxiliaryMat(pc, is, aux, NULL, NULL));
235:       PetscCall(PCSetFromOptions(pc));
236:       PetscCall(VecSet(b, 1.0));
237:       PetscCall(KSPSolve(ksp, b, b));
238:       PetscCall(KSPGetConvergedReason(ksp, reason + 1));
239:       PetscCall(KSPGetTotalIterations(ksp, iterations + 2));
240:       iterations[2] -= iterations[0] + iterations[1];
241:       PetscCheck(reason[0] == reason[1] && PetscAbs(iterations[0] - iterations[2]) <= 3, PetscObjectComm((PetscObject)ksp), PETSC_ERR_PLIB, "Successive calls to KSPSolve() did not converge for the same reason (%s v. %s) or with the same number of iterations (+/- 3, %" PetscInt_FMT " v. %" PetscInt_FMT ")", KSPConvergedReasons[reason[0]], KSPConvergedReasons[reason[1]], iterations[0], iterations[2]);
242:       PetscCall(VecDestroy(&b));
243:       PetscCall(ISDestroy(&is));
244:       PetscCall(MatDestroy(&aux));
245:     }
246:   }
247:   PetscCall(PetscOptionsGetBool(NULL, NULL, "-viewer", &flg, NULL));
248:   if (flg) {
249:     PetscCall(PetscObjectTypeCompare((PetscObject)pc, PCHPDDM, &flg));
250:     if (flg) {
251:       PetscCall(PetscStrncpy(dir, "XXXXXX", sizeof(dir)));
252:       if (rank == 0) PetscCall(PetscMkdtemp(dir));
253:       PetscCallMPI(MPI_Bcast(dir, 6, MPI_CHAR, 0, PETSC_COMM_WORLD));
254:       for (PetscInt i = 0; i < 2; ++i) {
255:         PetscCall(PetscSNPrintf(name, sizeof(name), "%s/%s", dir, (i == 0 ? "A" : "A.dat")));
256:         PetscCall(PetscViewerASCIIOpen(PETSC_COMM_WORLD, name, &viewer));
257:         PetscCall(PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_INFO_DETAIL));
258:         PetscCall(PCView(pc, viewer));
259:         PetscCall(PetscViewerPopFormat(viewer));
260:         PetscCall(PetscViewerDestroy(&viewer));
261:       }
262:       PetscCallMPI(MPI_Barrier(PETSC_COMM_WORLD));
263:       if (rank == 0) PetscCall(PetscRMTree(dir));
264:     }
265:   }
266: #endif
267:   PetscCall(KSPDestroy(&ksp));
268:   PetscCall(MatDestroy(&A));
269:   PetscCall(PetscFinalize());
270:   return 0;
271: }

273: /*TEST

275:    test:
276:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
277:       nsize: 4
278:       args: -ksp_rtol 1e-3 -ksp_converged_reason -pc_type {{bjacobi hpddm}shared output} -pc_hpddm_coarse_sub_pc_type lu -sub_pc_type lu -options_left no -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO

280:    test:
281:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
282:       suffix: define_subdomains
283:       nsize: 4
284:       args: -ksp_rtol 1e-3 -ksp_converged_reason -pc_type {{asm hpddm}shared output} -pc_hpddm_coarse_sub_pc_type lu -sub_pc_type lu -pc_hpddm_define_subdomains -options_left no -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO -viewer

286:    testset:
287:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
288:       nsize: 4
289:       args: -ksp_converged_reason -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type cholesky -pc_hpddm_coarse_pc_type redundant -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO
290:       test:
291:         suffix: geneo
292:         args: -pc_hpddm_coarse_p {{1 2}shared output} -pc_hpddm_levels_1_st_pc_type cholesky -pc_hpddm_levels_1_eps_nev {{5 15}separate output} -mat_type {{aij baij sbaij}shared output}
293:       test:
294:         suffix: geneo_block_splitting
295:         output_file: output/ex76_geneo_pc_hpddm_levels_1_eps_nev-15.out
296:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 1[6-9]/Linear solve converged due to CONVERGED_RTOL iterations 11/g"
297:         args: -pc_hpddm_coarse_p 2 -pc_hpddm_levels_1_eps_nev 15 -pc_hpddm_block_splitting -pc_hpddm_levels_1_st_pc_type lu -pc_hpddm_levels_1_eps_gen_non_hermitian -mat_type {{aij baij}shared output} -successive_solves
298:       test:
299:         suffix: geneo_share
300:         output_file: output/ex76_geneo_pc_hpddm_levels_1_eps_nev-5.out
301:         args: -pc_hpddm_levels_1_st_pc_type cholesky -pc_hpddm_levels_1_eps_nev 5 -pc_hpddm_levels_1_st_share_sub_ksp -reset {{false true}shared output}
302:       test:
303:         suffix: harmonic_overlap_1_define_false
304:         output_file: output/ex76_geneo_share.out
305:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 1[0-3]/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
306:         args: -pc_hpddm_harmonic_overlap 1 -pc_hpddm_levels_1_eps_nev 30 -pc_hpddm_levels_1_eps_relative_threshold 1e+1 -pc_hpddm_levels_1_st_pc_type lu -pc_hpddm_levels_1_eps_pc_type lu -pc_hpddm_define_subdomains false -pc_hpddm_levels_1_pc_type asm -pc_hpddm_levels_1_pc_asm_overlap 2 -mat_type baij
307:       test:
308:         suffix: harmonic_overlap_1
309:         output_file: output/ex76_geneo_share.out
310:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 1[0-3]/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
311:         args: -pc_hpddm_harmonic_overlap 1 -pc_hpddm_levels_1_eps_nev 30 -pc_hpddm_levels_1_eps_relative_threshold 1e+1 -pc_hpddm_levels_1_st_pc_type lu -pc_hpddm_levels_1_eps_pc_type lu -mat_type baij
312:       test:
313:         suffix: harmonic_overlap_1_share_petsc
314:         output_file: output/ex76_geneo_share.out
315:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 1[0-3]/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
316:         args: -pc_hpddm_harmonic_overlap 1 -pc_hpddm_levels_1_eps_nev 30 -pc_hpddm_levels_1_eps_relative_threshold 1e+1 -pc_hpddm_levels_1_st_pc_type lu -pc_hpddm_levels_1_st_share_sub_ksp -pc_hpddm_levels_1_sub_pc_factor_mat_solver_type petsc -pc_hpddm_levels_1_eps_pc_type lu -mat_type baij
317:       test:
318:         requires: mumps
319:         suffix: harmonic_overlap_1_share_mumps
320:         output_file: output/ex76_geneo_share.out
321:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 1[0-3]/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
322:         args: -pc_hpddm_harmonic_overlap 1 -pc_hpddm_levels_1_eps_nev 30 -pc_hpddm_levels_1_eps_relative_threshold 1e+1 -pc_hpddm_levels_1_st_share_sub_ksp -pc_hpddm_levels_1_sub_pc_factor_mat_solver_type mumps
323:       test:
324:         requires: mumps
325:         suffix: harmonic_overlap_1_share_mumps_not_set_explicitly
326:         output_file: output/ex76_geneo_share.out
327:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 1[0-3]/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
328:         args: -pc_hpddm_harmonic_overlap 1 -pc_hpddm_levels_1_eps_nev 30 -pc_hpddm_levels_1_eps_relative_threshold 1e+1 -pc_hpddm_levels_1_st_share_sub_ksp -pc_hpddm_levels_1_eps_mat_type baij
329:       test:
330:         requires: mkl_pardiso
331:         suffix: harmonic_overlap_1_share_mkl_pardiso
332:         output_file: output/ex76_geneo_share.out
333:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations [12][0-3]/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
334:         args: -pc_hpddm_harmonic_overlap 1 -pc_hpddm_levels_1_eps_nev 30 -pc_hpddm_levels_1_eps_relative_threshold 1e+1 -pc_hpddm_levels_1_st_share_sub_ksp -pc_hpddm_levels_1_eps_mat_type shell -pc_hpddm_levels_1_sub_pc_factor_mat_solver_type mkl_pardiso
335:       test:
336:         requires: mkl_pardiso !mumps
337:         suffix: harmonic_overlap_1_share_mkl_pardiso_no_set_explicitly
338:         output_file: output/ex76_geneo_share.out
339:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations [12][0-3]/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
340:         args: -pc_hpddm_harmonic_overlap 1 -pc_hpddm_levels_1_eps_nev 30 -pc_hpddm_levels_1_eps_relative_threshold 1e+1 -pc_hpddm_levels_1_st_share_sub_ksp -pc_hpddm_levels_1_eps_mat_type shell
341:       test:
342:         suffix: harmonic_overlap_2_relative_threshold
343:         output_file: output/ex76_geneo_share.out
344:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 9/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
345:         args: -pc_hpddm_harmonic_overlap 2 -pc_hpddm_levels_1_svd_nsv 15 -pc_hpddm_levels_1_svd_relative_threshold 1e-1 -pc_hpddm_levels_1_st_share_sub_ksp -mat_type sbaij
346:       test:
347:         suffix: harmonic_overlap_2
348:         output_file: output/ex76_geneo_share.out
349:         filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 9/Linear solve converged due to CONVERGED_RTOL iterations 15/g"
350:         args: -pc_hpddm_harmonic_overlap 2 -pc_hpddm_levels_1_svd_nsv 12 -pc_hpddm_levels_1_st_share_sub_ksp -mat_type sbaij

352:    testset:
353:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
354:       nsize: 4
355:       args: -ksp_converged_reason -ksp_max_it 150 -pc_type hpddm -pc_hpddm_levels_1_eps_nev 5 -pc_hpddm_coarse_p 1 -pc_hpddm_coarse_pc_type redundant -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO -pc_hpddm_define_subdomains
356:       test:
357:         suffix: geneo_share_cholesky
358:         output_file: output/ex76_geneo_share.out
359:         # extra -pc_hpddm_levels_1_eps_gen_non_hermitian needed to avoid failures with PETSc Cholesky
360:         args: -pc_hpddm_levels_1_sub_pc_type cholesky -pc_hpddm_levels_1_st_pc_type cholesky -mat_type {{aij sbaij}shared output} -pc_hpddm_levels_1_eps_gen_non_hermitian -pc_hpddm_has_neumann -pc_hpddm_levels_1_st_share_sub_ksp {{false true}shared output} -successive_solves
361:       test:
362:         suffix: geneo_share_cholesky_matstructure
363:         output_file: output/ex76_geneo_share.out
364:         # extra -pc_hpddm_levels_1_eps_gen_non_hermitian needed to avoid failures with PETSc Cholesky
365:         args: -pc_hpddm_levels_1_sub_pc_type cholesky -mat_type {{baij sbaij}shared output} -pc_hpddm_levels_1_eps_gen_non_hermitian -pc_hpddm_levels_1_st_share_sub_ksp -pc_hpddm_levels_1_st_matstructure same -set_rhs {{false true} shared output}
366:       test:
367:         requires: mumps
368:         suffix: geneo_share_lu
369:         output_file: output/ex76_geneo_share.out
370:         # extra -pc_factor_mat_solver_type mumps needed to avoid failures with PETSc LU
371:         args: -pc_hpddm_levels_1_sub_pc_type lu -pc_hpddm_levels_1_st_pc_type lu -mat_type baij -pc_hpddm_levels_1_st_pc_factor_mat_solver_type mumps -pc_hpddm_levels_1_sub_pc_factor_mat_solver_type mumps -pc_hpddm_has_neumann -pc_hpddm_levels_1_st_share_sub_ksp {{false true}shared output}
372:       test:
373:         requires: mumps
374:         suffix: geneo_share_lu_matstructure
375:         output_file: output/ex76_geneo_share.out
376:         # extra -pc_factor_mat_solver_type mumps needed to avoid failures with PETSc LU
377:         args: -pc_hpddm_levels_1_sub_pc_type lu -mat_type aij -pc_hpddm_levels_1_sub_pc_factor_mat_solver_type mumps -pc_hpddm_levels_1_st_share_sub_ksp -pc_hpddm_levels_1_st_matstructure {{same different}shared output} -pc_hpddm_levels_1_st_pc_type lu -pc_hpddm_levels_1_st_pc_factor_mat_solver_type mumps -successive_solves -pc_hpddm_levels_1_eps_target 1e-5
378:       test:
379:         suffix: geneo_share_not_asm
380:         output_file: output/ex76_geneo_pc_hpddm_levels_1_eps_nev-5.out
381:         # extra -pc_hpddm_levels_1_eps_gen_non_hermitian needed to avoid failures with PETSc Cholesky
382:         args: -pc_hpddm_levels_1_sub_pc_type cholesky -pc_hpddm_levels_1_st_pc_type cholesky -pc_hpddm_levels_1_eps_gen_non_hermitian -pc_hpddm_has_neumann -pc_hpddm_levels_1_st_share_sub_ksp true -pc_hpddm_levels_1_pc_type gasm -successive_solves

384:    test:
385:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
386:       suffix: fgmres_geneo_20_p_2
387:       nsize: 4
388:       args: -ksp_converged_reason -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type lu -pc_hpddm_levels_1_eps_nev 20 -pc_hpddm_coarse_p 2 -pc_hpddm_coarse_pc_type redundant -ksp_type fgmres -pc_hpddm_coarse_mat_type {{baij sbaij}shared output} -pc_hpddm_log_separate {{false true}shared output} -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO

390:    testset:
391:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
392:       output_file: output/ex76_fgmres_geneo_20_p_2.out
393:       nsize: 4
394:       args: -ksp_converged_reason -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type cholesky -pc_hpddm_levels_1_eps_nev 20 -pc_hpddm_levels_2_p 2 -pc_hpddm_levels_2_mat_type {{baij sbaij}shared output} -pc_hpddm_levels_2_eps_nev {{5 20}shared output} -pc_hpddm_levels_2_sub_pc_type cholesky -pc_hpddm_levels_2_ksp_type gmres -ksp_type fgmres -pc_hpddm_coarse_mat_type {{baij sbaij}shared output} -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO
395:       test:
396:         suffix: fgmres_geneo_20_p_2_geneo
397:         args: -mat_type {{aij sbaij}shared output}
398:       test:
399:         suffix: fgmres_geneo_20_p_2_geneo_algebraic
400:         args: -pc_hpddm_levels_2_st_pc_type mat
401:    # PCHPDDM + KSPHPDDM test to exercise multilevel + multiple RHS in one go
402:    test:
403:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
404:       suffix: fgmres_geneo_20_p_2_geneo_rhs
405:       output_file: output/ex76_fgmres_geneo_20_p_2.out
406:       # for -pc_hpddm_coarse_correction additive
407:       filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 37/Linear solve converged due to CONVERGED_RTOL iterations 25/g"
408:       nsize: 4
409:       args: -ksp_converged_reason -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type cholesky -pc_hpddm_levels_1_eps_nev 20 -pc_hpddm_levels_2_p 2 -pc_hpddm_levels_2_mat_type baij -pc_hpddm_levels_2_eps_nev 5 -pc_hpddm_levels_2_sub_pc_type cholesky -pc_hpddm_levels_2_ksp_max_it 10 -pc_hpddm_levels_2_ksp_type hpddm -pc_hpddm_levels_2_ksp_hpddm_type gmres -ksp_type hpddm -ksp_hpddm_variant flexible -pc_hpddm_coarse_mat_type baij -mat_type aij -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO -rhs 4 -pc_hpddm_coarse_correction {{additive deflated balanced}shared output}

411:    testset:
412:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES) mumps defined(PETSC_HAVE_OPENMP_SUPPORT)
413:       filter: grep -E -e "Linear solve" -e "      executing" | sed -e "s/MPI =      1/MPI =      2/g" -e "s/OMP =      1/OMP =      2/g"
414:       nsize: 4
415:       args: -ksp_converged_reason -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type cholesky -pc_hpddm_levels_1_eps_nev 15 -pc_hpddm_levels_1_st_pc_type cholesky -pc_hpddm_coarse_p {{1 2}shared output} -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO -pc_hpddm_coarse_pc_factor_mat_solver_type mumps -pc_hpddm_coarse_mat_mumps_icntl_4 2 -pc_hpddm_coarse_mat_mumps_use_omp_threads {{1 2}shared output}
416:       test:
417:         suffix: geneo_mumps_use_omp_threads_1
418:         output_file: output/ex76_geneo_mumps_use_omp_threads.out
419:         args: -pc_hpddm_coarse_mat_type {{baij sbaij}shared output}
420:       test:
421:         suffix: geneo_mumps_use_omp_threads_2
422:         output_file: output/ex76_geneo_mumps_use_omp_threads.out
423:         args: -pc_hpddm_coarse_mat_type aij -pc_hpddm_levels_1_eps_threshold 0.4 -pc_hpddm_coarse_pc_type cholesky -pc_hpddm_coarse_mat_filter 1e-12

425:    testset: # converge really poorly because of a tiny -pc_hpddm_levels_1_eps_threshold, but needed for proper code coverage where some subdomains don't call EPSSolve()
426:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
427:       nsize: 4
428:       args: -ksp_converged_reason -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type cholesky -pc_hpddm_levels_1_eps_threshold 0.005 -pc_hpddm_levels_1_eps_use_inertia -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO -pc_hpddm_coarse_pc_type cholesky -pc_hpddm_levels_1_st_share_sub_ksp -pc_hpddm_define_subdomains -pc_hpddm_has_neumann -ksp_rtol 0.9
429:       filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 1/Linear solve converged due to CONVERGED_RTOL iterations 141/g"
430:       test:
431:         suffix: inertia_petsc
432:         output_file: output/ex76_1.out
433:         args: -pc_hpddm_levels_1_sub_pc_factor_mat_solver_type petsc
434:       test:
435:         suffix: inertia_mumps
436:         output_file: output/ex76_1.out
437:         requires: mumps

439:    test:
440:       requires: hpddm slepc datafilespath double !complex !defined(PETSC_USE_64BIT_INDICES) defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
441:       suffix: reuse_symbolic
442:       output_file: output/ex77_preonly.out
443:       nsize: 4
444:       args: -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type cholesky -pc_hpddm_levels_1_eps_nev 20 -rhs 4 -pc_hpddm_coarse_correction {{additive deflated balanced}shared output} -ksp_pc_side {{left right}shared output} -ksp_max_it 20 -ksp_type hpddm -load_dir ${DATAFILESPATH}/matrices/hpddm/GENEO -pc_hpddm_define_subdomains -ksp_error_if_not_converged

446: TEST*/