Actual source code: bkernal.c

  1: #include "tao_general.h"      /*I "tao_general.h"  I*/

  3: #ifndef TAO_USE_PETSC

  5: #include "src/tao_impl.h"
  6: #include <stdlib.h>
  7: #include <string.h>

  9: #define MAX_SOLVER_NAME_LENGTH 20
 10: #define MAX_NUMBER_OF_SOLVERS 20

 12: typedef struct {
 13:   int (*rr)(TAO_SOLVER);
 14:   char identifier[MAX_SOLVER_NAME_LENGTH+1];
 15: } _P_TSolver;

 17: typedef struct {
 18:   _P_TSolver  TSolver[MAX_NUMBER_OF_SOLVERS];
 19:   int nsolvers;
 20:   int maxsolvers;
 21:   int argc;
 22:   char **args;
 23: } TaoSolverList;

 25: static TaoSolverList TaoList;


 30: int TaoPrintStatement(TAO_SOLVER tao, const char *statement){
 31:   TaoFunctionBegin;
 32:   printf(statement);
 33:   TaoFunctionReturn(0);
 34: }

 38: int TaoPrintInt(TAO_SOLVER tao, const char *statement, int n){
 39:   TaoFunctionBegin;
 40:   printf(statement,n);
 41:   TaoFunctionReturn(0);
 42: }

 46: int TaoPrintDouble(TAO_SOLVER tao, const char *statement,double dd){
 47:   TaoFunctionBegin;
 48:   printf(statement,dd);
 49:   TaoFunctionReturn(0);
 50: }

 54: int TaoPrintString(TAO_SOLVER tao, const char *statement,const char *str){
 55:   TaoFunctionBegin;
 56:   printf(statement,str);
 57:   TaoFunctionReturn(0);
 58: }

 62: int TaoOptionsHead(const char *heading){
 63:   TaoFunctionBegin;
 64:   TaoFunctionReturn(0);
 65: }

 69: int TaoOptionsTail(){
 70:   TaoFunctionBegin;
 71:   TaoFunctionReturn(0);
 72: }

 76: int TaoOptionInt(const char *opt,const char *text,const char *man,int defaultv,int *value,TaoTruth *set){
 77:   TaoFunctionBegin;
 78:   if (set) *set=TAO_FALSE;
 79:   TaoFunctionReturn(0);
 80: }

 84: int TaoOptionDouble(const char *opt,const char *text,const char *man,double defaultv,double *value,TaoTruth *set){
 85:   TaoFunctionBegin;
 86:   if (set) *set=TAO_FALSE;
 87:   TaoFunctionReturn(0);
 88: }

 92: int TaoOptionString(const char *opt,const char *text,const char *man,const char* defaultv,char *value, int len, TaoTruth *set){
 93:   TaoFunctionBegin;
 94:   if (set) *set=TAO_FALSE;
 95:   TaoFunctionReturn(0);
 96: }

100: int TaoOptionName(const char *opt,const char *text,const char *man,TaoTruth *set){
101:   TaoFunctionBegin;
102:   if (set) *set=TAO_FALSE;
103:   TaoFunctionReturn(0);
104: }

108: int TaoMethodsList(const char *opt,const char *ltext,const char *man,const char *defaultv,char *value,int len,TaoTruth *set){
109:   TaoFunctionBegin;
110:   if (set)  *set=TAO_FALSE;
111:   TaoFunctionReturn(0);
112: }


117: int TaoFindSolver(TAO_SOLVER tao, TaoMethod type,  int (**r)(TAO_SOLVER) ){
118:   int i;
119:   int nsolvers=TaoList.nsolvers;
120:   TaoFunctionBegin;
121:   *r=0;
122:   for (i=0; i<nsolvers; i++){
123:     if (strncmp(type,TaoList.TSolver[i].identifier,MAX_SOLVER_NAME_LENGTH)==0){
124:       *r=TaoList.TSolver[i].rr;
125:       strncpy(tao->type_name,type,MAX_SOLVER_NAME_LENGTH);
126:       break;
127:     }
128:   }
129:   TaoFunctionReturn(0);
130: }

134: int TaoRegisterDestroy(){
135:   TaoFunctionBegin;
136:   TaoList.nsolvers=0;
137:   TaoFunctionReturn(0);
138: }


144: int TaoRegisterDynamic(const char *sname,const char *path,const char *name,int (*function)(TAO_SOLVER))
145: {
146:   int i=TaoList.nsolvers;

148:   TaoFunctionBegin;
149:   if (TaoList.nsolvers>TaoList.maxsolvers-1){
150:     return 1;
151:   }
152:   TaoList.TSolver[i].rr=function;
153:   strncpy(TaoList.TSolver[i].identifier,sname,MAX_SOLVER_NAME_LENGTH);
154:   TaoList.nsolvers++;
155:   TaoFunctionReturn(0);
156: }

161: int TaoCompareMethod(TAO_SOLVER tao, TaoMethod type, TaoTruth *issame){
162:   int info;
163:   TaoMethod currenttype;
164:   TaoFunctionBegin;
165:   TaoValidHeaderSpecific(tao,TAO_COOKIE,1);
166:   info = TaoGetMethod(tao,&currenttype);CHKERRQ(info);
167:   if (currenttype && type){
168:     info = strncmp(type,currenttype,MAX_SOLVER_NAME_LENGTH);
169:     if (info==0){
170:       *issame=TAO_TRUE;
171:     } else {
172:       *issame=TAO_FALSE;
173:     }
174:   } else {
175:     *issame=TAO_FALSE;
176:   }
177:   TaoFunctionReturn(0);
178: }


183: int TaoObjectCreate( TAO_SOLVER *newsolver, MPI_Comm comm){
184:   TAO_SOLVER solver;
185:   int info;
186: 
187:   TaoFunctionBegin;
188:   info=TaoNew(struct _p_TAO_SOLVER,(void**)&solver);CHKERRQ(info);
189:   //solver=(TAO_SOLVER)malloc(sizeof(struct _p_TAO_SOLVER));
190:   *newsolver = solver;
191:   TaoFunctionReturn(0);
192: }

196: int TaoObjectDestroy( TAO_SOLVER solver){
197:   int info;
198:   TaoFunctionBegin;
199:   info=TaoFree(solver);
200:   TaoFunctionReturn(0);
201: }

205: int TaoStrcpy(char* str1,const char*str2){
206:   TaoFunctionBegin;
207:   strcpy(str1,str2);
208:   TaoFunctionReturn(0);
209: }

213: int TaoStrcmp(const char *str1,const char *str2,TaoTruth *flag){
214:   int info;
215:   TaoFunctionBegin;
216:   info = strcmp(str1,str2);
217:   if (info) *flag=TAO_FALSE; else *flag=TAO_TRUE;
218:   TaoFunctionReturn(0);
219: }

223: int TaoLogClassRegister(int*,const char*){
224:   int i,info;
225:   TaoFunctionBegin;
226:   TaoList.nsolvers=0;
227:   TaoList.maxsolvers=MAX_NUMBER_OF_SOLVERS;
228:   for (i=0;i<TaoList.maxsolvers;i++){
229:     //    TaoList.TSolver[i].identifier[0]='';
230:     TaoList.TSolver[i].rr=0;
231:   }
232:   info = TaoGetArgs(&TaoList.argc,&TaoList.args);CHKERRQ(info);
233:   TaoFunctionReturn(0);
234: }

236: int TaoHelpPrintf(MPI_Comm,const char*,...){
237:   return 0;
238: }


241: #define PetscLogInfo  (a)   0;


244: #endif