/*@C DMDARestoreElements - Returns an array containing the indices (in local coordinates) of all the local elements obtained with DMDAGetElements() Not Collective Input Parameter: + dm - the DM object . nel - number of local elements . nen - number of element nodes - e - the local indices of the elements' vertices Level: intermediate .seealso: DMDAElementType, DMDASetElementType(), DMDAGetElements() @*/ PetscErrorCode DMDARestoreElements(DM dm,PetscInt *nel,PetscInt *nen,const PetscInt *e[]) { PetscFunctionBegin; PetscValidHeaderSpecific(dm,DM_CLASSID,1); PetscValidIntPointer(nel,2); PetscValidIntPointer(nen,3); PetscValidPointer(e,4); /* XXX */ PetscFunctionReturn(0); }
/*@C TSAdaptChoose - choose which method and step size to use for the next step Collective on TSAdapt Input Arguments: + adapt - adaptive contoller - h - current step size Output Arguments: + next_sc - optional, scheme to use for the next step . next_h - step size to use for the next step - accept - PETSC_TRUE to accept the current step, PETSC_FALSE to repeat the current step with the new step size Note: The input value of parameter accept is retained from the last time step, so it will be PETSC_FALSE if the step is being retried after an initial rejection. Level: developer .seealso: TSAdapt, TSAdaptCandidatesClear(), TSAdaptCandidateAdd() @*/ PetscErrorCode TSAdaptChoose(TSAdapt adapt,TS ts,PetscReal h,PetscInt *next_sc,PetscReal *next_h,PetscBool *accept) { PetscErrorCode ierr; PetscInt ncandidates = adapt->candidates.n; PetscInt scheme = 0; PetscReal wlte = -1.0; PetscReal wltea = -1.0; PetscReal wlter = -1.0; PetscFunctionBegin; PetscValidHeaderSpecific(adapt,TSADAPT_CLASSID,1); PetscValidHeaderSpecific(ts,TS_CLASSID,2); if (next_sc) PetscValidIntPointer(next_sc,4); PetscValidPointer(next_h,5); PetscValidIntPointer(accept,6); if (next_sc) *next_sc = 0; /* Do not mess with adaptivity while handling events*/ if (ts->event && ts->event->status != TSEVENT_NONE) { *next_h = h; *accept = PETSC_TRUE; PetscFunctionReturn(0); } ierr = (*adapt->ops->choose)(adapt,ts,h,&scheme,next_h,accept,&wlte,&wltea,&wlter);CHKERRQ(ierr); if (scheme < 0 || (ncandidates > 0 && scheme >= ncandidates)) SETERRQ2(PetscObjectComm((PetscObject)adapt),PETSC_ERR_ARG_OUTOFRANGE,"Chosen scheme %D not in valid range 0..%D",scheme,ncandidates-1); if (*next_h < 0) SETERRQ1(PetscObjectComm((PetscObject)adapt),PETSC_ERR_ARG_OUTOFRANGE,"Computed step size %g must be positive",(double)*next_h); if (next_sc) *next_sc = scheme; if (*accept && ts->exact_final_time == TS_EXACTFINALTIME_MATCHSTEP) { /* Increase/reduce step size if end time of next step is close to or overshoots max time */ PetscReal t = ts->ptime + ts->time_step, h = *next_h; PetscReal tend = t + h, tmax = ts->max_time, hmax = tmax - t; PetscReal a = (PetscReal)(1.0 + adapt->matchstepfac[0]); PetscReal b = adapt->matchstepfac[1]; if (t < tmax && tend > tmax) *next_h = hmax; if (t < tmax && tend < tmax && h*b > hmax) *next_h = hmax/2; if (t < tmax && tend < tmax && h*a > hmax) *next_h = hmax; } if (adapt->monitor) { const char *sc_name = (scheme < ncandidates) ? adapt->candidates.name[scheme] : ""; ierr = PetscViewerASCIIAddTab(adapt->monitor,((PetscObject)adapt)->tablevel);CHKERRQ(ierr); if (wlte < 0) { ierr = PetscViewerASCIIPrintf(adapt->monitor," TSAdapt %s %s %D:%s step %3D %s t=%-11g+%10.3e dt=%-10.3e\n",((PetscObject)adapt)->type_name,((PetscObject)ts)->type_name,scheme,sc_name,ts->steps,*accept ? "accepted" : "rejected",(double)ts->ptime,(double)h,(double)*next_h);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(adapt->monitor," TSAdapt %s %s %D:%s step %3D %s t=%-11g+%10.3e dt=%-10.3e wlte=%5.3g wltea=%5.3g wlter=%5.3g\n",((PetscObject)adapt)->type_name,((PetscObject)ts)->type_name,scheme,sc_name,ts->steps,*accept ? "accepted" : "rejected",(double)ts->ptime,(double)h,(double)*next_h,(double)wlte,(double)wltea,(double)wlter);CHKERRQ(ierr); } ierr = PetscViewerASCIISubtractTab(adapt->monitor,((PetscObject)adapt)->tablevel);CHKERRQ(ierr); } PetscFunctionReturn(0); }
/*@C TSAdaptChoose - choose which method and step size to use for the next step Logically Collective Input Arguments: + adapt - adaptive contoller - h - current step size Output Arguments: + next_sc - optional, scheme to use for the next step . next_h - step size to use for the next step - accept - PETSC_TRUE to accept the current step, PETSC_FALSE to repeat the current step with the new step size Note: The input value of parameter accept is retained from the last time step, so it will be PETSC_FALSE if the step is being retried after an initial rejection. Level: developer .seealso: TSAdapt, TSAdaptCandidatesClear(), TSAdaptCandidateAdd() @*/ PetscErrorCode TSAdaptChoose(TSAdapt adapt,TS ts,PetscReal h,PetscInt *next_sc,PetscReal *next_h,PetscBool *accept) { PetscErrorCode ierr; PetscInt ncandidates = adapt->candidates.n; PetscInt scheme = 0; PetscReal wlte = -1.0; PetscReal wltea = -1.0; PetscReal wlter = -1.0; PetscFunctionBegin; PetscValidHeaderSpecific(adapt,TSADAPT_CLASSID,1); PetscValidHeaderSpecific(ts,TS_CLASSID,2); if (next_sc) PetscValidIntPointer(next_sc,4); PetscValidPointer(next_h,5); PetscValidIntPointer(accept,6); if (next_sc) *next_sc = 0; /* Do not mess with adaptivity while handling events*/ if (ts->event && ts->event->status != TSEVENT_NONE) { *next_h = h; *accept = PETSC_TRUE; PetscFunctionReturn(0); } ierr = (*adapt->ops->choose)(adapt,ts,h,&scheme,next_h,accept,&wlte,&wltea,&wlter);CHKERRQ(ierr); if (scheme < 0 || (ncandidates > 0 && scheme >= ncandidates)) SETERRQ2(PetscObjectComm((PetscObject)adapt),PETSC_ERR_ARG_OUTOFRANGE,"Chosen scheme %D not in valid range 0..%D",scheme,ncandidates-1); if (*next_h < 0) SETERRQ1(PetscObjectComm((PetscObject)adapt),PETSC_ERR_ARG_OUTOFRANGE,"Computed step size %g must be positive",(double)*next_h); if (next_sc) *next_sc = scheme; if (*accept && ts->exact_final_time == TS_EXACTFINALTIME_MATCHSTEP) { /* Reduce time step if it overshoots max time */ if (ts->ptime + ts->time_step + *next_h >= ts->max_time) { PetscReal next_dt = ts->max_time - (ts->ptime + ts->time_step); if (next_dt > PETSC_SMALL) *next_h = next_dt; else ts->reason = TS_CONVERGED_TIME; } } if (adapt->monitor) { const char *sc_name = (scheme < ncandidates) ? adapt->candidates.name[scheme] : ""; ierr = PetscViewerASCIIAddTab(adapt->monitor,((PetscObject)adapt)->tablevel);CHKERRQ(ierr); if (wlte < 0) { ierr = PetscViewerASCIIPrintf(adapt->monitor," TSAdapt '%s': step %3D %s t=%-11g+%10.3e family='%s' scheme=%D:'%s' dt=%-10.3e\n",((PetscObject)adapt)->type_name,ts->steps,*accept ? "accepted" : "rejected",(double)ts->ptime,(double)h,((PetscObject)ts)->type_name,scheme,sc_name,(double)*next_h);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(adapt->monitor," TSAdapt '%s': step %3D %s t=%-11g+%10.3e wlte=%5.3g family='%s' scheme=%D:'%s' dt=%-10.3e\n",((PetscObject)adapt)->type_name,ts->steps,*accept ? "accepted" : "rejected",(double)ts->ptime,(double)h,(double)wlte,((PetscObject)ts)->type_name,scheme,sc_name,(double)*next_h);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(adapt->monitor," wlte=%5.3g wltea=%5.3g wlter=%5.3g \n",(double)wlte,(double)wltea,(double)wlter);CHKERRQ(ierr); } ierr = PetscViewerASCIISubtractTab(adapt->monitor,((PetscObject)adapt)->tablevel);CHKERRQ(ierr); } PetscFunctionReturn(0); }
/*@ ISStrideGetInfo - Returns the first index in a stride index set and the stride width. Not Collective Input Parameter: . is - the index set Output Parameters: . first - the first index . step - the stride width Level: intermediate Notes: Returns info on stride index set. This is a pseudo-public function that should not be needed by most users. Concepts: index sets^getting information Concepts: IS^getting information .seealso: ISCreateStride(), ISGetSize() @*/ PetscErrorCode ISStrideGetInfo(IS is,PetscInt *first,PetscInt *step) { IS_Stride *sub; PetscFunctionBegin; PetscValidHeaderSpecific(is,IS_CLASSID,1); if (first) PetscValidIntPointer(first,2); if (step) PetscValidIntPointer(step,3); sub = (IS_Stride*)is->data; if (first) *first = sub->first; if (step) *step = sub->step; PetscFunctionReturn(0); }
PetscErrorCode TSGLLEAdaptChoose(TSGLLEAdapt adapt,PetscInt n,const PetscInt orders[],const PetscReal errors[],const PetscReal cost[],PetscInt cur,PetscReal h,PetscReal tleft,PetscInt *next_sc,PetscReal *next_h,PetscBool *finish) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(adapt,TSGLLEADAPT_CLASSID,1); PetscValidIntPointer(orders,3); PetscValidPointer(errors,4); PetscValidPointer(cost,5); PetscValidIntPointer(next_sc,9); PetscValidPointer(next_h,10); PetscValidIntPointer(finish,11); ierr = (*adapt->ops->choose)(adapt,n,orders,errors,cost,cur,h,tleft,next_sc,next_h,finish);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode DMInterpolationGetDof(DMInterpolationInfo ctx, PetscInt *dof) { PetscFunctionBegin; PetscValidIntPointer(dof, 2); *dof = ctx->dof; PetscFunctionReturn(0); }
PetscErrorCode DMInterpolationGetDim(DMInterpolationInfo ctx, PetscInt *dim) { PetscFunctionBegin; PetscValidIntPointer(dim, 2); *dim = ctx->dim; PetscFunctionReturn(0); }
/*@ ISEqual - Compares if two index sets have the same set of indices. Collective on IS Input Parameters: . is1, is2 - The index sets being compared Output Parameters: . flg - output flag, either PETSC_TRUE (if both index sets have the same indices), or PETSC_FALSE if the index sets differ by size or by the set of indices) Level: intermediate Note: This routine sorts the contents of the index sets before the comparision is made, so the order of the indices on a processor is immaterial. Each processor has to have the same indices in the two sets, for example, $ Processor $ 0 1 $ is1 = {0, 1} {2, 3} $ is2 = {2, 3} {0, 1} will return false. Concepts: index sets^equal Concepts: IS^equal @*/ PetscErrorCode PETSCVEC_DLLEXPORT ISEqual(IS is1,IS is2,PetscTruth *flg) { PetscInt sz1,sz2,*a1,*a2; const PetscInt *ptr1,*ptr2; PetscTruth flag; MPI_Comm comm; PetscErrorCode ierr; PetscMPIInt mflg; PetscFunctionBegin; PetscValidHeaderSpecific(is1,IS_COOKIE,1); PetscValidHeaderSpecific(is2,IS_COOKIE,2); PetscValidIntPointer(flg,3); if (is1 == is2) { *flg = PETSC_TRUE; PetscFunctionReturn(0); } ierr = MPI_Comm_compare(((PetscObject)is1)->comm,((PetscObject)is2)->comm,&mflg);CHKERRQ(ierr); if (mflg != MPI_CONGRUENT && mflg != MPI_IDENT) { *flg = PETSC_FALSE; PetscFunctionReturn(0); } ierr = ISGetSize(is1,&sz1);CHKERRQ(ierr); ierr = ISGetSize(is2,&sz2);CHKERRQ(ierr); if (sz1 != sz2) { *flg = PETSC_FALSE; } else { ierr = ISGetLocalSize(is1,&sz1);CHKERRQ(ierr); ierr = ISGetLocalSize(is2,&sz2);CHKERRQ(ierr); if (sz1 != sz2) { flag = PETSC_FALSE; } else { ierr = ISGetIndices(is1,&ptr1);CHKERRQ(ierr); ierr = ISGetIndices(is2,&ptr2);CHKERRQ(ierr); ierr = PetscMalloc(sz1*sizeof(PetscInt),&a1);CHKERRQ(ierr); ierr = PetscMalloc(sz2*sizeof(PetscInt),&a2);CHKERRQ(ierr); ierr = PetscMemcpy(a1,ptr1,sz1*sizeof(PetscInt));CHKERRQ(ierr); ierr = PetscMemcpy(a2,ptr2,sz2*sizeof(PetscInt));CHKERRQ(ierr); ierr = PetscSortInt(sz1,a1);CHKERRQ(ierr); ierr = PetscSortInt(sz2,a2);CHKERRQ(ierr); ierr = PetscMemcmp(a1,a2,sz1*sizeof(PetscInt),&flag);CHKERRQ(ierr); ierr = ISRestoreIndices(is1,&ptr1);CHKERRQ(ierr); ierr = ISRestoreIndices(is2,&ptr2);CHKERRQ(ierr); ierr = PetscFree(a1);CHKERRQ(ierr); ierr = PetscFree(a2);CHKERRQ(ierr); } ierr = PetscObjectGetComm((PetscObject)is1,&comm);CHKERRQ(ierr); ierr = MPI_Allreduce(&flag,flg,1,MPI_INT,MPI_MIN,comm);CHKERRQ(ierr); } PetscFunctionReturn(0); }
PetscErrorCode ISGeneralSetIndices_General(IS is,PetscInt n,const PetscInt idx[],PetscCopyMode mode) { PetscErrorCode ierr; IS_General *sub = (IS_General*)is->data; PetscFunctionBegin; if (n < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"length < 0"); if (n) PetscValidIntPointer(idx,3); if (sub->allocated) {ierr = PetscFree(sub->idx);CHKERRQ(ierr);} ierr = PetscLayoutSetLocalSize(is->map, n);CHKERRQ(ierr); if (mode == PETSC_COPY_VALUES) { ierr = PetscMalloc1(n,&sub->idx);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)is,n*sizeof(PetscInt));CHKERRQ(ierr); ierr = PetscMemcpy(sub->idx,idx,n*sizeof(PetscInt));CHKERRQ(ierr); sub->allocated = PETSC_TRUE; } else if (mode == PETSC_OWN_POINTER) { sub->idx = (PetscInt*)idx; sub->allocated = PETSC_TRUE; } else { sub->idx = (PetscInt*)idx; sub->allocated = PETSC_FALSE; } ierr = ISCreateGeneral_Private(is);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C ISLocalToGlobalMappingCreateNC - Creates a mapping between a local (0 to n) ordering and a global parallel ordering. Not Collective, but communicator may have more than one process Input Parameters: + comm - MPI communicator . n - the number of local elements - indices - the global index for each local element Output Parameter: . mapping - new mapping data structure Level: developer Notes: Does not copy the indices, just keeps the pointer to the indices. The ISLocalToGlobalMappingDestroy() will free the space so it must be obtained with PetscMalloc() and it must not be freed elsewhere. Concepts: mapping^local to global .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS(), ISLocalToGlobalMappingCreate() @*/ PetscErrorCode PETSCVEC_DLLEXPORT ISLocalToGlobalMappingCreateNC(MPI_Comm cm,PetscInt n,const PetscInt indices[],ISLocalToGlobalMapping *mapping) { PetscErrorCode ierr; PetscFunctionBegin; if (n) PetscValidIntPointer(indices,3); PetscValidPointer(mapping,4); *mapping = PETSC_NULL; #ifndef PETSC_USE_DYNAMIC_LIBRARIES ierr = ISInitializePackage(PETSC_NULL);CHKERRQ(ierr); #endif ierr = PetscHeaderCreate(*mapping,_p_ISLocalToGlobalMapping,int,IS_LTOGM_COOKIE,0,"ISLocalToGlobalMapping", cm,ISLocalToGlobalMappingDestroy,ISLocalToGlobalMappingView);CHKERRQ(ierr); (*mapping)->n = n; (*mapping)->indices = (PetscInt*)indices; ierr = PetscLogObjectMemory(*mapping,n*sizeof(PetscInt));CHKERRQ(ierr); /* Do not create the global to local mapping. This is only created if ISGlobalToLocalMapping() is called */ (*mapping)->globals = 0; PetscFunctionReturn(0); }
/*@ PetscCommGetNewTag - Gets a unique new tag from a PETSc communicator. All processors that share the communicator MUST call this routine EXACTLY the same number of times. This tag should only be used with the current objects communicator; do NOT use it with any other MPI communicator. Collective on comm Input Parameter: . comm - the MPI communicator Output Parameter: . tag - the new tag Level: developer Concepts: tag^getting Concepts: message tag^getting Concepts: MPI message tag^getting .seealso: PetscObjectGetNewTag(), PetscCommDuplicate() @*/ PetscErrorCode PetscCommGetNewTag(MPI_Comm comm,PetscMPIInt *tag) { PetscErrorCode ierr; PetscCommCounter *counter; PetscMPIInt *maxval,flg; PetscFunctionBegin; PetscValidIntPointer(tag,2); ierr = MPI_Attr_get(comm,Petsc_Counter_keyval,&counter,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_CORRUPT,"Bad MPI communicator supplied; must be a PETSc communicator"); if (counter->tag < 1) { ierr = PetscInfo1(0,"Out of tags for object, starting to recycle. Comm reference count %d\n",counter->refcount);CHKERRQ(ierr); ierr = MPI_Attr_get(MPI_COMM_WORLD,MPI_TAG_UB,&maxval,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"MPI error: MPI_Attr_get() is not returning a MPI_TAG_UB"); counter->tag = *maxval - 128; /* hope that any still active tags were issued right at the beginning of the run */ } *tag = counter->tag--; #if defined(PETSC_USE_DEBUG) /* Hanging here means that some processes have called PetscCommGetNewTag() and others have not. */ ierr = MPI_Barrier(comm);CHKERRQ(ierr); #endif PetscFunctionReturn(0); }
/*@C EventPerfLogGetVisible - This function returns whether an event is printed during PetscLogPrintSummary() Not Collective Input Parameters: + eventLog - The EventPerfLog - event - The event id to log Output Parameter: . isVisible - The visibility flag, PETSC_TRUE for printing, otherwise PETSC_FALSE (default is PETSC_TRUE) Database Options: . -log_summary - Activates log summary Level: intermediate .keywords: log, visible, event .seealso: EventPerfLogSetVisible(), EventRegLogRegister(), StageLogGetEventLog() @*/ PetscErrorCode EventPerfLogGetVisible(EventPerfLog eventLog, PetscLogEvent event, PetscTruth *isVisible) { PetscFunctionBegin; PetscValidIntPointer(isVisible,3); *isVisible = eventLog->eventInfo[event].visible; PetscFunctionReturn(0); }
/*@ ISContiguousLocal - Locates an index set with contiguous range within a global range, if possible Not Collective Input Parmeters: + is - the index set . gstart - global start . gend - global end Output Parameters: + start - start of contiguous block, as an offset from gstart - contig - PETSC_TRUE if the index set refers to contiguous entries on this process, else PETSC_FALSE Level: developer Concepts: index sets^is contiguous .seealso: ISGetLocalSize(), VecGetOwnershipRange() @*/ PetscErrorCode ISContiguousLocal(IS is,PetscInt gstart,PetscInt gend,PetscInt *start,PetscBool *contig) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(is,IS_CLASSID,1); PetscValidIntPointer(start,5); PetscValidIntPointer(contig,5); if (is->ops->contiguous) { ierr = (*is->ops->contiguous)(is,gstart,gend,start,contig);CHKERRQ(ierr); } else { *start = -1; *contig = PETSC_FALSE; } PetscFunctionReturn(0); }
/*@ EPSGetIterationNumber - Gets the current iteration number. If the call to EPSSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . its - number of iterations Level: intermediate Note: During the i-th iteration this call returns i-1. If EPSSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call EPSGetConvergedReason() to determine if the solver converged or failed and why. .seealso: EPSGetConvergedReason(), EPSSetTolerances() @*/ PetscErrorCode EPSGetIterationNumber(EPS eps,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(its,2); *its = eps->its; PetscFunctionReturn(0); }
/*@ SVDGetConverged - Gets the number of converged singular values. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . nconv - number of converged singular values Note: This function should be called after SVDSolve() has finished. Level: beginner @*/ PetscErrorCode SVDGetConverged(SVD svd,PetscInt *nconv) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidIntPointer(nconv,2); *nconv = svd->nconv; PetscFunctionReturn(0); }
/*@C SVDGetConvergedReason - Gets the reason why the SVDSolve() iteration was stopped. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . reason - negative value indicates diverged, positive value converged (see SVDConvergedReason) Possible values for reason: + SVD_CONVERGED_TOL - converged up to tolerance . SVD_DIVERGED_ITS - required more than its to reach convergence - SVD_DIVERGED_BREAKDOWN - generic breakdown in method Level: intermediate Notes: Can only be called after the call to SVDSolve() is complete. .seealso: SVDSetTolerances(), SVDSolve(), SVDConvergedReason @*/ PetscErrorCode SVDGetConvergedReason(SVD svd,SVDConvergedReason *reason) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidIntPointer(reason,2); *reason = svd->reason; PetscFunctionReturn(0); }
/*@ SVDGetIterationNumber - Gets the current iteration number. If the call to SVDSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . its - number of iterations Level: intermediate Notes: During the i-th iteration this call returns i-1. If SVDSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call SVDGetConvergedReason() to determine if the solver converged or failed and why. @*/ PetscErrorCode SVDGetIterationNumber(SVD svd,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidIntPointer(its,2); *its = svd->its; PetscFunctionReturn(0); }
/*@ PetscDrawLGGetDimension - Change the number of lines that are to be drawn. Not Collective Input Parameter: . lg - the line graph context. Output Parameter: . dim - the number of curves. Level: intermediate Concepts: line graph^setting number of lines .seealso: PetscDrawLGCreate(), PetscDrawLGSetDimension() @*/ PetscErrorCode PetscDrawLGGetDimension(PetscDrawLG lg,PetscInt *dim) { PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1); PetscValidIntPointer(dim,2); *dim = lg->dim; PetscFunctionReturn(0); }
/*@ PEPGetIterationNumber - Gets the current iteration number. If the call to PEPSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameter: . its - number of iterations Level: intermediate Note: During the i-th iteration this call returns i-1. If PEPSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call PEPGetConvergedReason() to determine if the solver converged or failed and why. .seealso: PEPGetConvergedReason(), PEPSetTolerances() @*/ PetscErrorCode PEPGetIterationNumber(PEP pep,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidIntPointer(its,2); *its = pep->its; PetscFunctionReturn(0); }
/*@ ISPermutation - PETSC_TRUE or PETSC_FALSE depending on whether the index set has been declared to be a permutation. Logically Collective on IS Input Parmeters: . is - the index set Output Parameters: . perm - PETSC_TRUE if a permutation, else PETSC_FALSE Level: intermediate Concepts: permutation Concepts: index sets^is permutation .seealso: ISSetPermutation() @*/ PetscErrorCode ISPermutation(IS is,PetscBool *perm) { PetscFunctionBegin; PetscValidHeaderSpecific(is,IS_CLASSID,1); PetscValidIntPointer(perm,2); *perm = (PetscBool) is->isperm; PetscFunctionReturn(0); }
/*@ KSPGetTotalIterations - Gets the total number of iterations this KSP object has performed since was created, counted over all linear solves Not Collective Input Parameters: . ksp - the iterative context Output Parameters: . its - total number of iterations Level: intermediate Notes: Use KSPGetIterationNumber() to get the count for the most recent solve only If this is called within a linear solve (such as in a KSPMonitor routine) then it does not include iterations within that current solve .keywords: KSP, get, residual norm .seealso: KSPBuildResidual(), KSPGetResidualNorm(), KSPGetIterationNumber() @*/ PetscErrorCode KSPGetTotalIterations(KSP ksp,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(ksp,KSP_CLASSID,1); PetscValidIntPointer(its,2); *its = ksp->totalits; PetscFunctionReturn(0); }
/*@C PetscObjectStateGet - Gets the state of any PetscObject, regardless of the type. Not Collective Input Parameter: . obj - any PETSc object, for example a Vec, Mat or KSP. This must be cast with a (PetscObject), for example, PetscObjectStateGet((PetscObject)mat,&state); Output Parameter: . state - the object state Notes: object state is an integer which gets increased every time the object is changed. By saving and later querying the object state one can determine whether information about the object is still current. Currently, state is maintained for Vec and Mat objects. Level: advanced seealso: PetscObjectStateIncrease(), PetscObjectStateSet() Concepts: state @*/ PetscErrorCode PetscObjectStateGet(PetscObject obj,PetscObjectState *state) { PetscFunctionBegin; PetscValidHeader(obj,1); PetscValidIntPointer(state,2); *state = obj->state; PetscFunctionReturn(0); }
/*@C PetscObjectGetReference - Gets the current reference count for any PETSc object. Not Collective Input Parameter: . obj - the PETSc object; this must be cast with (PetscObject), for example, PetscObjectGetReference((PetscObject)mat,&cnt); Output Parameter: . cnt - the reference count Level: advanced .seealso: PetscObjectCompose(), PetscObjectDereference(), PetscObjectReference() @*/ PetscErrorCode PetscObjectGetReference(PetscObject obj,PetscInt *cnt) { PetscFunctionBegin; PetscValidHeader(obj,1); PetscValidIntPointer(cnt,2); *cnt = obj->refct; PetscFunctionReturn(0); }
/*@C MFNGetConvergedReason - Gets the reason why the MFNSolve() iteration was stopped. Not Collective Input Parameter: . mfn - the matrix function context Output Parameter: . reason - negative value indicates diverged, positive value converged Possible values for reason: + MFN_CONVERGED_TOL - converged up to tolerance . MFN_DIVERGED_ITS - required more than its to reach convergence - MFN_DIVERGED_BREAKDOWN - generic breakdown in method Note: Can only be called after the call to MFNSolve() is complete. Level: intermediate .seealso: MFNSetTolerances(), MFNSolve(), MFNConvergedReason, MFNSetErrorIfNotConverged() @*/ PetscErrorCode MFNGetConvergedReason(MFN mfn,MFNConvergedReason *reason) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidIntPointer(reason,2); *reason = mfn->reason; PetscFunctionReturn(0); }
/*@ MFNGetIterationNumber - Gets the current iteration number. If the call to MFNSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . mfn - the matrix function context Output Parameter: . its - number of iterations Level: intermediate Note: During the i-th iteration this call returns i-1. If MFNSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call MFNGetConvergedReason() to determine if the solver converged or failed and why. .seealso: MFNGetConvergedReason(), MFNSetTolerances() @*/ PetscErrorCode MFNGetIterationNumber(MFN mfn,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidIntPointer(its,2); *its = mfn->its; PetscFunctionReturn(0); }
/*@C ISLocalToGlobalMappingGetSize - Gets the local size of a local to global mapping. Not Collective Input Parameter: . ltog - local to global mapping Output Parameter: . n - the number of entries in the local mapping Level: advanced Concepts: mapping^local to global .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreate() @*/ PetscErrorCode PETSCVEC_DLLEXPORT ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping mapping,PetscInt *n) { PetscFunctionBegin; PetscValidHeaderSpecific(mapping,IS_LTOGM_COOKIE,1); PetscValidIntPointer(n,2); *n = mapping->n; PetscFunctionReturn(0); }
/*@ PEPGetConverged - Gets the number of converged eigenpairs. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameter: . nconv - number of converged eigenpairs Note: This function should be called after PEPSolve() has finished. Level: beginner .seealso: PEPSetDimensions(), PEPSolve() @*/ PetscErrorCode PEPGetConverged(PEP pep,PetscInt *nconv) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidIntPointer(nconv,2); PEPCheckSolved(pep,1); *nconv = pep->nconv; PetscFunctionReturn(0); }
/*@ EPSGetConverged - Gets the number of converged eigenpairs. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . nconv - number of converged eigenpairs Note: This function should be called after EPSSolve() has finished. Level: beginner .seealso: EPSSetDimensions(), EPSSolve() @*/ PetscErrorCode EPSGetConverged(EPS eps,PetscInt *nconv) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(nconv,2); EPSCheckSolved(eps,1); *nconv = eps->nconv; PetscFunctionReturn(0); }
/*@C EPSGetConvergedReason - Gets the reason why the EPSSolve() iteration was stopped. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . reason - negative value indicates diverged, positive value converged Possible values for reason: + EPS_CONVERGED_TOL - converged up to tolerance . EPS_DIVERGED_ITS - required more than its to reach convergence - EPS_DIVERGED_BREAKDOWN - generic breakdown in method Note: Can only be called after the call to EPSSolve() is complete. Level: intermediate .seealso: EPSSetTolerances(), EPSSolve(), EPSConvergedReason @*/ PetscErrorCode EPSGetConvergedReason(EPS eps,EPSConvergedReason *reason) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(reason,2); EPSCheckSolved(eps,1); *reason = eps->reason; PetscFunctionReturn(0); }
/*@ ISStrideGetInfo - Returns the first index in a stride index set and the stride width. Not Collective Input Parameter: . is - the index set Output Parameters: . first - the first index . step - the stride width Level: intermediate Notes: Returns info on stride index set. This is a pseudo-public function that should not be needed by most users. Concepts: index sets^getting information Concepts: IS^getting information .seealso: ISCreateStride(), ISGetSize() @*/ PetscErrorCode ISStrideGetInfo(IS is,PetscInt *first,PetscInt *step) { IS_Stride *sub; PetscBool flg; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(is,IS_CLASSID,1); if (first) PetscValidIntPointer(first,2); if (step) PetscValidIntPointer(step,3); ierr = PetscObjectTypeCompare((PetscObject)is,ISSTRIDE,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)is),PETSC_ERR_ARG_WRONG,"IS must be of type ISSTRIDE"); sub = (IS_Stride*)is->data; if (first) *first = sub->first; if (step) *step = sub->step; PetscFunctionReturn(0); }