本文整理汇总了C++中KSPDestroy函数的典型用法代码示例。如果您正苦于以下问题:C++ KSPDestroy函数的具体用法?C++ KSPDestroy怎么用?C++ KSPDestroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KSPDestroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KSPDestroy_SpecEst
static PetscErrorCode KSPDestroy_SpecEst(KSP ksp)
{
PetscErrorCode ierr;
KSP_SpecEst *spec = (KSP_SpecEst*)ksp->data;
PetscFunctionBegin;
ierr = KSPDestroy(&spec->kspest);CHKERRQ(ierr);
ierr = KSPDestroy(&spec->kspcheap);CHKERRQ(ierr);
ierr = PCDestroy(&spec->pcnone);CHKERRQ(ierr);
ierr = PetscFree(ksp->data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例2: PCReset_PCD_Feelpp
static PetscErrorCode PCReset_PCD_Feelpp(PC pc)
{
PC_PCD_Feelpp *pcpcd = (PC_PCD_Feelpp*)pc->data;
KSPDestroy(&pcpcd->kspAp);
KSPDestroy(&pcpcd->kspMp);
MatDestroy(&pcpcd->matApLaplacian);
MatDestroy(&pcpcd->matMp);
MatDestroy(&pcpcd->matFp);
MatDestroy(&pcpcd->matApBTBt);
MatDestroy(&pcpcd->matMv);
VecDestroy(&pcpcd->x1);
VecDestroy(&pcpcd->x2);
VecDestroy(&pcpcd->MvDiag);
PetscFunctionReturn(0);
}
示例3: KSPChebyshevEstEigSet_Chebyshev
static PetscErrorCode KSPChebyshevEstEigSet_Chebyshev(KSP ksp,PetscReal a,PetscReal b,PetscReal c,PetscReal d)
{
KSP_Chebyshev *cheb = (KSP_Chebyshev*)ksp->data;
PetscErrorCode ierr;
PetscFunctionBegin;
if (a != 0.0 || b != 0.0 || c != 0.0 || d != 0.0) {
if (!cheb->kspest) { /* should this block of code be moved to KSPSetUp_Chebyshev()? */
ierr = KSPCreate(PetscObjectComm((PetscObject)ksp),&cheb->kspest);CHKERRQ(ierr);
ierr = PetscObjectIncrementTabLevel((PetscObject)cheb->kspest,(PetscObject)ksp,1);CHKERRQ(ierr);
ierr = KSPSetOptionsPrefix(cheb->kspest,((PetscObject)ksp)->prefix);CHKERRQ(ierr);
ierr = KSPAppendOptionsPrefix(cheb->kspest,"esteig_");CHKERRQ(ierr);
ierr = KSPSetSkipPCSetFromOptions(cheb->kspest,PETSC_TRUE);CHKERRQ(ierr);
ierr = KSPSetPC(cheb->kspest,ksp->pc);CHKERRQ(ierr);
ierr = KSPSetComputeEigenvalues(cheb->kspest,PETSC_TRUE);CHKERRQ(ierr);
/* We cannot turn off convergence testing because GMRES will break down if you attempt to keep iterating after a zero norm is obtained */
ierr = KSPSetTolerances(cheb->kspest,1.e-12,PETSC_DEFAULT,PETSC_DEFAULT,cheb->eststeps);CHKERRQ(ierr);
}
if (a >= 0) cheb->tform[0] = a;
if (b >= 0) cheb->tform[1] = b;
if (c >= 0) cheb->tform[2] = c;
if (d >= 0) cheb->tform[3] = d;
cheb->amatid = 0;
cheb->pmatid = 0;
cheb->amatstate = -1;
cheb->pmatstate = -1;
} else {
ierr = KSPDestroy(&cheb->kspest);CHKERRQ(ierr);
}
PetscFunctionReturn(0);
}
示例4: main
int main(int argc,char **argv)
{
PetscErrorCode ierr;
KSP ksp;
DM da,shell;
PetscInt levels;
PetscInitialize(&argc,&argv,(char*)0,help);
ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);
ierr = DMDACreate1d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,-129,1,1,0,&da);CHKERRQ(ierr);
ierr = MyDMShellCreate(PETSC_COMM_WORLD,da,&shell);CHKERRQ(ierr);
/* these two lines are not needed but allow PCMG to automatically know how many multigrid levels the user wants */
ierr = DMGetRefineLevel(da,&levels);CHKERRQ(ierr);
ierr = DMSetRefineLevel(shell,levels);CHKERRQ(ierr);
ierr = KSPSetDM(ksp,shell);CHKERRQ(ierr);
ierr = KSPSetComputeRHS(ksp,ComputeRHS,NULL);CHKERRQ(ierr);
ierr = KSPSetComputeOperators(ksp,ComputeMatrix,NULL);CHKERRQ(ierr);
ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
ierr = KSPSolve(ksp,NULL,NULL);CHKERRQ(ierr);
ierr = KSPDestroy(&ksp);CHKERRQ(ierr);
ierr = DMDestroy(&shell);CHKERRQ(ierr);
ierr = DMDestroy(&da);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
示例5: efs_destroy
PetscErrorCode efs_destroy(efs *slv)
{
PetscErrorCode ierr;
int i;
ierr = ef_boundary_destroy(slv->boundary);CHKERRQ(ierr);
ierr = ef_operator_destroy(slv->op);CHKERRQ(ierr); free(slv->op);
ierr = ef_fd_destroy(slv->fd);CHKERRQ(ierr); free(slv->fd);
ef_dmap_destroy(slv->dmap); free(slv->dmap);
if (slv->options.galerkin) {
ierr = ef_metric_destroy(slv->levels[0].metric);CHKERRQ(ierr);
free(slv->levels[0].metric);
} else {
for (i = 0; i < slv->options.levels; i++) {
ierr = ef_metric_destroy(slv->levels[i].metric);CHKERRQ(ierr);
free(slv->levels[i].metric);
}
}
free(slv->levels);
free(slv->callback);
ierr = DMDestroy(&slv->dm);CHKERRQ(ierr);
ierr = KSPDestroy(&slv->ksp);CHKERRQ(ierr);
return 0;
}
示例6: main
int main(int argc, char **argv)
{
Mat A;
KSP ksp;
DM shell;
Vec *left, *right;
MPI_Comm c;
PetscErrorCode ierr;
ierr = PetscInitialize(&argc, &argv, NULL, NULL);if (ierr) return ierr;
c = PETSC_COMM_WORLD;
ierr = MatCreate(c, &A); CHKERRQ(ierr);
ierr = MatSetSizes(A, 1, 1, PETSC_DECIDE, PETSC_DECIDE); CHKERRQ(ierr);
ierr = MatSetFromOptions(A); CHKERRQ(ierr);
ierr = MatSetUp(A); CHKERRQ(ierr);
ierr = KSPCreate(c, &ksp); CHKERRQ(ierr);
ierr = KSPSetOperators(ksp, A, A); CHKERRQ(ierr);
ierr = KSPSetFromOptions(ksp); CHKERRQ(ierr);
ierr = DMShellCreate(c, &shell); CHKERRQ(ierr);
ierr = DMSetFromOptions(shell); CHKERRQ(ierr);
ierr = DMSetUp(shell); CHKERRQ(ierr);
ierr = KSPSetDM(ksp, shell); CHKERRQ(ierr);
ierr = KSPCreateVecs(ksp, 1, &right, 1, &left); CHKERRQ(ierr);
ierr = VecView(right[0], PETSC_VIEWER_STDOUT_(c));CHKERRQ(ierr);
ierr = VecDestroyVecs(1,&right); CHKERRQ(ierr);
ierr = VecDestroyVecs(1,&left); CHKERRQ(ierr);
ierr = DMDestroy(&shell); CHKERRQ(ierr);
ierr = KSPDestroy(&ksp); CHKERRQ(ierr);
ierr = MatDestroy(&A); CHKERRQ(ierr);
PetscFinalize();
return 0;
}
示例7: main
int main(int argc,char **argv)
{
PetscErrorCode ierr;
PetscInt i;
KSP ksp;
DM da;
Vec x;
PetscInitialize(&argc,&argv,(char*)0,help);
ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);
ierr = DMDACreate1d(PETSC_COMM_WORLD,DMDA_BOUNDARY_PERIODIC,-3,2,1,0,&da);CHKERRQ(ierr);
ierr = KSPSetDM(ksp,da);CHKERRQ(ierr);
ierr = KSPSetComputeRHS(ksp,ComputeRHS,NULL);CHKERRQ(ierr);
ierr = KSPSetComputeOperators(ksp,ComputeMatrix,NULL);CHKERRQ(ierr);
ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
ierr = DMCreateGlobalVector(da,&x);CHKERRQ(ierr);
ierr = ComputeInitialSolution(da,x);CHKERRQ(ierr);
ierr = DMSetApplicationContext(da,x);CHKERRQ(ierr);
ierr = KSPSetUp(ksp);CHKERRQ(ierr);
ierr = VecView(x,PETSC_VIEWER_DRAW_WORLD);CHKERRQ(ierr);
for (i=0; i<10; i++) {
ierr = KSPSolve(ksp,NULL,x);CHKERRQ(ierr);
ierr = VecView(x,PETSC_VIEWER_DRAW_WORLD);CHKERRQ(ierr);
}
ierr = VecDestroy(&x);CHKERRQ(ierr);
ierr = KSPDestroy(&ksp);CHKERRQ(ierr);
ierr = DMDestroy(&da);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
示例8: VecDestroy
PETSc::~PETSc()
{
if(x!=NULL)
{
VecDestroy(&x);
x = NULL;
}
if(b!=NULL)
{
VecDestroy(&b);
b = NULL;
}
if(A!=NULL)
{
MatDestroy(&A);
A = NULL;
}
if(ksp!=NULL)
{
KSPDestroy(&ksp);
ksp = NULL;
}
if(nullsp!=NULL)
{
MatNullSpaceDestroy(&nullsp);
nullsp = NULL;
}
}
示例9: MatDestroy
~DistributedCSR() {
MatDestroy(&_petsc);
for(int i = 0; i < _S.size(); ++i)
MatDestroy(&_S[i]);
KSPDestroy(&_ksp);
if(_exchange) {
_exchange[0]->clearBuffer();
delete _exchange[0];
if(_exchange[1]) {
_exchange[1]->clearBuffer();
delete _exchange[1];
}
delete [] _exchange;
}
if(_A) {
if(!std::is_same<HpddmType, HpSchwarz<PetscScalar>>::value)
VecScatterDestroy(&_scatter);
else
_A->clearBuffer();
delete _A;
_A = nullptr;
}
delete [] _num;
_num = nullptr;
}
示例10: IBAMR_TIMER_START
void
IBImplicitModHelmholtzPETScLevelSolver::deallocateSolverState()
{
if (!d_is_initialized) return;
IBAMR_TIMER_START(t_deallocate_solver_state);
// Deallocate PETSc objects.
int ierr;
ierr = KSPDestroy(d_petsc_ksp); IBTK_CHKERRQ(ierr);
ierr = MatDestroy(d_petsc_mat); IBTK_CHKERRQ(ierr);
ierr = VecDestroy(d_petsc_x); IBTK_CHKERRQ(ierr);
ierr = VecDestroy(d_petsc_b); IBTK_CHKERRQ(ierr);
d_dof_index_fill.setNull();
d_petsc_ksp = PETSC_NULL;
d_petsc_mat = PETSC_NULL;
d_petsc_x = PETSC_NULL;
d_petsc_b = PETSC_NULL;
// Deallocate DOF index data.
Pointer<PatchLevel<NDIM> > level = d_hierarchy->getPatchLevel(d_level_num);
if (level->checkAllocated(d_dof_index_idx)) level->deallocatePatchData(d_dof_index_idx);
// Indicate that the solver is NOT initialized.
d_is_initialized = false;
IBAMR_TIMER_STOP(t_deallocate_solver_state);
return;
}// deallocateSolverState
示例11: main
int main(int argc,char **argv)
{
KSP ksp;
DM da;
UserContext user;
PetscInt bc;
PetscErrorCode ierr;
PetscInitialize(&argc,&argv,(char *)0,help);
ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);
ierr = DMDACreate2d(PETSC_COMM_WORLD, DMDA_BOUNDARY_NONE, DMDA_BOUNDARY_NONE,DMDA_STENCIL_STAR,-11,-11,PETSC_DECIDE,PETSC_DECIDE,1,1,PETSC_NULL,PETSC_NULL,&da);CHKERRQ(ierr);
ierr = KSPSetDM(ksp,(DM)da);
ierr = DMSetApplicationContext(da,&user);CHKERRQ(ierr);
user.uu = 1.0;
user.tt = 1.0;
bc = (PetscInt)NEUMANN; // Use Neumann Boundary Conditions
user.bcType = (BCType)bc;
ierr = KSPSetComputeRHS(ksp,ComputeRHS,&user);CHKERRQ(ierr);
ierr = KSPSetComputeOperators(ksp,ComputeJacobian,&user);CHKERRQ(ierr);
ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
ierr = KSPSolve(ksp,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr);
ierr = DMDestroy(&da);CHKERRQ(ierr);
ierr = KSPDestroy(&ksp);CHKERRQ(ierr);
ierr = PetscFinalize();CHKERRQ(ierr);
return 0;
}
示例12: main
int main(int argc,char **args)
{
KSP ksp; /* linear solver context */
Mat A; /* matrix */
Vec x,b; /* approx solution, RHS, exact solution */
PetscViewer fd; /* viewer */
PetscErrorCode ierr;
PetscInitialize(&argc,&args,(char *)0,help);
fd = PETSC_VIEWER_SOCKET_WORLD;
ierr = VecCreate(PETSC_COMM_WORLD,&b);CHKERRQ(ierr);
ierr = VecLoad(b,fd);CHKERRQ(ierr);
ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);
ierr = MatLoad(A,fd);CHKERRQ(ierr);
ierr = VecDuplicate(b,&x);CHKERRQ(ierr);
ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);
ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
ierr = KSPSetUp(ksp);CHKERRQ(ierr);
ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
ierr = VecView(x,fd);CHKERRQ(ierr);
ierr = MatDestroy(&A);CHKERRQ(ierr);
ierr = VecDestroy(&b);CHKERRQ(ierr);
ierr = VecDestroy(&x);CHKERRQ(ierr);
ierr = KSPDestroy(&ksp);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
示例13: finalize
PetscErrorCode NavierStokesSolver::finalize()
{
PetscErrorCode ierr;
// DMs
if(pda != PETSC_NULL) {ierr = DMDestroy(&pda); CHKERRQ(ierr);}
if(uda != PETSC_NULL) {ierr = DMDestroy(&uda); CHKERRQ(ierr);}
if(vda != PETSC_NULL) {ierr = DMDestroy(&vda); CHKERRQ(ierr);}
if(qPack != PETSC_NULL) {ierr = DMDestroy(&qPack); CHKERRQ(ierr);}
if(lambdaPack != PETSC_NULL) {ierr = DMDestroy(&lambdaPack); CHKERRQ(ierr);}
//Vecs
if(q != PETSC_NULL) {ierr = VecDestroy(&q); CHKERRQ(ierr);}
if(qStar != PETSC_NULL) {ierr = VecDestroy(&qStar); CHKERRQ(ierr);}
if(qxLocal != PETSC_NULL) {ierr = VecDestroy(&qxLocal); CHKERRQ(ierr);}
if(qyLocal != PETSC_NULL) {ierr = VecDestroy(&qyLocal); CHKERRQ(ierr);}
if(H != PETSC_NULL) {ierr = VecDestroy(&H); CHKERRQ(ierr);}
if(rn != PETSC_NULL) {ierr = VecDestroy(&rn); CHKERRQ(ierr);}
if(bc1 != PETSC_NULL) {ierr = VecDestroy(&bc1); CHKERRQ(ierr);}
if(rhs1 != PETSC_NULL) {ierr = VecDestroy(&rhs1); CHKERRQ(ierr);}
if(temp != PETSC_NULL) {ierr = VecDestroy(&temp); CHKERRQ(ierr);}
if(lambda != PETSC_NULL) {ierr = VecDestroy(&lambda); CHKERRQ(ierr);}
if(bc2 != PETSC_NULL) {ierr = VecDestroy(&bc2); CHKERRQ(ierr);}
if(rhs2 != PETSC_NULL) {ierr = VecDestroy(&rhs2); CHKERRQ(ierr);}
if(uMapping != PETSC_NULL) {ierr = VecDestroy(&uMapping); CHKERRQ(ierr);}
if(vMapping != PETSC_NULL) {ierr = VecDestroy(&vMapping); CHKERRQ(ierr);}
if(pMapping != PETSC_NULL) {ierr = VecDestroy(&pMapping); CHKERRQ(ierr);}
if(MHat != PETSC_NULL) {ierr = VecDestroy(&MHat); CHKERRQ(ierr);}
if(RInv != PETSC_NULL) {ierr = VecDestroy(&RInv); CHKERRQ(ierr);}
if(BN != PETSC_NULL) {ierr = VecDestroy(&BN); CHKERRQ(ierr);}
//Mats
if(A!=PETSC_NULL) {ierr = MatDestroy(&A); CHKERRQ(ierr);}
if(QT != PETSC_NULL) {ierr = MatDestroy(&QT); CHKERRQ(ierr);}
if(BNQ != PETSC_NULL) {ierr = MatDestroy(&BNQ); CHKERRQ(ierr);}
if(QTBNQ != PETSC_NULL) {ierr = MatDestroy(&QTBNQ); CHKERRQ(ierr);}
//KSPs
if(ksp1 != PETSC_NULL) {ierr = KSPDestroy(&ksp1); CHKERRQ(ierr);}
if(ksp2 != PETSC_NULL) {ierr = KSPDestroy(&ksp2); CHKERRQ(ierr);}
return 0;
}
示例14: main
int main(int argc,char **argv)
{
KSP ksp;
DM da;
UserContext user;
const char *bcTypes[2] = {"dirichlet","neumann"};
PetscErrorCode ierr;
PetscInt bc;
Vec b,x;
PetscInitialize(&argc,&argv,(char *)0,help);
ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);
CHKERRQ(ierr);
ierr = DMDACreate2d(PETSC_COMM_WORLD, DMDA_BOUNDARY_NONE, DMDA_BOUNDARY_NONE,DMDA_STENCIL_STAR,-3,-3,PETSC_DECIDE,PETSC_DECIDE,1,1,0,0,&da);
CHKERRQ(ierr);
ierr = DMDASetUniformCoordinates(da,0,1,0,1,0,0);
CHKERRQ(ierr);
ierr = DMDASetFieldName(da,0,"Pressure");
CHKERRQ(ierr);
ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "", "Options for the inhomogeneous Poisson equation", "DMqq");
user.rho = 1.0;
ierr = PetscOptionsReal("-rho", "The conductivity", "ex29.c", user.rho, &user.rho, PETSC_NULL);
CHKERRQ(ierr);
user.nu = 0.1;
ierr = PetscOptionsReal("-nu", "The width of the Gaussian source", "ex29.c", user.nu, &user.nu, PETSC_NULL);
CHKERRQ(ierr);
bc = (PetscInt)DIRICHLET;
ierr = PetscOptionsEList("-bc_type","Type of boundary condition","ex29.c",bcTypes,2,bcTypes[0],&bc,PETSC_NULL);
CHKERRQ(ierr);
user.bcType = (BCType)bc;
ierr = PetscOptionsEnd();
ierr = KSPSetComputeRHS(ksp,ComputeRHS,&user);
CHKERRQ(ierr);
ierr = KSPSetComputeOperators(ksp,ComputeMatrix,&user);
CHKERRQ(ierr);
ierr = KSPSetDM(ksp,da);
CHKERRQ(ierr);
ierr = KSPSetFromOptions(ksp);
CHKERRQ(ierr);
ierr = KSPSetUp(ksp);
CHKERRQ(ierr);
ierr = KSPSolve(ksp,PETSC_NULL,PETSC_NULL);
CHKERRQ(ierr);
ierr = KSPGetSolution(ksp,&x);
CHKERRQ(ierr);
ierr = KSPGetRhs(ksp,&b);
CHKERRQ(ierr);
ierr = DMDestroy(&da);
CHKERRQ(ierr);
ierr = KSPDestroy(&ksp);
CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
示例15: VecDestroy
Field_solver::~Field_solver()
{
PetscErrorCode ierr;
ierr = VecDestroy( &phi_vec ); CHKERRXX( ierr );
ierr = VecDestroy( &rhs ); CHKERRXX( ierr );
ierr = MatDestroy( &A ); CHKERRXX( ierr );
ierr = KSPDestroy( &ksp ); CHKERRXX( ierr );
}