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: /*@
 18:     KSPAddOptionsChecker - Adds an additional function to check for KSP options.

 20:     Not Collective

 22:     Input Parameter:
 23: .   kspcheck - function that checks for options

 25:     Level: developer

 27: .keywords: KSP, add, options, checker

 29: .seealso: KSPSetFromOptions()
 30: @*/
 31: int KSPAddOptionsChecker(int (*kspcheck)(KSP))
 32: {
 34:   if (numberofsetfromoptions >= MAXSETFROMOPTIONS) {
 35:     SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Too many options checkers, only 5 allowed");
 36:   }

 38:   othersetfromoptions[numberofsetfromoptions++] = kspcheck;
 39:   return(0);
 40: }

 42: /*@C
 43:    KSPSetOptionsPrefix - Sets the prefix used for searching for all 
 44:    KSP options in the database.

 46:    Collective on KSP

 48:    Input Parameters:
 49: +  ksp - the Krylov context
 50: -  prefix - the prefix string to prepend to all KSP option requests

 52:    Notes:
 53:    A hyphen (-) must NOT be given at the beginning of the prefix name.
 54:    The first character of all runtime options is AUTOMATICALLY the
 55:    hyphen.

 57:    For example, to distinguish between the runtime options for two
 58:    different KSP contexts, one could call
 59: .vb
 60:       KSPSetOptionsPrefix(ksp1,"sys1_")
 61:       KSPSetOptionsPrefix(ksp2,"sys2_")
 62: .ve

 64:    This would enable use of different options for each system, such as
 65: .vb
 66:       -sys1_ksp_type gmres -sys1_ksp_rtol 1.e-3
 67:       -sys2_ksp_type bcgs  -sys2_ksp_rtol 1.e-4
 68: .ve

 70:    Level: advanced

 72: .keywords: KSP, set, options, prefix, database

 74: .seealso: KSPAppendOptionsPrefix(), KSPGetOptionsPrefix()
 75: @*/
 76: int KSPSetOptionsPrefix(KSP ksp,char *prefix)
 77: {
 81:   PetscObjectSetOptionsPrefix((PetscObject)ksp,prefix);
 82:   return(0);
 83: }
 84: 
 85: /*@C
 86:    KSPAppendOptionsPrefix - Appends to the prefix used for searching for all 
 87:    KSP options in the database.

 89:    Collective on KSP

 91:    Input Parameters:
 92: +  ksp - the Krylov context
 93: -  prefix - the prefix string to prepend to all KSP option requests

 95:    Notes:
 96:    A hyphen (-) must NOT be given at the beginning of the prefix name.
 97:    The first character of all runtime options is AUTOMATICALLY the hyphen.

 99:    Level: advanced

101: .keywords: KSP, append, options, prefix, database

103: .seealso: KSPSetOptionsPrefix(), KSPGetOptionsPrefix()
104: @*/
105: int KSPAppendOptionsPrefix(KSP ksp,char *prefix)
106: {
110:   PetscObjectAppendOptionsPrefix((PetscObject)ksp,prefix);
111:   return(0);
112: }

114: /*@C
115:    KSPGetOptionsPrefix - Gets the prefix used for searching for all 
116:    KSP options in the database.

118:    Not Collective

120:    Input Parameters:
121: .  ksp - the Krylov context

123:    Output Parameters:
124: .  prefix - pointer to the prefix string used is returned

126:    Notes: On the fortran side, the user should pass in a string 'prifix' of
127:    sufficient length to hold the prefix.

129:    Level: advanced

131: .keywords: KSP, set, options, prefix, database

133: .seealso: KSPSetOptionsPrefix(), KSPAppendOptionsPrefix()
134: @*/
135: int KSPGetOptionsPrefix(KSP ksp,char **prefix)
136: {
140:   PetscObjectGetOptionsPrefix((PetscObject)ksp,prefix);
141:   return(0);
142: }

144: