| 519 |
dsic.upv.es!antodo |
1 |
/*
|
|
|
2 |
The basic EPS routines, Create, View, etc. are here.
|
| 1376 |
slepc |
3 |
|
|
|
4 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
5 |
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
|
|
6 |
Copyright (c) 2002-2007, Universidad Politecnica de Valencia, Spain
|
|
|
7 |
|
|
|
8 |
This file is part of SLEPc. See the README file for conditions of use
|
|
|
9 |
and additional information.
|
|
|
10 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 519 |
dsic.upv.es!antodo |
11 |
*/
|
| 1376 |
slepc |
12 |
|
| 1521 |
slepc |
13 |
#include "private/epsimpl.h" /*I "slepceps.h" I*/
|
| 519 |
dsic.upv.es!antodo |
14 |
|
|
|
15 |
PetscFList EPSList = 0;
|
| 842 |
dsic.upv.es!antodo |
16 |
PetscCookie EPS_COOKIE = 0;
|
| 1493 |
slepc |
17 |
PetscLogEvent EPS_SetUp = 0, EPS_Solve = 0, EPS_Dense = 0;
|
| 519 |
dsic.upv.es!antodo |
18 |
|
|
|
19 |
#undef __FUNCT__
|
| 842 |
dsic.upv.es!antodo |
20 |
#define __FUNCT__ "EPSInitializePackage"
|
|
|
21 |
/*@C
|
|
|
22 |
EPSInitializePackage - This function initializes everything in the EPS package. It is called
|
|
|
23 |
from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to EPSCreate()
|
|
|
24 |
when using static libraries.
|
|
|
25 |
|
|
|
26 |
Input Parameter:
|
|
|
27 |
path - The dynamic library path, or PETSC_NULL
|
|
|
28 |
|
|
|
29 |
Level: developer
|
|
|
30 |
|
|
|
31 |
.seealso: SlepcInitialize()
|
|
|
32 |
@*/
|
|
|
33 |
PetscErrorCode EPSInitializePackage(char *path) {
|
|
|
34 |
static PetscTruth initialized = PETSC_FALSE;
|
|
|
35 |
char logList[256];
|
|
|
36 |
char *className;
|
|
|
37 |
PetscTruth opt;
|
|
|
38 |
PetscErrorCode ierr;
|
|
|
39 |
|
|
|
40 |
PetscFunctionBegin;
|
|
|
41 |
if (initialized) PetscFunctionReturn(0);
|
|
|
42 |
initialized = PETSC_TRUE;
|
|
|
43 |
/* Register Classes */
|
| 1493 |
slepc |
44 |
ierr = PetscCookieRegister("Eigenproblem Solver",&EPS_COOKIE);CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
45 |
/* Register Constructors */
|
|
|
46 |
ierr = EPSRegisterAll(path);CHKERRQ(ierr);
|
|
|
47 |
/* Register Events */
|
| 1493 |
slepc |
48 |
ierr = PetscLogEventRegister("EPSSetUp",EPS_COOKIE,&EPS_SetUp);CHKERRQ(ierr);
|
|
|
49 |
ierr = PetscLogEventRegister("EPSSolve",EPS_COOKIE,&EPS_Solve);CHKERRQ(ierr);
|
|
|
50 |
ierr = PetscLogEventRegister("EPSDense",EPS_COOKIE,&EPS_Dense); CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
51 |
/* Process info exclusions */
|
|
|
52 |
ierr = PetscOptionsGetString(PETSC_NULL, "-log_info_exclude", logList, 256, &opt);CHKERRQ(ierr);
|
|
|
53 |
if (opt) {
|
|
|
54 |
ierr = PetscStrstr(logList, "eps", &className);CHKERRQ(ierr);
|
|
|
55 |
if (className) {
|
| 1037 |
slepc |
56 |
ierr = PetscInfoDeactivateClass(EPS_COOKIE);CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
57 |
}
|
|
|
58 |
}
|
|
|
59 |
/* Process summary exclusions */
|
|
|
60 |
ierr = PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
|
|
|
61 |
if (opt) {
|
|
|
62 |
ierr = PetscStrstr(logList, "eps", &className);CHKERRQ(ierr);
|
|
|
63 |
if (className) {
|
|
|
64 |
ierr = PetscLogEventDeactivateClass(EPS_COOKIE);CHKERRQ(ierr);
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
PetscFunctionReturn(0);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
#undef __FUNCT__
|
| 519 |
dsic.upv.es!antodo |
71 |
#define __FUNCT__ "EPSView"
|
|
|
72 |
/*@C
|
|
|
73 |
EPSView - Prints the EPS data structure.
|
|
|
74 |
|
|
|
75 |
Collective on EPS
|
|
|
76 |
|
|
|
77 |
Input Parameters:
|
|
|
78 |
+ eps - the eigenproblem solver context
|
|
|
79 |
- viewer - optional visualization context
|
|
|
80 |
|
|
|
81 |
Options Database Key:
|
|
|
82 |
. -eps_view - Calls EPSView() at end of EPSSolve()
|
|
|
83 |
|
|
|
84 |
Note:
|
|
|
85 |
The available visualization contexts include
|
|
|
86 |
+ PETSC_VIEWER_STDOUT_SELF - standard output (default)
|
|
|
87 |
- PETSC_VIEWER_STDOUT_WORLD - synchronized standard
|
|
|
88 |
output where only the first processor opens
|
|
|
89 |
the file. All other processors send their
|
|
|
90 |
data to the first processor to print.
|
|
|
91 |
|
|
|
92 |
The user can open an alternative visualization context with
|
|
|
93 |
PetscViewerASCIIOpen() - output to a specified file.
|
|
|
94 |
|
|
|
95 |
Level: beginner
|
|
|
96 |
|
|
|
97 |
.seealso: STView(), PetscViewerASCIIOpen()
|
|
|
98 |
@*/
|
|
|
99 |
PetscErrorCode EPSView(EPS eps,PetscViewer viewer)
|
|
|
100 |
{
|
|
|
101 |
PetscErrorCode ierr;
|
| 1507 |
slepc |
102 |
const EPSType type;
|
|
|
103 |
const char *proj, *which;
|
| 1004 |
slepc |
104 |
PetscTruth isascii;
|
| 519 |
dsic.upv.es!antodo |
105 |
|
|
|
106 |
PetscFunctionBegin;
|
|
|
107 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
| 1422 |
slepc |
108 |
if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)eps)->comm);
|
| 519 |
dsic.upv.es!antodo |
109 |
PetscValidHeaderSpecific(viewer,PETSC_VIEWER_COOKIE,2);
|
|
|
110 |
PetscCheckSameComm(eps,1,viewer,2);
|
|
|
111 |
|
|
|
112 |
#if defined(PETSC_USE_COMPLEX)
|
|
|
113 |
#define HERM "hermitian"
|
|
|
114 |
#else
|
|
|
115 |
#define HERM "symmetric"
|
|
|
116 |
#endif
|
|
|
117 |
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
|
|
118 |
if (isascii) {
|
|
|
119 |
ierr = PetscViewerASCIIPrintf(viewer,"EPS Object:\n");CHKERRQ(ierr);
|
|
|
120 |
switch (eps->problem_type) {
|
|
|
121 |
case EPS_HEP: type = HERM " eigenvalue problem"; break;
|
|
|
122 |
case EPS_GHEP: type = "generalized " HERM " eigenvalue problem"; break;
|
|
|
123 |
case EPS_NHEP: type = "non-" HERM " eigenvalue problem"; break;
|
|
|
124 |
case EPS_GNHEP: type = "generalized non-" HERM " eigenvalue problem"; break;
|
|
|
125 |
case 0: type = "not yet set"; break;
|
|
|
126 |
default: SETERRQ(1,"Wrong value of eps->problem_type");
|
|
|
127 |
}
|
|
|
128 |
ierr = PetscViewerASCIIPrintf(viewer," problem type: %s\n",type);CHKERRQ(ierr);
|
|
|
129 |
ierr = EPSGetType(eps,&type);CHKERRQ(ierr);
|
|
|
130 |
if (type) {
|
| 780 |
dsic.upv.es!jroman |
131 |
ierr = PetscViewerASCIIPrintf(viewer," method: %s",type);CHKERRQ(ierr);
|
|
|
132 |
switch (eps->solverclass) {
|
|
|
133 |
case EPS_ONE_SIDE:
|
|
|
134 |
ierr = PetscViewerASCIIPrintf(viewer,"\n",type);CHKERRQ(ierr); break;
|
|
|
135 |
case EPS_TWO_SIDE:
|
|
|
136 |
ierr = PetscViewerASCIIPrintf(viewer," (two-sided)\n",type);CHKERRQ(ierr); break;
|
|
|
137 |
default: SETERRQ(1,"Wrong value of eps->solverclass");
|
|
|
138 |
}
|
| 519 |
dsic.upv.es!antodo |
139 |
} else {
|
|
|
140 |
ierr = PetscViewerASCIIPrintf(viewer," method: not yet set\n");CHKERRQ(ierr);
|
|
|
141 |
}
|
|
|
142 |
if (eps->ops->view) {
|
|
|
143 |
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
|
|
|
144 |
ierr = (*eps->ops->view)(eps,viewer);CHKERRQ(ierr);
|
|
|
145 |
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
|
|
|
146 |
}
|
| 1426 |
slepc |
147 |
if (eps->projection) {
|
|
|
148 |
switch (eps->projection) {
|
|
|
149 |
case EPS_RITZ: proj = "Rayleigh-Ritz"; break;
|
|
|
150 |
case EPS_HARMONIC: proj = "harmonic Ritz"; break;
|
|
|
151 |
case EPS_REFINED: proj = "refined Ritz"; break;
|
|
|
152 |
case EPS_REFINED_HARMONIC: proj = "refined harmonic Ritz"; break;
|
|
|
153 |
default: SETERRQ(1,"Wrong value of eps->projection");
|
|
|
154 |
}
|
|
|
155 |
ierr = PetscViewerASCIIPrintf(viewer," projection type: %s\n",proj);CHKERRQ(ierr);
|
|
|
156 |
}
|
| 1425 |
slepc |
157 |
ierr = PetscViewerASCIIPrintf(viewer," selected portion of the spectrum: ");CHKERRQ(ierr);
|
|
|
158 |
if (eps->target_set) {
|
|
|
159 |
#if !defined(PETSC_USE_COMPLEX)
|
|
|
160 |
ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %g\n",eps->target);CHKERRQ(ierr);
|
|
|
161 |
#else
|
|
|
162 |
ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %g+%g i\n",PetscRealPart(eps->target),PetscImaginaryPart(eps->target));CHKERRQ(ierr);
|
|
|
163 |
#endif
|
|
|
164 |
} else {
|
|
|
165 |
switch (eps->which) {
|
|
|
166 |
case EPS_LARGEST_MAGNITUDE: which = "largest eigenvalues in magnitude"; break;
|
|
|
167 |
case EPS_SMALLEST_MAGNITUDE: which = "smallest eigenvalues in magnitude"; break;
|
|
|
168 |
case EPS_LARGEST_REAL: which = "largest real parts"; break;
|
|
|
169 |
case EPS_SMALLEST_REAL: which = "smallest real parts"; break;
|
|
|
170 |
case EPS_LARGEST_IMAGINARY: which = "largest imaginary parts"; break;
|
|
|
171 |
case EPS_SMALLEST_IMAGINARY: which = "smallest imaginary parts"; break;
|
|
|
172 |
default: SETERRQ(1,"Wrong value of eps->which");
|
|
|
173 |
}
|
|
|
174 |
ierr = PetscViewerASCIIPrintf(viewer,"%s\n",which);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
175 |
}
|
|
|
176 |
ierr = PetscViewerASCIIPrintf(viewer," number of eigenvalues (nev): %d\n",eps->nev);CHKERRQ(ierr);
|
| 600 |
dsic.upv.es!jroman |
177 |
ierr = PetscViewerASCIIPrintf(viewer," number of column vectors (ncv): %d\n",eps->ncv);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
178 |
ierr = PetscViewerASCIIPrintf(viewer," maximum number of iterations: %d\n", eps->max_it);
|
|
|
179 |
ierr = PetscViewerASCIIPrintf(viewer," tolerance: %g\n",eps->tol);CHKERRQ(ierr);
|
|
|
180 |
ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided deflation space: %d\n",eps->nds);CHKERRQ(ierr);
|
|
|
181 |
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
|
| 1345 |
slepc |
182 |
ierr = IPView(eps->ip,viewer); CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
183 |
ierr = STView(eps->OP,viewer); CHKERRQ(ierr);
|
|
|
184 |
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
|
|
|
185 |
} else {
|
|
|
186 |
if (eps->ops->view) {
|
|
|
187 |
ierr = (*eps->ops->view)(eps,viewer);CHKERRQ(ierr);
|
|
|
188 |
}
|
|
|
189 |
ierr = STView(eps->OP,viewer); CHKERRQ(ierr);
|
|
|
190 |
}
|
|
|
191 |
PetscFunctionReturn(0);
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
#undef __FUNCT__
|
|
|
195 |
#define __FUNCT__ "EPSCreate"
|
|
|
196 |
/*@C
|
|
|
197 |
EPSCreate - Creates the default EPS context.
|
|
|
198 |
|
|
|
199 |
Collective on MPI_Comm
|
|
|
200 |
|
|
|
201 |
Input Parameter:
|
|
|
202 |
. comm - MPI communicator
|
|
|
203 |
|
|
|
204 |
Output Parameter:
|
|
|
205 |
. eps - location to put the EPS context
|
|
|
206 |
|
|
|
207 |
Note:
|
| 1198 |
slepc |
208 |
The default EPS type is EPSKRYLOVSCHUR
|
| 519 |
dsic.upv.es!antodo |
209 |
|
|
|
210 |
Level: beginner
|
|
|
211 |
|
|
|
212 |
.seealso: EPSSetUp(), EPSSolve(), EPSDestroy(), EPS
|
|
|
213 |
@*/
|
|
|
214 |
PetscErrorCode EPSCreate(MPI_Comm comm,EPS *outeps)
|
|
|
215 |
{
|
|
|
216 |
PetscErrorCode ierr;
|
|
|
217 |
EPS eps;
|
|
|
218 |
|
|
|
219 |
PetscFunctionBegin;
|
|
|
220 |
PetscValidPointer(outeps,2);
|
|
|
221 |
*outeps = 0;
|
|
|
222 |
|
| 1454 |
slepc |
223 |
ierr = PetscHeaderCreate(eps,_p_EPS,struct _EPSOps,EPS_COOKIE,-1,"EPS",comm,EPSDestroy,EPSView);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
224 |
*outeps = eps;
|
|
|
225 |
|
|
|
226 |
ierr = PetscMemzero(eps->ops,sizeof(struct _EPSOps));CHKERRQ(ierr);
|
|
|
227 |
|
|
|
228 |
eps->max_it = 0;
|
|
|
229 |
eps->nev = 1;
|
|
|
230 |
eps->ncv = 0;
|
|
|
231 |
eps->allocated_ncv = 0;
|
|
|
232 |
eps->nds = 0;
|
| 1282 |
slepc |
233 |
eps->tol = 1e-7;
|
| 519 |
dsic.upv.es!antodo |
234 |
eps->which = EPS_LARGEST_MAGNITUDE;
|
| 1425 |
slepc |
235 |
eps->target = 0.0;
|
|
|
236 |
eps->target_set = PETSC_FALSE;
|
| 519 |
dsic.upv.es!antodo |
237 |
eps->evecsavailable = PETSC_FALSE;
|
|
|
238 |
eps->problem_type = (EPSProblemType)0;
|
| 1426 |
slepc |
239 |
eps->projection = (EPSProjection)0;
|
| 780 |
dsic.upv.es!jroman |
240 |
eps->solverclass = (EPSClass)0;
|
| 519 |
dsic.upv.es!antodo |
241 |
|
| 1385 |
slepc |
242 |
eps->vec_initial = 0;
|
|
|
243 |
eps->vec_initial_left= 0;
|
| 519 |
dsic.upv.es!antodo |
244 |
eps->V = 0;
|
|
|
245 |
eps->AV = 0;
|
| 780 |
dsic.upv.es!jroman |
246 |
eps->W = 0;
|
|
|
247 |
eps->AW = 0;
|
| 519 |
dsic.upv.es!antodo |
248 |
eps->T = 0;
|
|
|
249 |
eps->DS = 0;
|
|
|
250 |
eps->ds_ortho = PETSC_TRUE;
|
|
|
251 |
eps->eigr = 0;
|
|
|
252 |
eps->eigi = 0;
|
|
|
253 |
eps->errest = 0;
|
| 780 |
dsic.upv.es!jroman |
254 |
eps->errest_left = 0;
|
| 519 |
dsic.upv.es!antodo |
255 |
eps->OP = 0;
|
| 1345 |
slepc |
256 |
eps->ip = 0;
|
| 519 |
dsic.upv.es!antodo |
257 |
eps->data = 0;
|
|
|
258 |
eps->nconv = 0;
|
|
|
259 |
eps->its = 0;
|
|
|
260 |
eps->perm = PETSC_NULL;
|
|
|
261 |
|
|
|
262 |
eps->nwork = 0;
|
|
|
263 |
eps->work = 0;
|
|
|
264 |
eps->isgeneralized = PETSC_FALSE;
|
|
|
265 |
eps->ishermitian = PETSC_FALSE;
|
| 1358 |
slepc |
266 |
eps->ispositive = PETSC_FALSE;
|
| 519 |
dsic.upv.es!antodo |
267 |
eps->setupcalled = 0;
|
|
|
268 |
eps->reason = EPS_CONVERGED_ITERATING;
|
|
|
269 |
|
|
|
270 |
eps->numbermonitors = 0;
|
|
|
271 |
|
|
|
272 |
ierr = STCreate(comm,&eps->OP); CHKERRQ(ierr);
|
|
|
273 |
PetscLogObjectParent(eps,eps->OP);
|
| 1345 |
slepc |
274 |
ierr = IPCreate(comm,&eps->ip); CHKERRQ(ierr);
|
| 1422 |
slepc |
275 |
ierr = IPSetOptionsPrefix(eps->ip,((PetscObject)eps)->prefix);
|
| 1345 |
slepc |
276 |
ierr = IPAppendOptionsPrefix(eps->ip,"eps_");
|
|
|
277 |
PetscLogObjectParent(eps,eps->ip);
|
| 519 |
dsic.upv.es!antodo |
278 |
ierr = PetscPublishAll(eps);CHKERRQ(ierr);
|
|
|
279 |
PetscFunctionReturn(0);
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
#undef __FUNCT__
|
|
|
283 |
#define __FUNCT__ "EPSSetType"
|
|
|
284 |
/*@C
|
|
|
285 |
EPSSetType - Selects the particular solver to be used in the EPS object.
|
|
|
286 |
|
|
|
287 |
Collective on EPS
|
|
|
288 |
|
|
|
289 |
Input Parameters:
|
|
|
290 |
+ eps - the eigensolver context
|
|
|
291 |
- type - a known method
|
|
|
292 |
|
|
|
293 |
Options Database Key:
|
|
|
294 |
. -eps_type <method> - Sets the method; use -help for a list
|
|
|
295 |
of available methods
|
|
|
296 |
|
|
|
297 |
Notes:
|
| 545 |
dsic.upv.es!jroman |
298 |
See "slepc/include/slepceps.h" for available methods. The default
|
| 1198 |
slepc |
299 |
is EPSKRYLOVSCHUR.
|
| 519 |
dsic.upv.es!antodo |
300 |
|
|
|
301 |
Normally, it is best to use the EPSSetFromOptions() command and
|
|
|
302 |
then set the EPS type from the options database rather than by using
|
|
|
303 |
this routine. Using the options database provides the user with
|
|
|
304 |
maximum flexibility in evaluating the different available methods.
|
|
|
305 |
The EPSSetType() routine is provided for those situations where it
|
|
|
306 |
is necessary to set the iterative solver independently of the command
|
|
|
307 |
line or options database.
|
|
|
308 |
|
|
|
309 |
Level: intermediate
|
|
|
310 |
|
|
|
311 |
.seealso: STSetType(), EPSType
|
|
|
312 |
@*/
|
| 1502 |
slepc |
313 |
PetscErrorCode EPSSetType(EPS eps,const EPSType type)
|
| 519 |
dsic.upv.es!antodo |
314 |
{
|
|
|
315 |
PetscErrorCode ierr,(*r)(EPS);
|
|
|
316 |
PetscTruth match;
|
|
|
317 |
|
|
|
318 |
PetscFunctionBegin;
|
|
|
319 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
320 |
PetscValidCharPointer(type,2);
|
|
|
321 |
|
|
|
322 |
ierr = PetscTypeCompare((PetscObject)eps,type,&match);CHKERRQ(ierr);
|
|
|
323 |
if (match) PetscFunctionReturn(0);
|
|
|
324 |
|
|
|
325 |
if (eps->data) {
|
|
|
326 |
/* destroy the old private EPS context */
|
|
|
327 |
ierr = (*eps->ops->destroy)(eps); CHKERRQ(ierr);
|
|
|
328 |
eps->data = 0;
|
|
|
329 |
}
|
|
|
330 |
|
| 1422 |
slepc |
331 |
ierr = PetscFListFind(EPSList,((PetscObject)eps)->comm,type,(void (**)(void)) &r);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
332 |
|
|
|
333 |
if (!r) SETERRQ1(1,"Unknown EPS type given: %s",type);
|
|
|
334 |
|
|
|
335 |
eps->setupcalled = 0;
|
|
|
336 |
ierr = PetscMemzero(eps->ops,sizeof(struct _EPSOps));CHKERRQ(ierr);
|
|
|
337 |
ierr = (*r)(eps); CHKERRQ(ierr);
|
|
|
338 |
|
|
|
339 |
ierr = PetscObjectChangeTypeName((PetscObject)eps,type);CHKERRQ(ierr);
|
|
|
340 |
PetscFunctionReturn(0);
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
#undef __FUNCT__
|
|
|
344 |
#define __FUNCT__ "EPSGetType"
|
|
|
345 |
/*@C
|
|
|
346 |
EPSGetType - Gets the EPS type as a string from the EPS object.
|
|
|
347 |
|
|
|
348 |
Not Collective
|
|
|
349 |
|
|
|
350 |
Input Parameter:
|
|
|
351 |
. eps - the eigensolver context
|
|
|
352 |
|
|
|
353 |
Output Parameter:
|
|
|
354 |
. name - name of EPS method
|
|
|
355 |
|
|
|
356 |
Level: intermediate
|
|
|
357 |
|
|
|
358 |
.seealso: EPSSetType()
|
|
|
359 |
@*/
|
| 1501 |
slepc |
360 |
PetscErrorCode EPSGetType(EPS eps,const EPSType *type)
|
| 519 |
dsic.upv.es!antodo |
361 |
{
|
|
|
362 |
PetscFunctionBegin;
|
|
|
363 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
| 1501 |
slepc |
364 |
PetscValidPointer(type,2);
|
| 1422 |
slepc |
365 |
*type = ((PetscObject)eps)->type_name;
|
| 519 |
dsic.upv.es!antodo |
366 |
PetscFunctionReturn(0);
|
|
|
367 |
}
|
|
|
368 |
|
|
|
369 |
/*MC
|
|
|
370 |
EPSRegisterDynamic - Adds a method to the eigenproblem solver package.
|
|
|
371 |
|
|
|
372 |
Synopsis:
|
| 1509 |
slepc |
373 |
EPSRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(EPS))
|
| 519 |
dsic.upv.es!antodo |
374 |
|
|
|
375 |
Not Collective
|
|
|
376 |
|
|
|
377 |
Input Parameters:
|
|
|
378 |
+ name_solver - name of a new user-defined solver
|
|
|
379 |
. path - path (either absolute or relative) the library containing this solver
|
|
|
380 |
. name_create - name of routine to create the solver context
|
|
|
381 |
- routine_create - routine to create the solver context
|
|
|
382 |
|
|
|
383 |
Notes:
|
|
|
384 |
EPSRegisterDynamic() may be called multiple times to add several user-defined solvers.
|
|
|
385 |
|
|
|
386 |
If dynamic libraries are used, then the fourth input argument (routine_create)
|
|
|
387 |
is ignored.
|
|
|
388 |
|
|
|
389 |
Sample usage:
|
|
|
390 |
.vb
|
|
|
391 |
EPSRegisterDynamic("my_solver",/home/username/my_lib/lib/libO/solaris/mylib.a,
|
|
|
392 |
"MySolverCreate",MySolverCreate);
|
|
|
393 |
.ve
|
|
|
394 |
|
|
|
395 |
Then, your solver can be chosen with the procedural interface via
|
|
|
396 |
$ EPSSetType(eps,"my_solver")
|
|
|
397 |
or at runtime via the option
|
|
|
398 |
$ -eps_type my_solver
|
|
|
399 |
|
|
|
400 |
Level: advanced
|
|
|
401 |
|
| 1389 |
slepc |
402 |
Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
|
| 519 |
dsic.upv.es!antodo |
403 |
and others of the form ${any_environmental_variable} occuring in pathname will be
|
|
|
404 |
replaced with appropriate values.
|
|
|
405 |
|
| 1389 |
slepc |
406 |
.seealso: EPSRegisterDestroy(), EPSRegisterAll()
|
| 519 |
dsic.upv.es!antodo |
407 |
|
|
|
408 |
M*/
|
|
|
409 |
|
|
|
410 |
#undef __FUNCT__
|
|
|
411 |
#define __FUNCT__ "EPSRegister"
|
| 1389 |
slepc |
412 |
/*@C
|
|
|
413 |
EPSRegister - See EPSRegisterDynamic()
|
|
|
414 |
|
|
|
415 |
Level: advanced
|
|
|
416 |
@*/
|
| 1509 |
slepc |
417 |
PetscErrorCode EPSRegister(const char *sname,const char *path,const char *name,PetscErrorCode (*function)(EPS))
|
| 519 |
dsic.upv.es!antodo |
418 |
{
|
|
|
419 |
PetscErrorCode ierr;
|
|
|
420 |
char fullname[256];
|
|
|
421 |
|
|
|
422 |
PetscFunctionBegin;
|
|
|
423 |
ierr = PetscFListConcat(path,name,fullname);CHKERRQ(ierr);
|
|
|
424 |
ierr = PetscFListAdd(&EPSList,sname,fullname,(void (*)(void))function);CHKERRQ(ierr);
|
|
|
425 |
PetscFunctionReturn(0);
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
#undef __FUNCT__
|
| 1389 |
slepc |
429 |
#define __FUNCT__ "EPSRegisterDestroy"
|
|
|
430 |
/*@
|
|
|
431 |
EPSRegisterDestroy - Frees the list of EPS methods that were
|
|
|
432 |
registered by EPSRegisterDynamic().
|
|
|
433 |
|
|
|
434 |
Not Collective
|
|
|
435 |
|
|
|
436 |
Level: advanced
|
|
|
437 |
|
|
|
438 |
.seealso: EPSRegisterDynamic(), EPSRegisterAll()
|
|
|
439 |
@*/
|
|
|
440 |
PetscErrorCode EPSRegisterDestroy(void)
|
|
|
441 |
{
|
|
|
442 |
PetscErrorCode ierr;
|
|
|
443 |
|
|
|
444 |
PetscFunctionBegin;
|
|
|
445 |
ierr = PetscFListDestroy(&EPSList);CHKERRQ(ierr);
|
|
|
446 |
ierr = EPSRegisterAll(PETSC_NULL);CHKERRQ(ierr);
|
|
|
447 |
PetscFunctionReturn(0);
|
|
|
448 |
}
|
|
|
449 |
|
|
|
450 |
#undef __FUNCT__
|
| 519 |
dsic.upv.es!antodo |
451 |
#define __FUNCT__ "EPSDestroy"
|
|
|
452 |
/*@
|
|
|
453 |
EPSDestroy - Destroys the EPS context.
|
|
|
454 |
|
|
|
455 |
Collective on EPS
|
|
|
456 |
|
|
|
457 |
Input Parameter:
|
|
|
458 |
. eps - eigensolver context obtained from EPSCreate()
|
|
|
459 |
|
|
|
460 |
Level: beginner
|
|
|
461 |
|
|
|
462 |
.seealso: EPSCreate(), EPSSetUp(), EPSSolve()
|
|
|
463 |
@*/
|
|
|
464 |
PetscErrorCode EPSDestroy(EPS eps)
|
|
|
465 |
{
|
|
|
466 |
PetscErrorCode ierr;
|
|
|
467 |
|
|
|
468 |
PetscFunctionBegin;
|
|
|
469 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
| 1422 |
slepc |
470 |
if (--((PetscObject)eps)->refct > 0) PetscFunctionReturn(0);
|
| 519 |
dsic.upv.es!antodo |
471 |
|
|
|
472 |
/* if memory was published with AMS then destroy it */
|
|
|
473 |
ierr = PetscObjectDepublish(eps);CHKERRQ(ierr);
|
|
|
474 |
|
|
|
475 |
ierr = STDestroy(eps->OP);CHKERRQ(ierr);
|
| 1345 |
slepc |
476 |
ierr = IPDestroy(eps->ip);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
477 |
|
|
|
478 |
if (eps->ops->destroy) {
|
|
|
479 |
ierr = (*eps->ops->destroy)(eps); CHKERRQ(ierr);
|
|
|
480 |
}
|
|
|
481 |
|
| 1040 |
slepc |
482 |
ierr = PetscFree(eps->T);CHKERRQ(ierr);
|
|
|
483 |
ierr = PetscFree(eps->Tl);CHKERRQ(ierr);
|
|
|
484 |
ierr = PetscFree(eps->perm);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
485 |
|
| 1385 |
slepc |
486 |
if (eps->vec_initial) {
|
|
|
487 |
ierr = VecDestroy(eps->vec_initial);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
488 |
}
|
|
|
489 |
|
| 1385 |
slepc |
490 |
if (eps->vec_initial_left) {
|
|
|
491 |
ierr = VecDestroy(eps->vec_initial_left);CHKERRQ(ierr);
|
| 780 |
dsic.upv.es!jroman |
492 |
}
|
|
|
493 |
|
| 519 |
dsic.upv.es!antodo |
494 |
if (eps->nds > 0) {
|
| 1343 |
slepc |
495 |
ierr = VecDestroyVecs(eps->DS, eps->nds);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
496 |
}
|
|
|
497 |
|
| 1040 |
slepc |
498 |
ierr = PetscFree(eps->DSV);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
499 |
|
| 1331 |
slepc |
500 |
ierr = EPSMonitorCancel(eps);CHKERRQ(ierr);
|
| 1287 |
slepc |
501 |
|
| 519 |
dsic.upv.es!antodo |
502 |
PetscHeaderDestroy(eps);
|
|
|
503 |
PetscFunctionReturn(0);
|
|
|
504 |
}
|
|
|
505 |
|
|
|
506 |
#undef __FUNCT__
|
| 1425 |
slepc |
507 |
#define __FUNCT__ "EPSSetTarget"
|
|
|
508 |
/*@
|
|
|
509 |
EPSSetTarget - Sets the value of the target.
|
|
|
510 |
|
|
|
511 |
Not collective
|
|
|
512 |
|
|
|
513 |
Input Parameters:
|
|
|
514 |
+ eps - eigensolver context
|
|
|
515 |
- target - the value of the target
|
|
|
516 |
|
|
|
517 |
Notes:
|
|
|
518 |
The target is a scalar value used to determine the portion of the spectrum
|
|
|
519 |
of interest.
|
|
|
520 |
|
|
|
521 |
If the target is not specified, then eigenvalues are computed according to
|
|
|
522 |
the which parameter (see EPSSetWhichEigenpairs()).
|
|
|
523 |
|
|
|
524 |
If the target is specified, then the sought-after eigenvalues are those
|
|
|
525 |
closest to the target.
|
|
|
526 |
|
|
|
527 |
Level: beginner
|
|
|
528 |
|
|
|
529 |
.seealso: EPSGetTarget(), EPSSetWhichEigenpairs()
|
|
|
530 |
@*/
|
|
|
531 |
PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target)
|
|
|
532 |
{
|
|
|
533 |
PetscFunctionBegin;
|
|
|
534 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
535 |
eps->target = target;
|
|
|
536 |
eps->target_set = PETSC_TRUE;
|
|
|
537 |
PetscFunctionReturn(0);
|
|
|
538 |
}
|
|
|
539 |
|
|
|
540 |
#undef __FUNCT__
|
|
|
541 |
#define __FUNCT__ "EPSGetTarget"
|
|
|
542 |
/*@
|
|
|
543 |
EPSGetTarget - Gets the value of the target.
|
|
|
544 |
|
|
|
545 |
Not collective
|
|
|
546 |
|
|
|
547 |
Input Parameter:
|
|
|
548 |
. eps - eigensolver context
|
|
|
549 |
|
|
|
550 |
Output Parameter:
|
|
|
551 |
. target - the value of the target
|
|
|
552 |
|
|
|
553 |
Level: beginner
|
|
|
554 |
|
|
|
555 |
Note:
|
|
|
556 |
If the target was not set by the user, then zero is returned.
|
|
|
557 |
|
|
|
558 |
.seealso: EPSSetTarget()
|
|
|
559 |
@*/
|
|
|
560 |
PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target)
|
|
|
561 |
{
|
|
|
562 |
PetscFunctionBegin;
|
|
|
563 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
564 |
if (target) {
|
|
|
565 |
if (eps->target_set) *target = eps->target;
|
|
|
566 |
else *target = 0.0;
|
|
|
567 |
}
|
|
|
568 |
PetscFunctionReturn(0);
|
|
|
569 |
}
|
|
|
570 |
|
|
|
571 |
#undef __FUNCT__
|
| 519 |
dsic.upv.es!antodo |
572 |
#define __FUNCT__ "EPSSetST"
|
|
|
573 |
/*@
|
|
|
574 |
EPSSetST - Associates a spectral transformation object to the
|
|
|
575 |
eigensolver.
|
|
|
576 |
|
|
|
577 |
Collective on EPS
|
|
|
578 |
|
|
|
579 |
Input Parameters:
|
|
|
580 |
+ eps - eigensolver context obtained from EPSCreate()
|
|
|
581 |
- st - the spectral transformation object
|
|
|
582 |
|
|
|
583 |
Note:
|
|
|
584 |
Use EPSGetST() to retrieve the spectral transformation context (for example,
|
|
|
585 |
to free it at the end of the computations).
|
|
|
586 |
|
|
|
587 |
Level: advanced
|
|
|
588 |
|
|
|
589 |
.seealso: EPSGetST()
|
|
|
590 |
@*/
|
|
|
591 |
PetscErrorCode EPSSetST(EPS eps,ST st)
|
|
|
592 |
{
|
|
|
593 |
PetscErrorCode ierr;
|
|
|
594 |
|
|
|
595 |
PetscFunctionBegin;
|
|
|
596 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
597 |
PetscValidHeaderSpecific(st,ST_COOKIE,2);
|
|
|
598 |
PetscCheckSameComm(eps,1,st,2);
|
| 1345 |
slepc |
599 |
ierr = PetscObjectReference((PetscObject)st);CHKERRQ(ierr);
|
| 519 |
dsic.upv.es!antodo |
600 |
ierr = STDestroy(eps->OP); CHKERRQ(ierr);
|
|
|
601 |
eps->OP = st;
|
|
|
602 |
PetscFunctionReturn(0);
|
|
|
603 |
}
|
|
|
604 |
|
|
|
605 |
#undef __FUNCT__
|
|
|
606 |
#define __FUNCT__ "EPSGetST"
|
| 707 |
dsic.upv.es!antodo |
607 |
/*@C
|
| 519 |
dsic.upv.es!antodo |
608 |
EPSGetST - Obtain the spectral transformation (ST) object associated
|
|
|
609 |
to the eigensolver object.
|
|
|
610 |
|
|
|
611 |
Not Collective
|
|
|
612 |
|
|
|
613 |
Input Parameters:
|
|
|
614 |
. eps - eigensolver context obtained from EPSCreate()
|
|
|
615 |
|
|
|
616 |
Output Parameter:
|
|
|
617 |
. st - spectral transformation context
|
|
|
618 |
|
|
|
619 |
Level: beginner
|
|
|
620 |
|
|
|
621 |
.seealso: EPSSetST()
|
|
|
622 |
@*/
|
|
|
623 |
PetscErrorCode EPSGetST(EPS eps, ST *st)
|
|
|
624 |
{
|
|
|
625 |
PetscFunctionBegin;
|
|
|
626 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
| 1248 |
slepc |
627 |
PetscValidPointer(st,2);
|
| 519 |
dsic.upv.es!antodo |
628 |
*st = eps->OP;
|
|
|
629 |
PetscFunctionReturn(0);
|
|
|
630 |
}
|
|
|
631 |
|
|
|
632 |
#undef __FUNCT__
|
| 1345 |
slepc |
633 |
#define __FUNCT__ "EPSSetIP"
|
|
|
634 |
/*@
|
| 1349 |
slepc |
635 |
EPSSetIP - Associates an inner product object to the
|
| 1345 |
slepc |
636 |
eigensolver.
|
|
|
637 |
|
|
|
638 |
Collective on EPS
|
|
|
639 |
|
|
|
640 |
Input Parameters:
|
|
|
641 |
+ eps - eigensolver context obtained from EPSCreate()
|
|
|
642 |
- ip - the inner product object
|
|
|
643 |
|
|
|
644 |
Note:
|
|
|
645 |
Use EPSGetIP() to retrieve the inner product context (for example,
|
|
|
646 |
to free it at the end of the computations).
|
|
|
647 |
|
|
|
648 |
Level: advanced
|
|
|
649 |
|
|
|
650 |
.seealso: EPSGetIP()
|
|
|
651 |
@*/
|
|
|
652 |
PetscErrorCode EPSSetIP(EPS eps,IP ip)
|
|
|
653 |
{
|
|
|
654 |
PetscErrorCode ierr;
|
|
|
655 |
|
|
|
656 |
PetscFunctionBegin;
|
|
|
657 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
658 |
PetscValidHeaderSpecific(ip,IP_COOKIE,2);
|
|
|
659 |
PetscCheckSameComm(eps,1,ip,2);
|
|
|
660 |
ierr = PetscObjectReference((PetscObject)ip);CHKERRQ(ierr);
|
|
|
661 |
ierr = IPDestroy(eps->ip); CHKERRQ(ierr);
|
|
|
662 |
eps->ip = ip;
|
|
|
663 |
PetscFunctionReturn(0);
|
|
|
664 |
}
|
|
|
665 |
|
|
|
666 |
#undef __FUNCT__
|
|
|
667 |
#define __FUNCT__ "EPSGetIP"
|
|
|
668 |
/*@C
|
|
|
669 |
EPSGetIP - Obtain the inner product object associated
|
|
|
670 |
to the eigensolver object.
|
|
|
671 |
|
|
|
672 |
Not Collective
|
|
|
673 |
|
|
|
674 |
Input Parameters:
|
|
|
675 |
. eps - eigensolver context obtained from EPSCreate()
|
|
|
676 |
|
|
|
677 |
Output Parameter:
|
|
|
678 |
. ip - inner product context
|
|
|
679 |
|
| 1349 |
slepc |
680 |
Level: advanced
|
| 1345 |
slepc |
681 |
|
|
|
682 |
.seealso: EPSSetIP()
|
|
|
683 |
@*/
|
|
|
684 |
PetscErrorCode EPSGetIP(EPS eps,IP *ip)
|
|
|
685 |
{
|
|
|
686 |
PetscFunctionBegin;
|
|
|
687 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
688 |
PetscValidPointer(ip,2);
|
|
|
689 |
*ip = eps->ip;
|
|
|
690 |
PetscFunctionReturn(0);
|
|
|
691 |
}
|
|
|
692 |
|
|
|
693 |
#undef __FUNCT__
|
| 519 |
dsic.upv.es!antodo |
694 |
#define __FUNCT__ "EPSIsGeneralized"
|
|
|
695 |
/*@
|
|
|
696 |
EPSIsGeneralized - Ask if the EPS object corresponds to a generalized
|
|
|
697 |
eigenvalue problem.
|
|
|
698 |
|
|
|
699 |
Not collective
|
|
|
700 |
|
|
|
701 |
Input Parameter:
|
|
|
702 |
. eps - the eigenproblem solver context
|
|
|
703 |
|
|
|
704 |
Output Parameter:
|
|
|
705 |
. is - the answer
|
|
|
706 |
|
|
|
707 |
Level: intermediate
|
|
|
708 |
|
|
|
709 |
@*/
|
|
|
710 |
PetscErrorCode EPSIsGeneralized(EPS eps,PetscTruth* is)
|
|
|
711 |
{
|
|
|
712 |
PetscErrorCode ierr;
|
|
|
713 |
Mat B;
|
|
|
714 |
|
|
|
715 |
PetscFunctionBegin;
|
|
|
716 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
717 |
ierr = STGetOperators(eps->OP,PETSC_NULL,&B);CHKERRQ(ierr);
|
|
|
718 |
if( B ) *is = PETSC_TRUE;
|
|
|
719 |
else *is = PETSC_FALSE;
|
|
|
720 |
if( eps->setupcalled ) {
|
|
|
721 |
if( eps->isgeneralized != *is ) {
|
|
|
722 |
SETERRQ(0,"Warning: Inconsistent EPS state");
|
|
|
723 |
}
|
|
|
724 |
}
|
|
|
725 |
PetscFunctionReturn(0);
|
|
|
726 |
}
|
|
|
727 |
|
|
|
728 |
#undef __FUNCT__
|
|
|
729 |
#define __FUNCT__ "EPSIsHermitian"
|
|
|
730 |
/*@
|
|
|
731 |
EPSIsHermitian - Ask if the EPS object corresponds to a Hermitian
|
|
|
732 |
eigenvalue problem.
|
|
|
733 |
|
|
|
734 |
Not collective
|
|
|
735 |
|
|
|
736 |
Input Parameter:
|
|
|
737 |
. eps - the eigenproblem solver context
|
|
|
738 |
|
|
|
739 |
Output Parameter:
|
|
|
740 |
. is - the answer
|
|
|
741 |
|
|
|
742 |
Level: intermediate
|
|
|
743 |
|
|
|
744 |
@*/
|
|
|
745 |
PetscErrorCode EPSIsHermitian(EPS eps,PetscTruth* is)
|
|
|
746 |
{
|
|
|
747 |
PetscFunctionBegin;
|
|
|
748 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
749 |
if( eps->ishermitian ) *is = PETSC_TRUE;
|
|
|
750 |
else *is = PETSC_FALSE;
|
|
|
751 |
PetscFunctionReturn(0);
|
|
|
752 |
}
|