Lines Matching refs:shell

33   Mat_Composite    *shell;  in MatDestroy_Composite()  local
38 PetscCall(MatShellGetContext(mat, &shell)); in MatDestroy_Composite()
39 next = shell->head; in MatDestroy_Composite()
47 PetscCall(VecDestroy(&shell->work)); in MatDestroy_Composite()
49 if (shell->Mvctx) { in MatDestroy_Composite()
50 for (i = 0; i < shell->nmat; i++) PetscCall(VecDestroy(&shell->lvecs[i])); in MatDestroy_Composite()
51 PetscCall(PetscFree3(shell->location, shell->larray, shell->lvecs)); in MatDestroy_Composite()
52 PetscCall(PetscFree(shell->larray)); in MatDestroy_Composite()
53 PetscCall(VecDestroy(&shell->gvec)); in MatDestroy_Composite()
54 PetscCall(VecScatterDestroy(&shell->Mvctx)); in MatDestroy_Composite()
57 PetscCall(PetscFree(shell->scalings)); in MatDestroy_Composite()
68 PetscCall(PetscFree(shell)); in MatDestroy_Composite()
75 Mat_Composite *shell; in MatMult_Composite_Multiplicative() local
80 PetscCall(MatShellGetContext(A, &shell)); in MatMult_Composite_Multiplicative()
81 next = shell->head; in MatMult_Composite_Multiplicative()
93 if (shell->scalings) { in MatMult_Composite_Multiplicative()
95 for (PetscInt i = 0; i < shell->nmat; i++) scale *= shell->scalings[i]; in MatMult_Composite_Multiplicative()
103 Mat_Composite *shell; in MatMultTranspose_Composite_Multiplicative() local
108 PetscCall(MatShellGetContext(A, &shell)); in MatMultTranspose_Composite_Multiplicative()
109 tail = shell->tail; in MatMultTranspose_Composite_Multiplicative()
121 if (shell->scalings) { in MatMultTranspose_Composite_Multiplicative()
123 for (PetscInt i = 0; i < shell->nmat; i++) scale *= shell->scalings[i]; in MatMultTranspose_Composite_Multiplicative()
131 Mat_Composite *shell; in MatMult_Composite() local
142 PetscCall(MatShellGetContext(mat, &shell)); in MatMult_Composite()
143 cur = shell->head; in MatMult_Composite()
150 if (shell->merge_mvctx && !shell->Mvctx) { in MatMult_Composite()
152 for (cur = shell->head; cur; cur = cur->next) { in MatMult_Composite()
155 shell->merge_mvctx = PETSC_FALSE; in MatMult_Composite()
162 for (cur = shell->head; cur; cur = cur->next) { in MatMult_Composite()
167 PetscCall(PetscMalloc3(tot, &shell->location, tot, &shell->larray, shell->nmat, &shell->lvecs)); in MatMult_Composite()
168 shell->len = tot; in MatMult_Composite()
174 for (cur = shell->head; cur; cur = cur->next) { in MatMult_Composite()
204 for (cur = shell->head, j = 0; cur; cur = cur->next, j++) { /* j-th matrix */ in MatMult_Composite()
207 PetscCall(VecCreateSeqWithArray(PETSC_COMM_SELF, 1, n, NULL, &shell->lvecs[j])); in MatMult_Composite()
217 shell->location[tot + i] = lo; /* gindices[lo] = garray[i] */ in MatMult_Composite()
227 PetscCall(VecCreateSeq(PETSC_COMM_SELF, nuniq, &shell->gvec)); in MatMult_Composite()
228 PetscCall(VecScatterCreate(xin, ix, shell->gvec, iy, &shell->Mvctx)); in MatMult_Composite()
239 if (shell->Mvctx) { /* Have a merged Mvctx */ in MatMult_Composite()
244 PetscCall(VecScatterBegin(shell->Mvctx, x, shell->gvec, INSERT_VALUES, SCATTER_FORWARD)); in MatMult_Composite()
245 PetscCall(VecScatterEnd(shell->Mvctx, x, shell->gvec, INSERT_VALUES, SCATTER_FORWARD)); in MatMult_Composite()
247 PetscCall(VecGetArrayRead(shell->gvec, &vals)); in MatMult_Composite()
248 for (i = 0; i < shell->len; i++) shell->larray[i] = vals[shell->location[i]]; in MatMult_Composite()
249 PetscCall(VecRestoreArrayRead(shell->gvec, &vals)); in MatMult_Composite()
251 for (cur = shell->head, tot = i = 0; cur; cur = cur->next, i++) { /* i-th matrix */ in MatMult_Composite()
255 PetscCall(VecPlaceArray(shell->lvecs[i], &shell->larray[tot])); in MatMult_Composite()
256 PetscUseTypeMethod(B, multadd, shell->lvecs[i], y2, y2); in MatMult_Composite()
257 PetscCall(VecResetArray(shell->lvecs[i])); in MatMult_Composite()
258 PetscCall(VecAXPY(y, shell->scalings ? shell->scalings[i] : 1.0, y2)); in MatMult_Composite()
262 if (shell->scalings) { in MatMult_Composite()
263 for (cur = shell->head, i = 0; cur; cur = cur->next, i++) { in MatMult_Composite()
265 PetscCall(VecAXPY(y, shell->scalings[i], y2)); in MatMult_Composite()
268 for (cur = shell->head; cur; cur = cur->next) PetscCall(MatMultAdd(cur->mat, x, y, y)); in MatMult_Composite()
276 Mat_Composite *shell; in MatMultTranspose_Composite() local
282 PetscCall(MatShellGetContext(A, &shell)); in MatMultTranspose_Composite()
283 next = shell->head; in MatMultTranspose_Composite()
287 if (shell->scalings) { in MatMultTranspose_Composite()
288 PetscCall(VecScale(y, shell->scalings[0])); in MatMultTranspose_Composite()
294 if (!shell->scalings) PetscCall(MatMultTransposeAdd(next->mat, x, y, y)); in MatMultTranspose_Composite()
297 PetscCall(VecAXPY(y, shell->scalings[i++], y2)); in MatMultTranspose_Composite()
305 Mat_Composite *shell; in MatGetDiagonal_Composite() local
310 PetscCall(MatShellGetContext(A, &shell)); in MatGetDiagonal_Composite()
311 next = shell->head; in MatGetDiagonal_Composite()
314 if (shell->scalings) PetscCall(VecScale(v, shell->scalings[0])); in MatGetDiagonal_Composite()
316 if (next->next && !shell->work) PetscCall(VecDuplicate(v, &shell->work)); in MatGetDiagonal_Composite()
319 PetscCall(MatGetDiagonal(next->mat, shell->work)); in MatGetDiagonal_Composite()
320 PetscCall(VecAXPY(v, shell->scalings ? shell->scalings[i++] : 1.0, shell->work)); in MatGetDiagonal_Composite()
327 Mat_Composite *shell; in MatAssemblyEnd_Composite() local
330 PetscCall(MatShellGetContext(Y, &shell)); in MatAssemblyEnd_Composite()
331 if (shell->merge) PetscCall(MatCompositeMerge(Y)); in MatAssemblyEnd_Composite()
403 Mat_Composite *shell; in MatCompositeAddMat_Composite() local
409 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeAddMat_Composite()
410 next = shell->head; in MatCompositeAddMat_Composite()
416 if (!next) shell->head = ilink; in MatCompositeAddMat_Composite()
422 shell->tail = ilink; in MatCompositeAddMat_Composite()
423 shell->nmat += 1; in MatCompositeAddMat_Composite()
428 if (shell->nmat == 1) PetscCall(MatSetVecType(mat, vtype_smat)); in MatCompositeAddMat_Composite()
436 if (shell->scalings) { in MatCompositeAddMat_Composite()
437 PetscCall(PetscRealloc(sizeof(PetscScalar) * shell->nmat, &shell->scalings)); in MatCompositeAddMat_Composite()
438 shell->scalings[shell->nmat - 1] = 1.0; in MatCompositeAddMat_Composite()
442 if (shell->nmat == 1) PetscCall(PetscLayoutReference(smat->cmap, &mat->cmap)); in MatCompositeAddMat_Composite()
514 Mat_Composite *shell; in MatCompositeGetType_Composite() local
517 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeGetType_Composite()
518 *type = shell->type; in MatCompositeGetType_Composite()
548 Mat_Composite *shell; in MatCompositeSetMatStructure_Composite() local
551 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeSetMatStructure_Composite()
552 shell->structure = str; in MatCompositeSetMatStructure_Composite()
582 Mat_Composite *shell; in MatCompositeGetMatStructure_Composite() local
585 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeGetMatStructure_Composite()
586 *str = shell->structure; in MatCompositeGetMatStructure_Composite()
616 Mat_Composite *shell; in MatCompositeSetMergeType_Composite() local
619 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeSetMergeType_Composite()
620 shell->mergetype = type; in MatCompositeSetMergeType_Composite()
654 Mat_Composite *shell; in MatCompositeMerge_Composite() local
662 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeMerge_Composite()
663 next = shell->head; in MatCompositeMerge_Composite()
664 prev = shell->tail; in MatCompositeMerge_Composite()
667 if (shell->type == MAT_COMPOSITE_ADDITIVE) { in MatCompositeMerge_Composite()
668 if (shell->mergetype == MAT_COMPOSITE_MERGE_RIGHT) { in MatCompositeMerge_Composite()
671 if (shell->scalings) PetscCall(MatScale(tmat, shell->scalings[i++])); in MatCompositeMerge_Composite()
672 …(next = next->next)) PetscCall(MatAXPY(tmat, shell->scalings ? shell->scalings[i++] : 1.0, next->m… in MatCompositeMerge_Composite()
674 i = shell->nmat - 1; in MatCompositeMerge_Composite()
676 if (shell->scalings) PetscCall(MatScale(tmat, shell->scalings[i--])); in MatCompositeMerge_Composite()
677 …(prev = prev->prev)) PetscCall(MatAXPY(tmat, shell->scalings ? shell->scalings[i--] : 1.0, prev->m… in MatCompositeMerge_Composite()
680 if (shell->mergetype == MAT_COMPOSITE_MERGE_RIGHT) { in MatCompositeMerge_Composite()
695 if (shell->scalings) { in MatCompositeMerge_Composite()
696 for (i = 0; i < shell->nmat; i++) scale *= shell->scalings[i]; in MatCompositeMerge_Composite()
748 Mat_Composite *shell; in MatCompositeGetNumberMat_Composite() local
751 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeGetNumberMat_Composite()
752 *nmat = shell->nmat; in MatCompositeGetNumberMat_Composite()
782 Mat_Composite *shell; in MatCompositeGetMat_Composite() local
787 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeGetMat_Composite()
788 …k(i < shell->nmat, PetscObjectComm((PetscObject)mat), PETSC_ERR_ARG_OUTOFRANGE, "index out of rang… in MatCompositeGetMat_Composite()
789 ilink = shell->head; in MatCompositeGetMat_Composite()
823 Mat_Composite *shell; in MatCompositeSetScalings_Composite() local
827 PetscCall(MatShellGetContext(mat, &shell)); in MatCompositeSetScalings_Composite()
829 if (!shell->scalings) PetscCall(PetscMalloc1(nmat, &shell->scalings)); in MatCompositeSetScalings_Composite()
830 PetscCall(PetscArraycpy(shell->scalings, scalings, nmat)); in MatCompositeSetScalings_Composite()