Skip to content

Commit

Permalink
Merge pull request #1637 from gforney/master
Browse files Browse the repository at this point in the history
speed up slice file loading, set default  geometry outline offset to 0.0
  • Loading branch information
gforney authored Jul 12, 2023
2 parents f929056 + 2f69e9a commit 42d92dc
Show file tree
Hide file tree
Showing 11 changed files with 683 additions and 194 deletions.
729 changes: 620 additions & 109 deletions Source/smokeview/IOgeometry.c

Large diffs are not rendered by default.

70 changes: 26 additions & 44 deletions Source/smokeview/IOslice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1700,62 +1700,45 @@ void GetSliceGeomHists(slicedata *sd){
CopyVals2Histogram(sd->patchgeom->geom_vals, NULL, NULL, sd->patchgeom->geom_nvals, sd->histograms);
}

/* ------------------ GetAllSliceHists ------------------------ */
/* ------------------ ComputeLoadedSliceHist ------------------------ */

void GetAllSliceHists(void){
int ii;
void ComputeLoadedSliceHist(char *label){
int i;

for(ii = 0; ii < nslice_loaded; ii++){
slicedata *sdi;
int i;
for(i = 0; i<nsliceinfo; i++){
slicedata *slicei;

i = slice_loaded_list[ii];
sdi = sliceinfo + i;
if(sdi->histograms==NULL){
if(sdi->slice_filetype==SLICE_GEOM){
GetSliceGeomHists(sdi);
slicei = sliceinfo+i;
if(slicei->loaded == 0)continue;
if(label!=NULL&&strcmp(slicei->label.shortlabel, label)!=0)continue;
if(slicei->histograms==NULL){
if(slicei->slice_filetype==SLICE_GEOM){
GetSliceGeomHists(slicei);
}
else{
GetSliceHists(sdi);
GetSliceHists(slicei);
}
}
}
}

/* ------------------ ComputeLoadedSliceHist ------------------------ */
/* ------------------ MergeLoadedSliceHist ------------------------ */

void ComputeLoadedSliceHist(char *label, histogramdata **histptr){
void MergeLoadedSliceHist(char *label, histogramdata **histptr){
histogramdata *hist;
int i, have_data=0;

for(i = 0; i<nsliceinfo; i++){
slicedata *slicei;

slicei = sliceinfo+i;
if(slicei->loaded==0||strcmp(slicei->label.shortlabel, label)!=0)continue;
have_data = 1;
}
if(have_data==0)return;
int i;

hist = *histptr;
if(*histptr!=NULL)FreeHistogram(*histptr);
if(*histptr != NULL)FreeHistogram(*histptr);
NewMemory((void **)&hist, sizeof(histogramdata));
*histptr = hist;

InitHistogram(hist, NHIST_BUCKETS, NULL, NULL);
for(i = 0; i<nsliceinfo; i++){
for(i = 0; i < nsliceinfo; i++){
slicedata *slicei;

slicei = sliceinfo+i;
if(slicei->loaded==0||strcmp(slicei->label.shortlabel, label)!=0)continue;
if(slicei->histograms==NULL){
if(slicei->slice_filetype==SLICE_GEOM){
GetSliceGeomHists(slicei);
}
else{
GetSliceHists(slicei);
}
}
slicei = sliceinfo + i;
if(slicei->loaded == 0 || strcmp(slicei->label.shortlabel, label) != 0)continue;
MergeHistogram(hist, slicei->histograms, MERGE_BOUNDS);
}
}
Expand All @@ -1768,7 +1751,7 @@ void UpdateSliceHist(void){
int is_fed = 0;

histograms_defined = 1;
GetAllSliceHists();
ComputeLoadedSliceHist(NULL);
if(hists256_slice != NULL){
for(i = 0; i < nhists256_slice; i++){
FreeHistogram(hists256_slice + i);
Expand Down Expand Up @@ -5143,17 +5126,18 @@ FILE_SIZE ReadSlice(const char *file, int ifile, int time_frame, float *time_val

update_slicefile_bounds = 1; // temporary fix to make sure bounds are always up to date
update_slice2device = 1;
if(update_slicefile_bounds==1){
if(update_slicefile_bounds==0){
update_slicefile_bounds = 0;
GetGlobalSliceBounds();
GetGlobalSliceBounds(sd->label.shortlabel);
SetLoadedSliceBounds(NULL, 0);
}
GetMinMax(BOUND_SLICE, sd->label.shortlabel, &set_valmin, &qmin, &set_valmax, &qmax);
if(set_valmin==BOUND_PERCENTILE_MIN||set_valmax==BOUND_PERCENTILE_MAX){
cpp_boundsdata *bounds;

bounds = GetBoundsData(BOUND_SLICE);
ComputeLoadedSliceHist(bounds->label, &(bounds->hist));
ComputeLoadedSliceHist(bounds->label);
MergeLoadedSliceHist(bounds->label, &(bounds->hist));
if(bounds->hist!=NULL&&bounds->hist->defined==1){
if(set_valmin==BOUND_PERCENTILE_MIN){
GetHistogramValProc(bounds->hist, percentile_level_min, &qmin);
Expand Down Expand Up @@ -6063,8 +6047,6 @@ void DrawVolSliceCellFaceCenterValues(const slicedata *sd, int flag){

}

#define FDS_OFFSET 0.01

/* ------------------ DrawVolSliceTerrain ------------------------ */

void DrawVolSliceTerrain(const slicedata *sd){
Expand Down Expand Up @@ -6118,7 +6100,7 @@ void DrawVolSliceTerrain(const slicedata *sd){
voffset = agl_smv;
}
else{
voffset = MAX(agl_smv, SCALE2FDS(FDS_OFFSET))+slice_dz;
voffset = MAX(agl_smv, slice_dz);
}

zmin = meshi->zplt_orig[0];
Expand Down Expand Up @@ -8645,7 +8627,7 @@ void DrawVVolSliceTerrain(const vslicedata *vd){
voffset = agl_smv;
}
else{
voffset = MAX(agl_smv, SCALE2FDS(FDS_OFFSET))+slice_dz;
voffset = MAX(agl_smv, slice_dz);
}

zmin = meshi->zplt_orig[0];
Expand Down
21 changes: 8 additions & 13 deletions Source/smokeview/IOwui.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ void DrawTerrainGeom(int option){
return;
}


showgeom_inside_domain_local = showgeom_inside_domain;
if(drawing_boundary_files==1)showgeom_inside_domain_local = 0; // hide terrain within FDS domain if drawing boundary files

Expand Down Expand Up @@ -337,7 +336,7 @@ void DrawTerrainGeom(int option){

float *v1, *v2, *v3;
float v1o[3], v2o[3], v3o[3];
float *n1, *n2, *n3;
float *n1;
unsigned int *ind;

ind = terrain_indices+3*i;
Expand All @@ -355,14 +354,12 @@ void DrawTerrainGeom(int option){
if(showgeom_outside_domain==0&&outside_domain==1)continue;

n1 = v1+3;
n2 = v2+3;
n3 = v3+3;
if(terrain_showonly_top==1&&n1[2]<0.0)continue;

for(j = 0; j<3; j++){
v1o[j] = v1[j]+SCALE2FDS(FDS_OFFSET*n1[j]);
v2o[j] = v2[j]+SCALE2FDS(FDS_OFFSET*n2[j]);
v3o[j] = v3[j]+SCALE2FDS(FDS_OFFSET*n3[j]);
v1o[j] = v1[j];
v2o[j] = v2[j];
v3o[j] = v3[j];
if(j==2){
v1o[j] = terrain_zmin+geom_vert_exag*(v1o[j]-terrain_zmin);
v2o[j] = terrain_zmin+geom_vert_exag*(v2o[j]-terrain_zmin);
Expand Down Expand Up @@ -399,7 +396,7 @@ void DrawTerrainGeom(int option){

float *v1, *v2, *v3;
float v1o[3], v2o[3], v3o[3];
float *n1, *n2, *n3;
float *n1;
unsigned int *ind;

ind = terrain_indices+3*i;
Expand All @@ -417,14 +414,12 @@ void DrawTerrainGeom(int option){
if(showgeom_outside_domain==0&&outside_domain==1)continue;

n1 = v1+3;
n2 = v2+3;
n3 = v3+3;
if(terrain_showonly_top==1&&n1[2]<0.0)continue;

for(j = 0; j<3; j++){
v1o[j] = v1[j]+SCALE2FDS(FDS_OFFSET*n1[j]);
v2o[j] = v2[j]+SCALE2FDS(FDS_OFFSET*n2[j]);
v3o[j] = v3[j]+SCALE2FDS(FDS_OFFSET*n3[j]);
v1o[j] = v1[j];
v2o[j] = v2[j];
v3o[j] = v3[j];
if(j==2){
v1o[j] = terrain_zmin+geom_vert_exag*(v1o[j]-terrain_zmin);
v2o[j] = terrain_zmin+geom_vert_exag*(v2o[j]-terrain_zmin);
Expand Down
7 changes: 6 additions & 1 deletion Source/smokeview/getdatabounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,15 @@ void GetLoadedPlot3dBounds(int *compute_loaded, float *loaded_min, float *loaded

/* ------------------ GetGlobalSliceBounds ------------------------ */

void GetGlobalSliceBounds(void){
void GetGlobalSliceBounds(char *type){
int i;

if(nsliceinfo==0)return;
for(i = 0;i<nslicebounds;i++){
boundsdata *boundi;

boundi = slicebounds+i;
if(type != NULL && strcmp(type, boundi->label->shortlabel) != 0)continue;
boundi->dlg_global_valmin = 1.0;
boundi->dlg_global_valmax = 0.0;
}
Expand All @@ -533,6 +534,8 @@ void GetGlobalSliceBounds(void){

slicei = sliceinfo+i;
if(slicei->is_fed==1)continue;
if(type != NULL && strcmp(type, slicei->label.shortlabel) != 0)continue;

if(slicei->valmin_fds>slicei->valmax_fds ||
current_script_command==NULL||current_script_command->command!=SCRIPT_LOADSLICERENDER){
if(GetBounds(slicei->bound_file, &valmin, &valmax, &sliceboundsinfo, &nsliceboundsinfo)==1){
Expand Down Expand Up @@ -562,6 +565,7 @@ void GetGlobalSliceBounds(void){
boundsdata *boundi;

boundi = slicebounds+i;
if(type != NULL && strcmp(type, boundi->label->shortlabel) != 0)continue;
boundi->dlg_valmin = boundi->dlg_global_valmin;
boundi->dlg_valmax = boundi->dlg_global_valmax;
}
Expand All @@ -574,6 +578,7 @@ void GetGlobalSliceBounds(void){

boundscppi = slicebounds_cpp + i;
boundi = slicebounds + i;
if(type != NULL && strcmp(type, boundi->label->shortlabel) != 0)continue;
strcpy(boundscppi->label, boundi->shortlabel);
strcpy(boundscppi->unit, boundi->label->unit);

Expand Down
12 changes: 7 additions & 5 deletions Source/smokeview/glui_bounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,8 @@ extern "C" void SliceBoundsCPP_CB(int var){
case BOUND_COMPUTE_ONLY_PERCENTILES:
bounds = GetBoundsData(BOUND_SLICE);
if(var==BOUND_COMPUTE_PERCENTILES||bounds->hist==NULL){
ComputeLoadedSliceHist(bounds->label,&(bounds->hist));
ComputeLoadedSliceHist(bounds->label);
MergeLoadedSliceHist(bounds->label, &(bounds->hist));
}
if(bounds->hist!=NULL&&bounds->hist->defined==1){
float per_00, per_50, per_100;
Expand All @@ -2010,7 +2011,8 @@ extern "C" void SliceBoundsCPP_CB(int var){
if(GetPercentileDraw(BOUND_SLICE)==1){
bounds = GetBoundsData(BOUND_SLICE);
if(bounds->hist==NULL){
ComputeLoadedSliceHist(bounds->label,&(bounds->hist));
ComputeLoadedSliceHist(bounds->label);
MergeLoadedSliceHist(bounds->label, &(bounds->hist));
}
if(bounds->hist!=NULL&&bounds->hist->defined==1){
float hist_min, hist_max;
Expand Down Expand Up @@ -4120,9 +4122,9 @@ extern "C" void ImmersedBoundCB(int var){
case OUTLINE_HIDDEN:
show_slice_outlines[i]=0;
break;
default:
ASSERT(FFALSE);
break;
default:
ASSERT(FFALSE);
break;
}
}
if(RADIO_slice_edgetype!=NULL)RADIO_slice_edgetype->set_int_val(glui_slice_edgetype);
Expand Down
3 changes: 3 additions & 0 deletions Source/smokeview/glui_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,9 @@ extern "C" void GluiGeometrySetup(int main_window){

PANEL_geom_offset_outline = glui_geometry->add_panel_to_panel(PANEL_group1, "offset outline/points");
PANEL_geom_offset_outline->set_alignment(GLUI_ALIGN_LEFT);
#define FDS_OFFSET 0.005
// geom_norm_offset = (float)((int)(SCALE2FDS(FDS_OFFSET)));
// geom_dz_offset = ( float )(( int )(SCALE2FDS(FDS_OFFSET)));
glui_geometry->add_spinner_to_panel(PANEL_geom_offset_outline, "normal", GLUI_SPINNER_FLOAT, &geom_norm_offset);
glui_geometry->add_spinner_to_panel(PANEL_geom_offset_outline, "vertical", GLUI_SPINNER_FLOAT, &geom_dz_offset);

Expand Down
19 changes: 7 additions & 12 deletions Source/smokeview/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,13 @@ char *ProcessCommandLine(CommandlineArgs *args) {
setup_only = 1;
}
if(args->bindir != NULL){
int len2;
int len2;

len2 = strlen(args->bindir);
NewMemory((void **)&smokeview_bindir, len2 + 2);
strcpy(smokeview_bindir, args->bindir);
if(smokeview_bindir[len2 - 1] != dirseparator[0])strcat(smokeview_bindir, dirseparator);
#ifdef pp_BINDIR
have_bindir_arg = 1;
#endif
len2 = strlen(args->bindir);
NewMemory((void **)&smokeview_bindir, len2 + 2);
strcpy(smokeview_bindir, args->bindir);
if(smokeview_bindir[len2 - 1] != dirseparator[0])strcat(smokeview_bindir, dirseparator);
have_bindir_arg = 1;
}
if(args->casedir){
int len2;
Expand Down Expand Up @@ -669,7 +667,7 @@ int CheckSMVFile(char *file, char *subdir){
}

/* ------------------ IsInstallBinDir ------------------------ */
#ifdef pp_BINDIR

int IsInstallBinDir(char *bindir){
char smvfile[1024];

Expand All @@ -679,7 +677,6 @@ int IsInstallBinDir(char *bindir){
strcat(smvfile, ".smokeview_bin");
return FileExistsOrig(smvfile);
}
#endif

/* ------------------ main ------------------------ */

Expand Down Expand Up @@ -739,7 +736,6 @@ int main(int argc, char **argv){
if(smokeview_bindir==NULL){
smokeview_bindir = GetProgDir(progname, &smokeviewpath);
}
#ifdef pp_BINDIR
int valid_bindir;

valid_bindir = have_bindir_arg;
Expand Down Expand Up @@ -808,7 +804,6 @@ int main(int argc, char **argv){
valid_bindir = 1;
}
}
#endif
#endif

if(smv_filename == NULL){
Expand Down
2 changes: 0 additions & 2 deletions Source/smokeview/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

//#define pp_BNDF // merge geometry and structured boundary files in load menus

#define pp_BINDIR // search for a installation bin directory if smokeview is not in one

//#define pp_DPRINT // turn on debug print (file, line number)

// streaming directives
Expand Down
2 changes: 1 addition & 1 deletion Source/smokeview/readsmv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3013,7 +3013,7 @@ void UpdateBoundInfo(void){
}
UpdateChar();
GetGlobalPartBounds(ALL_FILES);
GetGlobalSliceBounds();
GetGlobalSliceBounds(NULL);
GetGlobalPatchBounds();
GetGlobalHVACDuctBounds(0);
GetGlobalHVACNodeBounds(0);
Expand Down
6 changes: 3 additions & 3 deletions Source/smokeview/smokeheaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ EXTERNCPP int GetGlobalPartBounds(int flag);
EXTERNCPP void GetGlobalPatchBounds(void);
EXTERNCPP void GetLoadedPlot3dBounds(int *compute_loaded, float *loaded_min, float *loaded_max);
EXTERNCPP void GetGlobalPlot3DBounds(void);
EXTERNCPP void GetGlobalSliceBounds(void);
EXTERNCPP void GetGlobalSliceBounds(char *type);
EXTERNCPP void GetGlobalHVACDuctBounds(int flag);
EXTERNCPP void GetGlobalHVACNodeBounds(int flag);
EXTERNCPP void UpdateHVACDuctType(void);
Expand All @@ -201,7 +201,8 @@ EXTERNCPP void SetPercentilePlot3DBounds(void);
EXTERNCPP void DrawHistogram(histogramdata *histogram, float xxmin, float xxmax, float gmin, float gmax, int ndigits);
EXTERNCPP void SliceBoundsSetupNoGraphics(void);
EXTERNCPP void GetHistogramValProc(histogramdata*histogram, float cdf, float *val);
EXTERNCPP void ComputeLoadedSliceHist(char *label, histogramdata **histptr);
EXTERNCPP void ComputeLoadedSliceHist(char *label);
EXTERNCPP void MergeLoadedSliceHist(char *label, histogramdata **histptr);
EXTERNCPP void ComputeLoadedPatchHist(char *label, histogramdata **histptr, float *valmin, float *valmax);
EXTERNCPP void GetGlobalBoundsMinMax(int type, char *label, float *valmin, float *valmax);
EXTERNCPP void SliceBoundsCPP_CB(int var);
Expand Down Expand Up @@ -377,7 +378,6 @@ EXTERNCPP void TerrainCB(int var);
EXTERNCPP void GeometryMenu(int var);
EXTERNCPP void Smoke3dCB(int var);
EXTERNCPP void InitAllLightFractions(float *xyz_light, int light_type);
EXTERNCPP void GetAllSliceHists(void);
EXTERNCPP void UpdateHistogramType(void);
EXTERNCPP void UpdateSliceHist(void);
EXTERNCPP void Enable360Zoom(void);
Expand Down
Loading

0 comments on commit 42d92dc

Please sign in to comment.