本文整理汇总了C++中VecScatterDestroy函数的典型用法代码示例。如果您正苦于以下问题:C++ VecScatterDestroy函数的具体用法?C++ VecScatterDestroy怎么用?C++ VecScatterDestroy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VecScatterDestroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DMShellSetLocalToGlobal
/*@
DMShellSetLocalToGlobalVecScatter - Sets a VecScatter context for local to global communication
Logically Collective on DM
Input Arguments
+ dm - the shell DM
- ltog - the local to global VecScatter context
Level: advanced
.seealso: DMShellSetLocalToGlobal()
@*/
PetscErrorCode DMShellSetLocalToGlobalVecScatter(DM dm, VecScatter ltog)
{
DM_Shell *shell = (DM_Shell*)dm->data;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscObjectReference((PetscObject)ltog);CHKERRQ(ierr);
/* Call VecScatterDestroy() to avoid a memory leak in case of re-setting. */
ierr = VecScatterDestroy(&shell->ltog);CHKERRQ(ierr);
shell->ltog = ltog;
PetscFunctionReturn(0);
}
示例2: main
int main(int argc,char **argv)
{
PetscErrorCode ierr;
PetscInt n = 5,i,idx2[3] = {0,2,3},idx1[3] = {0,1,2};
PetscMPIInt size,rank;
PetscScalar value;
Vec x,y;
IS is1,is2;
VecScatter ctx = 0;
PetscInitialize(&argc,&argv,(char*)0,help);
ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
/* create two vectors */
ierr = VecCreate(PETSC_COMM_WORLD,&x);CHKERRQ(ierr);
ierr = VecSetSizes(x,PETSC_DECIDE,size*n);CHKERRQ(ierr);
ierr = VecSetFromOptions(x);CHKERRQ(ierr);
ierr = VecCreateSeq(PETSC_COMM_SELF,n,&y);CHKERRQ(ierr);
/* create two index sets */
ierr = ISCreateGeneral(PETSC_COMM_SELF,3,idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr);
ierr = ISCreateGeneral(PETSC_COMM_SELF,3,idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr);
/* fill local part of parallel vector */
for (i=n*rank; i<n*(rank+1); i++) {
value = (PetscScalar) i;
ierr = VecSetValues(x,1,&i,&value,INSERT_VALUES);CHKERRQ(ierr);
}
ierr = VecAssemblyBegin(x);CHKERRQ(ierr);
ierr = VecAssemblyEnd(x);CHKERRQ(ierr);
ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = VecSet(y,-1.0);CHKERRQ(ierr);
ierr = VecScatterCreate(x,is1,y,is2,&ctx);CHKERRQ(ierr);
ierr = VecScatterBegin(ctx,x,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterEnd(ctx,x,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterDestroy(&ctx);CHKERRQ(ierr);
if (!rank) {
ierr = PetscPrintf(PETSC_COMM_SELF,"scattered vector\n");CHKERRQ(ierr);
ierr = VecView(y,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);
}
ierr = ISDestroy(&is1);CHKERRQ(ierr);
ierr = ISDestroy(&is2);CHKERRQ(ierr);
ierr = VecDestroy(&x);CHKERRQ(ierr);
ierr = VecDestroy(&y);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
示例3: PCISDestroy
PetscErrorCode PCISDestroy(PC pc)
{
PC_IS *pcis = (PC_IS*)(pc->data);
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = ISDestroy(&pcis->is_B_local);CHKERRQ(ierr);
ierr = ISDestroy(&pcis->is_I_local);CHKERRQ(ierr);
ierr = ISDestroy(&pcis->is_B_global);CHKERRQ(ierr);
ierr = ISDestroy(&pcis->is_I_global);CHKERRQ(ierr);
ierr = MatDestroy(&pcis->A_II);CHKERRQ(ierr);
ierr = MatDestroy(&pcis->A_IB);CHKERRQ(ierr);
ierr = MatDestroy(&pcis->A_BI);CHKERRQ(ierr);
ierr = MatDestroy(&pcis->A_BB);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->D);CHKERRQ(ierr);
ierr = KSPDestroy(&pcis->ksp_N);CHKERRQ(ierr);
ierr = KSPDestroy(&pcis->ksp_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec1_N);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec2_N);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec1_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec2_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec3_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec4_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec1_B);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec2_B);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec3_B);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec1_global);CHKERRQ(ierr);
ierr = VecScatterDestroy(&pcis->global_to_D);CHKERRQ(ierr);
ierr = VecScatterDestroy(&pcis->N_to_B);CHKERRQ(ierr);
ierr = VecScatterDestroy(&pcis->global_to_B);CHKERRQ(ierr);
ierr = PetscFree(pcis->work_N);CHKERRQ(ierr);
if (pcis->n_neigh > -1) {
ierr = ISLocalToGlobalMappingRestoreInfo(pcis->mapping,&(pcis->n_neigh),&(pcis->neigh),&(pcis->n_shared),&(pcis->shared));CHKERRQ(ierr);
}
ierr = ISLocalToGlobalMappingDestroy(&pcis->mapping);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetUseStiffnessScaling_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetSubdomainScalingFactor_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetSubdomainDiagonalScaling_C",NULL);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例4: main
int main(int argc,char **argv)
{
PetscErrorCode ierr;
PetscMPIInt rank,size;
Vec x,y;
IS is1,is2;
PetscInt n,N,ix[2],iy[2];
VecScatter ctx;
ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
if (size < 3) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"This example needs at least 3 processes");
/* create two vectors */
n = 2;
N = 2*size;
ierr = VecCreateMPI(PETSC_COMM_WORLD,n,N,&x);CHKERRQ(ierr);
ierr = VecDuplicate(x,&y);CHKERRQ(ierr);
/* Specify indices to send from the next process in the ring */
ix[0] = ((rank+1)*n+0) % N;
ix[1] = ((rank+1)*n+1) % N;
/* And put them on the process after that in the ring */
iy[0] = ((rank+2)*n+0) % N;
iy[1] = ((rank+2)*n+1) % N;
/* create two index sets */
ierr = ISCreateGeneral(PETSC_COMM_WORLD,n,ix,PETSC_USE_POINTER,&is1);CHKERRQ(ierr);
ierr = ISCreateGeneral(PETSC_COMM_WORLD,n,iy,PETSC_USE_POINTER,&is2);CHKERRQ(ierr);
ierr = VecSetValue(x,rank*n,rank*n,INSERT_VALUES);CHKERRQ(ierr);
ierr = VecSetValue(x,rank*n+1,rank*n+1,INSERT_VALUES);CHKERRQ(ierr);
ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD,"----\n");CHKERRQ(ierr);
ierr = VecScatterCreate(x,is1,y,is2,&ctx);CHKERRQ(ierr);
ierr = VecScatterBegin(ctx,x,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterEnd(ctx,x,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterDestroy(&ctx);CHKERRQ(ierr);
ierr = VecView(y,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = ISDestroy(&is1);CHKERRQ(ierr);
ierr = ISDestroy(&is2);CHKERRQ(ierr);
ierr = VecDestroy(&x);CHKERRQ(ierr);
ierr = VecDestroy(&y);CHKERRQ(ierr);
ierr = PetscFinalize();
return ierr;
}
示例5: main
int main(int argc,char **argv)
{
PetscErrorCode ierr;
PetscMPIInt size,rank;
PetscInt n = 5,i;
PetscScalar value;
Vec x,y;
IS is1,is2;
VecScatter ctx = 0;
ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
/* create two vectors */
ierr = VecCreate(PETSC_COMM_WORLD,&x);CHKERRQ(ierr);
ierr = VecSetSizes(x,PETSC_DECIDE,size*n);CHKERRQ(ierr);
ierr = VecSetFromOptions(x);CHKERRQ(ierr);
ierr = VecCreateSeq(PETSC_COMM_SELF,n,&y);CHKERRQ(ierr);
/* create two index sets */
ierr = ISCreateStride(PETSC_COMM_SELF,n,n*rank,1,&is1);CHKERRQ(ierr);
ierr = ISCreateStride(PETSC_COMM_SELF,n,0,1,&is2);CHKERRQ(ierr);
/* each processor inserts the entire vector */
/* this is redundant but tests assembly */
for (i=0; i<n*size; i++) {
value = (PetscScalar) i;
ierr = VecSetValues(x,1,&i,&value,INSERT_VALUES);CHKERRQ(ierr);
}
ierr = VecAssemblyBegin(x);CHKERRQ(ierr);
ierr = VecAssemblyEnd(x);CHKERRQ(ierr);
ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = VecScatterCreate(x,is1,y,is2,&ctx);CHKERRQ(ierr);
ierr = VecScatterBegin(ctx,x,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterEnd(ctx,x,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterDestroy(&ctx);CHKERRQ(ierr);
if (!rank) {
printf("----\n");
VecView(y,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);
}
ierr = VecDestroy(&x);CHKERRQ(ierr);
ierr = VecDestroy(&y);CHKERRQ(ierr);
ierr = ISDestroy(&is1);CHKERRQ(ierr);
ierr = ISDestroy(&is2);CHKERRQ(ierr);
ierr = PetscFinalize();
return ierr;
}
示例6: TSMonitorDMDARayDestroy
PetscErrorCode TSMonitorDMDARayDestroy(void **mctx)
{
TSMonitorDMDARayCtx *rayctx = (TSMonitorDMDARayCtx *) *mctx;
PetscErrorCode ierr;
PetscFunctionBegin;
if (rayctx->lgctx) {ierr = TSMonitorLGCtxDestroy(&rayctx->lgctx);CHKERRQ(ierr);}
ierr = VecDestroy(&rayctx->ray);CHKERRQ(ierr);
ierr = VecScatterDestroy(&rayctx->scatter);CHKERRQ(ierr);
ierr = PetscViewerDestroy(&rayctx->viewer);CHKERRQ(ierr);
ierr = PetscFree(rayctx);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例7: MyMonitorDestroy
/*
Frees all data structures associated with the monitor
*/
PetscErrorCode MyMonitorDestroy(void **ictx)
{
MyMonitorCtx **ctx = (MyMonitorCtx**)ictx;
PetscErrorCode ierr;
PetscFunctionBeginUser;
ierr = VecScatterDestroy(&(*ctx)->scatter);CHKERRQ(ierr);
ierr = VecDestroy(&(*ctx)->He);CHKERRQ(ierr);
ierr = DMDestroy(&(*ctx)->da);CHKERRQ(ierr);
ierr = PetscViewerDestroy(&(*ctx)->viewer);CHKERRQ(ierr);
ierr = PetscFree(*ctx);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例8: VecScatterDestroy
SAMpatchPETSc::~SAMpatchPETSc()
{
for (auto& it : dofIS) {
if (it.second.scatterCreated)
VecScatterDestroy(&it.second.ctx);
ISDestroy(&it.second.local);
ISDestroy(&it.second.global);
}
dofIS.clear();
if (glob2LocEq)
ISDestroy(&glob2LocEq);
LinAlgInit::decrefs();
}
示例9: DMDestroy_Shell
static PetscErrorCode DMDestroy_Shell(DM dm)
{
PetscErrorCode ierr;
DM_Shell *shell = (DM_Shell*)dm->data;
PetscFunctionBegin;
ierr = MatDestroy(&shell->A);
CHKERRQ(ierr);
ierr = VecDestroy(&shell->Xglobal);
CHKERRQ(ierr);
ierr = VecDestroy(&shell->Xlocal);
CHKERRQ(ierr);
ierr = VecScatterDestroy(&shell->gtol);
CHKERRQ(ierr);
ierr = VecScatterDestroy(&shell->ltog);
CHKERRQ(ierr);
ierr = VecScatterDestroy(&shell->ltol);
CHKERRQ(ierr);
/* This was originally freed in DMDestroy(), but that prevents reference counting of backend objects */
ierr = PetscFree(shell);
CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例10: PCBDDCScalingReset_Deluxe_Solvers
static PetscErrorCode PCBDDCScalingReset_Deluxe_Solvers(PCBDDCDeluxeScaling deluxe_ctx)
{
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscFree(deluxe_ctx->idx_simple_B);CHKERRQ(ierr);
deluxe_ctx->n_simple = 0;
ierr = VecScatterDestroy(&deluxe_ctx->seq_scctx);CHKERRQ(ierr);
ierr = VecDestroy(&deluxe_ctx->seq_work1);CHKERRQ(ierr);
ierr = VecDestroy(&deluxe_ctx->seq_work2);CHKERRQ(ierr);
ierr = MatDestroy(&deluxe_ctx->seq_mat);CHKERRQ(ierr);
ierr = KSPDestroy(&deluxe_ctx->seq_ksp);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例11: main
-n <length> : vector length\n\n";
#include <petscvec.h>
#undef __FUNCT__
#define __FUNCT__ "main"
int main(int argc,char **argv)
{
PetscErrorCode ierr;
PetscInt n = 5,idx1[2] = {0,3},idx2[2] = {1,4};
PetscScalar one = 1.0,two = 2.0;
Vec x,y;
IS is1,is2;
VecScatter ctx = 0;
ierr = PetscInitialize(&argc,&argv,(char*)0,help);CHKERRQ(ierr);
ierr = PetscOptionsGetInt(NULL,"-n",&n,NULL);CHKERRQ(ierr);
/* create two vector */
ierr = VecCreateSeq(PETSC_COMM_SELF,n,&x);CHKERRQ(ierr);
ierr = VecDuplicate(x,&y);CHKERRQ(ierr);
/* create two index sets */
ierr = ISCreateGeneral(PETSC_COMM_SELF,2,idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr);
ierr = ISCreateGeneral(PETSC_COMM_SELF,2,idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr);
ierr = VecSet(x,one);CHKERRQ(ierr);
ierr = VecSet(y,two);CHKERRQ(ierr);
ierr = VecScatterCreate(x,is1,y,is2,&ctx);CHKERRQ(ierr);
ierr = VecScatterBegin(ctx,x,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterEnd(ctx,x,y,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecView(y,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);
ierr = VecScatterBegin(ctx,y,x,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterEnd(ctx,y,x,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterDestroy(&ctx);CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_SELF,"-------\n");CHKERRQ(ierr);
ierr = VecView(x,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);
ierr = ISDestroy(&is1);CHKERRQ(ierr);
ierr = ISDestroy(&is2);CHKERRQ(ierr);
ierr = VecDestroy(&x);CHKERRQ(ierr);
ierr = VecDestroy(&y);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
示例12: PCBDDCDestroyFETIDPPC
PetscErrorCode PCBDDCDestroyFETIDPPC(PC pc)
{
FETIDPPC_ctx pc_ctx;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PCShellGetContext(pc,(void**)&pc_ctx);CHKERRQ(ierr);
ierr = VecDestroy(&pc_ctx->lambda_local);CHKERRQ(ierr);
ierr = MatDestroy(&pc_ctx->B_Ddelta);CHKERRQ(ierr);
ierr = VecScatterDestroy(&pc_ctx->l2g_lambda);CHKERRQ(ierr);
ierr = MatDestroy(&pc_ctx->S_j);CHKERRQ(ierr);
ierr = PCDestroy(&pc_ctx->pc);CHKERRQ(ierr); /* decrease PCBDDC reference count */
ierr = PetscFree(pc_ctx);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例13: Monitor
PetscErrorCode Monitor(TS ts,PetscInt step,PetscReal time,Vec global,void *ctx)
{
VecScatter scatter;
IS from,to;
PetscInt i,n,*idx,nsteps,maxsteps;
Vec tmp_vec;
PetscErrorCode ierr;
PetscScalar *tmp;
PetscReal maxtime;
Data *data = (Data*)ctx;
PetscReal tfinal = data->tfinal;
PetscFunctionBeginUser;
if (time > tfinal) PetscFunctionReturn(0);
ierr = TSGetTimeStepNumber(ts,&nsteps);CHKERRQ(ierr);
/* display output at selected time steps */
ierr = TSGetDuration(ts, &maxsteps, &maxtime);CHKERRQ(ierr);
if (nsteps % 10 != 0 && time < maxtime) PetscFunctionReturn(0);
/* Get the size of the vector */
ierr = VecGetSize(global,&n);CHKERRQ(ierr);
/* Set the index sets */
ierr = PetscMalloc1(n,&idx);CHKERRQ(ierr);
for (i=0; i<n; i++) idx[i]=i;
/* Create local sequential vectors */
ierr = VecCreateSeq(PETSC_COMM_SELF,n,&tmp_vec);CHKERRQ(ierr);
/* Create scatter context */
ierr = ISCreateGeneral(PETSC_COMM_SELF,n,idx,PETSC_COPY_VALUES,&from);CHKERRQ(ierr);
ierr = ISCreateGeneral(PETSC_COMM_SELF,n,idx,PETSC_COPY_VALUES,&to);CHKERRQ(ierr);
ierr = VecScatterCreate(global,from,tmp_vec,to,&scatter);CHKERRQ(ierr);
ierr = VecScatterBegin(scatter,global,tmp_vec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecScatterEnd(scatter,global,tmp_vec,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
ierr = VecGetArray(tmp_vec,&tmp);CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD,"At t[%D] =%14.2e u= %14.2e at the center \n",nsteps,(double)time,(double)PetscRealPart(tmp[n/2]));CHKERRQ(ierr);
ierr = VecRestoreArray(tmp_vec,&tmp);CHKERRQ(ierr);
ierr = PetscFree(idx);CHKERRQ(ierr);
ierr = ISDestroy(&from);CHKERRQ(ierr);
ierr = ISDestroy(&to);CHKERRQ(ierr);
ierr = VecScatterDestroy(&scatter);CHKERRQ(ierr);
ierr = VecDestroy(&tmp_vec);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例14: MatDestroy_IS
PetscErrorCode MatDestroy_IS(Mat A)
{
PetscErrorCode ierr;
Mat_IS *b = (Mat_IS*)A->data;
PetscFunctionBegin;
ierr = MatDestroy(&b->A);CHKERRQ(ierr);
ierr = VecScatterDestroy(&b->ctx);CHKERRQ(ierr);
ierr = VecDestroy(&b->x);CHKERRQ(ierr);
ierr = VecDestroy(&b->y);CHKERRQ(ierr);
ierr = ISLocalToGlobalMappingDestroy(&b->mapping);CHKERRQ(ierr);
ierr = PetscFree(A->data);CHKERRQ(ierr);
ierr = PetscObjectChangeTypeName((PetscObject)A,0);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)A,"MatISGetLocalMat_C",NULL);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例15: PCBDDCDestroyFETIDPMat
PetscErrorCode PCBDDCDestroyFETIDPMat(Mat A)
{
FETIDPMat_ctx mat_ctx;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = MatShellGetContext(A,(void**)&mat_ctx);CHKERRQ(ierr);
ierr = VecDestroy(&mat_ctx->lambda_local);CHKERRQ(ierr);
ierr = VecDestroy(&mat_ctx->temp_solution_D);CHKERRQ(ierr);
ierr = VecDestroy(&mat_ctx->temp_solution_B);CHKERRQ(ierr);
ierr = MatDestroy(&mat_ctx->B_delta);CHKERRQ(ierr);
ierr = MatDestroy(&mat_ctx->B_Ddelta);CHKERRQ(ierr);
ierr = VecScatterDestroy(&mat_ctx->l2g_lambda);CHKERRQ(ierr);
ierr = PCDestroy(&mat_ctx->pc);CHKERRQ(ierr); /* decrease PCBDDC reference count */
ierr = PetscFree(mat_ctx);CHKERRQ(ierr);
PetscFunctionReturn(0);
}