--- ray/src/util/eplus_adduvf.c 2014/02/21 13:17:45 2.12 +++ ray/src/util/eplus_adduvf.c 2014/02/27 20:39:04 2.13 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: eplus_adduvf.c,v 2.12 2014/02/21 13:17:45 greg Exp $"; +static const char RCSid[] = "$Id: eplus_adduvf.c,v 2.13 2014/02/27 20:39:04 greg Exp $"; #endif /* * Add User View Factors to EnergyPlus Input Data File @@ -176,7 +176,11 @@ add_subsurf(IDF_OBJECT *param) static IDF_FIELD * get_vlist(IDF_OBJECT *param, const char *zname) { - int i = 0; + const int itm_len = sizeof(IDF_FIELD)+6; + static char fld_buf[4*itm_len]; + static char *next_fbp = fld_buf; + int i; + IDF_FIELD *res; /* check if subsurface */ if (!strcmp(param->pname, SUBSURF_PNAME)) { if (zname != NULL) { @@ -185,20 +189,36 @@ get_vlist(IDF_OBJECT *param, const char *zname) if (strcmp((*(ZONE *)lep->data).zname, zname)) return(NULL); } - return(idf_getfield(param, SS_VERT_FLD)); + res = idf_getfield(param, SS_VERT_FLD); + } else { + i = 0; /* check for surface type */ + while (strcmp(surf_type[i].pname, param->pname)) + if (surf_type[++i].pname == NULL) + return(NULL); + + if (zname != NULL) { /* matches specified zone? */ + IDF_FIELD *fptr = idf_getfield(param, surf_type[i].zone_fld); + if (fptr == NULL || strcmp(fptr->val, zname)) + return(NULL); + } + res = idf_getfield(param, surf_type[i].vert_fld); } - /* check for surface type */ - while (strcmp(surf_type[i].pname, param->pname)) - if (surf_type[++i].pname == NULL) + if (!res->val[0]) { /* hack for missing #vert */ + IDF_FIELD *fptr; + if (next_fbp >= fld_buf+sizeof(fld_buf)) + next_fbp = fld_buf; + i = 0; /* count vertices */ + for (fptr = res->next; fptr != NULL; fptr = fptr->next) + ++i; + if (i % 3) return(NULL); - - if (zname != NULL) { /* matches specified zone? */ - IDF_FIELD *fptr = idf_getfield(param, surf_type[i].zone_fld); - if (fptr == NULL || strcmp(fptr->val, zname)) - return(NULL); + fptr = res->next; + res = (IDF_FIELD *)next_fbp; next_fbp += itm_len; + res->next = fptr; + res->rem = ""; + sprintf(res->val, "%d", i/3); } - /* return field for #verts */ - return(idf_getfield(param, surf_type[i].vert_fld)); + return(res); } /* Get/allocate surface polygon */