• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

src/generic/femparm.c

Go to the documentation of this file.
00001 
00050 #include "apbscfg.h"
00051 #include "apbs/femparm.h"
00052 
00053 VEMBED(rcsid="$Id: femparm.c 1552 2010-02-10 17:46:27Z yhuang01 $")
00054 
00055 #if !defined(VINLINE_MGPARM)
00056 
00057 #endif /* if !defined(VINLINE_MGPARM) */
00058 
00059 VPUBLIC FEMparm* FEMparm_ctor(FEMparm_CalcType type) {
00060 
00061     /* Set up the structure */
00062     FEMparm *thee = VNULL;
00063     thee = Vmem_malloc(VNULL, 1, sizeof(FEMparm));
00064     VASSERT( thee != VNULL);
00065     VASSERT( FEMparm_ctor2(thee, type) );
00066 
00067     return thee;
00068 }
00069 
00070 VPUBLIC int FEMparm_ctor2(FEMparm *thee, FEMparm_CalcType type) {
00071 
00072     if (thee == VNULL) return 0;
00073 
00074     thee->parsed = 0;
00075     thee->type = type;
00076     thee->settype = 1;
00077 
00078     thee->setglen = 0;
00079     thee->setetol = 0;
00080     thee->setekey = 0;
00081     thee->setakeyPRE = 0;
00082     thee->setakeySOLVE = 0;
00083     thee->settargetNum = 0;
00084     thee->settargetRes = 0;
00085     thee->setmaxsolve = 0;
00086     thee->setmaxvert = 0;
00087  thee->useMesh = 0;
00088 
00089     return 1; 
00090 }
00091 
00092 VPUBLIC void FEMparm_copy(
00093         FEMparm *thee,
00094         FEMparm *source
00095         ) {
00096  
00097  int i;
00098  
00099  thee->parsed = source->parsed;
00100  thee->type = source->type;
00101  thee->settype = source->settype;
00102  for (i=0; i<3; i++) thee->glen[i] = source->glen[i];
00103  thee->setglen = source->setglen;
00104  thee->etol = source->etol;
00105  thee->setetol = source->setetol;
00106  thee->ekey = source->ekey;
00107  thee->setekey = source->setekey;
00108  thee->akeyPRE = source->akeyPRE;
00109  thee->setakeyPRE = source->setakeyPRE;
00110  thee->akeySOLVE = source->akeySOLVE;
00111  thee->setakeySOLVE = source->setakeySOLVE;
00112  thee->targetNum = source->targetNum;
00113  thee->settargetNum = source->settargetNum;
00114  thee->targetRes = source->targetRes;
00115  thee->settargetRes = source->settargetRes;
00116  thee->maxsolve = source->maxsolve;
00117  thee->setmaxsolve = source->setmaxsolve;
00118  thee->maxvert = source->maxvert;
00119  thee->setmaxvert = source->setmaxvert;
00120  thee->pkey = source->pkey;
00121  thee->useMesh = source->useMesh;
00122  thee->meshID = source->meshID;
00123 }
00124 
00125 VPUBLIC void FEMparm_dtor(FEMparm **thee) {
00126     if ((*thee) != VNULL) {
00127         FEMparm_dtor2(*thee);
00128         Vmem_free(VNULL, 1, sizeof(FEMparm), (void **)thee);
00129         (*thee) = VNULL;
00130     }
00131 }
00132 
00133 VPUBLIC void FEMparm_dtor2(FEMparm *thee) { ; }
00134 
00135 VPUBLIC int FEMparm_check(FEMparm *thee) { 
00136 
00137     int rc;
00138     rc = 1;
00139 
00140     if (!thee->parsed) {
00141         Vnm_print(2, "FEMparm_check:  not filled!\n");
00142         return 0;
00143     }
00144     if (!thee->settype) {
00145         Vnm_print(2, "FEMparm_check:  type not set!\n");
00146         rc = 0;
00147     }
00148     if (!thee->setglen) {
00149         Vnm_print(2, "FEMparm_check:  glen not set!\n");
00150         rc = 0;
00151     }
00152     if (!thee->setetol) {
00153         Vnm_print(2, "FEMparm_check:  etol not set!\n");
00154         rc = 0;
00155     }
00156     if (!thee->setekey) {
00157         Vnm_print(2, "FEMparm_check:  ekey not set!\n");
00158         rc = 0;
00159     }
00160     if (!thee->setakeyPRE) {
00161         Vnm_print(2, "FEMparm_check:  akeyPRE not set!\n");
00162         rc = 0;
00163     }
00164     if (!thee->setakeySOLVE) {
00165         Vnm_print(2, "FEMparm_check:  akeySOLVE not set!\n");
00166         rc = 0;
00167     }
00168     if (!thee->settargetNum) {
00169         Vnm_print(2, "FEMparm_check:  targetNum not set!\n");
00170         rc = 0;
00171     }
00172     if (!thee->settargetRes) {
00173         Vnm_print(2, "FEMparm_check:  targetRes not set!\n");
00174         rc = 0;
00175     }
00176     if (!thee->setmaxsolve) {
00177         Vnm_print(2, "FEMparm_check:  maxsolve not set!\n");
00178         rc = 0;
00179     }
00180     if (!thee->setmaxvert) {
00181         Vnm_print(2, "FEMparm_check:  maxvert not set!\n");
00182         rc = 0;
00183     }
00184 
00185     return rc;
00186 }
00187 
00188 VPRIVATE Vrc_Codes FEMparm_parseDOMAINLENGTH(FEMparm *thee, Vio *sock) {
00189 
00190     int i;
00191     double tf;
00192     char tok[VMAX_BUFSIZE];
00193 
00194     for (i=0; i<3; i++) {
00195         VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00196         if (sscanf(tok, "%lf", &tf) == 0) {
00197             Vnm_print(2, "parseFE:  Read non-double (%s) while parsing \
00198 DOMAINLENGTH keyword!\n", tok);
00199             return VRC_FAILURE;
00200         } 
00201         thee->glen[i] = tf;
00202     }
00203     thee->setglen = 1;
00204     return VRC_SUCCESS;
00205 VERROR1:
00206     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00207     return VRC_FAILURE;
00208 
00209 }
00210 
00211 VPRIVATE Vrc_Codes FEMparm_parseETOL(FEMparm *thee, Vio *sock) {
00212 
00213     double tf;
00214     char tok[VMAX_BUFSIZE];
00215 
00216     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00217     if (sscanf(tok, "%lf", &tf) == 0) {
00218         Vnm_print(2, "parseFE:  Read non-double (%s) while parsing \
00219 ETOL keyword!\n", tok);
00220         return VRC_FAILURE;
00221     }
00222     thee->etol = tf;
00223     thee->setetol = 1;
00224     return VRC_SUCCESS;
00225 VERROR1:
00226     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00227     return VRC_FAILURE;
00228 
00229 
00230 }
00231 
00232 VPRIVATE Vrc_Codes FEMparm_parseEKEY(FEMparm *thee, Vio *sock) {
00233 
00234     char tok[VMAX_BUFSIZE];
00235     Vrc_Codes vrc = VRC_FAILURE;
00236 
00237     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00238     if (Vstring_strcasecmp(tok, "simp") == 0) {
00239         thee->ekey = FET_SIMP;
00240         thee->setekey = 1;
00241         vrc = VRC_SUCCESS;
00242     } else if (Vstring_strcasecmp(tok, "glob") == 0) {
00243         thee->ekey = FET_GLOB;
00244         thee->setekey = 1;
00245         vrc = VRC_SUCCESS;
00246     } else if (Vstring_strcasecmp(tok, "frac") == 0) {
00247         thee->ekey = FET_FRAC;
00248         thee->setekey = 1;
00249         vrc = VRC_SUCCESS;
00250     } else {
00251         Vnm_print(2, "parseFE:  undefined value (%s) for ekey!\n", tok);
00252         vrc = VRC_FAILURE;
00253     }
00254 
00255     return vrc;
00256 VERROR1:
00257     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00258     return VRC_FAILURE;
00259 
00260 }
00261 
00262 VPRIVATE Vrc_Codes FEMparm_parseAKEYPRE(FEMparm *thee, Vio *sock) {
00263 
00264     char tok[VMAX_BUFSIZE];
00265     Vrc_Codes vrc = VRC_FAILURE;
00266 
00267     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00268     if (Vstring_strcasecmp(tok, "unif") == 0) {
00269         thee->akeyPRE = FRT_UNIF;
00270         thee->setakeyPRE = 1;
00271         vrc =  VRC_SUCCESS;
00272     } else if (Vstring_strcasecmp(tok, "geom") == 0) {
00273         thee->akeyPRE = FRT_GEOM;
00274         thee->setakeyPRE = 1;
00275         vrc =  VRC_SUCCESS;
00276     } else {
00277         Vnm_print(2, "parseFE:  undefined value (%s) for akeyPRE!\n", tok);
00278         vrc =  VRC_FAILURE;
00279     }
00280 
00281     return vrc;
00282 
00283 VERROR1:
00284     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00285     return VRC_FAILURE;
00286 
00287 }
00288 
00289 VPRIVATE Vrc_Codes FEMparm_parseAKEYSOLVE(FEMparm *thee, Vio *sock) {
00290 
00291     char tok[VMAX_BUFSIZE];
00292     Vrc_Codes vrc = VRC_FAILURE;
00293 
00294     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00295     if (Vstring_strcasecmp(tok, "resi") == 0) {
00296         thee->akeySOLVE = FRT_RESI;
00297         thee->setakeySOLVE = 1;
00298         vrc =  VRC_SUCCESS;
00299     } else if (Vstring_strcasecmp(tok, "dual") == 0) {
00300         thee->akeySOLVE = FRT_DUAL;
00301         thee->setakeySOLVE = 1;
00302         vrc =  VRC_SUCCESS;
00303     } else if (Vstring_strcasecmp(tok, "loca") == 0) {
00304         thee->akeySOLVE = FRT_LOCA;
00305         thee->setakeySOLVE = 1;
00306         vrc =  VRC_SUCCESS;
00307     } else {
00308         Vnm_print(2, "parseFE:  undefined value (%s) for akeyPRE!\n", tok);
00309         vrc =  VRC_FAILURE;
00310     }
00311 
00312     return vrc;
00313 VERROR1:
00314     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00315     return VRC_SUCCESS;
00316 
00317 }
00318 
00319 VPRIVATE Vrc_Codes FEMparm_parseTARGETNUM(FEMparm *thee, Vio *sock) {
00320 
00321     char tok[VMAX_BUFSIZE];
00322     int ti;
00323 
00324     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00325     if (sscanf(tok, "%d", &ti) == 0) {
00326         Vnm_print(2, "parseFE:  read non-int (%s) for targetNum!\n", tok);
00327         return VRC_FAILURE;
00328     }
00329     thee->targetNum = ti;
00330     thee->settargetNum = 1;
00331     return VRC_SUCCESS;
00332 VERROR1:
00333     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00334     return VRC_FAILURE;
00335 
00336 }
00337 
00338 VPRIVATE Vrc_Codes FEMparm_parseTARGETRES(FEMparm *thee, Vio *sock) {
00339 
00340     char tok[VMAX_BUFSIZE];
00341     double tf;
00342 
00343     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00344     if (sscanf(tok, "%lf", &tf) == 0) {
00345         Vnm_print(2, "parseFE:  read non-double (%s) for targetNum!\n", 
00346           tok);
00347         return VRC_FAILURE;
00348     }
00349     thee->targetRes = tf;
00350     thee->settargetRes = 1;
00351     return VRC_SUCCESS;
00352 VERROR1:
00353     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00354     return VRC_FAILURE;
00355 
00356 }
00357 
00358 VPRIVATE Vrc_Codes FEMparm_parseMAXSOLVE(FEMparm *thee, Vio *sock) {
00359 
00360     char tok[VMAX_BUFSIZE];
00361     int ti;
00362 
00363     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00364     if (sscanf(tok, "%d", &ti) == 0) {
00365         Vnm_print(2, "parseFE:  read non-int (%s) for maxsolve!\n", tok);
00366         return VRC_FAILURE;
00367     }
00368     thee->maxsolve = ti;
00369     thee->setmaxsolve = 1;
00370     return VRC_SUCCESS;
00371 VERROR1:
00372     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00373     return VRC_FAILURE;
00374 
00375 }
00376 
00377 VPRIVATE Vrc_Codes FEMparm_parseMAXVERT(FEMparm *thee, Vio *sock) {
00378 
00379     char tok[VMAX_BUFSIZE];
00380     int ti;
00381 
00382     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00383     if (sscanf(tok, "%d", &ti) == 0) {
00384         Vnm_print(2, "parseFE:  read non-int (%s) for maxvert!\n", tok);
00385         return VRC_FAILURE;
00386     }
00387     thee->maxvert = ti;
00388     thee->setmaxvert = 1;
00389     return VRC_SUCCESS;
00390  
00391 VERROR1:
00392     Vnm_print(2, "parseFE:  ran out of tokens!\n");
00393     return VRC_FAILURE;
00394 
00395 }
00396 
00397 VPRIVATE Vrc_Codes FEMparm_parseUSEMESH(FEMparm *thee, Vio *sock) {
00398     char tok[VMAX_BUFSIZE];
00399     int ti;
00400  
00401     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00402  if (sscanf(tok, "%d", &ti) == 0) {
00403         Vnm_print(2, "parseFE:  read non-int (%s) for usemesh!\n", tok);
00404         return VRC_FAILURE;
00405     } 
00406  thee->useMesh = 1;
00407  thee->meshID = ti;
00408  
00409  return VRC_SUCCESS;
00410  
00411 VERROR1:
00412  Vnm_print(2, "parsePBE:  ran out of tokens!\n");
00413  return VRC_FAILURE;
00414 }
00415 
00416 
00417 VPUBLIC Vrc_Codes FEMparm_parseToken(FEMparm *thee, char tok[VMAX_BUFSIZE],
00418   Vio *sock) {
00419 
00420     int i, ti;
00421     double tf;
00422 
00423     if (thee == VNULL) {
00424         Vnm_print(2, "parseFE:  got NULL thee!\n");
00425         return VRC_FAILURE;
00426     }
00427 
00428     if (sock == VNULL) {
00429         Vnm_print(2, "parseFE:  got NULL socket!\n");
00430         return VRC_FAILURE;
00431     }
00432 
00433     if (Vstring_strcasecmp(tok, "domainLength") == 0) {
00434         return FEMparm_parseDOMAINLENGTH(thee, sock);
00435     } else if (Vstring_strcasecmp(tok, "etol") == 0) {
00436         return FEMparm_parseETOL(thee, sock);
00437     } else if (Vstring_strcasecmp(tok, "ekey") == 0) {
00438         return FEMparm_parseEKEY(thee, sock);
00439     } else if (Vstring_strcasecmp(tok, "akeyPRE") == 0) {
00440         return FEMparm_parseAKEYPRE(thee, sock);
00441     } else if (Vstring_strcasecmp(tok, "akeySOLVE") == 0) {
00442         return FEMparm_parseAKEYSOLVE(thee, sock);
00443     } else if (Vstring_strcasecmp(tok, "targetNum") == 0) {
00444         return FEMparm_parseTARGETNUM(thee, sock);
00445     } else if (Vstring_strcasecmp(tok, "targetRes") == 0) {
00446         return FEMparm_parseTARGETRES(thee, sock);
00447     } else if (Vstring_strcasecmp(tok, "maxsolve") == 0) {
00448         return FEMparm_parseMAXSOLVE(thee, sock);
00449     } else if (Vstring_strcasecmp(tok, "maxvert") == 0) {
00450         return FEMparm_parseMAXVERT(thee, sock);
00451     } else if (Vstring_strcasecmp(tok, "usemesh") == 0) {
00452         return FEMparm_parseUSEMESH(thee, sock);
00453     }
00454 
00455     return VRC_WARNING;
00456 
00457 }

Generated on Wed Oct 20 2010 12:01:33 for APBS by  doxygen 1.7.2