Lines Matching refs:red

23   PC_Redundant *red = (PC_Redundant *)pc->data;  in PCFactorSetShiftType_Redundant()  local
26 if (red->ksp) { in PCFactorSetShiftType_Redundant()
28 PetscCall(KSPGetPC(red->ksp, &pc)); in PCFactorSetShiftType_Redundant()
31 red->shifttypeset = PETSC_TRUE; in PCFactorSetShiftType_Redundant()
32 red->shifttype = shifttype; in PCFactorSetShiftType_Redundant()
39 PC_Redundant *red = (PC_Redundant *)pc->data; in PCView_Redundant() local
47 if (!red->psubcomm) { in PCView_Redundant()
50 …cViewerASCIIPrintf(viewer, " First (color=0) of %" PetscInt_FMT " PCs follows\n", red->nsubcomm)); in PCView_Redundant()
51 PetscCall(PetscViewerGetSubViewer(viewer, ((PetscObject)red->pc)->comm, &subviewer)); in PCView_Redundant()
52 if (!red->psubcomm->color) { /* only view first redundant pc */ in PCView_Redundant()
54 PetscCall(KSPView(red->ksp, subviewer)); in PCView_Redundant()
57 PetscCall(PetscViewerRestoreSubViewer(viewer, ((PetscObject)red->pc)->comm, &subviewer)); in PCView_Redundant()
68 PC_Redundant *red = (PC_Redundant *)pc->data; in PCSetUp_Redundant() local
79 if (size == 1) red->useparallelmat = PETSC_FALSE; in PCSetUp_Redundant()
83 if (!red->psubcomm) { /* create red->psubcomm, new ksp and pc over subcomm */ in PCSetUp_Redundant()
87 subcomm = PetscSubcommChild(red->psubcomm); in PCSetUp_Redundant()
89 if (red->useparallelmat) { in PCSetUp_Redundant()
91 …PetscCall(MatCreateRedundantMatrix(pc->pmat, red->psubcomm->n, subcomm, MAT_INITIAL_MATRIX, &red->… in PCSetUp_Redundant()
96 PetscCall(PetscObjectTypeCompare((PetscObject)red->pmats, MATMPISBAIJ, &issbaij)); in PCSetUp_Redundant()
98 PetscCall(MatGetFactorAvailable(red->pmats, NULL, MAT_FACTOR_LU, &foundpack)); in PCSetUp_Redundant()
100 PetscCall(MatGetFactorAvailable(red->pmats, NULL, MAT_FACTOR_CHOLESKY, &foundpack)); in PCSetUp_Redundant()
103 PetscCall(KSPSetType(red->ksp, KSPGMRES)); in PCSetUp_Redundant()
104 PetscCall(PCSetType(red->pc, PCBJACOBI)); in PCSetUp_Redundant()
106 PetscCall(PCFactorSetMatSolverType(red->pc, NULL)); in PCSetUp_Redundant()
110 PetscCall(KSPSetOperators(red->ksp, red->pmats, red->pmats)); in PCSetUp_Redundant()
113 PetscCall(MatCreateVecs(red->pmats, &red->xsub, &red->ysub)); in PCSetUp_Redundant()
119 PetscCall(MatGetLocalSize(red->pmats, &mloc_sub, NULL)); in PCSetUp_Redundant()
120 …PetscCall(VecCreateMPI(PetscSubcommContiguousParent(red->psubcomm), mloc_sub, PETSC_DECIDE, &red->… in PCSetUp_Redundant()
121 …ecCreateMPIWithArray(PetscSubcommContiguousParent(red->psubcomm), 1, mloc_sub, PETSC_DECIDE, NULL,… in PCSetUp_Redundant()
124 if (!red->scatterin) { /* efficiency of scatterin is independent from psubcomm_type! */ in PCSetUp_Redundant()
132 PetscCall(PetscMalloc2(red->psubcomm->n * mlocal, &idx1, red->psubcomm->n * mlocal, &idx2)); in PCSetUp_Redundant()
134 for (k = 0; k < red->psubcomm->n; k++) { in PCSetUp_Redundant()
140 PetscCall(ISCreateGeneral(comm, red->psubcomm->n * mlocal, idx1, PETSC_COPY_VALUES, &is1)); in PCSetUp_Redundant()
141 PetscCall(ISCreateGeneral(comm, red->psubcomm->n * mlocal, idx2, PETSC_COPY_VALUES, &is2)); in PCSetUp_Redundant()
142 PetscCall(VecScatterCreate(x, is1, red->xdup, is2, &red->scatterin)); in PCSetUp_Redundant()
147 PetscCall(ISCreateStride(comm, mlocal, mstart + red->psubcomm->color * M, 1, &is1)); in PCSetUp_Redundant()
149 PetscCall(VecScatterCreate(red->xdup, is1, x, is2, &red->scatterout)); in PCSetUp_Redundant()
156 PetscCall(KSPSetOperators(red->ksp, pc->mat, pc->pmat)); in PCSetUp_Redundant()
159 if (red->useparallelmat) { in PCSetUp_Redundant()
164 PetscCall(MatDestroy(&red->pmats)); in PCSetUp_Redundant()
169 …PetscCall(MatCreateRedundantMatrix(pc->pmat, red->psubcomm->n, PetscSubcommChild(red->psubcomm), r… in PCSetUp_Redundant()
170 PetscCall(KSPSetOperators(red->ksp, red->pmats, red->pmats)); in PCSetUp_Redundant()
172 PetscCall(KSPSetOperators(red->ksp, pc->mat, pc->pmat)); in PCSetUp_Redundant()
176 if (pc->setfromoptionscalled) PetscCall(KSPSetFromOptions(red->ksp)); in PCSetUp_Redundant()
182 PC_Redundant *red = (PC_Redundant *)pc->data; in PCApply_Redundant() local
186 if (!red->useparallelmat) { in PCApply_Redundant()
187 PetscCall(KSPSolve(red->ksp, x, y)); in PCApply_Redundant()
188 PetscCall(KSPCheckSolve(red->ksp, pc, y)); in PCApply_Redundant()
193 PetscCall(VecScatterBegin(red->scatterin, x, red->xdup, INSERT_VALUES, SCATTER_FORWARD)); in PCApply_Redundant()
194 PetscCall(VecScatterEnd(red->scatterin, x, red->xdup, INSERT_VALUES, SCATTER_FORWARD)); in PCApply_Redundant()
197 PetscCall(VecGetArray(red->xdup, &array)); in PCApply_Redundant()
198 PetscCall(VecPlaceArray(red->xsub, (const PetscScalar *)array)); in PCApply_Redundant()
201 PetscCall(KSPSolve(red->ksp, red->xsub, red->ysub)); in PCApply_Redundant()
202 PetscCall(KSPCheckSolve(red->ksp, pc, red->ysub)); in PCApply_Redundant()
203 PetscCall(VecResetArray(red->xsub)); in PCApply_Redundant()
204 PetscCall(VecRestoreArray(red->xdup, &array)); in PCApply_Redundant()
207 PetscCall(VecGetArray(red->ysub, &array)); in PCApply_Redundant()
208 PetscCall(VecPlaceArray(red->ydup, (const PetscScalar *)array)); in PCApply_Redundant()
211 PetscCall(VecScatterBegin(red->scatterout, red->ydup, y, INSERT_VALUES, SCATTER_FORWARD)); in PCApply_Redundant()
212 PetscCall(VecScatterEnd(red->scatterout, red->ydup, y, INSERT_VALUES, SCATTER_FORWARD)); in PCApply_Redundant()
213 PetscCall(VecResetArray(red->ydup)); in PCApply_Redundant()
214 PetscCall(VecRestoreArray(red->ysub, &array)); in PCApply_Redundant()
220 PC_Redundant *red = (PC_Redundant *)pc->data; in PCApplyTranspose_Redundant() local
224 if (!red->useparallelmat) { in PCApplyTranspose_Redundant()
225 PetscCall(KSPSolveTranspose(red->ksp, x, y)); in PCApplyTranspose_Redundant()
226 PetscCall(KSPCheckSolve(red->ksp, pc, y)); in PCApplyTranspose_Redundant()
231 PetscCall(VecScatterBegin(red->scatterin, x, red->xdup, INSERT_VALUES, SCATTER_FORWARD)); in PCApplyTranspose_Redundant()
232 PetscCall(VecScatterEnd(red->scatterin, x, red->xdup, INSERT_VALUES, SCATTER_FORWARD)); in PCApplyTranspose_Redundant()
235 PetscCall(VecGetArray(red->xdup, &array)); in PCApplyTranspose_Redundant()
236 PetscCall(VecPlaceArray(red->xsub, (const PetscScalar *)array)); in PCApplyTranspose_Redundant()
239 PetscCall(KSPSolveTranspose(red->ksp, red->xsub, red->ysub)); in PCApplyTranspose_Redundant()
240 PetscCall(KSPCheckSolve(red->ksp, pc, red->ysub)); in PCApplyTranspose_Redundant()
241 PetscCall(VecResetArray(red->xsub)); in PCApplyTranspose_Redundant()
242 PetscCall(VecRestoreArray(red->xdup, &array)); in PCApplyTranspose_Redundant()
245 PetscCall(VecGetArray(red->ysub, &array)); in PCApplyTranspose_Redundant()
246 PetscCall(VecPlaceArray(red->ydup, (const PetscScalar *)array)); in PCApplyTranspose_Redundant()
249 PetscCall(VecScatterBegin(red->scatterout, red->ydup, y, INSERT_VALUES, SCATTER_FORWARD)); in PCApplyTranspose_Redundant()
250 PetscCall(VecScatterEnd(red->scatterout, red->ydup, y, INSERT_VALUES, SCATTER_FORWARD)); in PCApplyTranspose_Redundant()
251 PetscCall(VecResetArray(red->ydup)); in PCApplyTranspose_Redundant()
252 PetscCall(VecRestoreArray(red->ysub, &array)); in PCApplyTranspose_Redundant()
258 PC_Redundant *red = (PC_Redundant *)pc->data; in PCReset_Redundant() local
261 if (red->useparallelmat) { in PCReset_Redundant()
262 PetscCall(VecScatterDestroy(&red->scatterin)); in PCReset_Redundant()
263 PetscCall(VecScatterDestroy(&red->scatterout)); in PCReset_Redundant()
264 PetscCall(VecDestroy(&red->ysub)); in PCReset_Redundant()
265 PetscCall(VecDestroy(&red->xsub)); in PCReset_Redundant()
266 PetscCall(VecDestroy(&red->xdup)); in PCReset_Redundant()
267 PetscCall(VecDestroy(&red->ydup)); in PCReset_Redundant()
269 PetscCall(MatDestroy(&red->pmats)); in PCReset_Redundant()
270 PetscCall(KSPReset(red->ksp)); in PCReset_Redundant()
276 PC_Redundant *red = (PC_Redundant *)pc->data; in PCDestroy_Redundant() local
280 PetscCall(KSPDestroy(&red->ksp)); in PCDestroy_Redundant()
281 PetscCall(PetscSubcommDestroy(&red->psubcomm)); in PCDestroy_Redundant()
293 PC_Redundant *red = (PC_Redundant *)pc->data; in PCSetFromOptions_Redundant() local
297 …dundant_number", "Number of redundant pc", "PCRedundantSetNumber", red->nsubcomm, &red->nsubcomm, … in PCSetFromOptions_Redundant()
304 PC_Redundant *red = (PC_Redundant *)pc->data; in PCRedundantSetNumber_Redundant() local
307 red->nsubcomm = nreds; in PCRedundantSetNumber_Redundant()
336 PC_Redundant *red = (PC_Redundant *)pc->data; in PCRedundantSetScatter_Redundant() local
340 PetscCall(VecScatterDestroy(&red->scatterin)); in PCRedundantSetScatter_Redundant()
342 red->scatterin = in; in PCRedundantSetScatter_Redundant()
345 PetscCall(VecScatterDestroy(&red->scatterout)); in PCRedundantSetScatter_Redundant()
346 red->scatterout = out; in PCRedundantSetScatter_Redundant()
378 PC_Redundant *red = (PC_Redundant *)pc->data; in PCRedundantGetKSP_Redundant() local
384 if (!red->psubcomm) { in PCRedundantGetKSP_Redundant()
388 PetscCall(PetscSubcommCreate(comm, &red->psubcomm)); in PCRedundantGetKSP_Redundant()
389 PetscCall(PetscSubcommSetNumber(red->psubcomm, red->nsubcomm)); in PCRedundantGetKSP_Redundant()
390 PetscCall(PetscSubcommSetType(red->psubcomm, PETSC_SUBCOMM_CONTIGUOUS)); in PCRedundantGetKSP_Redundant()
392 PetscCall(PetscSubcommSetOptionsPrefix(red->psubcomm, prefix)); in PCRedundantGetKSP_Redundant()
393 PetscCall(PetscSubcommSetFromOptions(red->psubcomm)); in PCRedundantGetKSP_Redundant()
396 subcomm = PetscSubcommChild(red->psubcomm); in PCRedundantGetKSP_Redundant()
398 PetscCall(KSPCreate(subcomm, &red->ksp)); in PCRedundantGetKSP_Redundant()
399 PetscCall(KSPSetNestLevel(red->ksp, pc->kspnestlevel)); in PCRedundantGetKSP_Redundant()
400 PetscCall(KSPSetErrorIfNotConverged(red->ksp, pc->erroriffailure)); in PCRedundantGetKSP_Redundant()
401 PetscCall(PetscObjectIncrementTabLevel((PetscObject)red->ksp, (PetscObject)pc, 1)); in PCRedundantGetKSP_Redundant()
402 PetscCall(KSPSetType(red->ksp, KSPPREONLY)); in PCRedundantGetKSP_Redundant()
403 PetscCall(KSPGetPC(red->ksp, &red->pc)); in PCRedundantGetKSP_Redundant()
407 PetscCall(PCSetType(red->pc, PCLU)); in PCRedundantGetKSP_Redundant()
409 PetscCall(PCSetType(red->pc, PCCHOLESKY)); in PCRedundantGetKSP_Redundant()
411 if (red->shifttypeset) { in PCRedundantGetKSP_Redundant()
412 PetscCall(PCFactorSetShiftType(red->pc, red->shifttype)); in PCRedundantGetKSP_Redundant()
413 red->shifttypeset = PETSC_FALSE; in PCRedundantGetKSP_Redundant()
415 PetscCall(KSPSetOptionsPrefix(red->ksp, prefix)); in PCRedundantGetKSP_Redundant()
416 PetscCall(KSPAppendOptionsPrefix(red->ksp, "redundant_")); in PCRedundantGetKSP_Redundant()
418 *innerksp = red->ksp; in PCRedundantGetKSP_Redundant()
448 PC_Redundant *red = (PC_Redundant *)pc->data; in PCRedundantGetOperators_Redundant() local
451 if (mat) *mat = red->pmats; in PCRedundantGetOperators_Redundant()
452 if (pmat) *pmat = red->pmats; in PCRedundantGetOperators_Redundant()
507 PC_Redundant *red; in PCCreate_Redundant() local
511 PetscCall(PetscNew(&red)); in PCCreate_Redundant()
514 red->nsubcomm = size; in PCCreate_Redundant()
515 red->useparallelmat = PETSC_TRUE; in PCCreate_Redundant()
516 pc->data = (void *)red; in PCCreate_Redundant()