Actual source code: itcl.c
1: /*$Id: itcl.c,v 1.121 2001/03/23 23:23:29 balay Exp $*/
2: /*
3: Code for setting KSP options from the options database.
4: */
6: #include src/ksp/ksp/kspimpl.h
7: #include petscsys.h
9: /*
10: We retain a list of functions that also take KSP command
11: line options. These are called at the end KSPSetFromOptions()
12: */
13: #define MAXSETFROMOPTIONS 5
14: int numberofsetfromoptions = 0;
15: int (*othersetfromoptions[MAXSETFROMOPTIONS])(KSP) = {0};
19: /*@C
20: KSPAddOptionsChecker - Adds an additional function to check for KSP options.
22: Not Collective
24: Input Parameter:
25: . kspcheck - function that checks for options
27: Level: developer
29: .keywords: KSP, add, options, checker
31: .seealso: KSPSetFromOptions()
32: @*/
33: int KSPAddOptionsChecker(int (*kspcheck)(KSP))
34: {
36: if (numberofsetfromoptions >= MAXSETFROMOPTIONS) {
37: SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Too many options checkers, only 5 allowed");
38: }
40: othersetfromoptions[numberofsetfromoptions++] = kspcheck;
41: return(0);
42: }
46: /*@C
47: KSPSetOptionsPrefix - Sets the prefix used for searching for all
48: KSP options in the database.
50: Collective on KSP
52: Input Parameters:
53: + ksp - the Krylov context
54: - prefix - the prefix string to prepend to all KSP option requests
56: Notes:
57: A hyphen (-) must NOT be given at the beginning of the prefix name.
58: The first character of all runtime options is AUTOMATICALLY the
59: hyphen.
61: For example, to distinguish between the runtime options for two
62: different KSP contexts, one could call
63: .vb
64: KSPSetOptionsPrefix(ksp1,"sys1_")
65: KSPSetOptionsPrefix(ksp2,"sys2_")
66: .ve
68: This would enable use of different options for each system, such as
69: .vb
70: -sys1_ksp_type gmres -sys1_ksp_rtol 1.e-3
71: -sys2_ksp_type bcgs -sys2_ksp_rtol 1.e-4
72: .ve
74: Level: advanced
76: .keywords: KSP, set, options, prefix, database
78: .seealso: KSPAppendOptionsPrefix(), KSPGetOptionsPrefix()
79: @*/
80: int KSPSetOptionsPrefix(KSP ksp,const char prefix[])
81: {
85: PCSetOptionsPrefix(ksp->B,prefix);
86: PetscObjectSetOptionsPrefix((PetscObject)ksp,prefix);
87: return(0);
88: }
89:
92: /*@C
93: KSPAppendOptionsPrefix - Appends to the prefix used for searching for all
94: KSP options in the database.
96: Collective on KSP
98: Input Parameters:
99: + ksp - the Krylov context
100: - prefix - the prefix string to prepend to all KSP option requests
102: Notes:
103: A hyphen (-) must NOT be given at the beginning of the prefix name.
104: The first character of all runtime options is AUTOMATICALLY the hyphen.
106: Level: advanced
108: .keywords: KSP, append, options, prefix, database
110: .seealso: KSPSetOptionsPrefix(), KSPGetOptionsPrefix()
111: @*/
112: int KSPAppendOptionsPrefix(KSP ksp,const char prefix[])
113: {
117: PCAppendOptionsPrefix(ksp->B,prefix);
118: PetscObjectAppendOptionsPrefix((PetscObject)ksp,prefix);
119: return(0);
120: }
124: /*@C
125: KSPGetOptionsPrefix - Gets the prefix used for searching for all
126: KSP options in the database.
128: Not Collective
130: Input Parameters:
131: . ksp - the Krylov context
133: Output Parameters:
134: . prefix - pointer to the prefix string used is returned
136: Notes: On the fortran side, the user should pass in a string 'prifix' of
137: sufficient length to hold the prefix.
139: Level: advanced
141: .keywords: KSP, set, options, prefix, database
143: .seealso: KSPSetOptionsPrefix(), KSPAppendOptionsPrefix()
144: @*/
145: int KSPGetOptionsPrefix(KSP ksp,char *prefix[])
146: {
150: PetscObjectGetOptionsPrefix((PetscObject)ksp,prefix);
151: return(0);
152: }
154: