| 1302 |
slepc |
1 |
/*
|
|
|
2 |
Basic routines
|
| 1376 |
slepc |
3 |
|
|
|
4 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 1672 |
slepc |
5 |
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
| 2116 |
eromero |
6 |
Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
|
| 1376 |
slepc |
7 |
|
| 1672 |
slepc |
8 |
This file is part of SLEPc.
|
|
|
9 |
|
|
|
10 |
SLEPc is free software: you can redistribute it and/or modify it under the
|
|
|
11 |
terms of version 3 of the GNU Lesser General Public License as published by
|
|
|
12 |
the Free Software Foundation.
|
|
|
13 |
|
|
|
14 |
SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
15 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
16 |
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
17 |
more details.
|
|
|
18 |
|
|
|
19 |
You should have received a copy of the GNU Lesser General Public License
|
|
|
20 |
along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
| 1376 |
slepc |
21 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 1302 |
slepc |
22 |
*/
|
| 1376 |
slepc |
23 |
|
| 2283 |
jroman |
24 |
#include <private/ipimpl.h> /*I "slepcip.h" I*/
|
| 1302 |
slepc |
25 |
|
| 2213 |
jroman |
26 |
PetscClassId IP_CLASSID = 0;
|
| 1493 |
slepc |
27 |
PetscLogEvent IP_InnerProduct = 0, IP_Orthogonalize = 0, IP_ApplyMatrix = 0;
|
| 1302 |
slepc |
28 |
|
|
|
29 |
#undef __FUNCT__
|
| 1329 |
slepc |
30 |
#define __FUNCT__ "IPInitializePackage"
|
| 1345 |
slepc |
31 |
/*@C
|
|
|
32 |
IPInitializePackage - This function initializes everything in the IP package. It is called
|
|
|
33 |
from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to IPCreate()
|
|
|
34 |
when using static libraries.
|
|
|
35 |
|
|
|
36 |
Input Parameter:
|
|
|
37 |
path - The dynamic library path, or PETSC_NULL
|
|
|
38 |
|
|
|
39 |
Level: developer
|
|
|
40 |
|
|
|
41 |
.seealso: SlepcInitialize()
|
|
|
42 |
@*/
|
| 2212 |
jroman |
43 |
PetscErrorCode IPInitializePackage(const char *path)
|
| 1302 |
slepc |
44 |
{
|
| 2216 |
jroman |
45 |
static PetscBool initialized = PETSC_FALSE;
|
| 1302 |
slepc |
46 |
char logList[256];
|
|
|
47 |
char *className;
|
| 2216 |
jroman |
48 |
PetscBool opt;
|
| 1302 |
slepc |
49 |
PetscErrorCode ierr;
|
|
|
50 |
|
|
|
51 |
PetscFunctionBegin;
|
|
|
52 |
if (initialized) PetscFunctionReturn(0);
|
|
|
53 |
initialized = PETSC_TRUE;
|
|
|
54 |
/* Register Classes */
|
| 2213 |
jroman |
55 |
ierr = PetscClassIdRegister("Inner product",&IP_CLASSID);CHKERRQ(ierr);
|
| 1302 |
slepc |
56 |
/* Register Events */
|
| 2213 |
jroman |
57 |
ierr = PetscLogEventRegister("IPOrthogonalize",IP_CLASSID,&IP_Orthogonalize); CHKERRQ(ierr);
|
|
|
58 |
ierr = PetscLogEventRegister("IPInnerProduct",IP_CLASSID,&IP_InnerProduct); CHKERRQ(ierr);
|
|
|
59 |
ierr = PetscLogEventRegister("IPApplyMatrix",IP_CLASSID,&IP_ApplyMatrix); CHKERRQ(ierr);
|
| 1302 |
slepc |
60 |
/* Process info exclusions */
|
| 2213 |
jroman |
61 |
ierr = PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
|
| 1302 |
slepc |
62 |
if (opt) {
|
|
|
63 |
ierr = PetscStrstr(logList, "ip", &className);CHKERRQ(ierr);
|
|
|
64 |
if (className) {
|
| 2213 |
jroman |
65 |
ierr = PetscInfoDeactivateClass(IP_CLASSID);CHKERRQ(ierr);
|
| 1302 |
slepc |
66 |
}
|
|
|
67 |
}
|
|
|
68 |
/* Process summary exclusions */
|
|
|
69 |
ierr = PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
|
|
|
70 |
if (opt) {
|
|
|
71 |
ierr = PetscStrstr(logList, "ip", &className);CHKERRQ(ierr);
|
|
|
72 |
if (className) {
|
| 2213 |
jroman |
73 |
ierr = PetscLogEventDeactivateClass(IP_CLASSID);CHKERRQ(ierr);
|
| 1302 |
slepc |
74 |
}
|
|
|
75 |
}
|
|
|
76 |
PetscFunctionReturn(0);
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
#undef __FUNCT__
|
|
|
80 |
#define __FUNCT__ "IPCreate"
|
| 1345 |
slepc |
81 |
/*@C
|
|
|
82 |
IPCreate - Creates an IP context.
|
|
|
83 |
|
|
|
84 |
Collective on MPI_Comm
|
|
|
85 |
|
|
|
86 |
Input Parameter:
|
|
|
87 |
. comm - MPI communicator
|
|
|
88 |
|
|
|
89 |
Output Parameter:
|
| 1349 |
slepc |
90 |
. newip - location to put the IP context
|
| 1345 |
slepc |
91 |
|
|
|
92 |
Level: beginner
|
|
|
93 |
|
| 1349 |
slepc |
94 |
Note:
|
|
|
95 |
IP objects are not intended for normal users but only for
|
|
|
96 |
advanced user that for instance implement their own solvers.
|
|
|
97 |
|
| 1345 |
slepc |
98 |
.seealso: IPDestroy(), IP
|
|
|
99 |
@*/
|
| 1302 |
slepc |
100 |
PetscErrorCode IPCreate(MPI_Comm comm,IP *newip)
|
|
|
101 |
{
|
| 1345 |
slepc |
102 |
PetscErrorCode ierr;
|
| 1302 |
slepc |
103 |
IP ip;
|
|
|
104 |
|
|
|
105 |
PetscFunctionBegin;
|
|
|
106 |
PetscValidPointer(newip,2);
|
| 2213 |
jroman |
107 |
ierr = PetscHeaderCreate(ip,_p_IP,int,IP_CLASSID,-1,"IP",comm,IPDestroy,IPView);CHKERRQ(ierr);
|
| 1302 |
slepc |
108 |
*newip = ip;
|
| 1940 |
jroman |
109 |
ip->orthog_type = IP_ORTH_CGS;
|
| 1302 |
slepc |
110 |
ip->orthog_ref = IP_ORTH_REFINE_IFNEEDED;
|
|
|
111 |
ip->orthog_eta = 0.7071;
|
| 1940 |
jroman |
112 |
ip->bilinear_form = IP_INNER_HERMITIAN;
|
| 1302 |
slepc |
113 |
ip->innerproducts = 0;
|
| 1329 |
slepc |
114 |
ip->matrix = PETSC_NULL;
|
| 1361 |
slepc |
115 |
ip->Bx = PETSC_NULL;
|
|
|
116 |
ip->xid = 0;
|
|
|
117 |
ip->xstate = 0;
|
| 1345 |
slepc |
118 |
|
| 1302 |
slepc |
119 |
PetscFunctionReturn(0);
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
#undef __FUNCT__
|
| 1316 |
slepc |
123 |
#define __FUNCT__ "IPSetOptionsPrefix"
|
| 1345 |
slepc |
124 |
/*@C
|
|
|
125 |
IPSetOptionsPrefix - Sets the prefix used for searching for all
|
|
|
126 |
IP options in the database.
|
|
|
127 |
|
|
|
128 |
Collective on IP
|
|
|
129 |
|
|
|
130 |
Input Parameters:
|
|
|
131 |
+ ip - the innerproduct context
|
|
|
132 |
- prefix - the prefix string to prepend to all IP option requests
|
|
|
133 |
|
|
|
134 |
Notes:
|
|
|
135 |
A hyphen (-) must NOT be given at the beginning of the prefix name.
|
|
|
136 |
The first character of all runtime options is AUTOMATICALLY the
|
|
|
137 |
hyphen.
|
|
|
138 |
|
|
|
139 |
Level: advanced
|
|
|
140 |
|
|
|
141 |
.seealso: IPAppendOptionsPrefix()
|
|
|
142 |
@*/
|
| 1316 |
slepc |
143 |
PetscErrorCode IPSetOptionsPrefix(IP ip,const char *prefix)
|
|
|
144 |
{
|
|
|
145 |
PetscErrorCode ierr;
|
|
|
146 |
PetscFunctionBegin;
|
| 2213 |
jroman |
147 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1316 |
slepc |
148 |
ierr = PetscObjectSetOptionsPrefix((PetscObject)ip,prefix);CHKERRQ(ierr);
|
|
|
149 |
PetscFunctionReturn(0);
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
#undef __FUNCT__
|
| 1302 |
slepc |
153 |
#define __FUNCT__ "IPAppendOptionsPrefix"
|
| 1345 |
slepc |
154 |
/*@C
|
|
|
155 |
IPAppendOptionsPrefix - Appends to the prefix used for searching for all
|
|
|
156 |
IP options in the database.
|
|
|
157 |
|
|
|
158 |
Collective on IP
|
|
|
159 |
|
|
|
160 |
Input Parameters:
|
|
|
161 |
+ ip - the innerproduct context
|
|
|
162 |
- prefix - the prefix string to prepend to all IP option requests
|
|
|
163 |
|
|
|
164 |
Notes:
|
|
|
165 |
A hyphen (-) must NOT be given at the beginning of the prefix name.
|
|
|
166 |
The first character of all runtime options is AUTOMATICALLY the hyphen.
|
|
|
167 |
|
|
|
168 |
Level: advanced
|
|
|
169 |
|
|
|
170 |
.seealso: IPSetOptionsPrefix()
|
|
|
171 |
@*/
|
| 1302 |
slepc |
172 |
PetscErrorCode IPAppendOptionsPrefix(IP ip,const char *prefix)
|
|
|
173 |
{
|
|
|
174 |
PetscErrorCode ierr;
|
|
|
175 |
PetscFunctionBegin;
|
| 2213 |
jroman |
176 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1302 |
slepc |
177 |
ierr = PetscObjectAppendOptionsPrefix((PetscObject)ip,prefix);CHKERRQ(ierr);
|
|
|
178 |
PetscFunctionReturn(0);
|
|
|
179 |
}
|
|
|
180 |
|
| 1518 |
slepc |
181 |
#undef __FUNCT__
|
|
|
182 |
#define __FUNCT__ "IPGetOptionsPrefix"
|
|
|
183 |
/*@C
|
|
|
184 |
IPGetOptionsPrefix - Gets the prefix used for searching for all
|
|
|
185 |
IP options in the database.
|
|
|
186 |
|
|
|
187 |
Not Collective
|
|
|
188 |
|
|
|
189 |
Input Parameters:
|
|
|
190 |
. ip - the innerproduct context
|
|
|
191 |
|
|
|
192 |
Output Parameters:
|
|
|
193 |
. prefix - pointer to the prefix string used is returned
|
|
|
194 |
|
|
|
195 |
Notes: On the fortran side, the user should pass in a string 'prefix' of
|
|
|
196 |
sufficient length to hold the prefix.
|
|
|
197 |
|
|
|
198 |
Level: advanced
|
|
|
199 |
|
|
|
200 |
.seealso: IPSetOptionsPrefix(), IPAppendOptionsPrefix()
|
|
|
201 |
@*/
|
|
|
202 |
PetscErrorCode IPGetOptionsPrefix(IP ip,const char *prefix[])
|
|
|
203 |
{
|
|
|
204 |
PetscErrorCode ierr;
|
|
|
205 |
PetscFunctionBegin;
|
| 2213 |
jroman |
206 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1518 |
slepc |
207 |
PetscValidPointer(prefix,2);
|
|
|
208 |
ierr = PetscObjectGetOptionsPrefix((PetscObject)ip, prefix);CHKERRQ(ierr);
|
|
|
209 |
PetscFunctionReturn(0);
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
|
| 1302 |
slepc |
213 |
#undef __FUNCT__
|
|
|
214 |
#define __FUNCT__ "IPSetFromOptions"
|
| 1345 |
slepc |
215 |
/*@
|
|
|
216 |
IPSetFromOptions - Sets IP options from the options database.
|
|
|
217 |
|
|
|
218 |
Collective on IP
|
|
|
219 |
|
|
|
220 |
Input Parameters:
|
|
|
221 |
. ip - the innerproduct context
|
|
|
222 |
|
|
|
223 |
Notes:
|
|
|
224 |
To see all options, run your program with the -help option.
|
|
|
225 |
|
|
|
226 |
Level: beginner
|
|
|
227 |
@*/
|
| 1302 |
slepc |
228 |
PetscErrorCode IPSetFromOptions(IP ip)
|
|
|
229 |
{
|
|
|
230 |
PetscErrorCode ierr;
|
| 1858 |
antodo |
231 |
const char *orth_list[2] = { "mgs" , "cgs" };
|
| 1302 |
slepc |
232 |
const char *ref_list[3] = { "never" , "ifneeded", "always" };
|
|
|
233 |
PetscReal r;
|
|
|
234 |
PetscInt i,j;
|
|
|
235 |
|
|
|
236 |
PetscFunctionBegin;
|
| 2213 |
jroman |
237 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1422 |
slepc |
238 |
ierr = PetscOptionsBegin(((PetscObject)ip)->comm,((PetscObject)ip)->prefix,"Inner Product (IP) Options","IP");CHKERRQ(ierr);
|
| 1302 |
slepc |
239 |
i = ip->orthog_type;
|
| 1858 |
antodo |
240 |
ierr = PetscOptionsEList("-orthog_type","Orthogonalization method","IPSetOrthogonalization",orth_list,2,orth_list[i],&i,PETSC_NULL);CHKERRQ(ierr);
|
| 1302 |
slepc |
241 |
j = ip->orthog_ref;
|
|
|
242 |
ierr = PetscOptionsEList("-orthog_refinement","Iterative refinement mode during orthogonalization","IPSetOrthogonalization",ref_list,3,ref_list[j],&j,PETSC_NULL);CHKERRQ(ierr);
|
|
|
243 |
r = ip->orthog_eta;
|
|
|
244 |
ierr = PetscOptionsReal("-orthog_eta","Parameter of iterative refinement during orthogonalization","IPSetOrthogonalization",r,&r,PETSC_NULL);CHKERRQ(ierr);
|
|
|
245 |
ierr = IPSetOrthogonalization(ip,(IPOrthogonalizationType)i,(IPOrthogonalizationRefinementType)j,r);CHKERRQ(ierr);
|
|
|
246 |
ierr = PetscOptionsEnd();CHKERRQ(ierr);
|
|
|
247 |
PetscFunctionReturn(0);
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
#undef __FUNCT__
|
|
|
251 |
#define __FUNCT__ "IPSetOrthogonalization"
|
| 1345 |
slepc |
252 |
/*@
|
|
|
253 |
IPSetOrthogonalization - Specifies the type of orthogonalization technique
|
|
|
254 |
to be used (classical or modified Gram-Schmidt with or without refinement).
|
|
|
255 |
|
|
|
256 |
Collective on IP
|
|
|
257 |
|
|
|
258 |
Input Parameters:
|
|
|
259 |
+ ip - the innerproduct context
|
|
|
260 |
. type - the type of orthogonalization technique
|
|
|
261 |
. refinement - type of refinement
|
|
|
262 |
- eta - parameter for selective refinement
|
|
|
263 |
|
|
|
264 |
Options Database Keys:
|
|
|
265 |
+ -orthog_type <type> - Where <type> is cgs for Classical Gram-Schmidt
|
|
|
266 |
orthogonalization (default)
|
|
|
267 |
or mgs for Modified Gram-Schmidt orthogonalization
|
|
|
268 |
. -orthog_refinement <type> - Where <type> is one of never, ifneeded
|
|
|
269 |
(default) or always
|
|
|
270 |
- -orthog_eta <eta> - For setting the value of eta
|
|
|
271 |
|
|
|
272 |
Notes:
|
|
|
273 |
The default settings work well for most problems.
|
|
|
274 |
|
|
|
275 |
The parameter eta should be a real value between 0 and 1 (or PETSC_DEFAULT).
|
|
|
276 |
The value of eta is used only when the refinement type is "ifneeded".
|
|
|
277 |
|
|
|
278 |
When using several processors, MGS is likely to result in bad scalability.
|
|
|
279 |
|
|
|
280 |
Level: advanced
|
|
|
281 |
|
| 1364 |
slepc |
282 |
.seealso: IPOrthogonalize(), IPGetOrthogonalization(), IPOrthogonalizationType,
|
|
|
283 |
IPOrthogonalizationRefinementType
|
| 1345 |
slepc |
284 |
@*/
|
| 1302 |
slepc |
285 |
PetscErrorCode IPSetOrthogonalization(IP ip,IPOrthogonalizationType type, IPOrthogonalizationRefinementType refinement, PetscReal eta)
|
|
|
286 |
{
|
|
|
287 |
PetscFunctionBegin;
|
| 2213 |
jroman |
288 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1302 |
slepc |
289 |
switch (type) {
|
| 1940 |
jroman |
290 |
case IP_ORTH_CGS:
|
|
|
291 |
case IP_ORTH_MGS:
|
| 1302 |
slepc |
292 |
ip->orthog_type = type;
|
|
|
293 |
break;
|
|
|
294 |
default:
|
| 2214 |
jroman |
295 |
SETERRQ(((PetscObject)ip)->comm,PETSC_ERR_ARG_WRONG,"Unknown orthogonalization type");
|
| 1302 |
slepc |
296 |
}
|
|
|
297 |
switch (refinement) {
|
|
|
298 |
case IP_ORTH_REFINE_NEVER:
|
|
|
299 |
case IP_ORTH_REFINE_IFNEEDED:
|
|
|
300 |
case IP_ORTH_REFINE_ALWAYS:
|
|
|
301 |
ip->orthog_ref = refinement;
|
|
|
302 |
break;
|
|
|
303 |
default:
|
| 2214 |
jroman |
304 |
SETERRQ(((PetscObject)ip)->comm,PETSC_ERR_ARG_WRONG,"Unknown refinement type");
|
| 1302 |
slepc |
305 |
}
|
|
|
306 |
if (eta == PETSC_DEFAULT) {
|
|
|
307 |
ip->orthog_eta = 0.7071;
|
|
|
308 |
} else {
|
| 2214 |
jroman |
309 |
if (eta <= 0.0 || eta > 1.0) SETERRQ(((PetscObject)ip)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Invalid eta value");
|
| 1302 |
slepc |
310 |
ip->orthog_eta = eta;
|
|
|
311 |
}
|
|
|
312 |
PetscFunctionReturn(0);
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
#undef __FUNCT__
|
| 1345 |
slepc |
316 |
#define __FUNCT__ "IPGetOrthogonalization"
|
|
|
317 |
/*@C
|
|
|
318 |
IPGetOrthogonalization - Gets the orthogonalization settings from the
|
|
|
319 |
IP object.
|
|
|
320 |
|
|
|
321 |
Not Collective
|
|
|
322 |
|
|
|
323 |
Input Parameter:
|
|
|
324 |
. ip - inner product context
|
|
|
325 |
|
|
|
326 |
Output Parameter:
|
|
|
327 |
+ type - type of orthogonalization technique
|
|
|
328 |
. refinement - type of refinement
|
|
|
329 |
- eta - parameter for selective refinement
|
|
|
330 |
|
|
|
331 |
Level: advanced
|
|
|
332 |
|
| 1364 |
slepc |
333 |
.seealso: IPOrthogonalize(), IPSetOrthogonalization(), IPOrthogonalizationType,
|
|
|
334 |
IPOrthogonalizationRefinementType
|
| 1345 |
slepc |
335 |
@*/
|
|
|
336 |
PetscErrorCode IPGetOrthogonalization(IP ip,IPOrthogonalizationType *type,IPOrthogonalizationRefinementType *refinement, PetscReal *eta)
|
|
|
337 |
{
|
|
|
338 |
PetscFunctionBegin;
|
| 2213 |
jroman |
339 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1345 |
slepc |
340 |
if (type) *type = ip->orthog_type;
|
|
|
341 |
if (refinement) *refinement = ip->orthog_ref;
|
|
|
342 |
if (eta) *eta = ip->orthog_eta;
|
|
|
343 |
PetscFunctionReturn(0);
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
#undef __FUNCT__
|
| 1302 |
slepc |
347 |
#define __FUNCT__ "IPView"
|
| 1345 |
slepc |
348 |
/*@C
|
|
|
349 |
IPView - Prints the IP data structure.
|
|
|
350 |
|
|
|
351 |
Collective on IP
|
|
|
352 |
|
|
|
353 |
Input Parameters:
|
|
|
354 |
+ ip - the innerproduct context
|
|
|
355 |
- viewer - optional visualization context
|
|
|
356 |
|
|
|
357 |
Note:
|
|
|
358 |
The available visualization contexts include
|
|
|
359 |
+ PETSC_VIEWER_STDOUT_SELF - standard output (default)
|
|
|
360 |
- PETSC_VIEWER_STDOUT_WORLD - synchronized standard
|
|
|
361 |
output where only the first processor opens
|
|
|
362 |
the file. All other processors send their
|
|
|
363 |
data to the first processor to print.
|
|
|
364 |
|
|
|
365 |
The user can open an alternative visualization context with
|
|
|
366 |
PetscViewerASCIIOpen() - output to a specified file.
|
|
|
367 |
|
|
|
368 |
Level: beginner
|
|
|
369 |
|
| 2242 |
jroman |
370 |
.seealso: EPSView(), SVDView(), PetscViewerASCIIOpen()
|
| 1345 |
slepc |
371 |
@*/
|
| 1302 |
slepc |
372 |
PetscErrorCode IPView(IP ip,PetscViewer viewer)
|
|
|
373 |
{
|
|
|
374 |
PetscErrorCode ierr;
|
| 2216 |
jroman |
375 |
PetscBool isascii;
|
| 1302 |
slepc |
376 |
|
|
|
377 |
PetscFunctionBegin;
|
| 2213 |
jroman |
378 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1422 |
slepc |
379 |
if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)ip)->comm);
|
| 2213 |
jroman |
380 |
PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2);
|
| 1302 |
slepc |
381 |
PetscCheckSameComm(ip,1,viewer,2);
|
|
|
382 |
|
| 2215 |
jroman |
383 |
ierr = PetscTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr);
|
| 1302 |
slepc |
384 |
if (isascii) {
|
| 2224 |
jroman |
385 |
ierr = PetscObjectPrintClassNamePrefixType((PetscObject)ip,viewer,"IP Object");CHKERRQ(ierr);
|
| 1302 |
slepc |
386 |
ierr = PetscViewerASCIIPrintf(viewer," orthogonalization method: ");CHKERRQ(ierr);
|
|
|
387 |
switch (ip->orthog_type) {
|
| 1940 |
jroman |
388 |
case IP_ORTH_MGS:
|
| 1302 |
slepc |
389 |
ierr = PetscViewerASCIIPrintf(viewer,"modified Gram-Schmidt\n");CHKERRQ(ierr);
|
|
|
390 |
break;
|
| 1940 |
jroman |
391 |
case IP_ORTH_CGS:
|
| 1302 |
slepc |
392 |
ierr = PetscViewerASCIIPrintf(viewer,"classical Gram-Schmidt\n");CHKERRQ(ierr);
|
|
|
393 |
break;
|
| 2214 |
jroman |
394 |
default: SETERRQ(((PetscObject)ip)->comm,1,"Wrong value of ip->orth_type");
|
| 1302 |
slepc |
395 |
}
|
|
|
396 |
ierr = PetscViewerASCIIPrintf(viewer," orthogonalization refinement: ");CHKERRQ(ierr);
|
|
|
397 |
switch (ip->orthog_ref) {
|
|
|
398 |
case IP_ORTH_REFINE_NEVER:
|
|
|
399 |
ierr = PetscViewerASCIIPrintf(viewer,"never\n");CHKERRQ(ierr);
|
|
|
400 |
break;
|
|
|
401 |
case IP_ORTH_REFINE_IFNEEDED:
|
|
|
402 |
ierr = PetscViewerASCIIPrintf(viewer,"if needed (eta: %f)\n",ip->orthog_eta);CHKERRQ(ierr);
|
|
|
403 |
break;
|
|
|
404 |
case IP_ORTH_REFINE_ALWAYS:
|
|
|
405 |
ierr = PetscViewerASCIIPrintf(viewer,"always\n");CHKERRQ(ierr);
|
|
|
406 |
break;
|
| 2214 |
jroman |
407 |
default: SETERRQ(((PetscObject)ip)->comm,1,"Wrong value of ip->orth_ref");
|
| 1302 |
slepc |
408 |
}
|
|
|
409 |
} else {
|
| 2214 |
jroman |
410 |
SETERRQ1(((PetscObject)ip)->comm,1,"Viewer type %s not supported for IP",((PetscObject)viewer)->type_name);
|
| 1302 |
slepc |
411 |
}
|
|
|
412 |
PetscFunctionReturn(0);
|
|
|
413 |
}
|
|
|
414 |
|
|
|
415 |
#undef __FUNCT__
|
|
|
416 |
#define __FUNCT__ "IPDestroy"
|
| 1345 |
slepc |
417 |
/*@
|
|
|
418 |
IPDestroy - Destroys IP context that was created with IPCreate().
|
|
|
419 |
|
|
|
420 |
Collective on IP
|
|
|
421 |
|
|
|
422 |
Input Parameter:
|
|
|
423 |
. ip - the inner product context
|
|
|
424 |
|
|
|
425 |
Level: beginner
|
|
|
426 |
|
|
|
427 |
.seealso: IPCreate()
|
|
|
428 |
@*/
|
| 1302 |
slepc |
429 |
PetscErrorCode IPDestroy(IP ip)
|
|
|
430 |
{
|
|
|
431 |
PetscErrorCode ierr;
|
|
|
432 |
|
|
|
433 |
PetscFunctionBegin;
|
| 2213 |
jroman |
434 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1572 |
slepc |
435 |
if (--((PetscObject)ip)->refct > 0) PetscFunctionReturn(0);
|
|
|
436 |
|
| 1329 |
slepc |
437 |
if (ip->matrix) { ierr = MatDestroy(ip->matrix);CHKERRQ(ierr); }
|
| 1361 |
slepc |
438 |
if (ip->Bx) { ierr = VecDestroy(ip->Bx);CHKERRQ(ierr); }
|
| 1572 |
slepc |
439 |
ierr = PetscHeaderDestroy(ip);CHKERRQ(ierr);
|
| 1302 |
slepc |
440 |
PetscFunctionReturn(0);
|
|
|
441 |
}
|
| 1329 |
slepc |
442 |
|
|
|
443 |
#undef __FUNCT__
|
|
|
444 |
#define __FUNCT__ "IPGetOperationCounters"
|
| 1345 |
slepc |
445 |
/*@
|
|
|
446 |
IPGetOperationCounters - Gets the total number of inner product operations
|
|
|
447 |
made by the IP object.
|
|
|
448 |
|
|
|
449 |
Not Collective
|
|
|
450 |
|
|
|
451 |
Input Parameter:
|
|
|
452 |
. ip - the inner product context
|
|
|
453 |
|
|
|
454 |
Output Parameter:
|
|
|
455 |
. dots - number of inner product operations
|
|
|
456 |
|
|
|
457 |
Level: intermediate
|
|
|
458 |
|
|
|
459 |
.seealso: IPResetOperationCounters()
|
|
|
460 |
@*/
|
| 1509 |
slepc |
461 |
PetscErrorCode IPGetOperationCounters(IP ip,PetscInt *dots)
|
| 1329 |
slepc |
462 |
{
|
|
|
463 |
PetscFunctionBegin;
|
| 2213 |
jroman |
464 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1329 |
slepc |
465 |
PetscValidPointer(dots,2);
|
|
|
466 |
*dots = ip->innerproducts;
|
|
|
467 |
PetscFunctionReturn(0);
|
|
|
468 |
}
|
|
|
469 |
|
|
|
470 |
#undef __FUNCT__
|
|
|
471 |
#define __FUNCT__ "IPResetOperationCounters"
|
| 1345 |
slepc |
472 |
/*@
|
|
|
473 |
IPResetOperationCounters - Resets the counters for inner product operations
|
|
|
474 |
made by of the IP object.
|
|
|
475 |
|
|
|
476 |
Collective on IP
|
|
|
477 |
|
|
|
478 |
Input Parameter:
|
|
|
479 |
. ip - the inner product context
|
|
|
480 |
|
|
|
481 |
Level: intermediate
|
|
|
482 |
|
|
|
483 |
.seealso: IPGetOperationCounters()
|
|
|
484 |
@*/
|
| 1329 |
slepc |
485 |
PetscErrorCode IPResetOperationCounters(IP ip)
|
|
|
486 |
{
|
|
|
487 |
PetscFunctionBegin;
|
| 2213 |
jroman |
488 |
PetscValidHeaderSpecific(ip,IP_CLASSID,1);
|
| 1329 |
slepc |
489 |
ip->innerproducts = 0;
|
|
|
490 |
PetscFunctionReturn(0);
|
|
|
491 |
}
|
|
|
492 |
|