本文整理汇总了C++中PetscObjectComposeFunction函数的典型用法代码示例。如果您正苦于以下问题:C++ PetscObjectComposeFunction函数的具体用法?C++ PetscObjectComposeFunction怎么用?C++ PetscObjectComposeFunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PetscObjectComposeFunction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ISCreate_Block
PETSC_EXTERN PetscErrorCode ISCreate_Block(IS is)
{
PetscErrorCode ierr;
IS_Block *sub;
PetscFunctionBegin;
ierr = PetscNewLog(is,IS_Block,&sub);CHKERRQ(ierr);
is->data = sub;
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockSetIndices_C",ISBlockSetIndices_Block);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockGetIndices_C",ISBlockGetIndices_Block);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockRestoreIndices_C",ISBlockRestoreIndices_Block);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockGetSize_C",ISBlockGetSize_Block);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockGetLocalSize_C",ISBlockGetLocalSize_Block);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例2: ISDestroy_Block
PetscErrorCode ISDestroy_Block(IS is)
{
IS_Block *is_block = (IS_Block*)is->data;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscFree(is_block->idx);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockSetIndices_C",0);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockGetIndices_C",0);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockRestoreIndices_C",0);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockGetSize_C",0);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)is,"ISBlockGetLocalSize_C",0);CHKERRQ(ierr);
ierr = PetscFree(is->data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例3: MatPartitioningDestroy_Party
PetscErrorCode MatPartitioningDestroy_Party(MatPartitioning part)
{
MatPartitioning_Party *party = (MatPartitioning_Party*)part->data;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscFree(party);CHKERRQ(ierr);
/* clear composed functions */
ierr = PetscObjectComposeFunction((PetscObject)part,"MatPartitioningPartySetGlobal_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)part,"MatPartitioningPartySetLocal_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)part,"MatPartitioningPartySetCoarseLevel_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)part,"MatPartitioningPartySetMatchOptimization_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)part,"MatPartitioningPartySetBipart_C",NULL);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例4: KSPDestroy_CG
PetscErrorCode KSPDestroy_CG(KSP ksp)
{
KSP_CG *cg = (KSP_CG*)ksp->data;
PetscErrorCode ierr;
PetscFunctionBegin;
/* free space used for singular value calculations */
if (ksp->calc_sings) {
ierr = PetscFree4(cg->e,cg->d,cg->ee,cg->dd);CHKERRQ(ierr);
}
ierr = KSPDestroyDefault(ksp);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)ksp,"KSPCGSetType_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)ksp,"KSPCGUseSingleReduction_C",NULL);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例5: PCCreate_ICC
PETSC_EXTERN PetscErrorCode PCCreate_ICC(PC pc)
{
PetscErrorCode ierr;
PC_ICC *icc;
PetscFunctionBegin;
ierr = PetscNewLog(pc,PC_ICC,&icc);CHKERRQ(ierr);
((PC_Factor*)icc)->fact = 0;
ierr = PetscStrallocpy(MATORDERINGNATURAL,(char**)&((PC_Factor*)icc)->ordering);CHKERRQ(ierr);
ierr = PetscStrallocpy(MATSOLVERPETSC,&((PC_Factor*)icc)->solvertype);CHKERRQ(ierr);
ierr = MatFactorInfoInitialize(&((PC_Factor*)icc)->info);CHKERRQ(ierr);
((PC_Factor*)icc)->factortype = MAT_FACTOR_ICC;
((PC_Factor*)icc)->info.levels = 0.;
((PC_Factor*)icc)->info.fill = 1.0;
icc->implctx = 0;
((PC_Factor*)icc)->info.dtcol = PETSC_DEFAULT;
((PC_Factor*)icc)->info.shifttype = (PetscReal) MAT_SHIFT_POSITIVE_DEFINITE;
((PC_Factor*)icc)->info.shiftamount = 100.0*PETSC_MACHINE_EPSILON;
((PC_Factor*)icc)->info.zeropivot = 100.0*PETSC_MACHINE_EPSILON;
pc->data = (void*)icc;
pc->ops->apply = PCApply_ICC;
pc->ops->applytranspose = PCApply_ICC;
pc->ops->setup = PCSetup_ICC;
pc->ops->reset = PCReset_ICC;
pc->ops->destroy = PCDestroy_ICC;
pc->ops->setfromoptions = PCSetFromOptions_ICC;
pc->ops->view = PCView_ICC;
pc->ops->getfactoredmatrix = PCFactorGetMatrix_Factor;
pc->ops->applysymmetricleft = PCApplySymmetricLeft_ICC;
pc->ops->applysymmetricright = PCApplySymmetricRight_ICC;
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetUpMatSolverPackage_C",PCFactorSetUpMatSolverPackage_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorGetMatSolverPackage_C",PCFactorGetMatSolverPackage_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetZeroPivot_C",PCFactorSetZeroPivot_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetShiftType_C",PCFactorSetShiftType_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetShiftAmount_C",PCFactorSetShiftAmount_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetLevels_C",PCFactorSetLevels_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetFill_C",PCFactorSetFill_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetMatOrderingType_C",PCFactorSetMatOrderingType_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetMatSolverPackage_C",PCFactorSetMatSolverPackage_Factor);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCFactorSetDropTolerance_C",PCFactorSetDropTolerance_ILU);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例6: SNESCreate_NCG
PETSC_EXTERN PetscErrorCode SNESCreate_NCG(SNES snes)
{
PetscErrorCode ierr;
SNES_NCG * neP;
PetscFunctionBegin;
snes->ops->destroy = SNESDestroy_NCG;
snes->ops->setup = SNESSetUp_NCG;
snes->ops->setfromoptions = SNESSetFromOptions_NCG;
snes->ops->view = SNESView_NCG;
snes->ops->solve = SNESSolve_NCG;
snes->ops->reset = SNESReset_NCG;
snes->usesksp = PETSC_FALSE;
snes->usespc = PETSC_TRUE;
snes->pcside = PC_LEFT;
if (!snes->tolerancesset) {
snes->max_funcs = 30000;
snes->max_its = 10000;
snes->stol = 1e-20;
}
ierr = PetscNewLog(snes,&neP);CHKERRQ(ierr);
snes->data = (void*) neP;
neP->monitor = NULL;
neP->type = SNES_NCG_PRP;
ierr = PetscObjectComposeFunction((PetscObject)snes,"SNESNCGSetType_C", SNESNCGSetType_NCG);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例7: MatGetFactor_seqsbaij_sbstrm
PETSC_EXTERN PetscErrorCode MatGetFactor_seqsbaij_sbstrm(Mat A,MatFactorType ftype,Mat *F)
{
Mat B;
PetscInt bs = A->rmap->bs;
Mat_SeqSBSTRM *sbstrm;
PetscErrorCode ierr;
PetscFunctionBegin;
if (A->cmap->N != A->rmap->N) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be square matrix, rows %D columns %D",A->rmap->n,A->cmap->n);
ierr = MatCreate(PetscObjectComm((PetscObject)A),&B);CHKERRQ(ierr);
ierr = MatSetSizes(B,A->rmap->n,A->cmap->n,PETSC_DETERMINE,PETSC_DETERMINE);CHKERRQ(ierr);
ierr = MatSetType(B,((PetscObject)A)->type_name);CHKERRQ(ierr);
ierr = MatSeqSBAIJSetPreallocation_SeqSBAIJ(B,bs,MAT_SKIP_ALLOCATION,NULL);CHKERRQ(ierr);
B->ops->iccfactorsymbolic = MatICCFactorSymbolic_sbstrm;
B->ops->choleskyfactorsymbolic = MatCholeskyFactorSymbolic_sbstrm;
B->ops->choleskyfactornumeric = MatCholeskyFactorNumeric_sbstrm;
B->ops->destroy = MatDestroy_SeqSBSTRM;
B->factortype = ftype;
B->assembled = PETSC_TRUE; /* required by -ksp_view */
B->preallocated = PETSC_TRUE;
ierr = PetscNewLog(B,&sbstrm);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)B,"MatFactorGetSolverPackage_C",MatFactorGetSolverPackage_seqsbaij_sbstrm);CHKERRQ(ierr);
B->spptr = sbstrm;
*F = B;
PetscFunctionReturn(0);
}
示例8: KSPDestroy_Chebyshev
PetscErrorCode KSPDestroy_Chebyshev(KSP ksp)
{
KSP_Chebyshev *cheb = (KSP_Chebyshev*)ksp->data;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = KSPDestroy(&cheb->kspest);CHKERRQ(ierr);
ierr = PCDestroy(&cheb->pcnone);CHKERRQ(ierr);
ierr = PetscRandomDestroy(&cheb->random);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)ksp,"KSPChebyshevSetEigenvalues_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)ksp,"KSPChebyshevSetEstimateEigenvalues_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)ksp,"KSPChebyshevEstEigSetRandom_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)ksp,"KSPChebyshevSetNewMatrix_C",NULL);CHKERRQ(ierr);
ierr = KSPDestroyDefault(ksp);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例9: MatGetFactor_seqaij_lusol
PETSC_EXTERN PetscErrorCode MatGetFactor_seqaij_lusol(Mat A,MatFactorType ftype,Mat *F)
{
Mat B;
Mat_LUSOL *lusol;
PetscErrorCode ierr;
int m, n;
PetscFunctionBegin;
ierr = MatGetSize(A, &m, &n);CHKERRQ(ierr);
ierr = MatCreate(PetscObjectComm((PetscObject)A),&B);CHKERRQ(ierr);
ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,m,n);CHKERRQ(ierr);
ierr = MatSetType(B,((PetscObject)A)->type_name);CHKERRQ(ierr);
ierr = MatSeqAIJSetPreallocation(B,0,NULL);CHKERRQ(ierr);
ierr = PetscNewLog(B,&lusol);CHKERRQ(ierr);
B->spptr = lusol;
B->ops->lufactorsymbolic = MatLUFactorSymbolic_LUSOL;
B->ops->destroy = MatDestroy_LUSOL;
ierr = PetscObjectComposeFunction((PetscObject)B,"MatFactorGetSolverType_C",MatFactorGetSolverType_seqaij_lusol);CHKERRQ(ierr);
B->factortype = MAT_FACTOR_LU;
ierr = PetscFree(B->solvertype);CHKERRQ(ierr);
ierr = PetscStrallocpy(MATSOLVERLUSOL,&B->solvertype);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例10: SNESCreate_MS
PETSC_EXTERN PetscErrorCode SNESCreate_MS(SNES snes)
{
PetscErrorCode ierr;
SNES_MS *ms;
PetscFunctionBegin;
ierr = SNESMSInitializePackage();CHKERRQ(ierr);
snes->ops->setup = SNESSetUp_MS;
snes->ops->solve = SNESSolve_MS;
snes->ops->destroy = SNESDestroy_MS;
snes->ops->setfromoptions = SNESSetFromOptions_MS;
snes->ops->view = SNESView_MS;
snes->ops->reset = SNESReset_MS;
snes->usespc = PETSC_FALSE;
snes->usesksp = PETSC_TRUE;
ierr = PetscNewLog(snes,&ms);CHKERRQ(ierr);
snes->data = (void*)ms;
ms->damping = 0.9;
ms->norms = PETSC_FALSE;
ierr = PetscObjectComposeFunction((PetscObject)snes,"SNESMSSetType_C",SNESMSSetType_MS);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例11: MatConvert_MPISBAIJ_MPISBSTRM
PETSC_EXTERN PetscErrorCode MatConvert_MPISBAIJ_MPISBSTRM(Mat A,MatType type,MatReuse reuse,Mat *newmat)
{
PetscErrorCode ierr;
Mat B = *newmat;
Mat_SeqSBSTRM *sbstrm;
PetscFunctionBegin;
if (reuse == MAT_INITIAL_MATRIX) {
ierr = MatDuplicate(A,MAT_COPY_VALUES,&B);CHKERRQ(ierr);
}
/* printf(" --- in MatConvert_MPISBAIJ_MPISBSTRM -- 1 \n"); */
ierr = PetscNewLog(B, Mat_SeqSBSTRM,&sbstrm);CHKERRQ(ierr);
B->spptr = (void*)sbstrm;
/* Set function pointers for methods that we inherit from AIJ but override.
B->ops->duplicate = MatDuplicate_SBSTRM;
B->ops->mult = MatMult_SBSTRM;
B->ops->destroy = MatDestroy_MPISBSTRM;
*/
B->ops->assemblyend = MatAssemblyEnd_MPISBSTRM;
/* If A has already been assembled, compute the permutation. */
if (A->assembled) {
ierr = MPISBSTRM_create_sbstrm(B);CHKERRQ(ierr);
}
ierr = PetscObjectChangeTypeName((PetscObject) B, MATMPISBSTRM);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)B,"MatMPISBAIJSetPreallocation_C",MatMPISBAIJSetPreallocation_MPISBSTRM);CHKERRQ(ierr);
*newmat = B;
PetscFunctionReturn(0);
}
示例12: PCCreateGAMG_Classical
PetscErrorCode PCCreateGAMG_Classical(PC pc)
{
PetscErrorCode ierr;
PC_MG *mg = (PC_MG*)pc->data;
PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
PC_GAMG_Classical *pc_gamg_classical;
PetscFunctionBegin;
ierr = PCGAMGClassicalInitializePackage();
if (pc_gamg->subctx) {
/* call base class */
ierr = PCDestroy_GAMG(pc);CHKERRQ(ierr);
}
/* create sub context for SA */
ierr = PetscNewLog(pc,&pc_gamg_classical);CHKERRQ(ierr);
pc_gamg->subctx = pc_gamg_classical;
pc->ops->setfromoptions = PCGAMGSetFromOptions_Classical;
/* reset does not do anything; setup not virtual */
/* set internal function pointers */
pc_gamg->ops->destroy = PCGAMGDestroy_Classical;
pc_gamg->ops->graph = PCGAMGGraph_Classical;
pc_gamg->ops->coarsen = PCGAMGCoarsen_Classical;
pc_gamg->ops->prolongator = PCGAMGProlongator_Classical;
pc_gamg->ops->optprol = PCGAMGOptProl_Classical_Jacobi;
pc_gamg->ops->setfromoptions = PCGAMGSetFromOptions_Classical;
pc_gamg->ops->createdefaultdata = PCGAMGSetData_Classical;
pc_gamg_classical->interp_threshold = 0.2;
pc_gamg_classical->nsmooths = 0;
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCGAMGClassicalSetType_C",PCGAMGClassicalSetType_GAMG);CHKERRQ(ierr);
ierr = PCGAMGClassicalSetType(pc,PCGAMGCLASSICALSTANDARD);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例13: MatGetFactor_seqaij_matlab
PETSC_EXTERN PetscErrorCode MatGetFactor_seqaij_matlab(Mat A,MatFactorType ftype,Mat *F)
{
PetscErrorCode ierr;
PetscFunctionBegin;
if (A->cmap->N != A->rmap->N) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"matrix must be square");
ierr = MatCreate(PetscObjectComm((PetscObject)A),F);
CHKERRQ(ierr);
ierr = MatSetSizes(*F,A->rmap->n,A->cmap->n,A->rmap->n,A->cmap->n);
CHKERRQ(ierr);
ierr = PetscStrallocpy("matlab",&((PetscObject)*F)->type_name);
CHKERRQ(ierr);
ierr = MatSetUp(*F);
CHKERRQ(ierr);
(*F)->ops->destroy = MatDestroy_matlab;
(*F)->ops->getinfo = MatGetInfo_External;
(*F)->ops->lufactorsymbolic = MatLUFactorSymbolic_Matlab;
(*F)->ops->ilufactorsymbolic = MatLUFactorSymbolic_Matlab;
ierr = PetscObjectComposeFunction((PetscObject)(*F),"MatFactorGetSolverPackage_C",MatFactorGetSolverPackage_seqaij_matlab);
CHKERRQ(ierr);
(*F)->factortype = ftype;
ierr = PetscFree((*F)->solvertype);
CHKERRQ(ierr);
ierr = PetscStrallocpy(MATSOLVERMATLAB,&(*F)->solvertype);
CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例14: MatCreate_MPIAdj
PETSC_EXTERN PetscErrorCode MatCreate_MPIAdj(Mat B)
{
Mat_MPIAdj *b;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscNewLog(B,&b);CHKERRQ(ierr);
B->data = (void*)b;
ierr = PetscMemcpy(B->ops,&MatOps_Values,sizeof(struct _MatOps));CHKERRQ(ierr);
B->assembled = PETSC_FALSE;
ierr = PetscObjectComposeFunction((PetscObject)B,"MatMPIAdjSetPreallocation_C",MatMPIAdjSetPreallocation_MPIAdj);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)B,"MatMPIAdjCreateNonemptySubcommMat_C",MatMPIAdjCreateNonemptySubcommMat_MPIAdj);CHKERRQ(ierr);
ierr = PetscObjectChangeTypeName((PetscObject)B,MATMPIADJ);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例15: the
/*@
MatCreateTranspose - Creates a new matrix object that behaves like A'
Collective on Mat
Input Parameter:
. A - the (possibly rectangular) matrix
Output Parameter:
. N - the matrix that represents A'
Level: intermediate
Notes:
The transpose A' is NOT actually formed! Rather the new matrix
object performs the matrix-vector product by using the MatMultTranspose() on
the original matrix
.seealso: MatCreateNormal(), MatMult(), MatMultTranspose(), MatCreate()
@*/
PetscErrorCode MatCreateTranspose(Mat A,Mat *N)
{
PetscErrorCode ierr;
PetscInt m,n;
Mat_Transpose *Na;
PetscFunctionBegin;
ierr = MatGetLocalSize(A,&m,&n);CHKERRQ(ierr);
ierr = MatCreate(PetscObjectComm((PetscObject)A),N);CHKERRQ(ierr);
ierr = MatSetSizes(*N,n,m,PETSC_DECIDE,PETSC_DECIDE);CHKERRQ(ierr);
ierr = PetscLayoutSetUp((*N)->rmap);CHKERRQ(ierr);
ierr = PetscLayoutSetUp((*N)->cmap);CHKERRQ(ierr);
ierr = PetscObjectChangeTypeName((PetscObject)*N,MATTRANSPOSEMAT);CHKERRQ(ierr);
ierr = PetscNewLog(*N,&Na);CHKERRQ(ierr);
(*N)->data = (void*) Na;
ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr);
Na->A = A;
(*N)->ops->destroy = MatDestroy_Transpose;
(*N)->ops->mult = MatMult_Transpose;
(*N)->ops->multadd = MatMultAdd_Transpose;
(*N)->ops->multtranspose = MatMultTranspose_Transpose;
(*N)->ops->multtransposeadd = MatMultTransposeAdd_Transpose;
(*N)->ops->duplicate = MatDuplicate_Transpose;
(*N)->ops->getvecs = MatCreateVecs_Transpose;
(*N)->ops->axpy = MatAXPY_Transpose;
(*N)->assembled = PETSC_TRUE;
ierr = PetscObjectComposeFunction((PetscObject)(*N),"MatTransposeGetMat_C",MatTransposeGetMat_Transpose);CHKERRQ(ierr);
ierr = MatSetBlockSizes(*N,PetscAbs(A->cmap->bs),PetscAbs(A->rmap->bs));CHKERRQ(ierr);
ierr = MatSetUp(*N);CHKERRQ(ierr);
PetscFunctionReturn(0);
}