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/sles/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;
15: int (*othersetfromoptions[MAXSETFROMOPTIONS])(KSP);
17: #undef __FUNCT__
19: /*@
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: }
44: #undef __FUNCT__
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,char *prefix)
81: {
85: PetscObjectSetOptionsPrefix((PetscObject)ksp,prefix);
86: return(0);
87: }
88:
89: #undef __FUNCT__
91: /*@C
92: KSPAppendOptionsPrefix - Appends to the prefix used for searching for all
93: KSP options in the database.
95: Collective on KSP
97: Input Parameters:
98: + ksp - the Krylov context
99: - prefix - the prefix string to prepend to all KSP option requests
101: Notes:
102: A hyphen (-) must NOT be given at the beginning of the prefix name.
103: The first character of all runtime options is AUTOMATICALLY the hyphen.
105: Level: advanced
107: .keywords: KSP, append, options, prefix, database
109: .seealso: KSPSetOptionsPrefix(), KSPGetOptionsPrefix()
110: @*/
111: int KSPAppendOptionsPrefix(KSP ksp,char *prefix)
112: {
116: PetscObjectAppendOptionsPrefix((PetscObject)ksp,prefix);
117: return(0);
118: }
120: #undef __FUNCT__
122: /*@C
123: KSPGetOptionsPrefix - Gets the prefix used for searching for all
124: KSP options in the database.
126: Not Collective
128: Input Parameters:
129: . ksp - the Krylov context
131: Output Parameters:
132: . prefix - pointer to the prefix string used is returned
134: Notes: On the fortran side, the user should pass in a string 'prifix' of
135: sufficient length to hold the prefix.
137: Level: advanced
139: .keywords: KSP, set, options, prefix, database
141: .seealso: KSPSetOptionsPrefix(), KSPAppendOptionsPrefix()
142: @*/
143: int KSPGetOptionsPrefix(KSP ksp,char **prefix)
144: {
148: PetscObjectGetOptionsPrefix((PetscObject)ksp,prefix);
149: return(0);
150: }
152: