| 6 |
dsic.upv.es!jroman |
1 |
/*
|
|
|
2 |
This provides a simple shell interface for programmers to
|
|
|
3 |
create their own spectral transformations without writing much
|
|
|
4 |
interface code.
|
| 1376 |
slepc |
5 |
|
|
|
6 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 1672 |
slepc |
7 |
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
| 2116 |
eromero |
8 |
Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
|
| 1376 |
slepc |
9 |
|
| 1672 |
slepc |
10 |
This file is part of SLEPc.
|
|
|
11 |
|
|
|
12 |
SLEPc is free software: you can redistribute it and/or modify it under the
|
|
|
13 |
terms of version 3 of the GNU Lesser General Public License as published by
|
|
|
14 |
the Free Software Foundation.
|
|
|
15 |
|
|
|
16 |
SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
17 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
18 |
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
19 |
more details.
|
|
|
20 |
|
|
|
21 |
You should have received a copy of the GNU Lesser General Public License
|
|
|
22 |
along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
| 1376 |
slepc |
23 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 6 |
dsic.upv.es!jroman |
24 |
*/
|
|
|
25 |
|
| 1521 |
slepc |
26 |
#include "private/stimpl.h" /*I "slepcst.h" I*/
|
| 6 |
dsic.upv.es!jroman |
27 |
#include "slepceps.h"
|
|
|
28 |
|
| 1024 |
slepc |
29 |
EXTERN_C_BEGIN
|
| 6 |
dsic.upv.es!jroman |
30 |
typedef struct {
|
| 1024 |
slepc |
31 |
void *ctx; /* user provided context */
|
| 1760 |
antodo |
32 |
PetscErrorCode (*apply)(ST,Vec,Vec);
|
|
|
33 |
PetscErrorCode (*applytrans)(ST,Vec,Vec);
|
| 1779 |
antodo |
34 |
PetscErrorCode (*backtr)(ST,PetscInt n,PetscScalar*,PetscScalar*);
|
| 1024 |
slepc |
35 |
char *name;
|
| 6 |
dsic.upv.es!jroman |
36 |
} ST_Shell;
|
| 1024 |
slepc |
37 |
EXTERN_C_END
|
| 6 |
dsic.upv.es!jroman |
38 |
|
|
|
39 |
#undef __FUNCT__
|
| 1024 |
slepc |
40 |
#define __FUNCT__ "STShellGetContext"
|
| 1027 |
slepc |
41 |
/*@C
|
| 1024 |
slepc |
42 |
STShellGetContext - Returns the user-provided context associated with a shell ST
|
|
|
43 |
|
|
|
44 |
Not Collective
|
|
|
45 |
|
|
|
46 |
Input Parameter:
|
|
|
47 |
. st - spectral transformation context
|
|
|
48 |
|
|
|
49 |
Output Parameter:
|
|
|
50 |
. ctx - the user provided context
|
|
|
51 |
|
|
|
52 |
Level: advanced
|
|
|
53 |
|
|
|
54 |
Notes:
|
|
|
55 |
This routine is intended for use within various shell routines
|
|
|
56 |
|
|
|
57 |
.seealso: STShellSetContext()
|
|
|
58 |
@*/
|
|
|
59 |
PetscErrorCode STShellGetContext(ST st,void **ctx)
|
|
|
60 |
{
|
|
|
61 |
PetscErrorCode ierr;
|
|
|
62 |
PetscTruth flg;
|
|
|
63 |
|
|
|
64 |
PetscFunctionBegin;
|
| 2213 |
jroman |
65 |
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
| 1024 |
slepc |
66 |
PetscValidPointer(ctx,2);
|
|
|
67 |
ierr = PetscTypeCompare((PetscObject)st,STSHELL,&flg);CHKERRQ(ierr);
|
|
|
68 |
if (!flg) *ctx = 0;
|
|
|
69 |
else *ctx = ((ST_Shell*)(st->data))->ctx;
|
|
|
70 |
PetscFunctionReturn(0);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
#undef __FUNCT__
|
|
|
74 |
#define __FUNCT__ "STShellSetContext"
|
| 1780 |
antodo |
75 |
/*@
|
| 1024 |
slepc |
76 |
STShellSetContext - sets the context for a shell ST
|
|
|
77 |
|
|
|
78 |
Collective on ST
|
|
|
79 |
|
|
|
80 |
Input Parameters:
|
|
|
81 |
+ st - the shell ST
|
|
|
82 |
- ctx - the context
|
|
|
83 |
|
|
|
84 |
Level: advanced
|
|
|
85 |
|
|
|
86 |
Fortran Notes: The context can only be an integer or a PetscObject;
|
|
|
87 |
unfortunately it cannot be a Fortran array or derived type.
|
|
|
88 |
|
|
|
89 |
.seealso: STShellGetContext()
|
|
|
90 |
@*/
|
|
|
91 |
PetscErrorCode STShellSetContext(ST st,void *ctx)
|
|
|
92 |
{
|
|
|
93 |
ST_Shell *shell = (ST_Shell*)st->data;
|
|
|
94 |
PetscErrorCode ierr;
|
|
|
95 |
PetscTruth flg;
|
|
|
96 |
|
|
|
97 |
PetscFunctionBegin;
|
| 2213 |
jroman |
98 |
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
| 1024 |
slepc |
99 |
ierr = PetscTypeCompare((PetscObject)st,STSHELL,&flg);CHKERRQ(ierr);
|
|
|
100 |
if (flg) {
|
|
|
101 |
shell->ctx = ctx;
|
|
|
102 |
}
|
|
|
103 |
PetscFunctionReturn(0);
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
107 |
#define __FUNCT__ "STApply_Shell"
|
| 476 |
dsic.upv.es!antodo |
108 |
PetscErrorCode STApply_Shell(ST st,Vec x,Vec y)
|
| 6 |
dsic.upv.es!jroman |
109 |
{
|
| 476 |
dsic.upv.es!antodo |
110 |
PetscErrorCode ierr;
|
| 1024 |
slepc |
111 |
ST_Shell *shell = (ST_Shell*)st->data;
|
| 6 |
dsic.upv.es!jroman |
112 |
|
|
|
113 |
PetscFunctionBegin;
|
| 1024 |
slepc |
114 |
if (!shell->apply) SETERRQ(PETSC_ERR_USER,"No apply() routine provided to Shell ST");
|
| 1763 |
antodo |
115 |
PetscStackPush("STSHELL apply() user function");
|
| 1024 |
slepc |
116 |
CHKMEMQ;
|
| 1760 |
antodo |
117 |
ierr = (*shell->apply)(st,x,y);CHKERRQ(ierr);
|
| 1024 |
slepc |
118 |
CHKMEMQ;
|
|
|
119 |
PetscStackPop;
|
| 6 |
dsic.upv.es!jroman |
120 |
PetscFunctionReturn(0);
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
#undef __FUNCT__
|
| 780 |
dsic.upv.es!jroman |
124 |
#define __FUNCT__ "STApplyTranspose_Shell"
|
|
|
125 |
PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y)
|
|
|
126 |
{
|
|
|
127 |
PetscErrorCode ierr;
|
| 1024 |
slepc |
128 |
ST_Shell *shell = (ST_Shell*)st->data;
|
| 780 |
dsic.upv.es!jroman |
129 |
|
|
|
130 |
PetscFunctionBegin;
|
| 1024 |
slepc |
131 |
if (!shell->applytrans) SETERRQ(PETSC_ERR_USER,"No applytranspose() routine provided to Shell ST");
|
| 1763 |
antodo |
132 |
PetscStackPush("STSHELL applytranspose() user function");
|
|
|
133 |
CHKMEMQ;
|
| 1760 |
antodo |
134 |
ierr = (*shell->applytrans)(st,x,y);CHKERRQ(ierr);
|
| 1763 |
antodo |
135 |
CHKMEMQ;
|
|
|
136 |
PetscStackPop;
|
| 780 |
dsic.upv.es!jroman |
137 |
PetscFunctionReturn(0);
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
141 |
#define __FUNCT__ "STBackTransform_Shell"
|
| 1779 |
antodo |
142 |
PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
|
| 6 |
dsic.upv.es!jroman |
143 |
{
|
| 476 |
dsic.upv.es!antodo |
144 |
PetscErrorCode ierr;
|
| 1024 |
slepc |
145 |
ST_Shell *shell = (ST_Shell*)st->data;
|
| 6 |
dsic.upv.es!jroman |
146 |
|
|
|
147 |
PetscFunctionBegin;
|
|
|
148 |
if (shell->backtr) {
|
| 1763 |
antodo |
149 |
PetscStackPush("STSHELL backtransform() user function");
|
|
|
150 |
CHKMEMQ;
|
| 1778 |
antodo |
151 |
ierr = (*shell->backtr)(st,n,eigr,eigi);CHKERRQ(ierr);
|
| 1763 |
antodo |
152 |
CHKMEMQ;
|
|
|
153 |
PetscStackPop;
|
| 6 |
dsic.upv.es!jroman |
154 |
}
|
|
|
155 |
PetscFunctionReturn(0);
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
#undef __FUNCT__
|
|
|
159 |
#define __FUNCT__ "STDestroy_Shell"
|
| 476 |
dsic.upv.es!antodo |
160 |
PetscErrorCode STDestroy_Shell(ST st)
|
| 6 |
dsic.upv.es!jroman |
161 |
{
|
| 476 |
dsic.upv.es!antodo |
162 |
PetscErrorCode ierr;
|
| 1024 |
slepc |
163 |
ST_Shell *shell = (ST_Shell*)st->data;
|
| 6 |
dsic.upv.es!jroman |
164 |
|
|
|
165 |
PetscFunctionBegin;
|
| 1040 |
slepc |
166 |
ierr = PetscFree(shell->name);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
167 |
ierr = PetscFree(shell);CHKERRQ(ierr);
|
| 1925 |
jroman |
168 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApply_C","",PETSC_NULL);CHKERRQ(ierr);
|
|
|
169 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApplyTranspose_C","",PETSC_NULL);CHKERRQ(ierr);
|
|
|
170 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetBackTransform_C","",PETSC_NULL);CHKERRQ(ierr);
|
|
|
171 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetName_C","",PETSC_NULL);CHKERRQ(ierr);
|
|
|
172 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellGetName_C","",PETSC_NULL);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
173 |
PetscFunctionReturn(0);
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
#undef __FUNCT__
|
|
|
177 |
#define __FUNCT__ "STView_Shell"
|
| 476 |
dsic.upv.es!antodo |
178 |
PetscErrorCode STView_Shell(ST st,PetscViewer viewer)
|
| 6 |
dsic.upv.es!jroman |
179 |
{
|
| 476 |
dsic.upv.es!antodo |
180 |
PetscErrorCode ierr;
|
|
|
181 |
ST_Shell *ctx = (ST_Shell*)st->data;
|
|
|
182 |
PetscTruth isascii;
|
| 6 |
dsic.upv.es!jroman |
183 |
|
|
|
184 |
PetscFunctionBegin;
|
|
|
185 |
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
|
|
186 |
if (isascii) {
|
|
|
187 |
if (ctx->name) {ierr = PetscViewerASCIIPrintf(viewer," ST Shell: %s\n",ctx->name);CHKERRQ(ierr);}
|
|
|
188 |
else {ierr = PetscViewerASCIIPrintf(viewer," ST Shell: no name\n");CHKERRQ(ierr);}
|
|
|
189 |
} else {
|
|
|
190 |
SETERRQ1(1,"Viewer type %s not supported for STShell",((PetscObject)viewer)->type_name);
|
|
|
191 |
}
|
|
|
192 |
PetscFunctionReturn(0);
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
EXTERN_C_BEGIN
|
|
|
196 |
#undef __FUNCT__
|
|
|
197 |
#define __FUNCT__ "STShellSetApply_Shell"
|
| 1760 |
antodo |
198 |
PetscErrorCode STShellSetApply_Shell(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
|
| 6 |
dsic.upv.es!jroman |
199 |
{
|
| 1024 |
slepc |
200 |
ST_Shell *shell = (ST_Shell*)st->data;
|
| 6 |
dsic.upv.es!jroman |
201 |
|
|
|
202 |
PetscFunctionBegin;
|
|
|
203 |
shell->apply = apply;
|
|
|
204 |
PetscFunctionReturn(0);
|
|
|
205 |
}
|
|
|
206 |
EXTERN_C_END
|
|
|
207 |
|
|
|
208 |
EXTERN_C_BEGIN
|
|
|
209 |
#undef __FUNCT__
|
| 780 |
dsic.upv.es!jroman |
210 |
#define __FUNCT__ "STShellSetApplyTranspose_Shell"
|
| 1760 |
antodo |
211 |
PetscErrorCode STShellSetApplyTranspose_Shell(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
|
| 780 |
dsic.upv.es!jroman |
212 |
{
|
| 1024 |
slepc |
213 |
ST_Shell *shell = (ST_Shell*)st->data;
|
| 780 |
dsic.upv.es!jroman |
214 |
|
|
|
215 |
PetscFunctionBegin;
|
|
|
216 |
shell->applytrans = applytrans;
|
|
|
217 |
PetscFunctionReturn(0);
|
|
|
218 |
}
|
|
|
219 |
EXTERN_C_END
|
|
|
220 |
|
|
|
221 |
EXTERN_C_BEGIN
|
|
|
222 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
223 |
#define __FUNCT__ "STShellSetBackTransform_Shell"
|
| 1779 |
antodo |
224 |
PetscErrorCode STShellSetBackTransform_Shell(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
|
| 6 |
dsic.upv.es!jroman |
225 |
{
|
| 476 |
dsic.upv.es!antodo |
226 |
ST_Shell *shell = (ST_Shell *) st->data;
|
| 6 |
dsic.upv.es!jroman |
227 |
|
|
|
228 |
PetscFunctionBegin;
|
|
|
229 |
shell->backtr = backtr;
|
|
|
230 |
PetscFunctionReturn(0);
|
|
|
231 |
}
|
|
|
232 |
EXTERN_C_END
|
|
|
233 |
|
|
|
234 |
EXTERN_C_BEGIN
|
|
|
235 |
#undef __FUNCT__
|
|
|
236 |
#define __FUNCT__ "STShellSetName_Shell"
|
| 1024 |
slepc |
237 |
PetscErrorCode STShellSetName_Shell(ST st,const char name[])
|
| 6 |
dsic.upv.es!jroman |
238 |
{
|
| 1024 |
slepc |
239 |
ST_Shell *shell = (ST_Shell*)st->data;
|
|
|
240 |
PetscErrorCode ierr;
|
| 6 |
dsic.upv.es!jroman |
241 |
|
|
|
242 |
PetscFunctionBegin;
|
| 1959 |
jroman |
243 |
ierr = PetscFree(shell->name);CHKERRQ(ierr);
|
| 1024 |
slepc |
244 |
ierr = PetscStrallocpy(name,&shell->name);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
245 |
PetscFunctionReturn(0);
|
|
|
246 |
}
|
|
|
247 |
EXTERN_C_END
|
|
|
248 |
|
|
|
249 |
EXTERN_C_BEGIN
|
|
|
250 |
#undef __FUNCT__
|
|
|
251 |
#define __FUNCT__ "STShellGetName_Shell"
|
| 1024 |
slepc |
252 |
PetscErrorCode STShellGetName_Shell(ST st,char *name[])
|
| 6 |
dsic.upv.es!jroman |
253 |
{
|
| 1024 |
slepc |
254 |
ST_Shell *shell = (ST_Shell*)st->data;
|
| 6 |
dsic.upv.es!jroman |
255 |
|
|
|
256 |
PetscFunctionBegin;
|
|
|
257 |
*name = shell->name;
|
|
|
258 |
PetscFunctionReturn(0);
|
|
|
259 |
}
|
|
|
260 |
EXTERN_C_END
|
|
|
261 |
|
|
|
262 |
#undef __FUNCT__
|
|
|
263 |
#define __FUNCT__ "STShellSetApply"
|
|
|
264 |
/*@C
|
|
|
265 |
STShellSetApply - Sets routine to use as the application of the
|
|
|
266 |
operator to a vector in the user-defined spectral transformation.
|
|
|
267 |
|
|
|
268 |
Collective on ST
|
|
|
269 |
|
|
|
270 |
Input Parameters:
|
|
|
271 |
+ st - the spectral transformation context
|
| 1024 |
slepc |
272 |
- apply - the application-provided transformation routine
|
| 6 |
dsic.upv.es!jroman |
273 |
|
|
|
274 |
Calling sequence of apply:
|
|
|
275 |
.vb
|
| 1760 |
antodo |
276 |
PetscErrorCode apply (ST st,Vec xin,Vec xout)
|
| 6 |
dsic.upv.es!jroman |
277 |
.ve
|
|
|
278 |
|
| 1760 |
antodo |
279 |
+ st - the spectral transformation context
|
| 6 |
dsic.upv.es!jroman |
280 |
. xin - input vector
|
|
|
281 |
- xout - output vector
|
|
|
282 |
|
|
|
283 |
Level: developer
|
|
|
284 |
|
| 780 |
dsic.upv.es!jroman |
285 |
.seealso: STShellSetBackTransform(), STShellSetApplyTranspose()
|
| 6 |
dsic.upv.es!jroman |
286 |
@*/
|
| 1760 |
antodo |
287 |
PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
|
| 6 |
dsic.upv.es!jroman |
288 |
{
|
| 1760 |
antodo |
289 |
PetscErrorCode ierr, (*f)(ST,PetscErrorCode (*)(ST,Vec,Vec));
|
| 6 |
dsic.upv.es!jroman |
290 |
|
|
|
291 |
PetscFunctionBegin;
|
| 2213 |
jroman |
292 |
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
| 6 |
dsic.upv.es!jroman |
293 |
ierr = PetscObjectQueryFunction((PetscObject)st,"STShellSetApply_C",(void (**)(void))&f);CHKERRQ(ierr);
|
|
|
294 |
if (f) {
|
| 1024 |
slepc |
295 |
ierr = (*f)(st,apply);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
296 |
}
|
|
|
297 |
PetscFunctionReturn(0);
|
|
|
298 |
}
|
|
|
299 |
|
|
|
300 |
#undef __FUNCT__
|
| 780 |
dsic.upv.es!jroman |
301 |
#define __FUNCT__ "STShellSetApplyTranspose"
|
|
|
302 |
/*@C
|
|
|
303 |
STShellSetApplyTranspose - Sets routine to use as the application of the
|
|
|
304 |
transposed operator to a vector in the user-defined spectral transformation.
|
|
|
305 |
|
|
|
306 |
Collective on ST
|
|
|
307 |
|
|
|
308 |
Input Parameters:
|
|
|
309 |
+ st - the spectral transformation context
|
| 1024 |
slepc |
310 |
- applytrans - the application-provided transformation routine
|
| 780 |
dsic.upv.es!jroman |
311 |
|
|
|
312 |
Calling sequence of apply:
|
|
|
313 |
.vb
|
| 1760 |
antodo |
314 |
PetscErrorCode applytrans (ST st,Vec xin,Vec xout)
|
| 780 |
dsic.upv.es!jroman |
315 |
.ve
|
|
|
316 |
|
| 1760 |
antodo |
317 |
+ st - the spectral transformation context
|
| 780 |
dsic.upv.es!jroman |
318 |
. xin - input vector
|
|
|
319 |
- xout - output vector
|
|
|
320 |
|
|
|
321 |
Level: developer
|
|
|
322 |
|
|
|
323 |
.seealso: STShellSetApply(), STShellSetBackTransform()
|
|
|
324 |
@*/
|
| 1760 |
antodo |
325 |
PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
|
| 780 |
dsic.upv.es!jroman |
326 |
{
|
| 1760 |
antodo |
327 |
PetscErrorCode ierr, (*f)(ST,PetscErrorCode (*)(ST,Vec,Vec));
|
| 780 |
dsic.upv.es!jroman |
328 |
|
|
|
329 |
PetscFunctionBegin;
|
| 2213 |
jroman |
330 |
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
| 780 |
dsic.upv.es!jroman |
331 |
ierr = PetscObjectQueryFunction((PetscObject)st,"STShellSetApplyTranspose_C",(void (**)(void))&f);CHKERRQ(ierr);
|
|
|
332 |
if (f) {
|
| 1024 |
slepc |
333 |
ierr = (*f)(st,applytrans);CHKERRQ(ierr);
|
| 780 |
dsic.upv.es!jroman |
334 |
}
|
|
|
335 |
PetscFunctionReturn(0);
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
339 |
#define __FUNCT__ "STShellSetBackTransform"
|
|
|
340 |
/*@C
|
|
|
341 |
STShellSetBackTransform - Sets the routine to be called after the
|
|
|
342 |
eigensolution process has finished in order to transform back the
|
|
|
343 |
computed eigenvalues.
|
|
|
344 |
|
|
|
345 |
Collective on ST
|
|
|
346 |
|
|
|
347 |
Input Parameters:
|
|
|
348 |
+ st - the spectral transformation context
|
| 1024 |
slepc |
349 |
- backtr - the application-provided backtransform routine
|
| 6 |
dsic.upv.es!jroman |
350 |
|
|
|
351 |
Calling sequence of backtr:
|
|
|
352 |
.vb
|
| 1760 |
antodo |
353 |
PetscErrorCode backtr (ST st,PetscScalar *eigr,PetscScalar *eigi)
|
| 6 |
dsic.upv.es!jroman |
354 |
.ve
|
|
|
355 |
|
| 1760 |
antodo |
356 |
+ st - the spectral transformation context
|
| 6 |
dsic.upv.es!jroman |
357 |
. eigr - pointer ot the real part of the eigenvalue to transform back
|
| 1024 |
slepc |
358 |
- eigi - pointer ot the imaginary part
|
| 6 |
dsic.upv.es!jroman |
359 |
|
|
|
360 |
Level: developer
|
|
|
361 |
|
| 780 |
dsic.upv.es!jroman |
362 |
.seealso: STShellSetApply(), STShellSetApplyTranspose()
|
| 6 |
dsic.upv.es!jroman |
363 |
@*/
|
| 1780 |
antodo |
364 |
PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
|
| 6 |
dsic.upv.es!jroman |
365 |
{
|
| 1780 |
antodo |
366 |
PetscErrorCode ierr, (*f)(ST,PetscErrorCode (*)(ST,PetscInt,PetscScalar*,PetscScalar*));
|
| 6 |
dsic.upv.es!jroman |
367 |
|
|
|
368 |
PetscFunctionBegin;
|
| 2213 |
jroman |
369 |
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
| 6 |
dsic.upv.es!jroman |
370 |
ierr = PetscObjectQueryFunction((PetscObject)st,"STShellSetBackTransform_C",(void (**)(void))&f);CHKERRQ(ierr);
|
|
|
371 |
if (f) {
|
| 1760 |
antodo |
372 |
ierr = (*f)(st,backtr);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
373 |
}
|
|
|
374 |
PetscFunctionReturn(0);
|
|
|
375 |
}
|
|
|
376 |
|
|
|
377 |
#undef __FUNCT__
|
|
|
378 |
#define __FUNCT__ "STShellSetName"
|
|
|
379 |
/*@C
|
|
|
380 |
STShellSetName - Sets an optional name to associate with a shell
|
|
|
381 |
spectral transformation.
|
|
|
382 |
|
|
|
383 |
Not Collective
|
|
|
384 |
|
|
|
385 |
Input Parameters:
|
|
|
386 |
+ st - the spectral transformation context
|
|
|
387 |
- name - character string describing the shell spectral transformation
|
|
|
388 |
|
|
|
389 |
Level: developer
|
|
|
390 |
|
|
|
391 |
.seealso: STShellGetName()
|
|
|
392 |
@*/
|
| 1024 |
slepc |
393 |
PetscErrorCode STShellSetName(ST st,const char name[])
|
| 6 |
dsic.upv.es!jroman |
394 |
{
|
| 1024 |
slepc |
395 |
PetscErrorCode ierr, (*f)(ST,const char []);
|
| 6 |
dsic.upv.es!jroman |
396 |
|
|
|
397 |
PetscFunctionBegin;
|
| 2213 |
jroman |
398 |
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
| 6 |
dsic.upv.es!jroman |
399 |
ierr = PetscObjectQueryFunction((PetscObject)st,"STShellSetName_C",(void (**)(void))&f);CHKERRQ(ierr);
|
|
|
400 |
if (f) {
|
|
|
401 |
ierr = (*f)(st,name);CHKERRQ(ierr);
|
|
|
402 |
}
|
|
|
403 |
PetscFunctionReturn(0);
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
#undef __FUNCT__
|
|
|
407 |
#define __FUNCT__ "STShellGetName"
|
|
|
408 |
/*@C
|
|
|
409 |
STShellGetName - Gets an optional name that the user has set for a shell
|
|
|
410 |
spectral transformation.
|
|
|
411 |
|
|
|
412 |
Not Collective
|
|
|
413 |
|
|
|
414 |
Input Parameter:
|
|
|
415 |
. st - the spectral transformation context
|
|
|
416 |
|
|
|
417 |
Output Parameter:
|
| 1024 |
slepc |
418 |
. name - character string describing the shell spectral transformation
|
|
|
419 |
(you should not free this)
|
| 6 |
dsic.upv.es!jroman |
420 |
|
|
|
421 |
Level: developer
|
|
|
422 |
|
|
|
423 |
.seealso: STShellSetName()
|
|
|
424 |
@*/
|
| 1024 |
slepc |
425 |
PetscErrorCode STShellGetName(ST st,char *name[])
|
| 6 |
dsic.upv.es!jroman |
426 |
{
|
| 1024 |
slepc |
427 |
PetscErrorCode ierr, (*f)(ST,char *[]);
|
| 6 |
dsic.upv.es!jroman |
428 |
|
|
|
429 |
PetscFunctionBegin;
|
| 2213 |
jroman |
430 |
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
| 6 |
dsic.upv.es!jroman |
431 |
ierr = PetscObjectQueryFunction((PetscObject)st,"STShellGetName_C",(void (**)(void))&f);CHKERRQ(ierr);
|
|
|
432 |
if (f) {
|
|
|
433 |
ierr = (*f)(st,name);CHKERRQ(ierr);
|
|
|
434 |
} else {
|
| 1024 |
slepc |
435 |
SETERRQ(PETSC_ERR_ARG_WRONG,"Not shell spectral transformation, cannot get name");
|
| 6 |
dsic.upv.es!jroman |
436 |
}
|
|
|
437 |
PetscFunctionReturn(0);
|
|
|
438 |
}
|
|
|
439 |
|
| 2005 |
eromero |
440 |
#undef __FUNCT__
|
|
|
441 |
#define __FUNCT__ "STSetFromOptions_Shell"
|
|
|
442 |
PetscErrorCode STSetFromOptions_Shell(ST st)
|
|
|
443 |
{
|
|
|
444 |
PetscErrorCode ierr;
|
|
|
445 |
PC pc;
|
|
|
446 |
const PCType pctype;
|
|
|
447 |
const KSPType ksptype;
|
|
|
448 |
|
|
|
449 |
PetscFunctionBegin;
|
|
|
450 |
|
|
|
451 |
ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr);
|
|
|
452 |
ierr = KSPGetType(st->ksp,&ksptype);CHKERRQ(ierr);
|
|
|
453 |
ierr = PCGetType(pc,&pctype);CHKERRQ(ierr);
|
|
|
454 |
if (!pctype && !ksptype) {
|
|
|
455 |
if (st->shift_matrix == ST_MATMODE_SHELL) {
|
|
|
456 |
/* in shell mode use GMRES with Jacobi as the default */
|
|
|
457 |
ierr = KSPSetType(st->ksp,KSPGMRES);CHKERRQ(ierr);
|
|
|
458 |
ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr);
|
|
|
459 |
} else {
|
|
|
460 |
/* use direct solver as default */
|
|
|
461 |
ierr = KSPSetType(st->ksp,KSPPREONLY);CHKERRQ(ierr);
|
|
|
462 |
ierr = PCSetType(pc,PCREDUNDANT);CHKERRQ(ierr);
|
|
|
463 |
}
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
PetscFunctionReturn(0);
|
|
|
467 |
}
|
|
|
468 |
|
| 1024 |
slepc |
469 |
/*MC
|
|
|
470 |
STSHELL - Creates a new spectral transformation class.
|
| 6 |
dsic.upv.es!jroman |
471 |
This is intended to provide a simple class to use with EPS.
|
|
|
472 |
You should not use this if you plan to make a complete class.
|
|
|
473 |
|
| 1024 |
slepc |
474 |
Level: advanced
|
|
|
475 |
|
| 6 |
dsic.upv.es!jroman |
476 |
Usage:
|
| 1024 |
slepc |
477 |
$ PetscErrorCode (*apply)(void*,Vec,Vec);
|
|
|
478 |
$ PetscErrorCode (*applytrans)(void*,Vec,Vec);
|
|
|
479 |
$ PetscErrorCode (*backtr)(void*,PetscScalar*,PetscScalar*);
|
| 6 |
dsic.upv.es!jroman |
480 |
$ STCreate(comm,&st);
|
|
|
481 |
$ STSetType(st,STSHELL);
|
| 1024 |
slepc |
482 |
$ STShellSetApply(st,apply);
|
|
|
483 |
$ STShellSetApplyTranspose(st,applytrans);
|
| 6 |
dsic.upv.es!jroman |
484 |
$ STShellSetBackTransform(st,backtr); (optional)
|
|
|
485 |
|
| 1024 |
slepc |
486 |
M*/
|
|
|
487 |
|
| 6 |
dsic.upv.es!jroman |
488 |
EXTERN_C_BEGIN
|
|
|
489 |
#undef __FUNCT__
|
|
|
490 |
#define __FUNCT__ "STCreate_Shell"
|
| 476 |
dsic.upv.es!antodo |
491 |
PetscErrorCode STCreate_Shell(ST st)
|
| 6 |
dsic.upv.es!jroman |
492 |
{
|
| 476 |
dsic.upv.es!antodo |
493 |
PetscErrorCode ierr;
|
|
|
494 |
ST_Shell *shell;
|
| 6 |
dsic.upv.es!jroman |
495 |
|
|
|
496 |
PetscFunctionBegin;
|
|
|
497 |
st->ops->destroy = STDestroy_Shell;
|
| 1024 |
slepc |
498 |
ierr = PetscNew(ST_Shell,&shell);CHKERRQ(ierr);
|
|
|
499 |
ierr = PetscLogObjectMemory(st,sizeof(ST_Shell));CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
500 |
|
|
|
501 |
st->data = (void *) shell;
|
| 1422 |
slepc |
502 |
((PetscObject)st)->name = 0;
|
| 6 |
dsic.upv.es!jroman |
503 |
|
| 2005 |
eromero |
504 |
st->ops->apply = STApply_Shell;
|
|
|
505 |
st->ops->applytrans = STApplyTranspose_Shell;
|
|
|
506 |
st->ops->backtr = STBackTransform_Shell;
|
|
|
507 |
st->ops->view = STView_Shell;
|
|
|
508 |
st->ops->setfromoptions = STSetFromOptions_Shell;
|
| 6 |
dsic.upv.es!jroman |
509 |
|
|
|
510 |
shell->apply = 0;
|
| 1024 |
slepc |
511 |
shell->applytrans = 0;
|
|
|
512 |
shell->backtr = 0;
|
| 6 |
dsic.upv.es!jroman |
513 |
shell->name = 0;
|
|
|
514 |
shell->ctx = 0;
|
|
|
515 |
|
| 1925 |
jroman |
516 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApply_C","STShellSetApply_Shell",STShellSetApply_Shell);CHKERRQ(ierr);
|
|
|
517 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApplyTranspose_C","STShellSetApplyTranspose_Shell",STShellSetApplyTranspose_Shell);CHKERRQ(ierr);
|
|
|
518 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetBackTransform_C","STShellSetBackTransform_Shell",STShellSetBackTransform_Shell);CHKERRQ(ierr);
|
|
|
519 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetName_C","STShellSetName_Shell",STShellSetName_Shell);CHKERRQ(ierr);
|
|
|
520 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellGetName_C","STShellGetName_Shell",STShellGetName_Shell);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
521 |
|
|
|
522 |
PetscFunctionReturn(0);
|
|
|
523 |
}
|
|
|
524 |
EXTERN_C_END
|
|
|
525 |
|