[petsc-dev] PetscOptionsTail
Mark F. Adams
mark.adams at columbia.edu
Mon Apr 2 15:01:41 CDT 2012
On Apr 2, 2012, at 3:43 PM, Peter Brune wrote:
> Does PCGAMGSetType() call PetscOptionsHead() from KSP/PCSetFromOptions on some subsolver? I had a similar issue recently with FAS. The fix is to move other function calls that might do this out of your PetscOptionsHead/Tail() pair.
I don't think so ... I think this is the code stack that is invoked with PCGAMGSetType:
PetscErrorCode PCGAMGSetType( PC pc, const PCGAMGType type )
{
PetscErrorCode ierr;
PetscFunctionBegin;
PetscValidHeaderSpecific(pc,PC_CLASSID,1);
ierr = PetscTryMethod(pc,"PCGAMGSetType_C",(PC,const PCGAMGType),(pc,type));
CHKERRQ(ierr);
PetscFunctionReturn(0);
}
EXTERN_C_BEGIN
#undef __FUNCT__
#define __FUNCT__ "PCGAMGSetType_GAMG"
PetscErrorCode PCGAMGSetType_GAMG( PC pc, const PCGAMGType type )
{
PetscErrorCode ierr,(*r)(PC);
PetscFunctionBegin;
ierr = PetscFListFind(GAMGList,((PetscObject)pc)->comm,type,PETSC_FALSE,(PetscVoidStarFunction)&r);
CHKERRQ(ierr);
if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown GAMG type %s given",type);
/* call sub create method */
ierr = (*r)(pc); CHKERRQ(ierr);
PetscFunctionReturn(0);
}
EXTERN_C_END
PetscErrorCode PCCreateGAMG_AGG( PC pc )
{
PetscErrorCode ierr;
PC_MG *mg = (PC_MG*)pc->data;
PC_GAMG *pc_gamg = (PC_GAMG*)mg->innerctx;
PC_GAMG_AGG *pc_gamg_agg;
PetscFunctionBegin;
/* create sub context for SA */
ierr = PetscNewLog( pc, PC_GAMG_AGG, &pc_gamg_agg ); CHKERRQ(ierr);
assert(!pc_gamg->subctx);
pc_gamg->subctx = pc_gamg_agg;
pc->ops->setfromoptions = PCSetFromOptions_GAMG_AGG;
pc->ops->destroy = PCDestroy_AGG;
/* reset does not do anything; setup not virtual */
/* set internal function pointers */
pc_gamg->graph = PCGAMGgraph_AGG;
pc_gamg->coarsen = PCGAMGCoarsen_AGG;
pc_gamg->prolongator = PCGAMGProlongator_AGG;
pc_gamg->optprol = PCGAMGOptprol_AGG;
pc_gamg->createdefaultdata = PCSetData_AGG;
ierr = PetscObjectComposeFunctionDynamic( (PetscObject)pc,
"PCSetCoordinates_C",
"PCSetCoordinates_AGG",
PCSetCoordinates_AGG);
PetscFunctionReturn(0);
}
Mark
>
> - Peter
>
> On Mon, Apr 2, 2012 at 2:40 PM, Mark F. Adams <mark.adams at columbia.edu> wrote:
> I am getting strange behavior with PetscOptionsTail. I have this code:
>
> /* instantiate derived type */
> ierr = PetscOptionsHead("GAMG options"); CHKERRQ(ierr);
> {
> char tname[256] = GAMGAGG;
> ierr = PetscOptionsList("-pc_gamg_type","Type of GAMG method","PCGAMGSetType",
> GAMGList, tname, tname, sizeof(tname), PETSC_NULL );
> CHKERRQ(ierr);
> ierr = PCGAMGSetType( pc, tname ); CHKERRQ(ierr);
> }
> PetscPrintf(wcomm,"******* [%d]%s 5555\n",0,__FUNCT__);
> ierr = PetscOptionsTail(); CHKERRQ(ierr);
> PetscPrintf(wcomm,"******* [%d]%s 6666\n",0,__FUNCT__);
>
> and this last line does not get executed. It is as if CHKERRQ is silently returning. I see the usage in KSPSetFromOptions_GMRES has this code (PetscOptionsTail) at the very end and so this behavior would not be noticed.
>
> Mark
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120402/0a87ba16/attachment.html>
More information about the petsc-dev
mailing list