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 TaoOptionList(const char *opt, const char *ltext, const char *man,
109:                   const char **list, int nlist, const char *defaultv,
110:                   int *value, TaoTruth *set)
111: {
112:   TaoFunctionBegin;
113:   if (set) *set=TAO_FALSE;
114:   TaoFunctionReturn(0);
115: }

119: int TaoMethodsList(const char *opt,const char *ltext,const char *man,const char *defaultv,char *value,int len,TaoTruth *set){
120:   TaoFunctionBegin;
121:   if (set)  *set=TAO_FALSE;
122:   TaoFunctionReturn(0);
123: }


128: int TaoFindSolver(TAO_SOLVER tao, TaoMethod type,  int (**r)(TAO_SOLVER) ){
129:   int i;
130:   int nsolvers=TaoList.nsolvers;
131:   TaoFunctionBegin;
132:   *r=0;
133:   for (i=0; i<nsolvers; i++){
134:     if (strncmp(type,TaoList.TSolver[i].identifier,MAX_SOLVER_NAME_LENGTH)==0){
135:       *r=TaoList.TSolver[i].rr;
136:       strncpy(tao->type_name,type,MAX_SOLVER_NAME_LENGTH);
137:       break;
138:     }
139:   }
140:   TaoFunctionReturn(0);
141: }

145: int TaoRegisterDestroy(){
146:   TaoFunctionBegin;
147:   TaoList.nsolvers=0;
148:   TaoFunctionReturn(0);
149: }


155: int TaoRegisterDynamic(const char *sname,const char *path,const char *name,int (*function)(TAO_SOLVER))
156: {
157:   int i=TaoList.nsolvers;

159:   TaoFunctionBegin;
160:   if (TaoList.nsolvers>TaoList.maxsolvers-1){
161:     return 1;
162:   } 
163:   TaoList.TSolver[i].rr=function;
164:   strncpy(TaoList.TSolver[i].identifier,sname,MAX_SOLVER_NAME_LENGTH);
165:   TaoList.nsolvers++;
166:   TaoFunctionReturn(0);
167: }

172: int TaoCompareMethod(TAO_SOLVER tao, TaoMethod type, TaoTruth *issame){
173:   int info;
174:   TaoMethod currenttype;
175:   TaoFunctionBegin;
176:   TaoValidHeaderSpecific(tao,TAO_COOKIE,1);
177:   info = TaoGetMethod(tao,&currenttype);CHKERRQ(info);
178:   if (currenttype && type){
179:     info = strncmp(type,currenttype,MAX_SOLVER_NAME_LENGTH);  
180:     if (info==0){
181:       *issame=TAO_TRUE; 
182:     } else {
183:       *issame=TAO_FALSE;
184:     }
185:   } else {
186:     *issame=TAO_FALSE;
187:   }
188:   TaoFunctionReturn(0);
189: }


194: int TaoObjectCreate( TAO_SOLVER *newsolver, MPI_Comm comm){
195:   TAO_SOLVER solver;
196:   int info;
197:   
198:   TaoFunctionBegin;
199:   info=TaoNew(struct _p_TAO_SOLVER,(void**)&solver);CHKERRQ(info);
200:   //solver=(TAO_SOLVER)malloc(sizeof(struct _p_TAO_SOLVER)); 
201:   *newsolver = solver;
202:   TaoFunctionReturn(0);
203: }

207: int TaoObjectDestroy( TAO_SOLVER solver){
208:   int info;
209:   TaoFunctionBegin;
210:   info=TaoFree(solver);
211:   TaoFunctionReturn(0);
212: }

216: int TaoStrcpy(char* str1,const char*str2){
217:   TaoFunctionBegin;
218:   strcpy(str1,str2);
219:   TaoFunctionReturn(0);
220: }

224: int TaoStrcmp(const char *str1,const char *str2,TaoTruth *flag){
225:   int info;
226:   TaoFunctionBegin;
227:   info = strcmp(str1,str2);
228:   if (info) *flag=TAO_FALSE; else *flag=TAO_TRUE;
229:   TaoFunctionReturn(0);
230: }

234: int TaoLogClassRegister(int*,const char*){
235:   int i,info;
236:   TaoFunctionBegin;
237:   TaoList.nsolvers=0;
238:   TaoList.maxsolvers=MAX_NUMBER_OF_SOLVERS;
239:   for (i=0;i<TaoList.maxsolvers;i++){
240:     //    TaoList.TSolver[i].identifier[0]='';
241:     TaoList.TSolver[i].rr=0;
242:   }
243:   info = TaoGetArgs(&TaoList.argc,&TaoList.args);CHKERRQ(info);
244:   TaoFunctionReturn(0);
245: }

247: int TaoHelpPrintf(MPI_Comm,const char*,...){
248:   return 0;
249: }


252: #define PetscInfo  (a)   0;


255: #endif