Actual source code: nepopts.c
1: /*
2: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3: SLEPc - Scalable Library for Eigenvalue Problem Computations
4: Copyright (c) 2002-, 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: /*@
19: NEPMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
20: indicated by the user.
22: Collective
24: Input Parameters:
25: + nep - the nonlinear eigensolver context
26: . opt - the command line option for this monitor
27: . name - the monitor type one is seeking
28: . ctx - an optional user context for the monitor, or `NULL`
29: - trackall - whether this monitor tracks all eigenvalues or not
31: Level: developer
33: .seealso: [](ch:nep), `NEPMonitorSet()`, `NEPSetTrackAll()`
34: @*/
35: PetscErrorCode NEPMonitorSetFromOptions(NEP nep,const char opt[],const char name[],PetscCtx ctx,PetscBool trackall)
36: {
37: PetscErrorCode (*mfunc)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
38: PetscErrorCode (*cfunc)(PetscViewer,PetscViewerFormat,void*,PetscViewerAndFormat**);
39: PetscErrorCode (*dfunc)(PetscViewerAndFormat**);
40: PetscViewerAndFormat *vf;
41: PetscViewer viewer;
42: PetscViewerFormat format;
43: PetscViewerType vtype;
44: char key[PETSC_MAX_PATH_LEN];
45: PetscBool flg;
47: PetscFunctionBegin;
48: PetscCall(PetscOptionsCreateViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->options,((PetscObject)nep)->prefix,opt,&viewer,&format,&flg));
49: if (!flg) PetscFunctionReturn(PETSC_SUCCESS);
51: PetscCall(PetscViewerGetType(viewer,&vtype));
52: PetscCall(SlepcMonitorMakeKey_Internal(name,vtype,format,key));
53: PetscCall(PetscFunctionListFind(NEPMonitorList,key,&mfunc));
54: PetscCheck(mfunc,PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Specified viewer and format not supported");
55: PetscCall(PetscFunctionListFind(NEPMonitorCreateList,key,&cfunc));
56: PetscCall(PetscFunctionListFind(NEPMonitorDestroyList,key,&dfunc));
57: if (!cfunc) cfunc = PetscViewerAndFormatCreate_Internal;
58: if (!dfunc) dfunc = PetscViewerAndFormatDestroy;
60: PetscCall((*cfunc)(viewer,format,ctx,&vf));
61: PetscCall(PetscViewerDestroy(&viewer));
62: PetscCall(NEPMonitorSet(nep,mfunc,vf,(PetscCtxDestroyFn*)dfunc));
63: if (trackall) PetscCall(NEPSetTrackAll(nep,PETSC_TRUE));
64: PetscFunctionReturn(PETSC_SUCCESS);
65: }
67: /*@
68: NEPSetFromOptions - Sets `NEP` options from the options database.
69: This routine must be called before `NEPSetUp()` if the user is to be
70: allowed to configure the solver.
72: Collective
74: Input Parameter:
75: . nep - the nonlinear eigensolver context
77: Note:
78: To see all options, run your program with the `-help` option.
80: Level: beginner
82: .seealso: [](ch:nep), `NEPSetOptionsPrefix()`
83: @*/
84: PetscErrorCode NEPSetFromOptions(NEP nep)
85: {
86: char type[256];
87: PetscBool set,flg,flg1,flg2,flg3,flg4,flg5,bval;
88: PetscReal r;
89: PetscScalar s;
90: PetscInt i,j,k;
91: NEPRefine refine;
92: NEPRefineScheme scheme;
94: PetscFunctionBegin;
96: PetscCall(NEPRegisterAll());
97: PetscObjectOptionsBegin((PetscObject)nep);
98: PetscCall(PetscOptionsFList("-nep_type","Nonlinear eigensolver method","NEPSetType",NEPList,(char*)(((PetscObject)nep)->type_name?((PetscObject)nep)->type_name:NEPRII),type,sizeof(type),&flg));
99: if (flg) PetscCall(NEPSetType(nep,type));
100: else if (!((PetscObject)nep)->type_name) PetscCall(NEPSetType(nep,NEPRII));
102: PetscCall(PetscOptionsBoolGroupBegin("-nep_general","General nonlinear eigenvalue problem","NEPSetProblemType",&flg));
103: if (flg) PetscCall(NEPSetProblemType(nep,NEP_GENERAL));
104: PetscCall(PetscOptionsBoolGroupEnd("-nep_rational","Rational eigenvalue problem","NEPSetProblemType",&flg));
105: if (flg) PetscCall(NEPSetProblemType(nep,NEP_RATIONAL));
107: refine = nep->refine;
108: PetscCall(PetscOptionsEnum("-nep_refine","Iterative refinement method","NEPSetRefine",NEPRefineTypes,(PetscEnum)refine,(PetscEnum*)&refine,&flg1));
109: i = nep->npart;
110: PetscCall(PetscOptionsInt("-nep_refine_partitions","Number of partitions of the communicator for iterative refinement","NEPSetRefine",nep->npart,&i,&flg2));
111: r = nep->rtol;
112: PetscCall(PetscOptionsReal("-nep_refine_tol","Tolerance for iterative refinement","NEPSetRefine",nep->rtol==(PetscReal)PETSC_DETERMINE?SLEPC_DEFAULT_TOL/1000:nep->rtol,&r,&flg3));
113: j = nep->rits;
114: PetscCall(PetscOptionsInt("-nep_refine_its","Maximum number of iterations for iterative refinement","NEPSetRefine",nep->rits,&j,&flg4));
115: scheme = nep->scheme;
116: PetscCall(PetscOptionsEnum("-nep_refine_scheme","Scheme used for linear systems within iterative refinement","NEPSetRefine",NEPRefineSchemes,(PetscEnum)scheme,(PetscEnum*)&scheme,&flg5));
117: if (flg1 || flg2 || flg3 || flg4 || flg5) PetscCall(NEPSetRefine(nep,refine,i,r,j,scheme));
119: i = nep->max_it;
120: PetscCall(PetscOptionsInt("-nep_max_it","Maximum number of iterations","NEPSetTolerances",nep->max_it,&i,&flg1));
121: r = nep->tol;
122: PetscCall(PetscOptionsReal("-nep_tol","Tolerance","NEPSetTolerances",SlepcDefaultTol(nep->tol),&r,&flg2));
123: if (flg1 || flg2) PetscCall(NEPSetTolerances(nep,r,i));
125: PetscCall(PetscOptionsBoolGroupBegin("-nep_conv_rel","Relative error convergence test","NEPSetConvergenceTest",&flg));
126: if (flg) PetscCall(NEPSetConvergenceTest(nep,NEP_CONV_REL));
127: PetscCall(PetscOptionsBoolGroup("-nep_conv_norm","Convergence test relative to the matrix norms","NEPSetConvergenceTest",&flg));
128: if (flg) PetscCall(NEPSetConvergenceTest(nep,NEP_CONV_NORM));
129: PetscCall(PetscOptionsBoolGroup("-nep_conv_abs","Absolute error convergence test","NEPSetConvergenceTest",&flg));
130: if (flg) PetscCall(NEPSetConvergenceTest(nep,NEP_CONV_ABS));
131: PetscCall(PetscOptionsBoolGroupEnd("-nep_conv_user","User-defined convergence test","NEPSetConvergenceTest",&flg));
132: if (flg) PetscCall(NEPSetConvergenceTest(nep,NEP_CONV_USER));
134: PetscCall(PetscOptionsBoolGroupBegin("-nep_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","NEPSetStoppingTest",&flg));
135: if (flg) PetscCall(NEPSetStoppingTest(nep,NEP_STOP_BASIC));
136: PetscCall(PetscOptionsBoolGroupEnd("-nep_stop_user","User-defined stopping test","NEPSetStoppingTest",&flg));
137: if (flg) PetscCall(NEPSetStoppingTest(nep,NEP_STOP_USER));
139: i = nep->nev;
140: PetscCall(PetscOptionsInt("-nep_nev","Number of eigenvalues to compute","NEPSetDimensions",nep->nev,&i,&flg1));
141: j = nep->ncv;
142: PetscCall(PetscOptionsInt("-nep_ncv","Number of basis vectors","NEPSetDimensions",nep->ncv,&j,&flg2));
143: k = nep->mpd;
144: PetscCall(PetscOptionsInt("-nep_mpd","Maximum dimension of projected problem","NEPSetDimensions",nep->mpd,&k,&flg3));
145: if (flg1 || flg2 || flg3) PetscCall(NEPSetDimensions(nep,i,j,k));
147: PetscCall(PetscOptionsBoolGroupBegin("-nep_largest_magnitude","Compute largest eigenvalues in magnitude","NEPSetWhichEigenpairs",&flg));
148: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_LARGEST_MAGNITUDE));
149: PetscCall(PetscOptionsBoolGroup("-nep_smallest_magnitude","Compute smallest eigenvalues in magnitude","NEPSetWhichEigenpairs",&flg));
150: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_SMALLEST_MAGNITUDE));
151: PetscCall(PetscOptionsBoolGroup("-nep_largest_real","Compute eigenvalues with largest real parts","NEPSetWhichEigenpairs",&flg));
152: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_LARGEST_REAL));
153: PetscCall(PetscOptionsBoolGroup("-nep_smallest_real","Compute eigenvalues with smallest real parts","NEPSetWhichEigenpairs",&flg));
154: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_SMALLEST_REAL));
155: PetscCall(PetscOptionsBoolGroup("-nep_largest_imaginary","Compute eigenvalues with largest imaginary parts","NEPSetWhichEigenpairs",&flg));
156: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_LARGEST_IMAGINARY));
157: PetscCall(PetscOptionsBoolGroup("-nep_smallest_imaginary","Compute eigenvalues with smallest imaginary parts","NEPSetWhichEigenpairs",&flg));
158: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_SMALLEST_IMAGINARY));
159: PetscCall(PetscOptionsBoolGroup("-nep_target_magnitude","Compute eigenvalues closest to target","NEPSetWhichEigenpairs",&flg));
160: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_TARGET_MAGNITUDE));
161: PetscCall(PetscOptionsBoolGroup("-nep_target_real","Compute eigenvalues with real parts closest to target","NEPSetWhichEigenpairs",&flg));
162: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_TARGET_REAL));
163: PetscCall(PetscOptionsBoolGroup("-nep_target_imaginary","Compute eigenvalues with imaginary parts closest to target","NEPSetWhichEigenpairs",&flg));
164: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_TARGET_IMAGINARY));
165: PetscCall(PetscOptionsBoolGroup("-nep_all","Compute all eigenvalues in a region","NEPSetWhichEigenpairs",&flg));
166: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_ALL));
167: PetscCall(PetscOptionsBoolGroupEnd("-nep_which_user","Select the user-defined selection criterion","NEPSetWhichEigenpairs",&flg));
168: if (flg) PetscCall(NEPSetWhichEigenpairs(nep,NEP_WHICH_USER));
170: PetscCall(PetscOptionsScalar("-nep_target","Value of the target","NEPSetTarget",nep->target,&s,&flg));
171: if (flg) {
172: if (nep->which!=NEP_TARGET_REAL && nep->which!=NEP_TARGET_IMAGINARY) PetscCall(NEPSetWhichEigenpairs(nep,NEP_TARGET_MAGNITUDE));
173: PetscCall(NEPSetTarget(nep,s));
174: }
176: PetscCall(PetscOptionsBool("-nep_two_sided","Use two-sided variant (to compute left eigenvectors)","NEPSetTwoSided",nep->twosided,&bval,&flg));
177: if (flg) PetscCall(NEPSetTwoSided(nep,bval));
179: /* -----------------------------------------------------------------------*/
180: /*
181: Cancels all monitors hardwired into code before call to NEPSetFromOptions()
182: */
183: PetscCall(PetscOptionsBool("-nep_monitor_cancel","Remove any hardwired monitor routines","NEPMonitorCancel",PETSC_FALSE,&flg,&set));
184: if (set && flg) PetscCall(NEPMonitorCancel(nep));
185: PetscCall(NEPMonitorSetFromOptions(nep,"-nep_monitor","first_approximation",NULL,PETSC_FALSE));
186: PetscCall(NEPMonitorSetFromOptions(nep,"-nep_monitor_all","all_approximations",NULL,PETSC_TRUE));
187: PetscCall(NEPMonitorSetFromOptions(nep,"-nep_monitor_conv","convergence_history",NULL,PETSC_FALSE));
189: /* -----------------------------------------------------------------------*/
190: PetscCall(PetscOptionsName("-nep_view","Print detailed information on solver used","NEPView",&set));
191: PetscCall(PetscOptionsName("-nep_view_vectors","View computed eigenvectors","NEPVectorsView",&set));
192: PetscCall(PetscOptionsName("-nep_view_values","View computed eigenvalues","NEPValuesView",&set));
193: PetscCall(PetscOptionsName("-nep_converged_reason","Print reason for convergence, and number of iterations","NEPConvergedReasonView",&set));
194: PetscCall(PetscOptionsName("-nep_error_absolute","Print absolute errors of each eigenpair","NEPErrorView",&set));
195: PetscCall(PetscOptionsName("-nep_error_relative","Print relative errors of each eigenpair","NEPErrorView",&set));
197: PetscTryTypeMethod(nep,setfromoptions,PetscOptionsObject);
198: PetscCall(PetscObjectProcessOptionsHandlers((PetscObject)nep,PetscOptionsObject));
199: PetscOptionsEnd();
201: if (!nep->V) PetscCall(NEPGetBV(nep,&nep->V));
202: PetscCall(BVSetFromOptions(nep->V));
203: if (!nep->rg) PetscCall(NEPGetRG(nep,&nep->rg));
204: PetscCall(RGSetFromOptions(nep->rg));
205: if (nep->useds) {
206: if (!nep->ds) PetscCall(NEPGetDS(nep,&nep->ds));
207: PetscCall(NEPSetDSType(nep));
208: PetscCall(DSSetFromOptions(nep->ds));
209: }
210: if (!nep->refineksp) PetscCall(NEPRefineGetKSP(nep,&nep->refineksp));
211: PetscCall(KSPSetFromOptions(nep->refineksp));
212: if (nep->fui==NEP_USER_INTERFACE_SPLIT) for (i=0;i<nep->nt;i++) PetscCall(FNSetFromOptions(nep->f[i]));
213: nep->setfromoptionscalled++;
214: PetscFunctionReturn(PETSC_SUCCESS);
215: }
217: /*@
218: NEPGetTolerances - Gets the tolerance and maximum iteration count used
219: by the `NEP` convergence tests.
221: Not Collective
223: Input Parameter:
224: . nep - the nonlinear eigensolver context
226: Output Parameters:
227: + tol - the convergence tolerance
228: - maxits - maximum number of iterations
230: Notes:
231: The user can specify `NULL` for any parameter that is not needed.
233: Level: intermediate
235: .seealso: [](ch:nep), `NEPSetTolerances()`
236: @*/
237: PetscErrorCode NEPGetTolerances(NEP nep,PetscReal *tol,PetscInt *maxits)
238: {
239: PetscFunctionBegin;
241: if (tol) *tol = nep->tol;
242: if (maxits) *maxits = nep->max_it;
243: PetscFunctionReturn(PETSC_SUCCESS);
244: }
246: /*@
247: NEPSetTolerances - Sets the tolerance and maximum iteration count used
248: by the `NEP` convergence tests.
250: Logically Collective
252: Input Parameters:
253: + nep - the nonlinear eigensolver context
254: . tol - the convergence tolerance
255: - maxits - maximum number of iterations to use
257: Options Database Keys:
258: + -nep_tol tol - sets the convergence tolerance
259: - -nep_max_it maxits - sets the maximum number of iterations allowed
261: Note:
262: Use `PETSC_CURRENT` to retain the current value of any of the parameters.
263: Use `PETSC_DETERMINE` for either argument to assign a default value computed
264: internally (may be different in each solver).
265: For `maxits` use `PETSC_UNLIMITED` to indicate there is no upper bound on this value.
267: Level: intermediate
269: .seealso: [](ch:nep), `NEPGetTolerances()`
270: @*/
271: PetscErrorCode NEPSetTolerances(NEP nep,PetscReal tol,PetscInt maxits)
272: {
273: PetscFunctionBegin;
277: if (tol == (PetscReal)PETSC_DETERMINE) {
278: nep->tol = PETSC_DETERMINE;
279: nep->state = NEP_STATE_INITIAL;
280: } else if (tol != (PetscReal)PETSC_CURRENT) {
281: PetscCheck(tol>0.0,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
282: nep->tol = tol;
283: }
284: if (maxits == PETSC_DETERMINE) {
285: nep->max_it = PETSC_DETERMINE;
286: nep->state = NEP_STATE_INITIAL;
287: } else if (maxits == PETSC_UNLIMITED) {
288: nep->max_it = PETSC_INT_MAX;
289: } else if (maxits != PETSC_CURRENT) {
290: PetscCheck(maxits>0,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
291: nep->max_it = maxits;
292: }
293: PetscFunctionReturn(PETSC_SUCCESS);
294: }
296: /*@
297: NEPGetDimensions - Gets the number of eigenvalues to compute
298: and the dimension of the subspace.
300: Not Collective
302: Input Parameter:
303: . nep - the nonlinear eigensolver context
305: Output Parameters:
306: + nev - number of eigenvalues to compute
307: . ncv - the maximum dimension of the subspace to be used by the solver
308: - mpd - the maximum dimension allowed for the projected problem
310: Note:
311: The user can specify `NULL` for any parameter that is not needed.
313: Level: intermediate
315: .seealso: [](ch:nep), `NEPSetDimensions()`
316: @*/
317: PetscErrorCode NEPGetDimensions(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
318: {
319: PetscFunctionBegin;
321: if (nev) *nev = nep->nev;
322: if (ncv) *ncv = nep->ncv;
323: if (mpd) *mpd = nep->mpd;
324: PetscFunctionReturn(PETSC_SUCCESS);
325: }
327: /*@
328: NEPSetDimensions - Sets the number of eigenvalues to compute
329: and the dimension of the subspace.
331: Logically Collective
333: Input Parameters:
334: + nep - the nonlinear eigensolver context
335: . nev - number of eigenvalues to compute
336: . ncv - the maximum dimension of the subspace to be used by the solver
337: - mpd - the maximum dimension allowed for the projected problem
339: Options Database Keys:
340: + -nep_nev nev - sets the number of eigenvalues
341: . -nep_ncv ncv - sets the dimension of the subspace
342: - -nep_mpd mpd - sets the maximum projected dimension
344: Notes:
345: Use `PETSC_DETERMINE` for `ncv` and `mpd` to assign a reasonably good value, which is
346: dependent on the solution method. For any of the arguments, use `PETSC_CURRENT`
347: to preserve the current value.
349: The parameters `ncv` and `mpd` are intimately related, so that the user is advised
350: to set one of them at most. Normal usage is\:
352: 1. in cases where `nev` is small, the user sets `ncv` (a reasonable default is `2*nev`).
353: 2. in cases where `nev` is large, the user sets `mpd`.
355: The value of `ncv` should always be between `nev` and `(nev+mpd)`, typically
356: `ncv=nev+mpd`. If `nev` is not too large, `mpd=nev` is a reasonable choice, otherwise
357: a smaller value should be used.
359: Level: intermediate
361: .seealso: [](ch:nep), `NEPGetDimensions()`
362: @*/
363: PetscErrorCode NEPSetDimensions(NEP nep,PetscInt nev,PetscInt ncv,PetscInt mpd)
364: {
365: PetscFunctionBegin;
370: if (nev != PETSC_CURRENT) {
371: PetscCheck(nev>0,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0");
372: nep->nev = nev;
373: }
374: if (ncv == PETSC_DETERMINE) {
375: nep->ncv = PETSC_DETERMINE;
376: } else if (ncv != PETSC_CURRENT) {
377: PetscCheck(ncv>0,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
378: nep->ncv = ncv;
379: }
380: if (mpd == PETSC_DETERMINE) {
381: nep->mpd = PETSC_DETERMINE;
382: } else if (mpd != PETSC_CURRENT) {
383: PetscCheck(mpd>0,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0");
384: nep->mpd = mpd;
385: }
386: nep->state = NEP_STATE_INITIAL;
387: PetscFunctionReturn(PETSC_SUCCESS);
388: }
390: /*@
391: NEPSetWhichEigenpairs - Specifies which portion of the spectrum is
392: to be sought.
394: Logically Collective
396: Input Parameters:
397: + nep - the nonlinear eigensolver context
398: - which - the portion of the spectrum to be sought, see `NEPWhich` for possible values
400: Options Database Keys:
401: + -nep_largest_magnitude - sets largest eigenvalues in magnitude
402: . -nep_smallest_magnitude - sets smallest eigenvalues in magnitude
403: . -nep_largest_real - sets largest real parts
404: . -nep_smallest_real - sets smallest real parts
405: . -nep_largest_imaginary - sets largest imaginary parts
406: . -nep_smallest_imaginary - sets smallest imaginary parts
407: . -nep_target_magnitude - sets eigenvalues closest to target
408: . -nep_target_real - sets real parts closest to target
409: . -nep_target_imaginary - sets imaginary parts closest to target
410: . -nep_all - sets all eigenvalues in a region
411: - -nep_which_user - select the user-defined selection criterion
413: Notes:
414: Not all eigensolvers implemented in `NEP` account for all the possible values
415: of `which`. Also, some values make sense only for certain types of
416: problems. If SLEPc is compiled for real numbers `NEP_LARGEST_IMAGINARY`
417: and `NEP_SMALLEST_IMAGINARY` use the absolute value of the imaginary part
418: for eigenvalue selection.
420: The target is a scalar value provided with `NEPSetTarget()`.
422: The criterion `NEP_TARGET_IMAGINARY` is available only in case PETSc and
423: SLEPc have been built with complex scalars.
425: `NEP_ALL` is intended for use in the context of the `NEPCISS` solver for
426: computing all eigenvalues in a region.
428: Level: intermediate
430: .seealso: [](ch:nep), `NEPGetWhichEigenpairs()`, `NEPSetTarget()`, `NEPSetDimensions()`, `NEPSetEigenvalueComparison()`, `NEPWhich`
431: @*/
432: PetscErrorCode NEPSetWhichEigenpairs(NEP nep,NEPWhich which)
433: {
434: PetscFunctionBegin;
437: switch (which) {
438: case NEP_LARGEST_MAGNITUDE:
439: case NEP_SMALLEST_MAGNITUDE:
440: case NEP_LARGEST_REAL:
441: case NEP_SMALLEST_REAL:
442: case NEP_LARGEST_IMAGINARY:
443: case NEP_SMALLEST_IMAGINARY:
444: case NEP_TARGET_MAGNITUDE:
445: case NEP_TARGET_REAL:
446: #if PetscDefined(USE_COMPLEX)
447: case NEP_TARGET_IMAGINARY:
448: #endif
449: case NEP_ALL:
450: case NEP_WHICH_USER:
451: if (nep->which != which) {
452: nep->state = NEP_STATE_INITIAL;
453: nep->which = which;
454: }
455: break;
456: #if !PetscDefined(USE_COMPLEX)
457: case NEP_TARGET_IMAGINARY:
458: SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NEP_TARGET_IMAGINARY can be used only with complex scalars");
459: #endif
460: default:
461: SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value");
462: }
463: PetscFunctionReturn(PETSC_SUCCESS);
464: }
466: /*@
467: NEPGetWhichEigenpairs - Returns which portion of the spectrum is to be
468: sought.
470: Not Collective
472: Input Parameter:
473: . nep - the nonlinear eigensolver context
475: Output Parameter:
476: . which - the portion of the spectrum to be sought
478: Level: intermediate
480: .seealso: [](ch:nep), `NEPSetWhichEigenpairs()`, `NEPWhich`
481: @*/
482: PetscErrorCode NEPGetWhichEigenpairs(NEP nep,NEPWhich *which)
483: {
484: PetscFunctionBegin;
486: PetscAssertPointer(which,2);
487: *which = nep->which;
488: PetscFunctionReturn(PETSC_SUCCESS);
489: }
491: /*@
492: NEPSetEigenvalueComparison - Specifies the eigenvalue comparison function
493: when `NEPSetWhichEigenpairs()` is set to `NEP_WHICH_USER`.
495: Logically Collective
497: Input Parameters:
498: + nep - the nonlinear eigensolver context
499: . comp - a pointer to the comparison function, see `SlepcEigenvalueComparisonFn` for the calling sequence
500: - ctx - a context pointer (the last parameter to the comparison function)
502: Level: advanced
504: .seealso: [](ch:nep), `NEPSetWhichEigenpairs()`, `NEPWhich`
505: @*/
506: PetscErrorCode NEPSetEigenvalueComparison(NEP nep,SlepcEigenvalueComparisonFn *comp,PetscCtx ctx)
507: {
508: PetscFunctionBegin;
510: nep->sc->comparison = comp;
511: nep->sc->comparisonctx = ctx;
512: nep->which = NEP_WHICH_USER;
513: PetscFunctionReturn(PETSC_SUCCESS);
514: }
516: /*@
517: NEPSetProblemType - Specifies the type of the nonlinear eigenvalue problem.
519: Logically Collective
521: Input Parameters:
522: + nep - the nonlinear eigensolver context
523: - type - a known type of nonlinear eigenvalue problem
525: Options Database Keys:
526: + -nep_general - general problem with no particular structure
527: - -nep_rational - a rational eigenvalue problem defined in split form with all $f_i$ rational
529: Notes:
530: See `NEPProblemType` for possible problem types.
532: This function is used to provide a hint to the `NEP` solver to exploit certain
533: properties of the nonlinear eigenproblem. This hint may be used or not,
534: depending on the solver. By default, no particular structure is assumed.
536: Level: intermediate
538: .seealso: [](ch:nep), `NEPSetType()`, `NEPGetProblemType()`, `NEPProblemType`
539: @*/
540: PetscErrorCode NEPSetProblemType(NEP nep,NEPProblemType type)
541: {
542: PetscFunctionBegin;
545: PetscCheck(type==NEP_GENERAL || type==NEP_RATIONAL,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type");
546: if (type != nep->problem_type) {
547: nep->problem_type = type;
548: nep->state = NEP_STATE_INITIAL;
549: }
550: PetscFunctionReturn(PETSC_SUCCESS);
551: }
553: /*@
554: NEPGetProblemType - Gets the problem type from the `NEP` object.
556: Not Collective
558: Input Parameter:
559: . nep - the nonlinear eigensolver context
561: Output Parameter:
562: . type - the problem type
564: Level: intermediate
566: .seealso: [](ch:nep), `NEPSetProblemType()`, `NEPProblemType`
567: @*/
568: PetscErrorCode NEPGetProblemType(NEP nep,NEPProblemType *type)
569: {
570: PetscFunctionBegin;
572: PetscAssertPointer(type,2);
573: *type = nep->problem_type;
574: PetscFunctionReturn(PETSC_SUCCESS);
575: }
577: /*@
578: NEPSetTwoSided - Sets the solver to use a two-sided variant so that left
579: eigenvectors are also computed.
581: Logically Collective
583: Input Parameters:
584: + nep - the nonlinear eigensolver context
585: - twosided - whether the two-sided variant is to be used or not
587: Options Database Key:
588: . -nep_two_sided (true|false) - toggles the twosided flag
590: Notes:
591: If the user sets `twosided`=`PETSC_TRUE` then the solver uses a variant of
592: the algorithm that computes both right and left eigenvectors. This is
593: usually much more costly. This option is not available in all solvers,
594: see table [](#tab:solversn).
596: When using two-sided solvers, the problem matrices must have both the
597: `MATOP_MULT` and `MATOP_MULT_TRANSPOSE` operations defined.
599: Level: advanced
601: .seealso: [](ch:nep), `NEPGetTwoSided()`, `NEPGetLeftEigenvector()`
602: @*/
603: PetscErrorCode NEPSetTwoSided(NEP nep,PetscBool twosided)
604: {
605: PetscFunctionBegin;
608: if (twosided!=nep->twosided) {
609: nep->twosided = twosided;
610: nep->state = NEP_STATE_INITIAL;
611: }
612: PetscFunctionReturn(PETSC_SUCCESS);
613: }
615: /*@
616: NEPGetTwoSided - Returns the flag indicating whether a two-sided variant
617: of the algorithm is being used or not.
619: Not Collective
621: Input Parameter:
622: . nep - the nonlinear eigensolver context
624: Output Parameter:
625: . twosided - the returned flag
627: Level: advanced
629: .seealso: [](ch:nep), `NEPSetTwoSided()`
630: @*/
631: PetscErrorCode NEPGetTwoSided(NEP nep,PetscBool *twosided)
632: {
633: PetscFunctionBegin;
635: PetscAssertPointer(twosided,2);
636: *twosided = nep->twosided;
637: PetscFunctionReturn(PETSC_SUCCESS);
638: }
640: /*@
641: NEPSetConvergenceTestFunction - Sets a function to compute the error estimate
642: used in the convergence test.
644: Logically Collective
646: Input Parameters:
647: + nep - the nonlinear eigensolver context
648: . conv - convergence test function, see `NEPConvergenceTestFn` for the calling sequence
649: . ctx - context for private data for the convergence routine (may be `NULL`)
650: - destroy - a routine for destroying the context (may be `NULL`), see `PetscCtxDestroyFn`
651: for the calling sequence
653: Notes:
654: When this is called with a user-defined function, then the convergence
655: criterion is set to `NEP_CONV_USER`, see `NEPSetConvergenceTest()`.
657: If the error estimate returned by the convergence test function is less than
658: the tolerance, then the eigenvalue is accepted as converged.
660: Level: advanced
662: .seealso: [](ch:nep), `NEPSetConvergenceTest()`, `NEPSetTolerances()`
663: @*/
664: PetscErrorCode NEPSetConvergenceTestFunction(NEP nep,NEPConvergenceTestFn *conv,PetscCtx ctx,PetscCtxDestroyFn *destroy)
665: {
666: PetscFunctionBegin;
668: if (nep->convergeddestroy) PetscCall((*nep->convergeddestroy)(&nep->convergedctx));
669: nep->convergeduser = conv;
670: nep->convergeddestroy = destroy;
671: nep->convergedctx = ctx;
672: if (conv == NEPConvergedRelative) nep->conv = NEP_CONV_REL;
673: else if (conv == NEPConvergedNorm) nep->conv = NEP_CONV_NORM;
674: else if (conv == NEPConvergedAbsolute) nep->conv = NEP_CONV_ABS;
675: else {
676: nep->conv = NEP_CONV_USER;
677: nep->converged = nep->convergeduser;
678: }
679: PetscFunctionReturn(PETSC_SUCCESS);
680: }
682: /*@
683: NEPSetConvergenceTest - Specifies how to compute the error estimate
684: used in the convergence test.
686: Logically Collective
688: Input Parameters:
689: + nep - the nonlinear eigensolver context
690: - conv - the type of convergence test, see `NEPConv` for possible values
692: Options Database Keys:
693: + -nep_conv_abs - sets the absolute convergence test
694: . -nep_conv_rel - sets the convergence test relative to the eigenvalue
695: . -nep_conv_norm - sets the convergence test relative to the matrix norms
696: - -nep_conv_user - selects the user-defined convergence test
698: Level: intermediate
700: .seealso: [](ch:nep), `NEPGetConvergenceTest()`, `NEPSetConvergenceTestFunction()`, `NEPSetStoppingTest()`, `NEPConv`
701: @*/
702: PetscErrorCode NEPSetConvergenceTest(NEP nep,NEPConv conv)
703: {
704: PetscFunctionBegin;
707: switch (conv) {
708: case NEP_CONV_ABS: nep->converged = NEPConvergedAbsolute; break;
709: case NEP_CONV_REL: nep->converged = NEPConvergedRelative; break;
710: case NEP_CONV_NORM: nep->converged = NEPConvergedNorm; break;
711: case NEP_CONV_USER:
712: PetscCheck(nep->convergeduser,PetscObjectComm((PetscObject)nep),PETSC_ERR_ORDER,"Must call NEPSetConvergenceTestFunction() first");
713: nep->converged = nep->convergeduser;
714: break;
715: default:
716: SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value");
717: }
718: nep->conv = conv;
719: PetscFunctionReturn(PETSC_SUCCESS);
720: }
722: /*@
723: NEPGetConvergenceTest - Gets the method used to compute the error estimate
724: used in the convergence test.
726: Not Collective
728: Input Parameter:
729: . nep - the nonlinear eigensolver context
731: Output Parameter:
732: . conv - the type of convergence test
734: Level: intermediate
736: .seealso: [](ch:nep), `NEPSetConvergenceTest()`, `NEPConv`
737: @*/
738: PetscErrorCode NEPGetConvergenceTest(NEP nep,NEPConv *conv)
739: {
740: PetscFunctionBegin;
742: PetscAssertPointer(conv,2);
743: *conv = nep->conv;
744: PetscFunctionReturn(PETSC_SUCCESS);
745: }
747: /*@
748: NEPSetStoppingTestFunction - Sets a function to decide when to stop the outer
749: iteration of the eigensolver.
751: Logically Collective
753: Input Parameters:
754: + nep - the nonlinear eigensolver context
755: . stop - the stopping test function, see `NEPStoppingTestFn` for the calling sequence
756: . ctx - context for private data for the stopping routine (may be `NULL`)
757: - destroy - a routine for destroying the context (may be `NULL`), see `PetscCtxDestroyFn`
758: for the calling sequence
760: Note:
761: When implementing a function for this, normal usage is to first call the
762: default routine `NEPStoppingBasic()` and then set `reason` to `NEP_CONVERGED_USER`
763: if some user-defined conditions have been met. To let the eigensolver continue
764: iterating, the result must be left as `NEP_CONVERGED_ITERATING`.
766: Level: advanced
768: .seealso: [](ch:nep), `NEPSetStoppingTest()`, `NEPStoppingBasic()`
769: @*/
770: PetscErrorCode NEPSetStoppingTestFunction(NEP nep,NEPStoppingTestFn *stop,PetscCtx ctx,PetscCtxDestroyFn *destroy)
771: {
772: PetscFunctionBegin;
774: if (nep->stoppingdestroy) PetscCall((*nep->stoppingdestroy)(&nep->stoppingctx));
775: nep->stoppinguser = stop;
776: nep->stoppingdestroy = destroy;
777: nep->stoppingctx = ctx;
778: if (stop == NEPStoppingBasic) nep->stop = NEP_STOP_BASIC;
779: else {
780: nep->stop = NEP_STOP_USER;
781: nep->stopping = nep->stoppinguser;
782: }
783: PetscFunctionReturn(PETSC_SUCCESS);
784: }
786: /*@
787: NEPSetStoppingTest - Specifies how to decide the termination of the outer
788: loop of the eigensolver.
790: Logically Collective
792: Input Parameters:
793: + nep - the nonlinear eigensolver context
794: - stop - the type of stopping test, see `NEPStop`
796: Options Database Keys:
797: + -nep_stop_basic - sets the default stopping test
798: - -nep_stop_user - selects the user-defined stopping test
800: Level: advanced
802: .seealso: [](ch:nep), `NEPGetStoppingTest()`, `NEPSetStoppingTestFunction()`, `NEPSetConvergenceTest()`, `NEPStop`
803: @*/
804: PetscErrorCode NEPSetStoppingTest(NEP nep,NEPStop stop)
805: {
806: PetscFunctionBegin;
809: switch (stop) {
810: case NEP_STOP_BASIC: nep->stopping = NEPStoppingBasic; break;
811: case NEP_STOP_USER:
812: PetscCheck(nep->stoppinguser,PetscObjectComm((PetscObject)nep),PETSC_ERR_ORDER,"Must call NEPSetStoppingTestFunction() first");
813: nep->stopping = nep->stoppinguser;
814: break;
815: default:
816: SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value");
817: }
818: nep->stop = stop;
819: PetscFunctionReturn(PETSC_SUCCESS);
820: }
822: /*@
823: NEPGetStoppingTest - Gets the method used to decide the termination of the outer
824: loop of the eigensolver.
826: Not Collective
828: Input Parameter:
829: . nep - the nonlinear eigensolver context
831: Output Parameter:
832: . stop - the type of stopping test
834: Level: advanced
836: .seealso: [](ch:nep), `NEPSetStoppingTest()`, `NEPStop`
837: @*/
838: PetscErrorCode NEPGetStoppingTest(NEP nep,NEPStop *stop)
839: {
840: PetscFunctionBegin;
842: PetscAssertPointer(stop,2);
843: *stop = nep->stop;
844: PetscFunctionReturn(PETSC_SUCCESS);
845: }
847: /*@
848: NEPSetTrackAll - Specifies if the solver must compute the residual of all
849: approximate eigenpairs or not.
851: Logically Collective
853: Input Parameters:
854: + nep - the nonlinear eigensolver context
855: - trackall - whether compute all residuals or not
857: Notes:
858: If the user sets `trackall`=`PETSC_TRUE` then the solver explicitly computes
859: the residual for each eigenpair approximation. Computing the residual is
860: usually an expensive operation and solvers commonly compute the associated
861: residual to the first unconverged eigenpair.
863: The option `-nep_monitor_all` automatically activates this option.
865: Level: developer
867: .seealso: [](ch:nep), `NEPGetTrackAll()`
868: @*/
869: PetscErrorCode NEPSetTrackAll(NEP nep,PetscBool trackall)
870: {
871: PetscFunctionBegin;
874: nep->trackall = trackall;
875: PetscFunctionReturn(PETSC_SUCCESS);
876: }
878: /*@
879: NEPGetTrackAll - Returns the flag indicating whether all residual norms must
880: be computed or not.
882: Not Collective
884: Input Parameter:
885: . nep - the nonlinear eigensolver context
887: Output Parameter:
888: . trackall - the returned flag
890: Level: developer
892: .seealso: [](ch:nep), `NEPSetTrackAll()`
893: @*/
894: PetscErrorCode NEPGetTrackAll(NEP nep,PetscBool *trackall)
895: {
896: PetscFunctionBegin;
898: PetscAssertPointer(trackall,2);
899: *trackall = nep->trackall;
900: PetscFunctionReturn(PETSC_SUCCESS);
901: }
903: /*@
904: NEPSetRefine - Specifies the refinement type (and options) to be used
905: after the solve.
907: Logically Collective
909: Input Parameters:
910: + nep - the nonlinear eigensolver context
911: . refine - refinement type, see `NEPRefine` for possible values
912: . npart - number of partitions of the communicator
913: . tol - the convergence tolerance
914: . its - maximum number of refinement iterations
915: - scheme - which scheme to be used for solving the involved linear systems, see `NEPRefineScheme`
916: for possible values
918: Options Database Keys:
919: + -nep_refine (none|simple|multiple) - set the refinement type
920: . -nep_refine_partitions npart - set the number of partitions
921: . -nep_refine_tol tol - set the tolerance
922: . -nep_refine_its its - set the number of iterations
923: - -nep_refine_scheme (schur|mbe|explicit) - set the scheme for the linear solves
925: Notes:
926: This function configures the parameters of Newton iterative refinement,
927: see section [](#sec:refine) for a discussion of the different strategies
928: in the context of polynomial eigenproblems.
930: By default, iterative refinement is disabled, since it may be very
931: costly. There are two possible refinement strategies, simple and multiple.
932: The simple approach performs iterative refinement on each of the
933: converged eigenpairs individually, whereas the multiple strategy works
934: with the invariant pair as a whole, refining all eigenpairs simultaneously.
935: The latter may be required for the case of multiple eigenvalues.
937: In some cases, especially when using direct solvers within the
938: iterative refinement method, it may be helpful for improved scalability
939: to split the communicator in several partitions. The `npart` parameter
940: indicates how many partitions to use (defaults to 1).
942: The `tol` and `its` parameters specify the stopping criterion. In the simple
943: method, refinement continues until the residual of each eigenpair is
944: below the tolerance (`tol` defaults to the `NEP` tolerance, but may be set to a
945: different value). In contrast, the multiple method simply performs its
946: refinement iterations (just one by default).
948: The `scheme` argument is used to change the way in which linear systems are
949: solved. Possible choices are explicit, mixed block elimination (MBE),
950: and Schur complement.
952: Use `PETSC_CURRENT` to retain the current value of `npart`, `tol` or `its`. Use
953: `PETSC_DETERMINE` to assign a default value.
955: Level: intermediate
957: .seealso: [](ch:nep), [](#sec:refine), `NEPGetRefine()`
958: @*/
959: PetscErrorCode NEPSetRefine(NEP nep,NEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,NEPRefineScheme scheme)
960: {
961: PetscMPIInt size;
963: PetscFunctionBegin;
970: nep->refine = refine;
971: if (refine) { /* process parameters only if not REFINE_NONE */
972: if (npart!=nep->npart) {
973: PetscCall(PetscSubcommDestroy(&nep->refinesubc));
974: PetscCall(KSPDestroy(&nep->refineksp));
975: }
976: if (npart == PETSC_DETERMINE) {
977: nep->npart = 1;
978: } else if (npart != PETSC_CURRENT) {
979: PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)nep),&size));
980: PetscCheck(npart>0 && npart<=size,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of npart");
981: nep->npart = npart;
982: }
983: if (tol == (PetscReal)PETSC_DETERMINE) {
984: nep->rtol = PETSC_DETERMINE;
985: } else if (tol != (PetscReal)PETSC_CURRENT) {
986: PetscCheck(tol>0.0,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
987: nep->rtol = tol;
988: }
989: if (its==PETSC_DETERMINE) {
990: nep->rits = PETSC_DETERMINE;
991: } else if (its != PETSC_CURRENT) {
992: PetscCheck(its>=0,PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be >= 0");
993: nep->rits = its;
994: }
995: nep->scheme = scheme;
996: }
997: nep->state = NEP_STATE_INITIAL;
998: PetscFunctionReturn(PETSC_SUCCESS);
999: }
1001: /*@
1002: NEPGetRefine - Gets the refinement strategy used by the `NEP` object, and the
1003: associated parameters.
1005: Not Collective
1007: Input Parameter:
1008: . nep - the nonlinear eigensolver context
1010: Output Parameters:
1011: + refine - refinement type
1012: . npart - number of partitions of the communicator
1013: . tol - the convergence tolerance
1014: . its - maximum number of refinement iterations
1015: - scheme - the scheme used for solving linear systems
1017: Level: intermediate
1019: Note:
1020: The user can specify `NULL` for any parameter that is not needed.
1022: .seealso: [](ch:nep), `NEPSetRefine()`
1023: @*/
1024: PetscErrorCode NEPGetRefine(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme)
1025: {
1026: PetscFunctionBegin;
1028: if (refine) *refine = nep->refine;
1029: if (npart) *npart = nep->npart;
1030: if (tol) *tol = nep->rtol;
1031: if (its) *its = nep->rits;
1032: if (scheme) *scheme = nep->scheme;
1033: PetscFunctionReturn(PETSC_SUCCESS);
1034: }
1036: /*@
1037: NEPSetOptionsPrefix - Sets the prefix used for searching for all
1038: `NEP` options in the database.
1040: Logically Collective
1042: Input Parameters:
1043: + nep - the nonlinear eigensolver context
1044: - prefix - the prefix string to prepend to all `NEP` option requests
1046: Notes:
1047: A hyphen (-) must NOT be given at the beginning of the prefix name.
1048: The first character of all runtime options is AUTOMATICALLY the
1049: hyphen.
1051: For example, to distinguish between the runtime options for two
1052: different `NEP` contexts, one could call
1053: .vb
1054: NEPSetOptionsPrefix(nep1,"neig1_")
1055: NEPSetOptionsPrefix(nep2,"neig2_")
1056: .ve
1058: Level: advanced
1060: .seealso: [](ch:nep), `NEPAppendOptionsPrefix()`, `NEPGetOptionsPrefix()`
1061: @*/
1062: PetscErrorCode NEPSetOptionsPrefix(NEP nep,const char prefix[])
1063: {
1064: PetscFunctionBegin;
1066: if (!nep->V) PetscCall(NEPGetBV(nep,&nep->V));
1067: PetscCall(BVSetOptionsPrefix(nep->V,prefix));
1068: if (!nep->ds) PetscCall(NEPGetDS(nep,&nep->ds));
1069: PetscCall(DSSetOptionsPrefix(nep->ds,prefix));
1070: if (!nep->rg) PetscCall(NEPGetRG(nep,&nep->rg));
1071: PetscCall(RGSetOptionsPrefix(nep->rg,prefix));
1072: PetscCall(PetscObjectSetOptionsPrefix((PetscObject)nep,prefix));
1073: PetscFunctionReturn(PETSC_SUCCESS);
1074: }
1076: /*@
1077: NEPAppendOptionsPrefix - Appends to the prefix used for searching for all
1078: `NEP` options in the database.
1080: Logically Collective
1082: Input Parameters:
1083: + nep - the nonlinear eigensolver context
1084: - prefix - the prefix string to prepend to all `NEP` option requests
1086: Notes:
1087: A hyphen (-) must NOT be given at the beginning of the prefix name.
1088: The first character of all runtime options is AUTOMATICALLY the hyphen.
1090: Level: advanced
1092: .seealso: [](ch:nep), `NEPSetOptionsPrefix()`, `NEPGetOptionsPrefix()`
1093: @*/
1094: PetscErrorCode NEPAppendOptionsPrefix(NEP nep,const char prefix[])
1095: {
1096: PetscFunctionBegin;
1098: if (!nep->V) PetscCall(NEPGetBV(nep,&nep->V));
1099: PetscCall(BVAppendOptionsPrefix(nep->V,prefix));
1100: if (!nep->ds) PetscCall(NEPGetDS(nep,&nep->ds));
1101: PetscCall(DSAppendOptionsPrefix(nep->ds,prefix));
1102: if (!nep->rg) PetscCall(NEPGetRG(nep,&nep->rg));
1103: PetscCall(RGAppendOptionsPrefix(nep->rg,prefix));
1104: PetscCall(PetscObjectAppendOptionsPrefix((PetscObject)nep,prefix));
1105: PetscFunctionReturn(PETSC_SUCCESS);
1106: }
1108: /*@
1109: NEPGetOptionsPrefix - Gets the prefix used for searching for all
1110: `NEP` options in the database.
1112: Not Collective
1114: Input Parameter:
1115: . nep - the nonlinear eigensolver context
1117: Output Parameter:
1118: . prefix - pointer to the prefix string used is returned
1120: Level: advanced
1122: .seealso: [](ch:nep), `NEPSetOptionsPrefix()`, `NEPAppendOptionsPrefix()`
1123: @*/
1124: PetscErrorCode NEPGetOptionsPrefix(NEP nep,const char *prefix[])
1125: {
1126: PetscFunctionBegin;
1128: PetscAssertPointer(prefix,2);
1129: PetscCall(PetscObjectGetOptionsPrefix((PetscObject)nep,prefix));
1130: PetscFunctionReturn(PETSC_SUCCESS);
1131: }