Lines Matching refs:red
30 PC_Redistribute *red = (PC_Redistribute *)pc->data; in PCFieldSplitSetIS_Redistribute() local
31 PC_FieldSplitLink *next = &red->splitlinks; in PCFieldSplitSetIS_Redistribute()
40 PetscCall(PetscSNPrintf((*next)->splitname, 7, "%" PetscInt_FMT, red->nsplits++)); in PCFieldSplitSetIS_Redistribute()
50 PC_Redistribute *red = (PC_Redistribute *)pc->data; in PCView_Redistribute() local
58 …PetscCallMPI(MPIU_Allreduce(&red->dcnt, &ncnt, 1, MPIU_INT, MPI_SUM, PetscObjectComm((PetscObject)… in PCView_Redistribute()
62 PetscCall(KSPView(red->ksp, viewer)); in PCView_Redistribute()
65 PetscCall(KSPView(red->ksp, viewer)); in PCView_Redistribute()
72 PC_Redistribute *red = (PC_Redistribute *)pc->data; in PCSetUp_Redistribute() local
90 PC_FieldSplitLink *next = &red->splitlinks; in PCSetUp_Redistribute()
95 PetscCall(KSPGetOperators(red->ksp, NULL, &tmat)); in PCSetUp_Redistribute()
96 PetscCall(MatCreateSubMatrix(pc->pmat, red->is, red->is, MAT_REUSE_MATRIX, &tmat)); in PCSetUp_Redistribute()
97 PetscCall(KSPSetOperators(red->ksp, tmat, tmat)); in PCSetUp_Redistribute()
206 red->drows = drows; in PCSetUp_Redistribute()
207 red->dcnt = dcnt; in PCSetUp_Redistribute()
228 PetscCall(ISCreateGeneral(comm, slen, rvalues, PETSC_COPY_VALUES, &red->is)); in PCSetUp_Redistribute()
242 PetscCall(ISCreateGeneral(comm, cnt, rows, PETSC_OWN_POINTER, &red->is)); in PCSetUp_Redistribute()
243 red->drows = drows; in PCSetUp_Redistribute()
244 red->dcnt = dcnt; in PCSetUp_Redistribute()
249 PetscCall(VecCreateMPI(comm, slen, PETSC_DETERMINE, &red->b)); in PCSetUp_Redistribute()
250 PetscCall(VecDuplicate(red->b, &red->x)); in PCSetUp_Redistribute()
252 PetscCall(VecScatterCreate(tvec, red->is, red->b, NULL, &red->scatter)); in PCSetUp_Redistribute()
255 PetscCall(KSPGetPC(red->ksp, &ipc)); in PCSetUp_Redistribute()
263 …PetscCheck(red->nsplits <= (PetscInt)PETSC_STATIC_ARRAY_LENGTH(primes), PETSC_COMM_SELF, PETSC_ERR… in PCSetUp_Redistribute()
279 PetscCall(VecScatterBegin(red->scatter, tvec, red->b, INSERT_VALUES, SCATTER_FORWARD)); in PCSetUp_Redistribute()
280 PetscCall(VecScatterEnd(red->scatter, tvec, red->b, INSERT_VALUES, SCATTER_FORWARD)); in PCSetUp_Redistribute()
282 PetscCall(VecGetArrayRead(red->b, &ab)); in PCSetUp_Redistribute()
283 next = &red->splitlinks; in PCSetUp_Redistribute()
304 PetscCall(VecRestoreArrayRead(red->b, &ab)); in PCSetUp_Redistribute()
307 PetscCall(MatCreateSubMatrix(pc->pmat, red->is, red->is, MAT_INITIAL_MATRIX, &tmat)); in PCSetUp_Redistribute()
308 PetscCall(KSPSetOperators(red->ksp, tmat, tmat)); in PCSetUp_Redistribute()
314 PetscCall(PetscFree(red->diag)); in PCSetUp_Redistribute()
315 PetscCall(PetscMalloc1(red->dcnt, &red->diag)); in PCSetUp_Redistribute()
319 for (PetscInt i = 0; i < red->dcnt; i++) { in PCSetUp_Redistribute()
320 if (d[red->drows[i]] != 0) red->diag[i] = 1.0 / d[red->drows[i]]; in PCSetUp_Redistribute()
322 red->zerodiag = PETSC_TRUE; in PCSetUp_Redistribute()
323 red->diag[i] = 0.0; in PCSetUp_Redistribute()
328 PetscCall(KSPSetUp(red->ksp)); in PCSetUp_Redistribute()
334 PC_Redistribute *red = (PC_Redistribute *)pc->data; in PCApply_Redistribute() local
335 PetscInt dcnt = red->dcnt, i; in PCApply_Redistribute()
336 const PetscInt *drows = red->drows; in PCApply_Redistribute()
338 const PetscScalar *bwork, *diag = red->diag; in PCApply_Redistribute()
342 if (!red->work) PetscCall(VecDuplicate(b, &red->work)); in PCApply_Redistribute()
343 PetscCall(KSPGetInitialGuessNonzero(red->ksp, &nonzero_guess)); in PCApply_Redistribute()
345 PetscCall(VecScatterBegin(red->scatter, x, red->x, INSERT_VALUES, SCATTER_FORWARD)); in PCApply_Redistribute()
346 PetscCall(VecScatterEnd(red->scatter, x, red->x, INSERT_VALUES, SCATTER_FORWARD)); in PCApply_Redistribute()
353 if (red->zerodiag) { in PCApply_Redistribute()
365 PetscCall(VecRestoreArray(red->work, &xwork)); in PCApply_Redistribute()
368 PetscCall(MatMult(pc->pmat, x, red->work)); in PCApply_Redistribute()
369 PetscCall(VecAYPX(red->work, -1.0, b)); /* red->work = b - A x */ in PCApply_Redistribute()
371 PetscCall(VecScatterBegin(red->scatter, red->work, red->b, INSERT_VALUES, SCATTER_FORWARD)); in PCApply_Redistribute()
372 PetscCall(VecScatterEnd(red->scatter, red->work, red->b, INSERT_VALUES, SCATTER_FORWARD)); in PCApply_Redistribute()
373 PetscCall(KSPSolve(red->ksp, red->b, red->x)); in PCApply_Redistribute()
374 PetscCall(KSPCheckSolve(red->ksp, pc, red->x)); in PCApply_Redistribute()
375 PetscCall(VecScatterBegin(red->scatter, red->x, x, INSERT_VALUES, SCATTER_REVERSE)); in PCApply_Redistribute()
376 PetscCall(VecScatterEnd(red->scatter, red->x, x, INSERT_VALUES, SCATTER_REVERSE)); in PCApply_Redistribute()
382 PC_Redistribute *red = (PC_Redistribute *)pc->data; in PCApplyTranspose_Redistribute() local
383 PetscInt dcnt = red->dcnt, i; in PCApplyTranspose_Redistribute()
384 const PetscInt *drows = red->drows; in PCApplyTranspose_Redistribute()
386 const PetscScalar *bwork, *diag = red->diag; in PCApplyTranspose_Redistribute()
392 if (!red->work) PetscCall(VecDuplicate(b, &red->work)); in PCApplyTranspose_Redistribute()
393 PetscCall(KSPGetInitialGuessNonzero(red->ksp, &nonzero_guess)); in PCApplyTranspose_Redistribute()
395 PetscCall(VecScatterBegin(red->scatter, x, red->x, INSERT_VALUES, SCATTER_FORWARD)); in PCApplyTranspose_Redistribute()
396 PetscCall(VecScatterEnd(red->scatter, x, red->x, INSERT_VALUES, SCATTER_FORWARD)); in PCApplyTranspose_Redistribute()
403 if (red->zerodiag) { in PCApplyTranspose_Redistribute()
415 PetscCall(VecRestoreArray(red->work, &xwork)); in PCApplyTranspose_Redistribute()
418 PetscCall(MatMultTranspose(pc->pmat, x, red->work)); in PCApplyTranspose_Redistribute()
419 PetscCall(VecAYPX(red->work, -1.0, b)); /* red->work = b - A^T x */ in PCApplyTranspose_Redistribute()
421 PetscCall(VecScatterBegin(red->scatter, red->work, red->b, INSERT_VALUES, SCATTER_FORWARD)); in PCApplyTranspose_Redistribute()
422 PetscCall(VecScatterEnd(red->scatter, red->work, red->b, INSERT_VALUES, SCATTER_FORWARD)); in PCApplyTranspose_Redistribute()
423 PetscCall(KSPSolveTranspose(red->ksp, red->b, red->x)); in PCApplyTranspose_Redistribute()
424 PetscCall(KSPCheckSolve(red->ksp, pc, red->x)); in PCApplyTranspose_Redistribute()
425 PetscCall(VecScatterBegin(red->scatter, red->x, x, INSERT_VALUES, SCATTER_REVERSE)); in PCApplyTranspose_Redistribute()
426 PetscCall(VecScatterEnd(red->scatter, red->x, x, INSERT_VALUES, SCATTER_REVERSE)); in PCApplyTranspose_Redistribute()
432 PC_Redistribute *red = (PC_Redistribute *)pc->data; in PCDestroy_Redistribute() local
433 PC_FieldSplitLink next = red->splitlinks; in PCDestroy_Redistribute()
446 PetscCall(VecScatterDestroy(&red->scatter)); in PCDestroy_Redistribute()
447 PetscCall(ISDestroy(&red->is)); in PCDestroy_Redistribute()
448 PetscCall(VecDestroy(&red->b)); in PCDestroy_Redistribute()
449 PetscCall(VecDestroy(&red->x)); in PCDestroy_Redistribute()
450 PetscCall(KSPDestroy(&red->ksp)); in PCDestroy_Redistribute()
451 PetscCall(VecDestroy(&red->work)); in PCDestroy_Redistribute()
452 PetscCall(PetscFree(red->drows)); in PCDestroy_Redistribute()
453 PetscCall(PetscFree(red->diag)); in PCDestroy_Redistribute()
460 PC_Redistribute *red = (PC_Redistribute *)pc->data; in PCSetFromOptions_Redistribute() local
463 PetscCall(KSPSetFromOptions(red->ksp)); in PCSetFromOptions_Redistribute()
484 PC_Redistribute *red = (PC_Redistribute *)pc->data; in PCRedistributeGetKSP() local
489 *innerksp = red->ksp; in PCRedistributeGetKSP()
524 PC_Redistribute *red; in PCCreate_Redistribute() local
528 PetscCall(PetscNew(&red)); in PCCreate_Redistribute()
529 pc->data = (void *)red; in PCCreate_Redistribute()
538 PetscCall(KSPCreate(PetscObjectComm((PetscObject)pc), &red->ksp)); in PCCreate_Redistribute()
539 PetscCall(KSPSetNestLevel(red->ksp, pc->kspnestlevel)); in PCCreate_Redistribute()
540 PetscCall(KSPSetErrorIfNotConverged(red->ksp, pc->erroriffailure)); in PCCreate_Redistribute()
541 PetscCall(PetscObjectIncrementTabLevel((PetscObject)red->ksp, (PetscObject)pc, 1)); in PCCreate_Redistribute()
543 PetscCall(KSPSetOptionsPrefix(red->ksp, prefix)); in PCCreate_Redistribute()
544 PetscCall(KSPAppendOptionsPrefix(red->ksp, "redistribute_")); in PCCreate_Redistribute()