本文整理汇总了C++中VecDestroyVecs函数的典型用法代码示例。如果您正苦于以下问题:C++ VecDestroyVecs函数的具体用法?C++ VecDestroyVecs怎么用?C++ VecDestroyVecs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VecDestroyVecs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KSPReset_GCR
PetscErrorCode KSPReset_GCR( KSP ksp )
{
PetscErrorCode ierr;
KSP_GCR *ctx = (KSP_GCR*)ksp->data;
PetscFunctionBegin;
ierr = VecDestroy(&ctx->R);CHKERRQ(ierr);
ierr = VecDestroyVecs(ctx->restart,&ctx->VV);CHKERRQ(ierr);
ierr = VecDestroyVecs(ctx->restart,&ctx->SS);CHKERRQ(ierr);
if (ctx->modifypc_destroy) {
ierr = (*ctx->modifypc_destroy)(ctx->modifypc_ctx);CHKERRQ(ierr);
}
ierr = PetscFree(ctx->val);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例2: KSPReset_LCD
PetscErrorCode KSPReset_LCD(KSP ksp)
{
KSP_LCD *lcd = (KSP_LCD*)ksp->data;
PetscErrorCode ierr;
PetscFunctionBegin;
if (lcd->P) {
ierr = VecDestroyVecs(lcd->restart+1,&lcd->P);
CHKERRQ(ierr);
}
if (lcd->Q) {
ierr = VecDestroyVecs(lcd->restart+1,&lcd->Q);
CHKERRQ(ierr);
}
PetscFunctionReturn(0);
}
示例3: KSPDestroy_AGMRES
PetscErrorCode KSPDestroy_AGMRES(KSP ksp)
{
PetscErrorCode ierr;
KSP_AGMRES *agmres = (KSP_AGMRES*)ksp->data;
PetscFunctionBegin;
ierr = PetscFree(agmres->hh_origin);CHKERRQ(ierr);
ierr = PetscFree(agmres->nrs);CHKERRQ(ierr);
ierr = PetscFree(agmres->Qloc);CHKERRQ(ierr);
ierr = PetscFree(agmres->Rloc);CHKERRQ(ierr);
ierr = PetscFree(agmres->sgn);CHKERRQ(ierr);
ierr = PetscFree(agmres->tloc);CHKERRQ(ierr);
ierr = PetscFree(agmres->Rshift);CHKERRQ(ierr);
ierr = PetscFree(agmres->Ishift);CHKERRQ(ierr);
ierr = PetscFree(agmres->Scale);CHKERRQ(ierr);
ierr = PetscFree(agmres->wbufptr);CHKERRQ(ierr);
ierr = PetscFree(agmres->tau);CHKERRQ(ierr);
ierr = PetscFree(agmres->work);CHKERRQ(ierr);
ierr = PetscFree(agmres->temp);CHKERRQ(ierr);
ierr = PetscFree(agmres->select);CHKERRQ(ierr);
ierr = PetscFree(agmres->wr);CHKERRQ(ierr);
ierr = PetscFree(agmres->wi);CHKERRQ(ierr);
if (agmres->neig) {
ierr = VecDestroyVecs(MAXKSPSIZE,&agmres->TmpU);CHKERRQ(ierr);
ierr = PetscFree(agmres->perm);CHKERRQ(ierr);
ierr = PetscFree(agmres->MatEigL);CHKERRQ(ierr);
ierr = PetscFree(agmres->MatEigR);CHKERRQ(ierr);
ierr = PetscFree(agmres->Q);CHKERRQ(ierr);
ierr = PetscFree(agmres->Z);CHKERRQ(ierr);
ierr = PetscFree(agmres->beta);CHKERRQ(ierr);
}
ierr = KSPDestroy_DGMRES(ksp);
PetscFunctionReturn(0);
}
示例4: KSPReset_GMRES
PetscErrorCode KSPReset_GMRES(KSP ksp)
{
KSP_GMRES *gmres = (KSP_GMRES*)ksp->data;
PetscErrorCode ierr;
PetscInt i;
PetscFunctionBegin;
/* Free the Hessenberg matrices */
ierr = PetscFree5(gmres->hh_origin,gmres->hes_origin,gmres->rs_origin,gmres->cc_origin,gmres->ss_origin);CHKERRQ(ierr);
/* free work vectors */
ierr = PetscFree(gmres->vecs);CHKERRQ(ierr);
for (i=0; i<gmres->nwork_alloc; i++) {
ierr = VecDestroyVecs(gmres->mwork_alloc[i],&gmres->user_work[i]);CHKERRQ(ierr);
}
gmres->nwork_alloc = 0;
ierr = PetscFree(gmres->user_work);CHKERRQ(ierr);
ierr = PetscFree(gmres->mwork_alloc);CHKERRQ(ierr);
ierr = PetscFree(gmres->nrs);CHKERRQ(ierr);
ierr = VecDestroy(&gmres->sol_temp);CHKERRQ(ierr);
ierr = PetscFree(gmres->Rsvd);CHKERRQ(ierr);
ierr = PetscFree(gmres->Dsvd);CHKERRQ(ierr);
ierr = PetscFree(gmres->orthogwork);CHKERRQ(ierr);
gmres->sol_temp = 0;
gmres->vv_allocated = 0;
gmres->vecs_allocated = 0;
gmres->sol_temp = 0;
PetscFunctionReturn(0);
}
示例5: MatPoissonDestroy
PetscErrorCode MatPoissonDestroy (Mat A) {
PetscErrorCode ierr;
MatPoisson *c;
PetscFunctionBegin;
ierr = MatShellGetContext(A, (void *)&c); CHKERRQ(ierr);
for (int i = 0; i < c->rank; i++) {
ierr = MatDestroy(c->A[i]); CHKERRQ(ierr);
}
ierr = PetscFree(c->A); CHKERRQ(ierr);
ierr = PetscFree(c->dim); CHKERRQ(ierr);
ierr = VecDestroyVecs(c->u, c->rank); CHKERRQ(ierr);
ierr = VecDestroyVecs(c->v, c->rank); CHKERRQ(ierr);
ierr = PetscFree(c);
PetscFunctionReturn(0);
}
示例6: KSPDestroy_CGLS
static PetscErrorCode KSPDestroy_CGLS(KSP ksp)
{
KSP_CGLS *cgls = (KSP_CGLS*)ksp->data;
PetscErrorCode ierr;
PetscFunctionBegin;
/* Free work vectors */
if (cgls->vwork_n) {
ierr = VecDestroyVecs(cgls->nwork_n,&cgls->vwork_n);CHKERRQ(ierr);
}
if (cgls->vwork_m) {
ierr = VecDestroyVecs(cgls->nwork_m,&cgls->vwork_m);CHKERRQ(ierr);
}
ierr = PetscFree(ksp->data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例7: MatDestroy_LMVM
PetscErrorCode MatDestroy_LMVM(Mat B)
{
Mat_LMVM *lmvm = (Mat_LMVM*)B->data;
PetscErrorCode ierr;
PetscFunctionBegin;
if (lmvm->allocated) {
ierr = VecDestroyVecs(lmvm->m, &lmvm->S);CHKERRQ(ierr);
ierr = VecDestroyVecs(lmvm->m, &lmvm->Y);CHKERRQ(ierr);
ierr = VecDestroy(&lmvm->Xprev);CHKERRQ(ierr);
ierr = VecDestroy(&lmvm->Fprev);CHKERRQ(ierr);
}
ierr = KSPDestroy(&lmvm->J0ksp);CHKERRQ(ierr);
ierr = MatLMVMClearJ0(B);CHKERRQ(ierr);
ierr = PetscFree(B->data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例8: TSReset_RK
static PetscErrorCode TSReset_RK(TS ts)
{
TS_RK *rk = (TS_RK*)ts->data;
PetscInt s;
PetscErrorCode ierr;
PetscFunctionBegin;
if (!rk->tableau) PetscFunctionReturn(0);
s = rk->tableau->s;
ierr = VecDestroyVecs(s,&rk->Y);CHKERRQ(ierr);
ierr = VecDestroyVecs(s,&rk->YdotRHS);CHKERRQ(ierr);
ierr = VecDestroyVecs(s*ts->numcost,&rk->VecDeltaLam);CHKERRQ(ierr);
ierr = VecDestroyVecs(s*ts->numcost,&rk->VecDeltaMu);CHKERRQ(ierr);
ierr = VecDestroyVecs(ts->numcost,&rk->VecSensiTemp);CHKERRQ(ierr);
ierr = PetscFree(rk->work);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例9: CheckMatrices
static PetscErrorCode CheckMatrices(Mat A,Mat B,Vec left,Vec right,Vec X,Vec Y,Vec X1,Vec Y1)
{
PetscErrorCode ierr;
Vec *ltmp,*rtmp;
PetscFunctionBegin;
ierr = VecDuplicateVecs(right,2,&rtmp);CHKERRQ(ierr);
ierr = VecDuplicateVecs(left,2,<mp);CHKERRQ(ierr);
ierr = MatScale(A,PETSC_PI);CHKERRQ(ierr);
ierr = MatScale(B,PETSC_PI);CHKERRQ(ierr);
ierr = MatDiagonalScale(A,left,right);CHKERRQ(ierr);
ierr = MatDiagonalScale(B,left,right);CHKERRQ(ierr);
ierr = MatMult(A,X,ltmp[0]);CHKERRQ(ierr);
ierr = MatMult(B,X,ltmp[1]);CHKERRQ(ierr);
ierr = Compare2(ltmp,"MatMult");CHKERRQ(ierr);
ierr = MatMultTranspose(A,Y,rtmp[0]);CHKERRQ(ierr);
ierr = MatMultTranspose(B,Y,rtmp[1]);CHKERRQ(ierr);
ierr = Compare2(rtmp,"MatMultTranspose");CHKERRQ(ierr);
ierr = VecCopy(Y1,ltmp[0]);CHKERRQ(ierr);
ierr = VecCopy(Y1,ltmp[1]);CHKERRQ(ierr);
ierr = MatMultAdd(A,X,ltmp[0],ltmp[0]);CHKERRQ(ierr);
ierr = MatMultAdd(B,X,ltmp[1],ltmp[1]);CHKERRQ(ierr);
ierr = Compare2(ltmp,"MatMultAdd v2==v3");CHKERRQ(ierr);
ierr = MatMultAdd(A,X,Y1,ltmp[0]);CHKERRQ(ierr);
ierr = MatMultAdd(B,X,Y1,ltmp[1]);CHKERRQ(ierr);
ierr = Compare2(ltmp,"MatMultAdd v2!=v3");CHKERRQ(ierr);
ierr = VecCopy(X1,rtmp[0]);CHKERRQ(ierr);
ierr = VecCopy(X1,rtmp[1]);CHKERRQ(ierr);
ierr = MatMultTransposeAdd(A,Y,rtmp[0],rtmp[0]);CHKERRQ(ierr);
ierr = MatMultTransposeAdd(B,Y,rtmp[1],rtmp[1]);CHKERRQ(ierr);
ierr = Compare2(rtmp,"MatMultTransposeAdd v2==v3");CHKERRQ(ierr);
ierr = MatMultTransposeAdd(A,Y,X1,rtmp[0]);CHKERRQ(ierr);
ierr = MatMultTransposeAdd(B,Y,X1,rtmp[1]);CHKERRQ(ierr);
ierr = Compare2(rtmp,"MatMultTransposeAdd v2!=v3");CHKERRQ(ierr);
ierr = VecDestroyVecs(2,<mp);CHKERRQ(ierr);
ierr = VecDestroyVecs(2,&rtmp);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例10: main
int main(int argc, char **argv)
{
PetscErrorCode ierr;
Vec *V,t;
PetscInt i,j,reps,n=15,k=6;
PetscRandom rctx;
PetscScalar *val_dot,*val_mdot,*tval_dot,*tval_mdot;
ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr);
ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD,"Test with %D random vectors of length %D",k,n);CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD,"\n",k,n);CHKERRQ(ierr);
ierr = PetscRandomCreate(PETSC_COMM_WORLD,&rctx);CHKERRQ(ierr);
ierr = PetscRandomSetFromOptions(rctx);CHKERRQ(ierr);
ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr);
ierr = VecSetSizes(t,n,PETSC_DECIDE);CHKERRQ(ierr);
ierr = VecSetFromOptions(t);CHKERRQ(ierr);
ierr = VecDuplicateVecs(t,k,&V);CHKERRQ(ierr);
ierr = VecSetRandom(t,rctx);CHKERRQ(ierr);
ierr = PetscMalloc1(k,&val_dot);CHKERRQ(ierr);
ierr = PetscMalloc1(k,&val_mdot);CHKERRQ(ierr);
ierr = PetscMalloc1(k,&tval_dot);CHKERRQ(ierr);
ierr = PetscMalloc1(k,&tval_mdot);CHKERRQ(ierr);
for (i=0; i<k; i++) { ierr = VecSetRandom(V[i],rctx);CHKERRQ(ierr); }
for (reps=0; reps<20; reps++) {
for (i=1; i<k; i++) {
ierr = VecMDot(t,i,V,val_mdot);CHKERRQ(ierr);
ierr = VecMTDot(t,i,V,tval_mdot);CHKERRQ(ierr);
for (j=0;j<i;j++) {
ierr = VecDot(t,V[j],&val_dot[j]);CHKERRQ(ierr);
ierr = VecTDot(t,V[j],&tval_dot[j]);CHKERRQ(ierr);
}
/* Check result */
for (j=0;j<i;j++) {
if (PetscAbsScalar(val_mdot[j] - val_dot[j])/PetscAbsScalar(val_dot[j]) > 1e-5) {
ierr = PetscPrintf(PETSC_COMM_WORLD, "[TEST FAILED] i=%D, j=%D, val_mdot[j]=%g, val_dot[j]=%g\n",i,j,(double)PetscAbsScalar(val_mdot[j]), (double)PetscAbsScalar(val_dot[j]));CHKERRQ(ierr);
break;
}
if (PetscAbsScalar(tval_mdot[j] - tval_dot[j])/PetscAbsScalar(tval_dot[j]) > 1e-5) {
ierr = PetscPrintf(PETSC_COMM_WORLD, "[TEST FAILED] i=%D, j=%D, tval_mdot[j]=%g, tval_dot[j]=%g\n",i,j,(double)PetscAbsScalar(tval_mdot[j]), (double)PetscAbsScalar(tval_dot[j]));CHKERRQ(ierr);
break;
}
}
}
}
ierr = PetscPrintf(PETSC_COMM_WORLD,"Test completed successfully!\n",k,n);CHKERRQ(ierr);
ierr = PetscFree(val_dot);CHKERRQ(ierr);
ierr = PetscFree(val_mdot);CHKERRQ(ierr);
ierr = PetscFree(tval_dot);CHKERRQ(ierr);
ierr = PetscFree(tval_mdot);CHKERRQ(ierr);
ierr = VecDestroyVecs(k,&V);CHKERRQ(ierr);
ierr = VecDestroy(&t);CHKERRQ(ierr);
ierr = PetscRandomDestroy(&rctx);CHKERRQ(ierr);
ierr = PetscFinalize();
return ierr;
}
示例11: KSPSetUp_CGLS
static PetscErrorCode KSPSetUp_CGLS(KSP ksp)
{
PetscErrorCode ierr;
KSP_CGLS *cgls = (KSP_CGLS*)ksp->data;
PetscFunctionBegin;
cgls->nwork_m = 2;
if (cgls->vwork_m) {
ierr = VecDestroyVecs(cgls->nwork_m,&cgls->vwork_m);CHKERRQ(ierr);
}
cgls->nwork_n = 2;
if (cgls->vwork_n) {
ierr = VecDestroyVecs(cgls->nwork_n,&cgls->vwork_n);CHKERRQ(ierr);
}
ierr = KSPCreateVecs(ksp,cgls->nwork_n,&cgls->vwork_n,cgls->nwork_m,&cgls->vwork_m);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例12: KSPDestroy_LSQR
PetscErrorCode KSPDestroy_LSQR(KSP ksp)
{
KSP_LSQR *lsqr = (KSP_LSQR*)ksp->data;
PetscErrorCode ierr;
PetscFunctionBegin;
/* Free work vectors */
if (lsqr->vwork_n) {
ierr = VecDestroyVecs(lsqr->nwork_n,&lsqr->vwork_n);CHKERRQ(ierr);
}
if (lsqr->vwork_m) {
ierr = VecDestroyVecs(lsqr->nwork_m,&lsqr->vwork_m);CHKERRQ(ierr);
}
if (lsqr->se_flg) {
ierr = VecDestroy(&lsqr->se);CHKERRQ(ierr);
}
ierr = PetscFree(ksp->data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例13: destroyPeriodicVec
PetscErrorCode destroyPeriodicVec(PeriodicVec *user)
{
/* Function to destroy Vec's in a PeriodicVec struct */
PetscErrorCode ierr;
ierr = VecDestroyVecs(user->up,user->numPeriods);CHKERRQ(ierr);
return 0;
}
示例14: KSPReset_PIPEFGMRES
PetscErrorCode KSPReset_PIPEFGMRES(KSP ksp)
{
KSP_PIPEFGMRES *pipefgmres = (KSP_PIPEFGMRES*)ksp->data;
PetscErrorCode ierr;
PetscInt i;
PetscFunctionBegin;
ierr = PetscFree(pipefgmres->prevecs);CHKERRQ(ierr);
ierr = PetscFree(pipefgmres->zvecs);CHKERRQ(ierr);
for (i=0; i<pipefgmres->nwork_alloc; i++) {
ierr = VecDestroyVecs(pipefgmres->mwork_alloc[i],&pipefgmres->prevecs_user_work[i]);CHKERRQ(ierr);
ierr = VecDestroyVecs(pipefgmres->mwork_alloc[i],&pipefgmres->zvecs_user_work[i]);CHKERRQ(ierr);
}
ierr = PetscFree(pipefgmres->prevecs_user_work);CHKERRQ(ierr);
ierr = PetscFree(pipefgmres->zvecs_user_work);CHKERRQ(ierr);
ierr = PetscFree(pipefgmres->redux);CHKERRQ(ierr);
ierr = KSPReset_GMRES(ksp);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例15: SNESDefaultGetWork
/*@
SNESDefaultGetWork - Gets a number of work vectors.
Input Parameters:
. snes - the SNES context
. nw - number of work vectors to allocate
Level: developer
Notes:
Call this only if no work vectors have been allocated
@*/
PetscErrorCode SNESDefaultGetWork(SNES snes,PetscInt nw)
{
PetscErrorCode ierr;
PetscFunctionBegin;
if (snes->work) {ierr = VecDestroyVecs(snes->nwork,&snes->work);CHKERRQ(ierr);}
snes->nwork = nw;
ierr = VecDuplicateVecs(snes->vec_sol,snes->nwork,&snes->work);CHKERRQ(ierr);
ierr = PetscLogObjectParents(snes,nw,snes->work);CHKERRQ(ierr);
PetscFunctionReturn(0);
}