Actual source code: itcl.c
1: #define PETSCKSP_DLL
3: /*
4: Code for setting KSP options from the options database.
5: */
7: #include src/ksp/ksp/kspimpl.h
8: #include petscsys.h
10: /*
11: We retain a list of functions that also take KSP command
12: line options. These are called at the end KSPSetFromOptions()
13: */
14: #define MAXSETFROMOPTIONS 5
15: PetscInt numberofsetfromoptions = 0;
16: PetscErrorCode (*othersetfromoptions[MAXSETFROMOPTIONS])(KSP) = {0};
20: /*@C
21: KSPAddOptionsChecker - Adds an additional function to check for KSP options.
23: Not Collective
25: Input Parameter:
26: . kspcheck - function that checks for options
28: Level: developer
30: .keywords: KSP, add, options, checker
32: .seealso: KSPSetFromOptions()
33: @*/
34: PetscErrorCode PETSCKSP_DLLEXPORT KSPAddOptionsChecker(PetscErrorCode (*kspcheck)(KSP))
35: {
37: if (numberofsetfromoptions >= MAXSETFROMOPTIONS) {
38: SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Too many options checkers, only 5 allowed");
39: }
41: othersetfromoptions[numberofsetfromoptions++] = kspcheck;
42: return(0);
43: }
47: /*@C
48: KSPSetOptionsPrefix - Sets the prefix used for searching for all
49: KSP options in the database.
51: Collective on KSP
53: Input Parameters:
54: + ksp - the Krylov context
55: - prefix - the prefix string to prepend to all KSP option requests
57: Notes:
58: A hyphen (-) must NOT be given at the beginning of the prefix name.
59: The first character of all runtime options is AUTOMATICALLY the
60: hyphen.
62: For example, to distinguish between the runtime options for two
63: different KSP contexts, one could call
64: .vb
65: KSPSetOptionsPrefix(ksp1,"sys1_")
66: KSPSetOptionsPrefix(ksp2,"sys2_")
67: .ve
69: This would enable use of different options for each system, such as
70: .vb
71: -sys1_ksp_type gmres -sys1_ksp_rtol 1.e-3
72: -sys2_ksp_type bcgs -sys2_ksp_rtol 1.e-4
73: .ve
75: Level: advanced
77: .keywords: KSP, set, options, prefix, database
79: .seealso: KSPAppendOptionsPrefix(), KSPGetOptionsPrefix()
80: @*/
81: PetscErrorCode PETSCKSP_DLLEXPORT KSPSetOptionsPrefix(KSP ksp,const char prefix[])
82: {
86: PCSetOptionsPrefix(ksp->pc,prefix);
87: PetscObjectSetOptionsPrefix((PetscObject)ksp,prefix);
88: return(0);
89: }
90:
93: /*@C
94: KSPAppendOptionsPrefix - Appends to the prefix used for searching for all
95: KSP options in the database.
97: Collective on KSP
99: Input Parameters:
100: + ksp - the Krylov context
101: - prefix - the prefix string to prepend to all KSP option requests
103: Notes:
104: A hyphen (-) must NOT be given at the beginning of the prefix name.
105: The first character of all runtime options is AUTOMATICALLY the hyphen.
107: Level: advanced
109: .keywords: KSP, append, options, prefix, database
111: .seealso: KSPSetOptionsPrefix(), KSPGetOptionsPrefix()
112: @*/
113: PetscErrorCode PETSCKSP_DLLEXPORT KSPAppendOptionsPrefix(KSP ksp,const char prefix[])
114: {
118: PCAppendOptionsPrefix(ksp->pc,prefix);
119: PetscObjectAppendOptionsPrefix((PetscObject)ksp,prefix);
120: return(0);
121: }
125: /*@C
126: KSPGetOptionsPrefix - Gets the prefix used for searching for all
127: KSP options in the database.
129: Not Collective
131: Input Parameters:
132: . ksp - the Krylov context
134: Output Parameters:
135: . prefix - pointer to the prefix string used is returned
137: Notes: On the fortran side, the user should pass in a string 'prifix' of
138: sufficient length to hold the prefix.
140: Level: advanced
142: .keywords: KSP, set, options, prefix, database
144: .seealso: KSPSetOptionsPrefix(), KSPAppendOptionsPrefix()
145: @*/
146: PetscErrorCode PETSCKSP_DLLEXPORT KSPGetOptionsPrefix(KSP ksp,const char *prefix[])
147: {
151: PetscObjectGetOptionsPrefix((PetscObject)ksp,prefix);
152: return(0);
153: }
155: