Actual source code: nepopts.c

slepc-3.14.1 2020-12-08
Report Typos and Errors
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2020, Universitat Politecnica de Valencia, Spain

  6:    This file is part of SLEPc.
  7:    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
  8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9: */
 10: /*
 11:    NEP routines related to options that can be set via the command-line
 12:    or procedurally
 13: */

 15: #include <slepc/private/nepimpl.h>
 16: #include <petscdraw.h>

 18: /*@C
 19:    NEPMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 20:    indicated by the user.

 22:    Collective on nep

 24:    Input Parameters:
 25: +  nep      - the nonlinear eigensolver context
 26: .  name     - the monitor option name
 27: .  help     - message indicating what monitoring is done
 28: .  manual   - manual page for the monitor
 29: .  monitor  - the monitor function, whose context is a PetscViewerAndFormat
 30: -  trackall - whether this monitor tracks all eigenvalues or not

 32:    Level: developer

 34: .seealso: NEPMonitorSet(), NEPSetTrackAll(), NEPConvMonitorSetFromOptions()
 35: @*/
 36: PetscErrorCode NEPMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
 37: {
 38:   PetscErrorCode       ierr;
 39:   PetscBool            flg;
 40:   PetscViewer          viewer;
 41:   PetscViewerFormat    format;
 42:   PetscViewerAndFormat *vf;

 45:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->options,((PetscObject)nep)->prefix,name,&viewer,&format,&flg);
 46:   if (flg) {
 47:     PetscViewerAndFormatCreate(viewer,format,&vf);
 48:     PetscObjectDereference((PetscObject)viewer);
 49:     NEPMonitorSet(nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);
 50:     if (trackall) {
 51:       NEPSetTrackAll(nep,PETSC_TRUE);
 52:     }
 53:   }
 54:   return(0);
 55: }

 57: /*@C
 58:    NEPConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 59:    indicated by the user (for monitors that only show iteration numbers of convergence).

 61:    Collective on nep

 63:    Input Parameters:
 64: +  nep      - the nonlinear eigensolver context
 65: .  name     - the monitor option name
 66: .  help     - message indicating what monitoring is done
 67: .  manual   - manual page for the monitor
 68: -  monitor  - the monitor function, whose context is a SlepcConvMonitor

 70:    Level: developer

 72: .seealso: NEPMonitorSet(), NEPMonitorSetFromOptions()
 73: @*/
 74: PetscErrorCode NEPConvMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))
 75: {
 76:   PetscErrorCode    ierr;
 77:   PetscBool         flg;
 78:   PetscViewer       viewer;
 79:   PetscViewerFormat format;
 80:   SlepcConvMonitor  ctx;

 83:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->options,((PetscObject)nep)->prefix,name,&viewer,&format,&flg);
 84:   if (flg) {
 85:     SlepcConvMonitorCreate(viewer,format,&ctx);
 86:     PetscObjectDereference((PetscObject)viewer);
 87:     NEPMonitorSet(nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);
 88:   }
 89:   return(0);
 90: }

 92: /*@
 93:    NEPSetFromOptions - Sets NEP options from the options database.
 94:    This routine must be called before NEPSetUp() if the user is to be
 95:    allowed to set the solver type.

 97:    Collective on nep

 99:    Input Parameters:
100: .  nep - the nonlinear eigensolver context

102:    Notes:
103:    To see all options, run your program with the -help option.

105:    Level: beginner
106: @*/
107: PetscErrorCode NEPSetFromOptions(NEP nep)
108: {
109:   PetscErrorCode  ierr;
110:   char            type[256];
111:   PetscBool       set,flg,flg1,flg2,flg3,flg4,flg5,bval;
112:   PetscReal       r;
113:   PetscScalar     s;
114:   PetscInt        i,j,k;
115:   PetscDrawLG     lg;
116:   NEPRefine       refine;
117:   NEPRefineScheme scheme;

121:   NEPRegisterAll();
122:   PetscObjectOptionsBegin((PetscObject)nep);
123:     PetscOptionsFList("-nep_type","Nonlinear eigensolver method","NEPSetType",NEPList,(char*)(((PetscObject)nep)->type_name?((PetscObject)nep)->type_name:NEPRII),type,sizeof(type),&flg);
124:     if (flg) {
125:       NEPSetType(nep,type);
126:     } else if (!((PetscObject)nep)->type_name) {
127:       NEPSetType(nep,NEPRII);
128:     }

130:     PetscOptionsBoolGroupBegin("-nep_general","General nonlinear eigenvalue problem","NEPSetProblemType",&flg);
131:     if (flg) { NEPSetProblemType(nep,NEP_GENERAL); }
132:     PetscOptionsBoolGroupEnd("-nep_rational","Rational eigenvalue problem","NEPSetProblemType",&flg);
133:     if (flg) { NEPSetProblemType(nep,NEP_RATIONAL); }

135:     refine = nep->refine;
136:     PetscOptionsEnum("-nep_refine","Iterative refinement method","NEPSetRefine",NEPRefineTypes,(PetscEnum)refine,(PetscEnum*)&refine,&flg1);
137:     i = nep->npart;
138:     PetscOptionsInt("-nep_refine_partitions","Number of partitions of the communicator for iterative refinement","NEPSetRefine",nep->npart,&i,&flg2);
139:     r = nep->rtol;
140:     PetscOptionsReal("-nep_refine_tol","Tolerance for iterative refinement","NEPSetRefine",nep->rtol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/1000:nep->rtol,&r,&flg3);
141:     j = nep->rits;
142:     PetscOptionsInt("-nep_refine_its","Maximum number of iterations for iterative refinement","NEPSetRefine",nep->rits,&j,&flg4);
143:     scheme = nep->scheme;
144:     PetscOptionsEnum("-nep_refine_scheme","Scheme used for linear systems within iterative refinement","NEPSetRefine",NEPRefineSchemes,(PetscEnum)scheme,(PetscEnum*)&scheme,&flg5);
145:     if (flg1 || flg2 || flg3 || flg4 || flg5) { NEPSetRefine(nep,refine,i,r,j,scheme); }

147:     i = nep->max_it;
148:     PetscOptionsInt("-nep_max_it","Maximum number of iterations","NEPSetTolerances",nep->max_it,&i,&flg1);
149:     r = nep->tol;
150:     PetscOptionsReal("-nep_tol","Tolerance","NEPSetTolerances",nep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:nep->tol,&r,&flg2);
151:     if (flg1 || flg2) { NEPSetTolerances(nep,r,i); }

153:     PetscOptionsBoolGroupBegin("-nep_conv_rel","Relative error convergence test","NEPSetConvergenceTest",&flg);
154:     if (flg) { NEPSetConvergenceTest(nep,NEP_CONV_REL); }
155:     PetscOptionsBoolGroup("-nep_conv_norm","Convergence test relative to the matrix norms","NEPSetConvergenceTest",&flg);
156:     if (flg) { NEPSetConvergenceTest(nep,NEP_CONV_NORM); }
157:     PetscOptionsBoolGroup("-nep_conv_abs","Absolute error convergence test","NEPSetConvergenceTest",&flg);
158:     if (flg) { NEPSetConvergenceTest(nep,NEP_CONV_ABS); }
159:     PetscOptionsBoolGroupEnd("-nep_conv_user","User-defined convergence test","NEPSetConvergenceTest",&flg);
160:     if (flg) { NEPSetConvergenceTest(nep,NEP_CONV_USER); }

162:     PetscOptionsBoolGroupBegin("-nep_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","NEPSetStoppingTest",&flg);
163:     if (flg) { NEPSetStoppingTest(nep,NEP_STOP_BASIC); }
164:     PetscOptionsBoolGroupEnd("-nep_stop_user","User-defined stopping test","NEPSetStoppingTest",&flg);
165:     if (flg) { NEPSetStoppingTest(nep,NEP_STOP_USER); }

167:     i = nep->nev;
168:     PetscOptionsInt("-nep_nev","Number of eigenvalues to compute","NEPSetDimensions",nep->nev,&i,&flg1);
169:     j = nep->ncv;
170:     PetscOptionsInt("-nep_ncv","Number of basis vectors","NEPSetDimensions",nep->ncv,&j,&flg2);
171:     k = nep->mpd;
172:     PetscOptionsInt("-nep_mpd","Maximum dimension of projected problem","NEPSetDimensions",nep->mpd,&k,&flg3);
173:     if (flg1 || flg2 || flg3) {
174:       NEPSetDimensions(nep,i,j,k);
175:     }

177:     PetscOptionsBoolGroupBegin("-nep_largest_magnitude","Compute largest eigenvalues in magnitude","NEPSetWhichEigenpairs",&flg);
178:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_LARGEST_MAGNITUDE); }
179:     PetscOptionsBoolGroup("-nep_smallest_magnitude","Compute smallest eigenvalues in magnitude","NEPSetWhichEigenpairs",&flg);
180:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_SMALLEST_MAGNITUDE); }
181:     PetscOptionsBoolGroup("-nep_largest_real","Compute eigenvalues with largest real parts","NEPSetWhichEigenpairs",&flg);
182:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_LARGEST_REAL); }
183:     PetscOptionsBoolGroup("-nep_smallest_real","Compute eigenvalues with smallest real parts","NEPSetWhichEigenpairs",&flg);
184:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_SMALLEST_REAL); }
185:     PetscOptionsBoolGroup("-nep_largest_imaginary","Compute eigenvalues with largest imaginary parts","NEPSetWhichEigenpairs",&flg);
186:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_LARGEST_IMAGINARY); }
187:     PetscOptionsBoolGroup("-nep_smallest_imaginary","Compute eigenvalues with smallest imaginary parts","NEPSetWhichEigenpairs",&flg);
188:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_SMALLEST_IMAGINARY); }
189:     PetscOptionsBoolGroup("-nep_target_magnitude","Compute eigenvalues closest to target","NEPSetWhichEigenpairs",&flg);
190:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_TARGET_MAGNITUDE); }
191:     PetscOptionsBoolGroup("-nep_target_real","Compute eigenvalues with real parts closest to target","NEPSetWhichEigenpairs",&flg);
192:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_TARGET_REAL); }
193:     PetscOptionsBoolGroup("-nep_target_imaginary","Compute eigenvalues with imaginary parts closest to target","NEPSetWhichEigenpairs",&flg);
194:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_TARGET_IMAGINARY); }
195:     PetscOptionsBoolGroupEnd("-nep_all","Compute all eigenvalues in a region","NEPSetWhichEigenpairs",&flg);
196:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_ALL); }

198:     PetscOptionsScalar("-nep_target","Value of the target","NEPSetTarget",nep->target,&s,&flg);
199:     if (flg) {
200:       if (nep->which!=NEP_TARGET_REAL && nep->which!=NEP_TARGET_IMAGINARY) {
201:         NEPSetWhichEigenpairs(nep,NEP_TARGET_MAGNITUDE);
202:       }
203:       NEPSetTarget(nep,s);
204:     }

206:     PetscOptionsBool("-nep_two_sided","Use two-sided variant (to compute left eigenvectors)","NEPSetTwoSided",nep->twosided,&bval,&flg);
207:     if (flg) { NEPSetTwoSided(nep,bval); }

209:     /* -----------------------------------------------------------------------*/
210:     /*
211:       Cancels all monitors hardwired into code before call to NEPSetFromOptions()
212:     */
213:     PetscOptionsBool("-nep_monitor_cancel","Remove any hardwired monitor routines","NEPMonitorCancel",PETSC_FALSE,&flg,&set);
214:     if (set && flg) {
215:       NEPMonitorCancel(nep);
216:     }
217:     /*
218:       Text monitors
219:     */
220:     NEPMonitorSetFromOptions(nep,"-nep_monitor","Monitor first unconverged approximate eigenvalue and error estimate","NEPMonitorFirst",NEPMonitorFirst,PETSC_FALSE);
221:     NEPConvMonitorSetFromOptions(nep,"-nep_monitor_conv","Monitor approximate eigenvalues and error estimates as they converge","NEPMonitorConverged",NEPMonitorConverged);
222:     NEPMonitorSetFromOptions(nep,"-nep_monitor_all","Monitor approximate eigenvalues and error estimates","NEPMonitorAll",NEPMonitorAll,PETSC_TRUE);
223:     /*
224:       Line graph monitors
225:     */
226:     PetscOptionsBool("-nep_monitor_lg","Monitor first unconverged approximate error estimate graphically","NEPMonitorSet",PETSC_FALSE,&flg,&set);
227:     if (set && flg) {
228:       NEPMonitorLGCreate(PetscObjectComm((PetscObject)nep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
229:       NEPMonitorSet(nep,NEPMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
230:     }
231:     PetscOptionsBool("-nep_monitor_lg_all","Monitor error estimates graphically","NEPMonitorSet",PETSC_FALSE,&flg,&set);
232:     if (set && flg) {
233:       NEPMonitorLGCreate(PetscObjectComm((PetscObject)nep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
234:       NEPMonitorSet(nep,NEPMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
235:       NEPSetTrackAll(nep,PETSC_TRUE);
236:     }

238:     /* -----------------------------------------------------------------------*/
239:     PetscOptionsName("-nep_view","Print detailed information on solver used","NEPView",NULL);
240:     PetscOptionsName("-nep_view_vectors","View computed eigenvectors","NEPVectorsView",NULL);
241:     PetscOptionsName("-nep_view_values","View computed eigenvalues","NEPValuesView",NULL);
242:     PetscOptionsName("-nep_converged_reason","Print reason for convergence, and number of iterations","NEPConvergedReasonView",NULL);
243:     PetscOptionsName("-nep_error_absolute","Print absolute errors of each eigenpair","NEPErrorView",NULL);
244:     PetscOptionsName("-nep_error_relative","Print relative errors of each eigenpair","NEPErrorView",NULL);

246:     if (nep->ops->setfromoptions) {
247:       (*nep->ops->setfromoptions)(PetscOptionsObject,nep);
248:     }
249:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)nep);
250:   PetscOptionsEnd();

252:   if (!nep->V) { NEPGetBV(nep,&nep->V); }
253:   BVSetFromOptions(nep->V);
254:   if (!nep->rg) { NEPGetRG(nep,&nep->rg); }
255:   RGSetFromOptions(nep->rg);
256:   if (nep->useds) {
257:     if (!nep->ds) { NEPGetDS(nep,&nep->ds); }
258:     DSSetFromOptions(nep->ds);
259:   }
260:   if (!nep->refineksp) { NEPRefineGetKSP(nep,&nep->refineksp); }
261:   KSPSetFromOptions(nep->refineksp);
262:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) for (i=0;i<nep->nt;i++) {FNSetFromOptions(nep->f[i]);}
263:   return(0);
264: }

266: /*@C
267:    NEPGetTolerances - Gets the tolerance and maximum iteration count used
268:    by the NEP convergence tests.

270:    Not Collective

272:    Input Parameter:
273: .  nep - the nonlinear eigensolver context

275:    Output Parameters:
276: +  tol - the convergence tolerance
277: -  maxits - maximum number of iterations

279:    Notes:
280:    The user can specify NULL for any parameter that is not needed.

282:    Level: intermediate

284: .seealso: NEPSetTolerances()
285: @*/
286: PetscErrorCode NEPGetTolerances(NEP nep,PetscReal *tol,PetscInt *maxits)
287: {
290:   if (tol)    *tol    = nep->tol;
291:   if (maxits) *maxits = nep->max_it;
292:   return(0);
293: }

295: /*@
296:    NEPSetTolerances - Sets the tolerance and maximum iteration count used
297:    by the NEP convergence tests.

299:    Logically Collective on nep

301:    Input Parameters:
302: +  nep    - the nonlinear eigensolver context
303: .  tol    - the convergence tolerance
304: -  maxits - maximum number of iterations to use

306:    Options Database Keys:
307: +  -nep_tol <tol> - Sets the convergence tolerance
308: -  -nep_max_it <maxits> - Sets the maximum number of iterations allowed

310:    Notes:
311:    Use PETSC_DEFAULT for either argument to assign a reasonably good value.

313:    Level: intermediate

315: .seealso: NEPGetTolerances()
316: @*/
317: PetscErrorCode NEPSetTolerances(NEP nep,PetscReal tol,PetscInt maxits)
318: {
323:   if (tol == PETSC_DEFAULT) {
324:     nep->tol   = PETSC_DEFAULT;
325:     nep->state = NEP_STATE_INITIAL;
326:   } else {
327:     if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
328:     nep->tol = tol;
329:   }
330:   if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) {
331:     nep->max_it = PETSC_DEFAULT;
332:     nep->state  = NEP_STATE_INITIAL;
333:   } else {
334:     if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
335:     nep->max_it = maxits;
336:   }
337:   return(0);
338: }

340: /*@C
341:    NEPGetDimensions - Gets the number of eigenvalues to compute
342:    and the dimension of the subspace.

344:    Not Collective

346:    Input Parameter:
347: .  nep - the nonlinear eigensolver context

349:    Output Parameters:
350: +  nev - number of eigenvalues to compute
351: .  ncv - the maximum dimension of the subspace to be used by the solver
352: -  mpd - the maximum dimension allowed for the projected problem

354:    Notes:
355:    The user can specify NULL for any parameter that is not needed.

357:    Level: intermediate

359: .seealso: NEPSetDimensions()
360: @*/
361: PetscErrorCode NEPGetDimensions(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
362: {
365:   if (nev) *nev = nep->nev;
366:   if (ncv) *ncv = nep->ncv;
367:   if (mpd) *mpd = nep->mpd;
368:   return(0);
369: }

371: /*@
372:    NEPSetDimensions - Sets the number of eigenvalues to compute
373:    and the dimension of the subspace.

375:    Logically Collective on nep

377:    Input Parameters:
378: +  nep - the nonlinear eigensolver context
379: .  nev - number of eigenvalues to compute
380: .  ncv - the maximum dimension of the subspace to be used by the solver
381: -  mpd - the maximum dimension allowed for the projected problem

383:    Options Database Keys:
384: +  -nep_nev <nev> - Sets the number of eigenvalues
385: .  -nep_ncv <ncv> - Sets the dimension of the subspace
386: -  -nep_mpd <mpd> - Sets the maximum projected dimension

388:    Notes:
389:    Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is
390:    dependent on the solution method.

392:    The parameters ncv and mpd are intimately related, so that the user is advised
393:    to set one of them at most. Normal usage is that
394:    (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and
395:    (b) in cases where nev is large, the user sets mpd.

397:    The value of ncv should always be between nev and (nev+mpd), typically
398:    ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise
399:    a smaller value should be used.

401:    Level: intermediate

403: .seealso: NEPGetDimensions()
404: @*/
405: PetscErrorCode NEPSetDimensions(NEP nep,PetscInt nev,PetscInt ncv,PetscInt mpd)
406: {
412:   if (nev<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0");
413:   nep->nev = nev;
414:   if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) {
415:     nep->ncv = PETSC_DEFAULT;
416:   } else {
417:     if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
418:     nep->ncv = ncv;
419:   }
420:   if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) {
421:     nep->mpd = PETSC_DEFAULT;
422:   } else {
423:     if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0");
424:     nep->mpd = mpd;
425:   }
426:   nep->state = NEP_STATE_INITIAL;
427:   return(0);
428: }

430: /*@
431:     NEPSetWhichEigenpairs - Specifies which portion of the spectrum is
432:     to be sought.

434:     Logically Collective on nep

436:     Input Parameters:
437: +   nep   - eigensolver context obtained from NEPCreate()
438: -   which - the portion of the spectrum to be sought

440:     Possible values:
441:     The parameter 'which' can have one of these values

443: +     NEP_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default)
444: .     NEP_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude
445: .     NEP_LARGEST_REAL - largest real parts
446: .     NEP_SMALLEST_REAL - smallest real parts
447: .     NEP_LARGEST_IMAGINARY - largest imaginary parts
448: .     NEP_SMALLEST_IMAGINARY - smallest imaginary parts
449: .     NEP_TARGET_MAGNITUDE - eigenvalues closest to the target (in magnitude)
450: .     NEP_TARGET_REAL - eigenvalues with real part closest to target
451: .     NEP_TARGET_IMAGINARY - eigenvalues with imaginary part closest to target
452: .     NEP_ALL - all eigenvalues contained in a given region
453: -     NEP_WHICH_USER - user defined ordering set with NEPSetEigenvalueComparison()

455:     Options Database Keys:
456: +   -nep_largest_magnitude - Sets largest eigenvalues in magnitude
457: .   -nep_smallest_magnitude - Sets smallest eigenvalues in magnitude
458: .   -nep_largest_real - Sets largest real parts
459: .   -nep_smallest_real - Sets smallest real parts
460: .   -nep_largest_imaginary - Sets largest imaginary parts
461: .   -nep_smallest_imaginary - Sets smallest imaginary parts
462: .   -nep_target_magnitude - Sets eigenvalues closest to target
463: .   -nep_target_real - Sets real parts closest to target
464: .   -nep_target_imaginary - Sets imaginary parts closest to target
465: -   -nep_all - Sets all eigenvalues in a region

467:     Notes:
468:     Not all eigensolvers implemented in NEP account for all the possible values
469:     stated above. If SLEPc is compiled for real numbers NEP_LARGEST_IMAGINARY
470:     and NEP_SMALLEST_IMAGINARY use the absolute value of the imaginary part
471:     for eigenvalue selection.

473:     The target is a scalar value provided with NEPSetTarget().

475:     Level: intermediate

477: .seealso: NEPGetWhichEigenpairs(), NEPSetTarget(), NEPSetEigenvalueComparison(), NEPWhich
478: @*/
479: PetscErrorCode NEPSetWhichEigenpairs(NEP nep,NEPWhich which)
480: {
484:   switch (which) {
485:     case NEP_LARGEST_MAGNITUDE:
486:     case NEP_SMALLEST_MAGNITUDE:
487:     case NEP_LARGEST_REAL:
488:     case NEP_SMALLEST_REAL:
489:     case NEP_LARGEST_IMAGINARY:
490:     case NEP_SMALLEST_IMAGINARY:
491:     case NEP_TARGET_MAGNITUDE:
492:     case NEP_TARGET_REAL:
493: #if defined(PETSC_USE_COMPLEX)
494:     case NEP_TARGET_IMAGINARY:
495: #endif
496:     case NEP_ALL:
497:     case NEP_WHICH_USER:
498:       if (nep->which != which) {
499:         nep->state = NEP_STATE_INITIAL;
500:         nep->which = which;
501:       }
502:       break;
503: #if !defined(PETSC_USE_COMPLEX)
504:     case NEP_TARGET_IMAGINARY:
505:       SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NEP_TARGET_IMAGINARY can be used only with complex scalars");
506: #endif
507:     default:
508:       SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value");
509:   }
510:   return(0);
511: }

513: /*@
514:     NEPGetWhichEigenpairs - Returns which portion of the spectrum is to be
515:     sought.

517:     Not Collective

519:     Input Parameter:
520: .   nep - eigensolver context obtained from NEPCreate()

522:     Output Parameter:
523: .   which - the portion of the spectrum to be sought

525:     Notes:
526:     See NEPSetWhichEigenpairs() for possible values of 'which'.

528:     Level: intermediate

530: .seealso: NEPSetWhichEigenpairs(), NEPWhich
531: @*/
532: PetscErrorCode NEPGetWhichEigenpairs(NEP nep,NEPWhich *which)
533: {
537:   *which = nep->which;
538:   return(0);
539: }

541: /*@C
542:    NEPSetEigenvalueComparison - Specifies the eigenvalue comparison function
543:    when NEPSetWhichEigenpairs() is set to NEP_WHICH_USER.

545:    Logically Collective on nep

547:    Input Parameters:
548: +  nep  - eigensolver context obtained from NEPCreate()
549: .  func - a pointer to the comparison function
550: -  ctx  - a context pointer (the last parameter to the comparison function)

552:    Calling Sequence of func:
553: $   func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx)

555: +   ar     - real part of the 1st eigenvalue
556: .   ai     - imaginary part of the 1st eigenvalue
557: .   br     - real part of the 2nd eigenvalue
558: .   bi     - imaginary part of the 2nd eigenvalue
559: .   res    - result of comparison
560: -   ctx    - optional context, as set by NEPSetEigenvalueComparison()

562:    Note:
563:    The returning parameter 'res' can be
564: +  negative - if the 1st eigenvalue is preferred to the 2st one
565: .  zero     - if both eigenvalues are equally preferred
566: -  positive - if the 2st eigenvalue is preferred to the 1st one

568:    Level: advanced

570: .seealso: NEPSetWhichEigenpairs(), NEPWhich
571: @*/
572: PetscErrorCode NEPSetEigenvalueComparison(NEP nep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)
573: {
576:   nep->sc->comparison    = func;
577:   nep->sc->comparisonctx = ctx;
578:   nep->which             = NEP_WHICH_USER;
579:   return(0);
580: }

582: /*@
583:    NEPSetProblemType - Specifies the type of the nonlinear eigenvalue problem.

585:    Logically Collective on nep

587:    Input Parameters:
588: +  nep  - the nonlinear eigensolver context
589: -  type - a known type of nonlinear eigenvalue problem

591:    Options Database Keys:
592: +  -nep_general - general problem with no particular structure
593: -  -nep_rational - a rational eigenvalue problem defined in split form with all f_i rational

595:    Notes:
596:    Allowed values for the problem type are: general (NEP_GENERAL), and rational
597:    (NEP_RATIONAL).

599:    This function is used to provide a hint to the NEP solver to exploit certain
600:    properties of the nonlinear eigenproblem. This hint may be used or not,
601:    depending on the solver. By default, no particular structure is assumed.

603:    Level: intermediate

605: .seealso: NEPSetType(), NEPGetProblemType(), NEPProblemType
606: @*/
607: PetscErrorCode NEPSetProblemType(NEP nep,NEPProblemType type)
608: {
612:   if (type!=NEP_GENERAL && type!=NEP_RATIONAL) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type");
613:   if (type != nep->problem_type) {
614:     nep->problem_type = type;
615:     nep->state = NEP_STATE_INITIAL;
616:   }
617:   return(0);
618: }

620: /*@
621:    NEPGetProblemType - Gets the problem type from the NEP object.

623:    Not Collective

625:    Input Parameter:
626: .  nep - the nonlinear eigensolver context

628:    Output Parameter:
629: .  type - the problem type

631:    Level: intermediate

633: .seealso: NEPSetProblemType(), NEPProblemType
634: @*/
635: PetscErrorCode NEPGetProblemType(NEP nep,NEPProblemType *type)
636: {
640:   *type = nep->problem_type;
641:   return(0);
642: }

644: /*@
645:    NEPSetTwoSided - Sets the solver to use a two-sided variant so that left
646:    eigenvectors are also computed.

648:    Logically Collective on nep

650:    Input Parameters:
651: +  nep      - the eigensolver context
652: -  twosided - whether the two-sided variant is to be used or not

654:    Options Database Keys:
655: .  -nep_two_sided <boolean> - Sets/resets the twosided flag

657:    Notes:
658:    If the user sets twosided=PETSC_TRUE then the solver uses a variant of
659:    the algorithm that computes both right and left eigenvectors. This is
660:    usually much more costly. This option is not available in all solvers.

662:    When using two-sided solvers, the problem matrices must have both the
663:    MatMult and MatMultTranspose operations defined.

665:    Level: advanced

667: .seealso: NEPGetTwoSided(), NEPGetLeftEigenvector()
668: @*/
669: PetscErrorCode NEPSetTwoSided(NEP nep,PetscBool twosided)
670: {
674:   if (twosided!=nep->twosided) {
675:     nep->twosided = twosided;
676:     nep->state    = NEP_STATE_INITIAL;
677:   }
678:   return(0);
679: }

681: /*@
682:    NEPGetTwoSided - Returns the flag indicating whether a two-sided variant
683:    of the algorithm is being used or not.

685:    Not Collective

687:    Input Parameter:
688: .  nep - the eigensolver context

690:    Output Parameter:
691: .  twosided - the returned flag

693:    Level: advanced

695: .seealso: NEPSetTwoSided()
696: @*/
697: PetscErrorCode NEPGetTwoSided(NEP nep,PetscBool *twosided)
698: {
702:   *twosided = nep->twosided;
703:   return(0);
704: }

706: /*@C
707:    NEPSetConvergenceTestFunction - Sets a function to compute the error estimate
708:    used in the convergence test.

710:    Logically Collective on nep

712:    Input Parameters:
713: +  nep     - nonlinear eigensolver context obtained from NEPCreate()
714: .  func    - a pointer to the convergence test function
715: .  ctx     - context for private data for the convergence routine (may be null)
716: -  destroy - a routine for destroying the context (may be null)

718:    Calling Sequence of func:
719: $   func(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)

721: +   nep    - nonlinear eigensolver context obtained from NEPCreate()
722: .   eigr   - real part of the eigenvalue
723: .   eigi   - imaginary part of the eigenvalue
724: .   res    - residual norm associated to the eigenpair
725: .   errest - (output) computed error estimate
726: -   ctx    - optional context, as set by NEPSetConvergenceTestFunction()

728:    Note:
729:    If the error estimate returned by the convergence test function is less than
730:    the tolerance, then the eigenvalue is accepted as converged.

732:    Level: advanced

734: .seealso: NEPSetConvergenceTest(), NEPSetTolerances()
735: @*/
736: PetscErrorCode NEPSetConvergenceTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
737: {

742:   if (nep->convergeddestroy) {
743:     (*nep->convergeddestroy)(nep->convergedctx);
744:   }
745:   nep->convergeduser    = func;
746:   nep->convergeddestroy = destroy;
747:   nep->convergedctx     = ctx;
748:   if (func == NEPConvergedRelative) nep->conv = NEP_CONV_REL;
749:   else if (func == NEPConvergedNorm) nep->conv = NEP_CONV_NORM;
750:   else if (func == NEPConvergedAbsolute) nep->conv = NEP_CONV_ABS;
751:   else {
752:     nep->conv      = NEP_CONV_USER;
753:     nep->converged = nep->convergeduser;
754:   }
755:   return(0);
756: }

758: /*@
759:    NEPSetConvergenceTest - Specifies how to compute the error estimate
760:    used in the convergence test.

762:    Logically Collective on nep

764:    Input Parameters:
765: +  nep  - nonlinear eigensolver context obtained from NEPCreate()
766: -  conv - the type of convergence test

768:    Options Database Keys:
769: +  -nep_conv_abs  - Sets the absolute convergence test
770: .  -nep_conv_rel  - Sets the convergence test relative to the eigenvalue
771: -  -nep_conv_user - Selects the user-defined convergence test

773:    Note:
774:    The parameter 'conv' can have one of these values
775: +     NEP_CONV_ABS  - absolute error ||r||
776: .     NEP_CONV_REL  - error relative to the eigenvalue l, ||r||/|l|
777: .     NEP_CONV_NORM - error relative matrix norms, ||r||/sum_i(|f_i(l)|*||A_i||)
778: -     NEP_CONV_USER - function set by NEPSetConvergenceTestFunction()

780:    Level: intermediate

782: .seealso: NEPGetConvergenceTest(), NEPSetConvergenceTestFunction(), NEPSetStoppingTest(), NEPConv
783: @*/
784: PetscErrorCode NEPSetConvergenceTest(NEP nep,NEPConv conv)
785: {
789:   switch (conv) {
790:     case NEP_CONV_ABS:  nep->converged = NEPConvergedAbsolute; break;
791:     case NEP_CONV_REL:  nep->converged = NEPConvergedRelative; break;
792:     case NEP_CONV_NORM: nep->converged = NEPConvergedNorm; break;
793:     case NEP_CONV_USER:
794:       if (!nep->convergeduser) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ORDER,"Must call NEPSetConvergenceTestFunction() first");
795:       nep->converged = nep->convergeduser;
796:       break;
797:     default:
798:       SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value");
799:   }
800:   nep->conv = conv;
801:   return(0);
802: }

804: /*@
805:    NEPGetConvergenceTest - Gets the method used to compute the error estimate
806:    used in the convergence test.

808:    Not Collective

810:    Input Parameters:
811: .  nep   - nonlinear eigensolver context obtained from NEPCreate()

813:    Output Parameters:
814: .  conv  - the type of convergence test

816:    Level: intermediate

818: .seealso: NEPSetConvergenceTest(), NEPConv
819: @*/
820: PetscErrorCode NEPGetConvergenceTest(NEP nep,NEPConv *conv)
821: {
825:   *conv = nep->conv;
826:   return(0);
827: }

829: /*@C
830:    NEPSetStoppingTestFunction - Sets a function to decide when to stop the outer
831:    iteration of the eigensolver.

833:    Logically Collective on nep

835:    Input Parameters:
836: +  nep     - nonlinear eigensolver context obtained from NEPCreate()
837: .  func    - pointer to the stopping test function
838: .  ctx     - context for private data for the stopping routine (may be null)
839: -  destroy - a routine for destroying the context (may be null)

841:    Calling Sequence of func:
842: $   func(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)

844: +   nep    - nonlinear eigensolver context obtained from NEPCreate()
845: .   its    - current number of iterations
846: .   max_it - maximum number of iterations
847: .   nconv  - number of currently converged eigenpairs
848: .   nev    - number of requested eigenpairs
849: .   reason - (output) result of the stopping test
850: -   ctx    - optional context, as set by NEPSetStoppingTestFunction()

852:    Note:
853:    Normal usage is to first call the default routine NEPStoppingBasic() and then
854:    set reason to NEP_CONVERGED_USER if some user-defined conditions have been
855:    met. To let the eigensolver continue iterating, the result must be left as
856:    NEP_CONVERGED_ITERATING.

858:    Level: advanced

860: .seealso: NEPSetStoppingTest(), NEPStoppingBasic()
861: @*/
862: PetscErrorCode NEPSetStoppingTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
863: {

868:   if (nep->stoppingdestroy) {
869:     (*nep->stoppingdestroy)(nep->stoppingctx);
870:   }
871:   nep->stoppinguser    = func;
872:   nep->stoppingdestroy = destroy;
873:   nep->stoppingctx     = ctx;
874:   if (func == NEPStoppingBasic) nep->stop = NEP_STOP_BASIC;
875:   else {
876:     nep->stop     = NEP_STOP_USER;
877:     nep->stopping = nep->stoppinguser;
878:   }
879:   return(0);
880: }

882: /*@
883:    NEPSetStoppingTest - Specifies how to decide the termination of the outer
884:    loop of the eigensolver.

886:    Logically Collective on nep

888:    Input Parameters:
889: +  nep  - nonlinear eigensolver context obtained from NEPCreate()
890: -  stop - the type of stopping test

892:    Options Database Keys:
893: +  -nep_stop_basic - Sets the default stopping test
894: -  -nep_stop_user  - Selects the user-defined stopping test

896:    Note:
897:    The parameter 'stop' can have one of these values
898: +     NEP_STOP_BASIC - default stopping test
899: -     NEP_STOP_USER  - function set by NEPSetStoppingTestFunction()

901:    Level: advanced

903: .seealso: NEPGetStoppingTest(), NEPSetStoppingTestFunction(), NEPSetConvergenceTest(), NEPStop
904: @*/
905: PetscErrorCode NEPSetStoppingTest(NEP nep,NEPStop stop)
906: {
910:   switch (stop) {
911:     case NEP_STOP_BASIC: nep->stopping = NEPStoppingBasic; break;
912:     case NEP_STOP_USER:
913:       if (!nep->stoppinguser) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ORDER,"Must call NEPSetStoppingTestFunction() first");
914:       nep->stopping = nep->stoppinguser;
915:       break;
916:     default:
917:       SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value");
918:   }
919:   nep->stop = stop;
920:   return(0);
921: }

923: /*@
924:    NEPGetStoppingTest - Gets the method used to decide the termination of the outer
925:    loop of the eigensolver.

927:    Not Collective

929:    Input Parameters:
930: .  nep   - nonlinear eigensolver context obtained from NEPCreate()

932:    Output Parameters:
933: .  stop  - the type of stopping test

935:    Level: advanced

937: .seealso: NEPSetStoppingTest(), NEPStop
938: @*/
939: PetscErrorCode NEPGetStoppingTest(NEP nep,NEPStop *stop)
940: {
944:   *stop = nep->stop;
945:   return(0);
946: }

948: /*@
949:    NEPSetTrackAll - Specifies if the solver must compute the residual of all
950:    approximate eigenpairs or not.

952:    Logically Collective on nep

954:    Input Parameters:
955: +  nep      - the eigensolver context
956: -  trackall - whether compute all residuals or not

958:    Notes:
959:    If the user sets trackall=PETSC_TRUE then the solver explicitly computes
960:    the residual for each eigenpair approximation. Computing the residual is
961:    usually an expensive operation and solvers commonly compute the associated
962:    residual to the first unconverged eigenpair.
963:    The options '-nep_monitor_all' and '-nep_monitor_lg_all' automatically
964:    activate this option.

966:    Level: developer

968: .seealso: NEPGetTrackAll()
969: @*/
970: PetscErrorCode NEPSetTrackAll(NEP nep,PetscBool trackall)
971: {
975:   nep->trackall = trackall;
976:   return(0);
977: }

979: /*@
980:    NEPGetTrackAll - Returns the flag indicating whether all residual norms must
981:    be computed or not.

983:    Not Collective

985:    Input Parameter:
986: .  nep - the eigensolver context

988:    Output Parameter:
989: .  trackall - the returned flag

991:    Level: developer

993: .seealso: NEPSetTrackAll()
994: @*/
995: PetscErrorCode NEPGetTrackAll(NEP nep,PetscBool *trackall)
996: {
1000:   *trackall = nep->trackall;
1001:   return(0);
1002: }

1004: /*@
1005:    NEPSetRefine - Specifies the refinement type (and options) to be used
1006:    after the solve.

1008:    Logically Collective on nep

1010:    Input Parameters:
1011: +  nep    - the nonlinear eigensolver context
1012: .  refine - refinement type
1013: .  npart  - number of partitions of the communicator
1014: .  tol    - the convergence tolerance
1015: .  its    - maximum number of refinement iterations
1016: -  scheme - which scheme to be used for solving the involved linear systems

1018:    Options Database Keys:
1019: +  -nep_refine <type> - refinement type, one of <none,simple,multiple>
1020: .  -nep_refine_partitions <n> - the number of partitions
1021: .  -nep_refine_tol <tol> - the tolerance
1022: .  -nep_refine_its <its> - number of iterations
1023: -  -nep_refine_scheme - to set the scheme for the linear solves

1025:    Notes:
1026:    By default, iterative refinement is disabled, since it may be very
1027:    costly. There are two possible refinement strategies: simple and multiple.
1028:    The simple approach performs iterative refinement on each of the
1029:    converged eigenpairs individually, whereas the multiple strategy works
1030:    with the invariant pair as a whole, refining all eigenpairs simultaneously.
1031:    The latter may be required for the case of multiple eigenvalues.

1033:    In some cases, especially when using direct solvers within the
1034:    iterative refinement method, it may be helpful for improved scalability
1035:    to split the communicator in several partitions. The npart parameter
1036:    indicates how many partitions to use (defaults to 1).

1038:    The tol and its parameters specify the stopping criterion. In the simple
1039:    method, refinement continues until the residual of each eigenpair is
1040:    below the tolerance (tol defaults to the NEP tol, but may be set to a
1041:    different value). In contrast, the multiple method simply performs its
1042:    refinement iterations (just one by default).

1044:    The scheme argument is used to change the way in which linear systems are
1045:    solved. Possible choices are: explicit, mixed block elimination (MBE),
1046:    and Schur complement.

1048:    Level: intermediate

1050: .seealso: NEPGetRefine()
1051: @*/
1052: PetscErrorCode NEPSetRefine(NEP nep,NEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,NEPRefineScheme scheme)
1053: {
1055:   PetscMPIInt    size;

1064:   nep->refine = refine;
1065:   if (refine) {  /* process parameters only if not REFINE_NONE */
1066:     if (npart!=nep->npart) {
1067:       PetscSubcommDestroy(&nep->refinesubc);
1068:       KSPDestroy(&nep->refineksp);
1069:     }
1070:     if (npart == PETSC_DEFAULT || npart == PETSC_DECIDE) {
1071:       nep->npart = 1;
1072:     } else {
1073:       MPI_Comm_size(PetscObjectComm((PetscObject)nep),&size);
1074:       if (npart<1 || npart>size) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of npart");
1075:       nep->npart = npart;
1076:     }
1077:     if (tol == PETSC_DEFAULT || tol == PETSC_DECIDE) {
1078:       nep->rtol = PETSC_DEFAULT;
1079:     } else {
1080:       if (tol<=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
1081:       nep->rtol = tol;
1082:     }
1083:     if (its==PETSC_DECIDE || its==PETSC_DEFAULT) {
1084:       nep->rits = PETSC_DEFAULT;
1085:     } else {
1086:       if (its<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be >= 0");
1087:       nep->rits = its;
1088:     }
1089:     nep->scheme = scheme;
1090:   }
1091:   nep->state = NEP_STATE_INITIAL;
1092:   return(0);
1093: }

1095: /*@C
1096:    NEPGetRefine - Gets the refinement strategy used by the NEP object, and the
1097:    associated parameters.

1099:    Not Collective

1101:    Input Parameter:
1102: .  nep - the nonlinear eigensolver context

1104:    Output Parameters:
1105: +  refine - refinement type
1106: .  npart  - number of partitions of the communicator
1107: .  tol    - the convergence tolerance
1108: -  its    - maximum number of refinement iterations
1109: -  scheme - the scheme used for solving linear systems

1111:    Level: intermediate

1113:    Note:
1114:    The user can specify NULL for any parameter that is not needed.

1116: .seealso: NEPSetRefine()
1117: @*/
1118: PetscErrorCode NEPGetRefine(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme)
1119: {
1122:   if (refine) *refine = nep->refine;
1123:   if (npart)  *npart  = nep->npart;
1124:   if (tol)    *tol    = nep->rtol;
1125:   if (its)    *its    = nep->rits;
1126:   if (scheme) *scheme = nep->scheme;
1127:   return(0);
1128: }

1130: /*@C
1131:    NEPSetOptionsPrefix - Sets the prefix used for searching for all
1132:    NEP options in the database.

1134:    Logically Collective on nep

1136:    Input Parameters:
1137: +  nep - the nonlinear eigensolver context
1138: -  prefix - the prefix string to prepend to all NEP option requests

1140:    Notes:
1141:    A hyphen (-) must NOT be given at the beginning of the prefix name.
1142:    The first character of all runtime options is AUTOMATICALLY the
1143:    hyphen.

1145:    For example, to distinguish between the runtime options for two
1146:    different NEP contexts, one could call
1147: .vb
1148:       NEPSetOptionsPrefix(nep1,"neig1_")
1149:       NEPSetOptionsPrefix(nep2,"neig2_")
1150: .ve

1152:    Level: advanced

1154: .seealso: NEPAppendOptionsPrefix(), NEPGetOptionsPrefix()
1155: @*/
1156: PetscErrorCode NEPSetOptionsPrefix(NEP nep,const char *prefix)
1157: {

1162:   if (!nep->V) { NEPGetBV(nep,&nep->V); }
1163:   BVSetOptionsPrefix(nep->V,prefix);
1164:   if (!nep->ds) { NEPGetDS(nep,&nep->ds); }
1165:   DSSetOptionsPrefix(nep->ds,prefix);
1166:   if (!nep->rg) { NEPGetRG(nep,&nep->rg); }
1167:   RGSetOptionsPrefix(nep->rg,prefix);
1168:   PetscObjectSetOptionsPrefix((PetscObject)nep,prefix);
1169:   return(0);
1170: }

1172: /*@C
1173:    NEPAppendOptionsPrefix - Appends to the prefix used for searching for all
1174:    NEP options in the database.

1176:    Logically Collective on nep

1178:    Input Parameters:
1179: +  nep - the nonlinear eigensolver context
1180: -  prefix - the prefix string to prepend to all NEP option requests

1182:    Notes:
1183:    A hyphen (-) must NOT be given at the beginning of the prefix name.
1184:    The first character of all runtime options is AUTOMATICALLY the hyphen.

1186:    Level: advanced

1188: .seealso: NEPSetOptionsPrefix(), NEPGetOptionsPrefix()
1189: @*/
1190: PetscErrorCode NEPAppendOptionsPrefix(NEP nep,const char *prefix)
1191: {

1196:   if (!nep->V) { NEPGetBV(nep,&nep->V); }
1197:   BVAppendOptionsPrefix(nep->V,prefix);
1198:   if (!nep->ds) { NEPGetDS(nep,&nep->ds); }
1199:   DSAppendOptionsPrefix(nep->ds,prefix);
1200:   if (!nep->rg) { NEPGetRG(nep,&nep->rg); }
1201:   RGAppendOptionsPrefix(nep->rg,prefix);
1202:   PetscObjectAppendOptionsPrefix((PetscObject)nep,prefix);
1203:   return(0);
1204: }

1206: /*@C
1207:    NEPGetOptionsPrefix - Gets the prefix used for searching for all
1208:    NEP options in the database.

1210:    Not Collective

1212:    Input Parameters:
1213: .  nep - the nonlinear eigensolver context

1215:    Output Parameters:
1216: .  prefix - pointer to the prefix string used is returned

1218:    Note:
1219:    On the Fortran side, the user should pass in a string 'prefix' of
1220:    sufficient length to hold the prefix.

1222:    Level: advanced

1224: .seealso: NEPSetOptionsPrefix(), NEPAppendOptionsPrefix()
1225: @*/
1226: PetscErrorCode NEPGetOptionsPrefix(NEP nep,const char *prefix[])
1227: {

1233:   PetscObjectGetOptionsPrefix((PetscObject)nep,prefix);
1234:   return(0);
1235: }