| 6 |
dsic.upv.es!jroman |
1 |
/*
|
|
|
2 |
The ST (spectral transformation) interface routines, callable by users.
|
| 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 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 6 |
dsic.upv.es!jroman |
11 |
*/
|
|
|
12 |
|
|
|
13 |
#include "src/st/stimpl.h" /*I "slepcst.h" I*/
|
|
|
14 |
|
| 842 |
dsic.upv.es!antodo |
15 |
PetscCookie ST_COOKIE = 0;
|
| 1493 |
slepc |
16 |
PetscLogEvent ST_SetUp = 0, ST_Apply = 0, ST_ApplyTranspose = 0;
|
| 842 |
dsic.upv.es!antodo |
17 |
|
| 6 |
dsic.upv.es!jroman |
18 |
#undef __FUNCT__
|
| 842 |
dsic.upv.es!antodo |
19 |
#define __FUNCT__ "STInitializePackage"
|
|
|
20 |
/*@C
|
|
|
21 |
STInitializePackage - This function initializes everything in the ST package. It is called
|
|
|
22 |
from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to STCreate()
|
|
|
23 |
when using static libraries.
|
|
|
24 |
|
|
|
25 |
Input Parameter:
|
|
|
26 |
path - The dynamic library path, or PETSC_NULL
|
|
|
27 |
|
|
|
28 |
Level: developer
|
|
|
29 |
|
|
|
30 |
.seealso: SlepcInitialize()
|
|
|
31 |
@*/
|
|
|
32 |
PetscErrorCode STInitializePackage(char *path) {
|
|
|
33 |
static PetscTruth initialized = PETSC_FALSE;
|
|
|
34 |
char logList[256];
|
|
|
35 |
char *className;
|
|
|
36 |
PetscTruth opt;
|
|
|
37 |
PetscErrorCode ierr;
|
|
|
38 |
|
|
|
39 |
PetscFunctionBegin;
|
|
|
40 |
if (initialized) PetscFunctionReturn(0);
|
|
|
41 |
initialized = PETSC_TRUE;
|
|
|
42 |
/* Register Classes */
|
| 1493 |
slepc |
43 |
ierr = PetscCookieRegister("Spectral Transform",&ST_COOKIE);CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
44 |
/* Register Constructors */
|
|
|
45 |
ierr = STRegisterAll(path);CHKERRQ(ierr);
|
|
|
46 |
/* Register Events */
|
| 1493 |
slepc |
47 |
ierr = PetscLogEventRegister("STSetUp",ST_COOKIE,&ST_SetUp);CHKERRQ(ierr);
|
|
|
48 |
ierr = PetscLogEventRegister("STApply",ST_COOKIE,&ST_Apply);CHKERRQ(ierr);
|
|
|
49 |
ierr = PetscLogEventRegister("STApplyTranspose",ST_COOKIE,&ST_ApplyTranspose); CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
50 |
/* Process info exclusions */
|
|
|
51 |
ierr = PetscOptionsGetString(PETSC_NULL, "-log_info_exclude", logList, 256, &opt);CHKERRQ(ierr);
|
|
|
52 |
if (opt) {
|
|
|
53 |
ierr = PetscStrstr(logList, "st", &className);CHKERRQ(ierr);
|
|
|
54 |
if (className) {
|
| 1037 |
slepc |
55 |
ierr = PetscInfoDeactivateClass(ST_COOKIE);CHKERRQ(ierr);
|
| 842 |
dsic.upv.es!antodo |
56 |
}
|
|
|
57 |
}
|
|
|
58 |
/* Process summary exclusions */
|
|
|
59 |
ierr = PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
|
|
|
60 |
if (opt) {
|
|
|
61 |
ierr = PetscStrstr(logList, "st", &className);CHKERRQ(ierr);
|
|
|
62 |
if (className) {
|
|
|
63 |
ierr = PetscLogEventDeactivateClass(ST_COOKIE);CHKERRQ(ierr);
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
PetscFunctionReturn(0);
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
70 |
#define __FUNCT__ "STDestroy"
|
| 1345 |
slepc |
71 |
/*@
|
| 6 |
dsic.upv.es!jroman |
72 |
STDestroy - Destroys ST context that was created with STCreate().
|
|
|
73 |
|
|
|
74 |
Collective on ST
|
|
|
75 |
|
|
|
76 |
Input Parameter:
|
|
|
77 |
. st - the spectral transformation context
|
|
|
78 |
|
|
|
79 |
Level: beginner
|
|
|
80 |
|
|
|
81 |
.seealso: STCreate(), STSetUp()
|
|
|
82 |
@*/
|
| 476 |
dsic.upv.es!antodo |
83 |
PetscErrorCode STDestroy(ST st)
|
| 6 |
dsic.upv.es!jroman |
84 |
{
|
| 476 |
dsic.upv.es!antodo |
85 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
86 |
|
|
|
87 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
88 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
| 1422 |
slepc |
89 |
if (--((PetscObject)st)->refct > 0) PetscFunctionReturn(0);
|
| 6 |
dsic.upv.es!jroman |
90 |
|
|
|
91 |
/* if memory was published with AMS then destroy it */
|
|
|
92 |
ierr = PetscObjectDepublish(st);CHKERRQ(ierr);
|
|
|
93 |
|
|
|
94 |
if (st->ops->destroy) { ierr = (*st->ops->destroy)(st);CHKERRQ(ierr); }
|
| 18 |
dsic.upv.es!jroman |
95 |
if (st->ksp) { ierr = KSPDestroy(st->ksp);CHKERRQ(ierr); }
|
| 344 |
dsic.upv.es!antodo |
96 |
if (st->w) { ierr = VecDestroy(st->w);CHKERRQ(ierr); }
|
|
|
97 |
if (st->shift_matrix != STMATMODE_INPLACE && st->mat) {
|
|
|
98 |
ierr = MatDestroy(st->mat);CHKERRQ(ierr);
|
|
|
99 |
}
|
| 6 |
dsic.upv.es!jroman |
100 |
|
|
|
101 |
PetscHeaderDestroy(st);
|
|
|
102 |
PetscFunctionReturn(0);
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
#undef __FUNCT__
|
|
|
106 |
#define __FUNCT__ "STCreate"
|
|
|
107 |
/*@C
|
|
|
108 |
STCreate - Creates a spectral transformation context.
|
|
|
109 |
|
|
|
110 |
Collective on MPI_Comm
|
|
|
111 |
|
|
|
112 |
Input Parameter:
|
|
|
113 |
. comm - MPI communicator
|
|
|
114 |
|
|
|
115 |
Output Parameter:
|
|
|
116 |
. st - location to put the spectral transformation context
|
|
|
117 |
|
|
|
118 |
Level: beginner
|
|
|
119 |
|
| 1364 |
slepc |
120 |
.seealso: STSetUp(), STApply(), STDestroy(), ST
|
| 6 |
dsic.upv.es!jroman |
121 |
@*/
|
| 476 |
dsic.upv.es!antodo |
122 |
PetscErrorCode STCreate(MPI_Comm comm,ST *newst)
|
| 6 |
dsic.upv.es!jroman |
123 |
{
|
| 476 |
dsic.upv.es!antodo |
124 |
PetscErrorCode ierr;
|
|
|
125 |
ST st;
|
| 812 |
dsic.upv.es!antodo |
126 |
const char *prefix;
|
| 6 |
dsic.upv.es!jroman |
127 |
|
|
|
128 |
PetscFunctionBegin;
|
| 476 |
dsic.upv.es!antodo |
129 |
PetscValidPointer(newst,2);
|
| 6 |
dsic.upv.es!jroman |
130 |
*newst = 0;
|
|
|
131 |
|
| 1454 |
slepc |
132 |
ierr = PetscHeaderCreate(st,_p_ST,struct _STOps,ST_COOKIE,-1,"ST",comm,STDestroy,STView);CHKERRQ(ierr);
|
| 337 |
dsic.upv.es!antodo |
133 |
ierr = PetscMemzero(st->ops,sizeof(struct _STOps));CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
134 |
|
|
|
135 |
st->A = 0;
|
|
|
136 |
st->B = 0;
|
| 110 |
dsic.upv.es!antodo |
137 |
st->sigma = 0.0;
|
| 6 |
dsic.upv.es!jroman |
138 |
st->data = 0;
|
|
|
139 |
st->setupcalled = 0;
|
| 344 |
dsic.upv.es!antodo |
140 |
st->w = 0;
|
|
|
141 |
st->shift_matrix = STMATMODE_COPY;
|
|
|
142 |
st->str = DIFFERENT_NONZERO_PATTERN;
|
| 246 |
dsic.upv.es!antodo |
143 |
|
| 1422 |
slepc |
144 |
ierr = KSPCreate(((PetscObject)st)->comm,&st->ksp);CHKERRQ(ierr);
|
| 246 |
dsic.upv.es!antodo |
145 |
ierr = STGetOptionsPrefix(st,&prefix);CHKERRQ(ierr);
|
|
|
146 |
ierr = KSPSetOptionsPrefix(st->ksp,prefix);CHKERRQ(ierr);
|
|
|
147 |
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
|
|
148 |
|
| 6 |
dsic.upv.es!jroman |
149 |
*newst = st;
|
|
|
150 |
ierr = PetscPublishAll(st);CHKERRQ(ierr);
|
|
|
151 |
PetscFunctionReturn(0);
|
|
|
152 |
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
#undef __FUNCT__
|
|
|
156 |
#define __FUNCT__ "STSetOperators"
|
|
|
157 |
/*@
|
|
|
158 |
STSetOperators - Sets the matrices associated with the eigenvalue problem.
|
|
|
159 |
|
|
|
160 |
Collective on ST and Mat
|
|
|
161 |
|
|
|
162 |
Input Parameters:
|
|
|
163 |
+ st - the spectral transformation context
|
|
|
164 |
. A - the matrix associated with the eigensystem
|
|
|
165 |
- B - the second matrix in the case of generalized eigenproblems
|
|
|
166 |
|
|
|
167 |
Notes:
|
|
|
168 |
To specify a standard eigenproblem, use PETSC_NULL for B.
|
|
|
169 |
|
|
|
170 |
Level: intermediate
|
|
|
171 |
|
|
|
172 |
.seealso: STGetOperators()
|
|
|
173 |
@*/
|
| 476 |
dsic.upv.es!antodo |
174 |
PetscErrorCode STSetOperators(ST st,Mat A,Mat B)
|
| 6 |
dsic.upv.es!jroman |
175 |
{
|
|
|
176 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
177 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
|
|
178 |
PetscValidHeaderSpecific(A,MAT_COOKIE,2);
|
|
|
179 |
if (B) PetscValidHeaderSpecific(B,MAT_COOKIE,3);
|
| 1014 |
slepc |
180 |
PetscCheckSameComm(st,1,A,2);
|
|
|
181 |
if (B) PetscCheckSameComm(st,1,B,3);
|
| 6 |
dsic.upv.es!jroman |
182 |
st->A = A;
|
|
|
183 |
st->B = B;
|
|
|
184 |
st->setupcalled = 0;
|
|
|
185 |
PetscFunctionReturn(0);
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
#undef __FUNCT__
|
|
|
189 |
#define __FUNCT__ "STGetOperators"
|
|
|
190 |
/*@C
|
|
|
191 |
STGetOperators - Gets the matrices associated with the eigensystem.
|
|
|
192 |
|
|
|
193 |
Not collective, though parallel Mats are returned if the ST is parallel
|
|
|
194 |
|
|
|
195 |
Input Parameter:
|
|
|
196 |
. st - the spectral transformation context
|
|
|
197 |
|
|
|
198 |
Output Parameters:
|
|
|
199 |
. A - the matrix associated with the eigensystem
|
|
|
200 |
- B - the second matrix in the case of generalized eigenproblems
|
|
|
201 |
|
|
|
202 |
Level: intermediate
|
|
|
203 |
|
|
|
204 |
.seealso: STSetOperators()
|
|
|
205 |
@*/
|
| 476 |
dsic.upv.es!antodo |
206 |
PetscErrorCode STGetOperators(ST st,Mat *A,Mat *B)
|
| 6 |
dsic.upv.es!jroman |
207 |
{
|
|
|
208 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
209 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
| 6 |
dsic.upv.es!jroman |
210 |
if (A) *A = st->A;
|
|
|
211 |
if (B) *B = st->B;
|
|
|
212 |
PetscFunctionReturn(0);
|
|
|
213 |
}
|
|
|
214 |
|
|
|
215 |
#undef __FUNCT__
|
|
|
216 |
#define __FUNCT__ "STSetShift"
|
|
|
217 |
/*@
|
|
|
218 |
STSetShift - Sets the shift associated with the spectral transformation
|
|
|
219 |
|
|
|
220 |
Not collective
|
|
|
221 |
|
|
|
222 |
Input Parameters:
|
|
|
223 |
+ st - the spectral transformation context
|
|
|
224 |
- shift - the value of the shift
|
|
|
225 |
|
|
|
226 |
Note:
|
|
|
227 |
In some spectral transformations, changing the shift may have associated
|
|
|
228 |
a lot of work, for example recomputing a factorization.
|
|
|
229 |
|
|
|
230 |
Level: beginner
|
|
|
231 |
|
|
|
232 |
@*/
|
| 476 |
dsic.upv.es!antodo |
233 |
PetscErrorCode STSetShift(ST st,PetscScalar shift)
|
| 6 |
dsic.upv.es!jroman |
234 |
{
|
| 476 |
dsic.upv.es!antodo |
235 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
236 |
|
|
|
237 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
238 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
| 6 |
dsic.upv.es!jroman |
239 |
if (st->sigma != shift) {
|
|
|
240 |
if (st->ops->setshift) {
|
|
|
241 |
ierr = (*st->ops->setshift)(st,shift); CHKERRQ(ierr);
|
|
|
242 |
}
|
|
|
243 |
}
|
|
|
244 |
st->sigma = shift;
|
|
|
245 |
PetscFunctionReturn(0);
|
|
|
246 |
}
|
|
|
247 |
|
|
|
248 |
#undef __FUNCT__
|
|
|
249 |
#define __FUNCT__ "STGetShift"
|
|
|
250 |
/*@
|
|
|
251 |
STGetShift - Gets the shift associated with the spectral transformation.
|
|
|
252 |
|
|
|
253 |
Not collective
|
|
|
254 |
|
|
|
255 |
Input Parameter:
|
|
|
256 |
. st - the spectral transformation context
|
|
|
257 |
|
|
|
258 |
Output Parameter:
|
|
|
259 |
. shift - the value of the shift
|
|
|
260 |
|
|
|
261 |
Level: beginner
|
|
|
262 |
|
|
|
263 |
@*/
|
| 476 |
dsic.upv.es!antodo |
264 |
PetscErrorCode STGetShift(ST st,PetscScalar* shift)
|
| 6 |
dsic.upv.es!jroman |
265 |
{
|
|
|
266 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
267 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
| 6 |
dsic.upv.es!jroman |
268 |
if (shift) *shift = st->sigma;
|
|
|
269 |
PetscFunctionReturn(0);
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
#undef __FUNCT__
|
|
|
273 |
#define __FUNCT__ "STSetOptionsPrefix"
|
|
|
274 |
/*@C
|
|
|
275 |
STSetOptionsPrefix - Sets the prefix used for searching for all
|
|
|
276 |
ST options in the database.
|
|
|
277 |
|
|
|
278 |
Collective on ST
|
|
|
279 |
|
|
|
280 |
Input Parameters:
|
|
|
281 |
+ st - the spectral transformation context
|
|
|
282 |
- prefix - the prefix string to prepend to all ST option requests
|
|
|
283 |
|
|
|
284 |
Notes:
|
|
|
285 |
A hyphen (-) must NOT be given at the beginning of the prefix name.
|
|
|
286 |
The first character of all runtime options is AUTOMATICALLY the
|
|
|
287 |
hyphen.
|
|
|
288 |
|
|
|
289 |
Level: advanced
|
|
|
290 |
|
|
|
291 |
.seealso: STAppendOptionsPrefix(), STGetOptionsPrefix()
|
|
|
292 |
@*/
|
| 1248 |
slepc |
293 |
PetscErrorCode STSetOptionsPrefix(ST st,const char *prefix)
|
| 6 |
dsic.upv.es!jroman |
294 |
{
|
| 476 |
dsic.upv.es!antodo |
295 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
296 |
|
|
|
297 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
298 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
| 1248 |
slepc |
299 |
ierr = PetscObjectSetOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr);
|
|
|
300 |
ierr = KSPSetOptionsPrefix(st->ksp,prefix);CHKERRQ(ierr);
|
|
|
301 |
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
302 |
PetscFunctionReturn(0);
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
#undef __FUNCT__
|
|
|
306 |
#define __FUNCT__ "STAppendOptionsPrefix"
|
|
|
307 |
/*@C
|
|
|
308 |
STAppendOptionsPrefix - Appends to the prefix used for searching for all
|
|
|
309 |
ST options in the database.
|
|
|
310 |
|
|
|
311 |
Collective on ST
|
|
|
312 |
|
|
|
313 |
Input Parameters:
|
|
|
314 |
+ st - the spectral transformation context
|
|
|
315 |
- prefix - the prefix string to prepend to all ST option requests
|
|
|
316 |
|
|
|
317 |
Notes:
|
|
|
318 |
A hyphen (-) must NOT be given at the beginning of the prefix name.
|
|
|
319 |
The first character of all runtime options is AUTOMATICALLY the
|
|
|
320 |
hyphen.
|
|
|
321 |
|
|
|
322 |
Level: advanced
|
|
|
323 |
|
|
|
324 |
.seealso: STSetOptionsPrefix(), STGetOptionsPrefix()
|
|
|
325 |
@*/
|
| 1248 |
slepc |
326 |
PetscErrorCode STAppendOptionsPrefix(ST st,const char *prefix)
|
| 6 |
dsic.upv.es!jroman |
327 |
{
|
| 476 |
dsic.upv.es!antodo |
328 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
329 |
|
|
|
330 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
331 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
| 1248 |
slepc |
332 |
ierr = PetscObjectAppendOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr);
|
| 1422 |
slepc |
333 |
ierr = KSPSetOptionsPrefix(st->ksp,((PetscObject)st)->prefix);CHKERRQ(ierr);
|
| 1248 |
slepc |
334 |
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
335 |
PetscFunctionReturn(0);
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
#undef __FUNCT__
|
|
|
339 |
#define __FUNCT__ "STGetOptionsPrefix"
|
|
|
340 |
/*@C
|
|
|
341 |
STGetOptionsPrefix - Gets the prefix used for searching for all
|
|
|
342 |
ST options in the database.
|
|
|
343 |
|
|
|
344 |
Not Collective
|
|
|
345 |
|
|
|
346 |
Input Parameters:
|
|
|
347 |
. st - the spectral transformation context
|
|
|
348 |
|
|
|
349 |
Output Parameters:
|
|
|
350 |
. prefix - pointer to the prefix string used, is returned
|
|
|
351 |
|
|
|
352 |
Notes: On the Fortran side, the user should pass in a string 'prefix' of
|
|
|
353 |
sufficient length to hold the prefix.
|
|
|
354 |
|
|
|
355 |
Level: advanced
|
|
|
356 |
|
|
|
357 |
.seealso: STSetOptionsPrefix(), STAppendOptionsPrefix()
|
|
|
358 |
@*/
|
| 812 |
dsic.upv.es!antodo |
359 |
PetscErrorCode STGetOptionsPrefix(ST st,const char *prefix[])
|
| 6 |
dsic.upv.es!jroman |
360 |
{
|
| 476 |
dsic.upv.es!antodo |
361 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
362 |
|
|
|
363 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
364 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
| 6 |
dsic.upv.es!jroman |
365 |
ierr = PetscObjectGetOptionsPrefix((PetscObject)st, prefix);CHKERRQ(ierr);
|
|
|
366 |
PetscFunctionReturn(0);
|
|
|
367 |
}
|
|
|
368 |
|
|
|
369 |
#undef __FUNCT__
|
|
|
370 |
#define __FUNCT__ "STView"
|
|
|
371 |
/*@C
|
|
|
372 |
STView - Prints the ST data structure.
|
|
|
373 |
|
|
|
374 |
Collective on ST
|
|
|
375 |
|
|
|
376 |
Input Parameters:
|
|
|
377 |
+ ST - the ST context
|
|
|
378 |
- viewer - optional visualization context
|
|
|
379 |
|
|
|
380 |
Note:
|
|
|
381 |
The available visualization contexts include
|
|
|
382 |
+ PETSC_VIEWER_STDOUT_SELF - standard output (default)
|
|
|
383 |
- PETSC_VIEWER_STDOUT_WORLD - synchronized standard
|
|
|
384 |
output where only the first processor opens
|
|
|
385 |
the file. All other processors send their
|
|
|
386 |
data to the first processor to print.
|
|
|
387 |
|
|
|
388 |
The user can open an alternative visualization contexts with
|
|
|
389 |
PetscViewerASCIIOpen() (output to a specified file).
|
|
|
390 |
|
|
|
391 |
Level: beginner
|
|
|
392 |
|
|
|
393 |
.seealso: EPSView(), PetscViewerASCIIOpen()
|
|
|
394 |
@*/
|
| 476 |
dsic.upv.es!antodo |
395 |
PetscErrorCode STView(ST st,PetscViewer viewer)
|
| 6 |
dsic.upv.es!jroman |
396 |
{
|
| 476 |
dsic.upv.es!antodo |
397 |
PetscErrorCode ierr;
|
| 1502 |
slepc |
398 |
const STType cstr;
|
| 1004 |
slepc |
399 |
const char* str;
|
| 6 |
dsic.upv.es!jroman |
400 |
PetscTruth isascii,isstring;
|
|
|
401 |
PetscViewerFormat format;
|
|
|
402 |
|
|
|
403 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
404 |
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
| 1422 |
slepc |
405 |
if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)st)->comm);
|
| 25 |
dsic.upv.es!jroman |
406 |
PetscValidHeaderSpecific(viewer,PETSC_VIEWER_COOKIE,2);
|
|
|
407 |
PetscCheckSameComm(st,1,viewer,2);
|
| 6 |
dsic.upv.es!jroman |
408 |
|
|
|
409 |
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
|
|
410 |
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_STRING,&isstring);CHKERRQ(ierr);
|
|
|
411 |
if (isascii) {
|
|
|
412 |
ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr);
|
|
|
413 |
ierr = PetscViewerASCIIPrintf(viewer,"ST Object:\n");CHKERRQ(ierr);
|
|
|
414 |
ierr = STGetType(st,&cstr);CHKERRQ(ierr);
|
|
|
415 |
if (cstr) {
|
|
|
416 |
ierr = PetscViewerASCIIPrintf(viewer," type: %s\n",cstr);CHKERRQ(ierr);
|
|
|
417 |
} else {
|
|
|
418 |
ierr = PetscViewerASCIIPrintf(viewer," type: not yet set\n");CHKERRQ(ierr);
|
|
|
419 |
}
|
|
|
420 |
#if !defined(PETSC_USE_COMPLEX)
|
| 358 |
dsic.upv.es!antodo |
421 |
ierr = PetscViewerASCIIPrintf(viewer," shift: %g\n",st->sigma);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
422 |
#else
|
| 358 |
dsic.upv.es!antodo |
423 |
ierr = PetscViewerASCIIPrintf(viewer," shift: %g+%g i\n",PetscRealPart(st->sigma),PetscImaginaryPart(st->sigma));CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
424 |
#endif
|
| 344 |
dsic.upv.es!antodo |
425 |
switch (st->shift_matrix) {
|
|
|
426 |
case STMATMODE_COPY:
|
|
|
427 |
break;
|
|
|
428 |
case STMATMODE_INPLACE:
|
|
|
429 |
ierr = PetscViewerASCIIPrintf(viewer,"Shifting the matrix and unshifting at exit\n");CHKERRQ(ierr);
|
|
|
430 |
break;
|
|
|
431 |
case STMATMODE_SHELL:
|
|
|
432 |
ierr = PetscViewerASCIIPrintf(viewer,"Using a shell matrix\n");CHKERRQ(ierr);
|
|
|
433 |
break;
|
|
|
434 |
}
|
|
|
435 |
if (st->B && st->shift_matrix != STMATMODE_SHELL) {
|
|
|
436 |
switch (st->str) {
|
|
|
437 |
case SAME_NONZERO_PATTERN: str = "same nonzero pattern";break;
|
|
|
438 |
case DIFFERENT_NONZERO_PATTERN: str = "different nonzero pattern";break;
|
|
|
439 |
case SUBSET_NONZERO_PATTERN: str = "subset nonzero pattern";break;
|
| 1069 |
slepc |
440 |
default: SETERRQ(1,"Wrong structure flag");
|
| 344 |
dsic.upv.es!antodo |
441 |
}
|
|
|
442 |
ierr = PetscViewerASCIIPrintf(viewer,"Matrices A and B have %s\n",str);CHKERRQ(ierr);
|
|
|
443 |
}
|
| 6 |
dsic.upv.es!jroman |
444 |
if (st->ops->view) {
|
|
|
445 |
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
|
|
|
446 |
ierr = (*st->ops->view)(st,viewer);CHKERRQ(ierr);
|
|
|
447 |
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
|
|
|
448 |
}
|
|
|
449 |
} else if (isstring) {
|
|
|
450 |
ierr = STGetType(st,&cstr);CHKERRQ(ierr);
|
|
|
451 |
ierr = PetscViewerStringSPrintf(viewer," %-7.7s",cstr);CHKERRQ(ierr);
|
|
|
452 |
if (st->ops->view) {ierr = (*st->ops->view)(st,viewer);CHKERRQ(ierr);}
|
|
|
453 |
} else {
|
|
|
454 |
SETERRQ1(1,"Viewer type %s not supported by ST",((PetscObject)viewer)->type_name);
|
|
|
455 |
}
|
|
|
456 |
PetscFunctionReturn(0);
|
|
|
457 |
}
|
|
|
458 |
|
| 438 |
dsic.upv.es!antodo |
459 |
#undef __FUNCT__
|
|
|
460 |
#define __FUNCT__ "STView_Default"
|
| 476 |
dsic.upv.es!antodo |
461 |
PetscErrorCode STView_Default(ST st,PetscViewer viewer)
|
| 438 |
dsic.upv.es!antodo |
462 |
{
|
| 476 |
dsic.upv.es!antodo |
463 |
PetscErrorCode ierr;
|
|
|
464 |
PetscTruth isascii,isstring;
|
| 438 |
dsic.upv.es!antodo |
465 |
|
|
|
466 |
PetscFunctionBegin;
|
|
|
467 |
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
|
|
468 |
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_STRING,&isstring);CHKERRQ(ierr);
|
|
|
469 |
if (isascii) {
|
|
|
470 |
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
|
|
|
471 |
ierr = PetscViewerASCIIPrintf(viewer,"Associated KSP object\n");CHKERRQ(ierr);
|
|
|
472 |
ierr = PetscViewerASCIIPrintf(viewer,"------------------------------\n");CHKERRQ(ierr);
|
|
|
473 |
ierr = KSPView(st->ksp,viewer);CHKERRQ(ierr);
|
|
|
474 |
ierr = PetscViewerASCIIPrintf(viewer,"------------------------------\n");CHKERRQ(ierr);
|
|
|
475 |
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
|
|
|
476 |
} else if (isstring) {
|
|
|
477 |
ierr = KSPView(st->ksp,viewer);CHKERRQ(ierr);
|
|
|
478 |
}
|
|
|
479 |
PetscFunctionReturn(0);
|
|
|
480 |
}
|
|
|
481 |
|
| 6 |
dsic.upv.es!jroman |
482 |
/*MC
|
|
|
483 |
STRegisterDynamic - Adds a method to the spectral transformation package.
|
|
|
484 |
|
|
|
485 |
Synopsis:
|
|
|
486 |
STRegisterDynamic(char *name_solver,char *path,char *name_create,int (*routine_create)(ST))
|
|
|
487 |
|
|
|
488 |
Not collective
|
|
|
489 |
|
|
|
490 |
Input Parameters:
|
|
|
491 |
+ name_solver - name of a new user-defined solver
|
|
|
492 |
. path - path (either absolute or relative) the library containing this solver
|
|
|
493 |
. name_create - name of routine to create method context
|
|
|
494 |
- routine_create - routine to create method context
|
|
|
495 |
|
|
|
496 |
Notes:
|
|
|
497 |
STRegisterDynamic() may be called multiple times to add several user-defined spectral transformations.
|
|
|
498 |
|
|
|
499 |
If dynamic libraries are used, then the fourth input argument (routine_create)
|
|
|
500 |
is ignored.
|
|
|
501 |
|
|
|
502 |
Sample usage:
|
|
|
503 |
.vb
|
|
|
504 |
STRegisterDynamic("my_solver","/home/username/my_lib/lib/libO/solaris/mylib.a",
|
|
|
505 |
"MySolverCreate",MySolverCreate);
|
|
|
506 |
.ve
|
|
|
507 |
|
|
|
508 |
Then, your solver can be chosen with the procedural interface via
|
|
|
509 |
$ STSetType(st,"my_solver")
|
|
|
510 |
or at runtime via the option
|
|
|
511 |
$ -st_type my_solver
|
|
|
512 |
|
|
|
513 |
Level: advanced
|
|
|
514 |
|
| 1389 |
slepc |
515 |
$PETSC_DIR, $PETSC_ARCH and $PETSC_LIB_DIR occuring in pathname will be replaced with appropriate values.
|
| 6 |
dsic.upv.es!jroman |
516 |
|
| 1389 |
slepc |
517 |
.seealso: STRegisterDestroy(), STRegisterAll()
|
| 6 |
dsic.upv.es!jroman |
518 |
M*/
|
|
|
519 |
|
|
|
520 |
#undef __FUNCT__
|
|
|
521 |
#define __FUNCT__ "STRegister"
|
| 1389 |
slepc |
522 |
/*@C
|
|
|
523 |
STRegister - See STRegisterDynamic()
|
|
|
524 |
|
|
|
525 |
Level: advanced
|
|
|
526 |
@*/
|
| 1004 |
slepc |
527 |
PetscErrorCode STRegister(const char *sname,const char *path,const char *name,int (*function)(ST))
|
| 6 |
dsic.upv.es!jroman |
528 |
{
|
| 476 |
dsic.upv.es!antodo |
529 |
PetscErrorCode ierr;
|
|
|
530 |
char fullname[256];
|
| 6 |
dsic.upv.es!jroman |
531 |
|
|
|
532 |
PetscFunctionBegin;
|
|
|
533 |
ierr = PetscFListConcat(path,name,fullname);CHKERRQ(ierr);
|
|
|
534 |
ierr = PetscFListAdd(&STList,sname,fullname,(void (*)(void))function);CHKERRQ(ierr);
|
|
|
535 |
PetscFunctionReturn(0);
|
|
|
536 |
}
|
| 1389 |
slepc |
537 |
|
|
|
538 |
#undef __FUNCT__
|
|
|
539 |
#define __FUNCT__ "STRegisterDestroy"
|
|
|
540 |
/*@
|
|
|
541 |
STRegisterDestroy - Frees the list of ST methods that were
|
|
|
542 |
registered by STRegisterDynamic().
|
|
|
543 |
|
|
|
544 |
Not Collective
|
|
|
545 |
|
|
|
546 |
Level: advanced
|
|
|
547 |
|
|
|
548 |
.seealso: STRegisterDynamic(), STRegisterAll()
|
|
|
549 |
@*/
|
|
|
550 |
PetscErrorCode STRegisterDestroy(void)
|
|
|
551 |
{
|
|
|
552 |
PetscErrorCode ierr;
|
|
|
553 |
|
|
|
554 |
PetscFunctionBegin;
|
|
|
555 |
ierr = PetscFListDestroy(&STList);CHKERRQ(ierr);
|
|
|
556 |
ierr = STRegisterAll(PETSC_NULL);CHKERRQ(ierr);
|
|
|
557 |
PetscFunctionReturn(0);
|
|
|
558 |
}
|