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