Lines Matching refs:pcis
5 PC_IS *pcis = (PC_IS *)pc->data; in PCISSetUseStiffnessScaling_IS() local
8 pcis->use_stiffness_scaling = use; in PCISSetUseStiffnessScaling_IS()
39 PC_IS *pcis = (PC_IS *)pc->data; in PCISSetSubdomainDiagonalScaling_IS() local
43 PetscCall(VecDestroy(&pcis->D)); in PCISSetSubdomainDiagonalScaling_IS()
44 pcis->D = scaling_factors; in PCISSetSubdomainDiagonalScaling_IS()
48 PetscCall(VecGetSize(pcis->D, &sn)); in PCISSetSubdomainDiagonalScaling_IS()
49 if (sn == pcis->n) { in PCISSetSubdomainDiagonalScaling_IS()
50 … PetscCall(VecScatterBegin(pcis->N_to_B, pcis->D, pcis->vec1_B, INSERT_VALUES, SCATTER_FORWARD)); in PCISSetSubdomainDiagonalScaling_IS()
51 PetscCall(VecScatterEnd(pcis->N_to_B, pcis->D, pcis->vec1_B, INSERT_VALUES, SCATTER_FORWARD)); in PCISSetSubdomainDiagonalScaling_IS()
52 PetscCall(VecDestroy(&pcis->D)); in PCISSetSubdomainDiagonalScaling_IS()
53 PetscCall(VecDuplicate(pcis->vec1_B, &pcis->D)); in PCISSetSubdomainDiagonalScaling_IS()
54 PetscCall(VecCopy(pcis->vec1_B, pcis->D)); in PCISSetSubdomainDiagonalScaling_IS()
55 …pcis->n_B, PETSC_COMM_SELF, PETSC_ERR_ARG_INCOMP, "Invalid size for scaling vector. Expected %" Pe… in PCISSetSubdomainDiagonalScaling_IS()
89 PC_IS *pcis = (PC_IS *)pc->data; in PCISSetSubdomainScalingFactor_IS() local
92 pcis->scaling_factor = scal; in PCISSetSubdomainScalingFactor_IS()
93 if (pcis->D) PetscCall(VecSet(pcis->D, pcis->scaling_factor)); in PCISSetSubdomainScalingFactor_IS()
139 PC_IS *pcis = (PC_IS *)pc->data; in PCISSetUp() local
161 PetscCall(ISLocalToGlobalMappingDestroy(&pcis->mapping)); in PCISSetUp()
162 pcis->mapping = matis->rmapping; in PCISSetUp()
163 PetscCall(ISLocalToGlobalMappingGetSize(pcis->mapping, &pcis->n)); in PCISSetUp()
164 …PetscCall(ISLocalToGlobalMappingGetInfo(pcis->mapping, &pcis->n_neigh, &pcis->neigh, &pcis->n_shar… in PCISSetUp()
167 PetscCall(ISLocalToGlobalMappingGetNodeInfo(pcis->mapping, NULL, &count, NULL)); in PCISSetUp()
168 PetscCall(PetscMalloc1(pcis->n, &idx_I_local)); in PCISSetUp()
169 PetscCall(PetscMalloc1(pcis->n, &idx_B_local)); in PCISSetUp()
170 for (i = 0, pcis->n_B = 0, n_I = 0; i < pcis->n; i++) { in PCISSetUp()
175 idx_B_local[pcis->n_B] = i; in PCISSetUp()
176 pcis->n_B++; in PCISSetUp()
179 PetscCall(ISLocalToGlobalMappingRestoreNodeInfo(pcis->mapping, NULL, &count, NULL)); in PCISSetUp()
183 idx_I_global = PetscSafePointerPlusOffset(idx_B_local, pcis->n_B); in PCISSetUp()
184 PetscCall(ISLocalToGlobalMappingApply(pcis->mapping, pcis->n_B, idx_B_local, idx_B_global)); in PCISSetUp()
185 PetscCall(ISLocalToGlobalMappingApply(pcis->mapping, n_I, idx_I_local, idx_I_global)); in PCISSetUp()
188 …PetscCall(ISCreateGeneral(PETSC_COMM_SELF, pcis->n_B, idx_B_local, PETSC_COPY_VALUES, &pcis->is_B_… in PCISSetUp()
189 …l(ISCreateGeneral(PetscObjectComm((PetscObject)pc), pcis->n_B, idx_B_global, PETSC_COPY_VALUES, &p… in PCISSetUp()
190 …PetscCall(ISCreateGeneral(PETSC_COMM_SELF, n_I, idx_I_local, PETSC_COPY_VALUES, &pcis->is_I_local)… in PCISSetUp()
191 …neral(PetscObjectComm((PetscObject)pc), n_I, idx_I_global, PETSC_COPY_VALUES, &pcis->is_I_global)); in PCISSetUp()
198 PetscCall(VecDuplicate(matis->x, &pcis->vec1_N)); in PCISSetUp()
199 PetscCall(VecDuplicate(pcis->vec1_N, &pcis->vec2_N)); in PCISSetUp()
200 PetscCall(VecCreate(PETSC_COMM_SELF, &pcis->vec1_D)); in PCISSetUp()
201 PetscCall(VecSetSizes(pcis->vec1_D, pcis->n - pcis->n_B, PETSC_DECIDE)); in PCISSetUp()
202 PetscCall(VecSetType(pcis->vec1_D, ((PetscObject)pcis->vec1_N)->type_name)); in PCISSetUp()
203 PetscCall(VecDuplicate(pcis->vec1_D, &pcis->vec2_D)); in PCISSetUp()
204 PetscCall(VecDuplicate(pcis->vec1_D, &pcis->vec3_D)); in PCISSetUp()
205 PetscCall(VecDuplicate(pcis->vec1_D, &pcis->vec4_D)); in PCISSetUp()
206 PetscCall(VecCreate(PETSC_COMM_SELF, &pcis->vec1_B)); in PCISSetUp()
207 PetscCall(VecSetSizes(pcis->vec1_B, pcis->n_B, PETSC_DECIDE)); in PCISSetUp()
208 PetscCall(VecSetType(pcis->vec1_B, ((PetscObject)pcis->vec1_N)->type_name)); in PCISSetUp()
209 PetscCall(VecDuplicate(pcis->vec1_B, &pcis->vec2_B)); in PCISSetUp()
210 PetscCall(VecDuplicate(pcis->vec1_B, &pcis->vec3_B)); in PCISSetUp()
211 PetscCall(MatCreateVecs(pc->pmat, &pcis->vec1_global, NULL)); in PCISSetUp()
212 PetscCall(PetscMalloc1(pcis->n, &pcis->work_N)); in PCISSetUp()
214 …if (!pcis->D) { /* it can happen that the user passed in a scaling vector via PCISSetSubdomainDiag… in PCISSetUp()
215 PetscCall(VecDuplicate(pcis->vec1_B, &pcis->D)); in PCISSetUp()
216 PetscCall(VecSet(pcis->D, pcis->scaling_factor)); in PCISSetUp()
220 PetscCall(VecScatterCreate(pcis->vec1_N, pcis->is_I_local, pcis->vec1_D, (IS)0, &pcis->N_to_D)); in PCISSetUp()
221 …PetscCall(VecScatterCreate(pcis->vec1_global, pcis->is_I_global, pcis->vec1_D, (IS)0, &pcis->globa… in PCISSetUp()
222 PetscCall(VecScatterCreate(pcis->vec1_N, pcis->is_B_local, pcis->vec1_B, (IS)0, &pcis->N_to_B)); in PCISSetUp()
223 …PetscCall(VecScatterCreate(pcis->vec1_global, pcis->is_B_global, pcis->vec1_B, (IS)0, &pcis->globa… in PCISSetUp()
226 PetscCall(ISLocalToGlobalMappingCreateIS(pcis->is_B_local, &pcis->BtoNmap)); in PCISSetUp()
232 PetscCall(VecGetSize(pcis->D, &sn)); in PCISSetUp()
233 if (sn == pcis->n) { in PCISSetUp()
234 … PetscCall(VecScatterBegin(pcis->N_to_B, pcis->D, pcis->vec1_B, INSERT_VALUES, SCATTER_FORWARD)); in PCISSetUp()
235 PetscCall(VecScatterEnd(pcis->N_to_B, pcis->D, pcis->vec1_B, INSERT_VALUES, SCATTER_FORWARD)); in PCISSetUp()
236 PetscCall(VecDestroy(&pcis->D)); in PCISSetUp()
237 PetscCall(VecDuplicate(pcis->vec1_B, &pcis->D)); in PCISSetUp()
238 PetscCall(VecCopy(pcis->vec1_B, pcis->D)); in PCISSetUp()
239 …pcis->n_B, PETSC_COMM_SELF, PETSC_ERR_ARG_INCOMP, "Invalid size for scaling vector. Expected %" Pe… in PCISSetUp()
255 if (pcis->reusesubmatrices && pc->setupcalled) { in PCISSetUp()
263 PetscCall(MatDestroy(&pcis->A_II)); in PCISSetUp()
264 PetscCall(MatDestroy(&pcis->pA_II)); in PCISSetUp()
265 PetscCall(MatDestroy(&pcis->A_IB)); in PCISSetUp()
266 PetscCall(MatDestroy(&pcis->A_BI)); in PCISSetUp()
267 PetscCall(MatDestroy(&pcis->A_BB)); in PCISSetUp()
270 PetscCall(ISLocalToGlobalMappingGetBlockSize(pcis->mapping, &ibs)); in PCISSetUp()
272 … PetscCall(MatCreateSubMatrix(matis->A, pcis->is_I_local, pcis->is_I_local, reuse, &pcis->pA_II)); in PCISSetUp()
275 … PetscCall(MatCreateSubMatrix(amatis->A, pcis->is_I_local, pcis->is_I_local, reuse, &pcis->A_II)); in PCISSetUp()
277 PetscCall(PetscObjectReference((PetscObject)pcis->pA_II)); in PCISSetUp()
278 PetscCall(MatDestroy(&pcis->A_II)); in PCISSetUp()
279 pcis->A_II = pcis->pA_II; in PCISSetUp()
281 PetscCall(MatSetBlockSize(pcis->A_II, bs == ibs ? bs : 1)); in PCISSetUp()
282 PetscCall(MatSetBlockSize(pcis->pA_II, bs == ibs ? bs : 1)); in PCISSetUp()
283 PetscCall(MatCreateSubMatrix(matis->A, pcis->is_B_local, pcis->is_B_local, reuse, &pcis->A_BB)); in PCISSetUp()
286 … PetscCall(MatCreateSubMatrix(matis->A, pcis->is_I_local, pcis->is_B_local, reuse, &pcis->A_IB)); in PCISSetUp()
287 … PetscCall(MatCreateSubMatrix(matis->A, pcis->is_B_local, pcis->is_I_local, reuse, &pcis->A_BI)); in PCISSetUp()
292 PetscCall(MatCreateSubMatrix(newmat, pcis->is_I_local, pcis->is_B_local, reuse, &pcis->A_IB)); in PCISSetUp()
293 PetscCall(MatCreateSubMatrix(newmat, pcis->is_B_local, pcis->is_I_local, reuse, &pcis->A_BI)); in PCISSetUp()
296 PetscCall(MatSetBlockSize(pcis->A_BB, bs == ibs ? bs : 1)); in PCISSetUp()
300 …pc)->options, ((PetscObject)pc)->prefix, "-pc_is_use_stiffness_scaling", &pcis->use_stiffness_scal… in PCISSetUp()
301 if (pcis->use_stiffness_scaling) { in PCISSetUp()
305 if (pcis->A_BB) { in PCISSetUp()
306 PetscCall(MatGetDiagonal(pcis->A_BB, pcis->D)); in PCISSetUp()
308 PetscCall(MatGetDiagonal(matis->A, pcis->vec1_N)); in PCISSetUp()
309 … PetscCall(VecScatterBegin(pcis->N_to_B, pcis->vec1_N, pcis->D, INSERT_VALUES, SCATTER_FORWARD)); in PCISSetUp()
310 PetscCall(VecScatterEnd(pcis->N_to_B, pcis->vec1_N, pcis->D, INSERT_VALUES, SCATTER_FORWARD)); in PCISSetUp()
312 PetscCall(VecAbs(pcis->D)); in PCISSetUp()
313 PetscCall(VecGetLocalSize(pcis->D, &n)); in PCISSetUp()
314 PetscCall(VecGetArray(pcis->D, &a)); in PCISSetUp()
317 PetscCall(VecRestoreArray(pcis->D, &a)); in PCISSetUp()
319 PetscCall(VecSet(pcis->vec1_global, 0.0)); in PCISSetUp()
320 …PetscCall(VecScatterBegin(pcis->global_to_B, pcis->D, pcis->vec1_global, ADD_VALUES, SCATTER_REVER… in PCISSetUp()
321 …PetscCall(VecScatterEnd(pcis->global_to_B, pcis->D, pcis->vec1_global, ADD_VALUES, SCATTER_REVERSE… in PCISSetUp()
322 …PetscCall(VecScatterBegin(pcis->global_to_B, pcis->vec1_global, pcis->vec1_B, INSERT_VALUES, SCATT… in PCISSetUp()
323 …PetscCall(VecScatterEnd(pcis->global_to_B, pcis->vec1_global, pcis->vec1_B, INSERT_VALUES, SCATTER… in PCISSetUp()
324 PetscCall(VecPointwiseDivide(pcis->D, pcis->D, pcis->vec1_B)); in PCISSetUp()
330 pcis->pure_neumann = matis->pure_neumann; in PCISSetUp()
332 PetscCall(KSPCreate(PETSC_COMM_SELF, &pcis->ksp_D)); in PCISSetUp()
333 PetscCall(KSPSetNestLevel(pcis->ksp_D, pc->kspnestlevel)); in PCISSetUp()
334 PetscCall(KSPSetErrorIfNotConverged(pcis->ksp_D, pc->erroriffailure)); in PCISSetUp()
335 PetscCall(PetscObjectIncrementTabLevel((PetscObject)pcis->ksp_D, (PetscObject)pc, 1)); in PCISSetUp()
336 PetscCall(KSPSetOperators(pcis->ksp_D, pcis->A_II, pcis->A_II)); in PCISSetUp()
337 PetscCall(KSPSetOptionsPrefix(pcis->ksp_D, "is_localD_")); in PCISSetUp()
338 PetscCall(KSPGetPC(pcis->ksp_D, &pc_ctx)); in PCISSetUp()
340 PetscCall(KSPSetType(pcis->ksp_D, KSPPREONLY)); in PCISSetUp()
341 PetscCall(KSPSetFromOptions(pcis->ksp_D)); in PCISSetUp()
343 PetscCall(KSPSetUp(pcis->ksp_D)); in PCISSetUp()
345 PetscCall(KSPCreate(PETSC_COMM_SELF, &pcis->ksp_N)); in PCISSetUp()
346 PetscCall(KSPSetNestLevel(pcis->ksp_N, pc->kspnestlevel)); in PCISSetUp()
347 PetscCall(KSPSetErrorIfNotConverged(pcis->ksp_N, pc->erroriffailure)); in PCISSetUp()
348 PetscCall(PetscObjectIncrementTabLevel((PetscObject)pcis->ksp_N, (PetscObject)pc, 1)); in PCISSetUp()
349 PetscCall(KSPSetOperators(pcis->ksp_N, matis->A, matis->A)); in PCISSetUp()
350 PetscCall(KSPSetOptionsPrefix(pcis->ksp_N, "is_localN_")); in PCISSetUp()
351 PetscCall(KSPGetPC(pcis->ksp_N, &pc_ctx)); in PCISSetUp()
353 PetscCall(KSPSetType(pcis->ksp_N, KSPPREONLY)); in PCISSetUp()
354 PetscCall(KSPSetFromOptions(pcis->ksp_N)); in PCISSetUp()
374 if (pcis->pure_neumann) { /* floating subdomain */ in PCISSetUp()
399 PetscCall(KSPSetUp(pcis->ksp_N)); in PCISSetUp()
417 PC_IS *pcis = (PC_IS *)pc->data; in PCISReset() local
424 PetscCall(ISDestroy(&pcis->is_B_local)); in PCISReset()
425 PetscCall(ISDestroy(&pcis->is_I_local)); in PCISReset()
426 PetscCall(ISDestroy(&pcis->is_B_global)); in PCISReset()
427 PetscCall(ISDestroy(&pcis->is_I_global)); in PCISReset()
428 PetscCall(MatDestroy(&pcis->A_II)); in PCISReset()
429 PetscCall(MatDestroy(&pcis->pA_II)); in PCISReset()
430 PetscCall(MatDestroy(&pcis->A_IB)); in PCISReset()
431 PetscCall(MatDestroy(&pcis->A_BI)); in PCISReset()
432 PetscCall(MatDestroy(&pcis->A_BB)); in PCISReset()
433 PetscCall(VecDestroy(&pcis->D)); in PCISReset()
434 PetscCall(KSPDestroy(&pcis->ksp_N)); in PCISReset()
435 PetscCall(KSPDestroy(&pcis->ksp_D)); in PCISReset()
436 PetscCall(VecDestroy(&pcis->vec1_N)); in PCISReset()
437 PetscCall(VecDestroy(&pcis->vec2_N)); in PCISReset()
438 PetscCall(VecDestroy(&pcis->vec1_D)); in PCISReset()
439 PetscCall(VecDestroy(&pcis->vec2_D)); in PCISReset()
440 PetscCall(VecDestroy(&pcis->vec3_D)); in PCISReset()
441 PetscCall(VecDestroy(&pcis->vec4_D)); in PCISReset()
442 PetscCall(VecDestroy(&pcis->vec1_B)); in PCISReset()
443 PetscCall(VecDestroy(&pcis->vec2_B)); in PCISReset()
444 PetscCall(VecDestroy(&pcis->vec3_B)); in PCISReset()
445 PetscCall(VecDestroy(&pcis->vec1_global)); in PCISReset()
446 PetscCall(VecScatterDestroy(&pcis->global_to_D)); in PCISReset()
447 PetscCall(VecScatterDestroy(&pcis->N_to_B)); in PCISReset()
448 PetscCall(VecScatterDestroy(&pcis->N_to_D)); in PCISReset()
449 PetscCall(VecScatterDestroy(&pcis->global_to_B)); in PCISReset()
450 PetscCall(PetscFree(pcis->work_N)); in PCISReset()
451 …if (pcis->n_neigh > -1) PetscCall(ISLocalToGlobalMappingRestoreInfo(pcis->mapping, &pcis->n_neigh,… in PCISReset()
452 PetscCall(ISLocalToGlobalMappingDestroy(&pcis->mapping)); in PCISReset()
453 PetscCall(ISLocalToGlobalMappingDestroy(&pcis->BtoNmap)); in PCISReset()
477 PC_IS *pcis = (PC_IS *)pc->data; in PCISInitialize() local
481 …PetscCheck(pcis, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_WRONGSTATE, "PC_IS context must b… in PCISInitialize()
484 pcis->n_neigh = -1; in PCISInitialize()
485 pcis->scaling_factor = 1.0; in PCISInitialize()
486 pcis->reusesubmatrices = PETSC_TRUE; in PCISInitialize()
512 PC_IS *pcis = (PC_IS *)pc->data; in PCISApplySchur() local
517 PetscCall(MatMult(pcis->A_BB, v, vec1_B)); in PCISApplySchur()
518 PetscCall(MatMult(pcis->A_IB, v, vec1_D)); in PCISApplySchur()
519 PetscCall(KSPSolve(pcis->ksp_D, vec1_D, vec2_D)); in PCISApplySchur()
520 PetscCall(KSPCheckSolve(pcis->ksp_D, pc, vec2_D)); in PCISApplySchur()
521 PetscCall(MatMult(pcis->A_BI, vec2_D, vec2_B)); in PCISApplySchur()
552 PC_IS *pcis = (PC_IS *)pc->data; in PCISScatterArrayNToVecB() local
556 PetscCall(ISGetIndices(pcis->is_B_local, &idex)); in PCISScatterArrayNToVecB()
560 for (i = 0; i < pcis->n_B; i++) array_B[i] = array_N[idex[i]]; in PCISScatterArrayNToVecB()
562 for (i = 0; i < pcis->n_B; i++) array_B[i] += array_N[idex[i]]; in PCISScatterArrayNToVecB()
566 for (i = 0; i < pcis->n_B; i++) array_N[idex[i]] = array_B[i]; in PCISScatterArrayNToVecB()
568 for (i = 0; i < pcis->n_B; i++) array_N[idex[i]] += array_B[i]; in PCISScatterArrayNToVecB()
571 PetscCall(ISRestoreIndices(pcis->is_B_local, &idex)); in PCISScatterArrayNToVecB()
602 PC_IS *pcis = (PC_IS *)pc->data; in PCISApplyInvSchur() local
614 PetscCall(VecScatterBegin(pcis->N_to_B, b, vec1_N, INSERT_VALUES, SCATTER_REVERSE)); in PCISApplyInvSchur()
615 PetscCall(VecScatterEnd(pcis->N_to_B, b, vec1_N, INSERT_VALUES, SCATTER_REVERSE)); in PCISApplyInvSchur()
626 average = average / ((PetscReal)pcis->n); in PCISApplyInvSchur()
628 if (pcis->pure_neumann) { in PCISApplyInvSchur()
638 PetscCall(KSPSolve(pcis->ksp_N, vec1_N, vec2_N)); in PCISApplyInvSchur()
639 PetscCall(KSPCheckSolve(pcis->ksp_N, pc, vec2_N)); in PCISApplyInvSchur()
641 PetscCall(VecScatterBegin(pcis->N_to_B, vec2_N, x, INSERT_VALUES, SCATTER_FORWARD)); in PCISApplyInvSchur()
642 PetscCall(VecScatterEnd(pcis->N_to_B, vec2_N, x, INSERT_VALUES, SCATTER_FORWARD)); in PCISApplyInvSchur()