Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce size of slice and boundary file .bnd files to speed up loading in smokview #12209

Merged
merged 13 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 115 additions & 27 deletions Source/dump.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,6 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM)

RESTART: IF (APPEND) THEN
OPEN(LU_BNDF(NF,NM),FILE=FN_BNDF(NF,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND')
OPEN(LU_BNDF(NF+N_BNDF,NM),FILE=FN_BNDF(NF+N_BNDF,NM),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND')
ELSE RESTART
IF (M%N_STRINGS+5>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM)
M%N_STRINGS = M%N_STRINGS + 1
Expand All @@ -1290,7 +1289,6 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM)
M%N_STRINGS = M%N_STRINGS + 1
WRITE(M%STRING(M%N_STRINGS),'(1X,A)') TRIM(BF%UNITS)
OPEN(LU_BNDF(NF,NM),FILE=FN_BNDF(NF,NM),FORM='UNFORMATTED',STATUS='REPLACE')
OPEN(LU_BNDF(NF+N_BNDF,NM),FILE=FN_BNDF(NF+N_BNDF,NM),FORM='FORMATTED',STATUS='REPLACE')
WRITE(LU_BNDF(NF,NM)) BF%SMOKEVIEW_LABEL(1:30)
WRITE(LU_BNDF(NF,NM)) BF%SMOKEVIEW_BAR_LABEL(1:30)
WRITE(LU_BNDF(NF,NM)) BF%UNITS(1:30)
Expand Down Expand Up @@ -5278,15 +5276,17 @@ SUBROUTINE DUMP_CFACES_GEOM(FUNIT,STIME)
END SUBROUTINE DUMP_CFACES_GEOM


SUBROUTINE DUMP_SLICE_GEOM_DATA(FUNIT_DATA,FUNIT_BOUNDS,CC_INTERP2FACES,CC_CELL_CENTERED,SLICETYPE, &
SUBROUTINE DUMP_SLICE_GEOM_DATA(FUNIT_DATA,CC_INTERP2FACES,CC_CELL_CENTERED,SLICETYPE, &
HEADER,STIME,I1,I2,J1,J2,K1,K2,DEBUG,&
IND,IND2,Y_INDEX,Z_INDEX,PART_INDEX,VELO_INDEX,PIPE_INDEX,PROP_INDEX,REAC_INDEX,MATL_INDEX,T,DT,NM)
IND,IND2,Y_INDEX,Z_INDEX,PART_INDEX,VELO_INDEX,PIPE_INDEX,PROP_INDEX,REAC_INDEX,MATL_INDEX,T, &
DT,NM,SLICE_MIN, SLICE_MAX)
REAL(EB), INTENT(IN) :: T,DT
CHARACTER(*), INTENT(IN) :: SLICETYPE
INTEGER, INTENT(IN) :: FUNIT_DATA,FUNIT_BOUNDS,HEADER,I1,I2,J1,J2,K1,K2,DEBUG, &
INTEGER, INTENT(IN) :: FUNIT_DATA,HEADER,I1,I2,J1,J2,K1,K2,DEBUG, &
IND,IND2,Y_INDEX,Z_INDEX,PART_INDEX,VELO_INDEX,PIPE_INDEX,PROP_INDEX,REAC_INDEX,MATL_INDEX,NM
REAL(FB), INTENT(IN):: STIME
LOGICAL, INTENT(IN) :: CC_INTERP2FACES,CC_CELL_CENTERED
REAL(FB), INTENT(OUT) :: SLICE_MIN, SLICE_MAX

INTEGER, PARAMETER :: VERSION=2
INTEGER :: NVERTS,NVERTS_CUTCELLS,NFACES,NFACES_CUTCELLS
Expand Down Expand Up @@ -5364,8 +5364,12 @@ SUBROUTINE DUMP_SLICE_GEOM_DATA(FUNIT_DATA,FUNIT_BOUNDS,CC_INTERP2FACES,CC_CELL_
VAL_MIN = REAL(100*NM,FB)
VAL_MAX = REAL(100*NM,FB)
ENDIF
WRITE(FUNIT_BOUNDS,'(ES13.6,1X,ES13.6,1X,ES13.6)') STIME, VAL_MIN, VAL_MAX
SLICE_MIN = VAL_MIN
SLICE_MAX = VAL_MAX
DEALLOCATE(VALS)
ELSE
SLICE_MIN = 1.0
SLICE_MAX = 0.0
ENDIF

END SUBROUTINE DUMP_SLICE_GEOM_DATA
Expand Down Expand Up @@ -5634,6 +5638,8 @@ SUBROUTINE DUMP_SLCF(T,DT,NM,IFRMT)
INTEGER, INTENT(IN) :: NM,IFRMT
REAL(EB), INTENT(IN) :: T,DT
REAL(EB) :: BSUM,TT
REAL(FB) :: T_BOUND, SLICE_MIN_BOUND, SLICE_MAX_BOUND
INTEGER :: CHANGE_BOUND
INTEGER :: I,J,K,NQT,I1,I2,J1,J2,K1,K2,ITM,ITM1,IQ,IQ2,IQ3,IQQ,IND,IND2,II1,II2,JJ1,JJ2,KK1,KK2, &
IC,Y_INDEX,Z_INDEX,PART_INDEX,VELO_INDEX,PROP_INDEX,REAC_INDEX,MATL_INDEX,NOM,IIO,JJO,KKO,I_INC,J_INC
INTEGER :: KTS,NTSL
Expand All @@ -5646,6 +5652,7 @@ SUBROUTINE DUMP_SLCF(T,DT,NM,IFRMT)
INTEGER :: IFACT, JFACT, KFACT
REAL(FB), ALLOCATABLE, DIMENSION(:) :: QQ_PACK
REAL(FB) :: UVEL, VVEL, WVEL, VEL, PLOT3D_MIN, PLOT3D_MAX
INTEGER :: IERROR

! Return if there are no slices to process and this is not a Plot3D dump

Expand Down Expand Up @@ -5977,33 +5984,73 @@ SUBROUTINE DUMP_SLCF(T,DT,NM,IFRMT)
ENDIF

IQ2 = IQ + N_SLCF_MAX
OPEN(LU_SLCF(IQ2,NM),FILE=FN_SLCF(IQ2,NM),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND')
WRITE(LU_SLCF(IQ2,NM),'(ES13.6,1X,ES13.6,1X,ES13.6)') STIME, SLICE_MIN, SLICE_MAX
CLOSE(LU_SLCF(IQ2,NM))
CHANGE_BOUND = 0
IF (ABS(STIME-T_BEGIN)<TWO_EPSILON_EB) THEN
SLICE_MIN_BOUND = SLICE_MIN
SLICE_MAX_BOUND = SLICE_MAX
CHANGE_BOUND = 1
ELSE
OPEN(LU_SLCF(IQ2,NM),FILE=FN_SLCF(IQ2,NM),ACTION='READ')
READ(LU_SLCF(IQ2,NM),FMT=*,IOSTAT=IERROR)T_BOUND, SLICE_MIN_BOUND, SLICE_MAX_BOUND
CLOSE(LU_SLCF(IQ2,NM))
IF (IERROR /= 0 .OR. SLICE_MIN < SLICE_MIN_BOUND) THEN
SLICE_MIN_BOUND = SLICE_MIN
CHANGE_BOUND = 1
ENDIF
IF (IERROR /= 0 .OR. SLICE_MAX > SLICE_MAX_BOUND) THEN
SLICE_MAX_BOUND = SLICE_MAX
CHANGE_BOUND = 1
ENDIF
ENDIF
IF (CHANGE_BOUND == 1) THEN
OPEN(LU_SLCF(IQ2,NM),FILE=FN_SLCF(IQ2,NM),FORM='FORMATTED',STATUS='REPLACE')
WRITE(LU_SLCF(IQ2,NM),'(ES13.6,1X,ES13.6,1X,ES13.6)') STIME, SLICE_MIN_BOUND, SLICE_MAX_BOUND
CLOSE(LU_SLCF(IQ2,NM))
ENDIF
ELSE
IQ2 = IQ + N_SLCF_MAX
STIME = REAL(T_BEGIN + (T-T_BEGIN)*TIME_SHRINK_FACTOR,FB)
! write geometry for slice file
CHANGE_BOUND = 0
IF (ABS(STIME-T_BEGIN)<TWO_EPSILON_EB) THEN
! geometry and data file at first time step
OPEN(LU_SLCF_GEOM(IQ,NM),FILE=FN_SLCF_GEOM(IQ,NM),FORM='UNFORMATTED',STATUS='REPLACE')
CALL DUMP_SLICE_GEOM(LU_SLCF_GEOM(IQ,NM),SL%SLICETYPE,1,STIME,I1,I2,J1,J2,K1,K2)
CLOSE(LU_SLCF_GEOM(IQ,NM))

OPEN(LU_SLCF(IQ,NM),FILE=FN_SLCF(IQ,NM),FORM='UNFORMATTED',STATUS='REPLACE')
OPEN(LU_SLCF(IQ+N_SLCF_MAX,NM),FILE=FN_SLCF(IQ+N_SLCF_MAX,NM),FORM='FORMATTED',STATUS='REPLACE')
CALL DUMP_SLICE_GEOM_DATA(LU_SLCF(IQ,NM),LU_SLCF(IQ+N_SLCF_MAX,NM),CC_INTERP2FACES,SL%CELL_CENTERED,SL%SLICETYPE, &
CALL DUMP_SLICE_GEOM_DATA(LU_SLCF(IQ,NM),CC_INTERP2FACES,SL%CELL_CENTERED,SL%SLICETYPE, &
1,STIME,I1,I2,J1,J2,K1,K2,0,&
IND,IND2,Y_INDEX,Z_INDEX,PART_INDEX,VELO_INDEX,0,PROP_INDEX,REAC_INDEX,MATL_INDEX,T,DT,NM)
IND,IND2,Y_INDEX,Z_INDEX,PART_INDEX,VELO_INDEX,0,PROP_INDEX,REAC_INDEX,MATL_INDEX,T,DT,NM, &
SLICE_MIN, SLICE_MAX)
SLICE_MIN_BOUND = SLICE_MIN
SLICE_MAX_BOUND = SLICE_MAX
CHANGE_BOUND = 1
ELSE
! data file at subsequent time steps
OPEN(LU_SLCF(IQ,NM),FILE=FN_SLCF(IQ,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND')
OPEN(LU_SLCF(IQ+N_SLCF_MAX,NM),FILE=FN_SLCF(IQ+N_SLCF_MAX,NM),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND')
CALL DUMP_SLICE_GEOM_DATA(LU_SLCF(IQ,NM),LU_SLCF(IQ+N_SLCF_MAX,NM),CC_INTERP2FACES,SL%CELL_CENTERED,SL%SLICETYPE, &
CALL DUMP_SLICE_GEOM_DATA(LU_SLCF(IQ,NM),CC_INTERP2FACES,SL%CELL_CENTERED,SL%SLICETYPE, &
0,STIME,I1,I2,J1,J2,K1,K2,0,&
IND,IND2,Y_INDEX,Z_INDEX,PART_INDEX,VELO_INDEX,0,PROP_INDEX,REAC_INDEX,MATL_INDEX,T,DT,NM)
IND,IND2,Y_INDEX,Z_INDEX,PART_INDEX,VELO_INDEX,0,PROP_INDEX,REAC_INDEX,MATL_INDEX,T,DT,NM, &
SLICE_MIN, SLICE_MAX)
OPEN(LU_SLCF(IQ2,NM),FILE=FN_SLCF(IQ2,NM),ACTION='READ')
READ(LU_SLCF(IQ2,NM),FMT=*,IOSTAT=IERROR)T_BOUND, SLICE_MIN_BOUND, SLICE_MAX_BOUND
CLOSE(LU_SLCF(IQ2,NM))
IF (IERROR /= 0 .OR. SLICE_MIN < SLICE_MIN_BOUND) THEN
SLICE_MIN_BOUND = SLICE_MIN
CHANGE_BOUND = 1
ENDIF
IF (IERROR /= 0 .OR. SLICE_MAX > SLICE_MAX_BOUND) THEN
SLICE_MAX_BOUND = SLICE_MAX
CHANGE_BOUND = 1
ENDIF
ENDIF
IF (CHANGE_BOUND == 1) THEN
OPEN(LU_SLCF(IQ2,NM),FILE=FN_SLCF(IQ2,NM),FORM='FORMATTED',STATUS='REPLACE')
WRITE(LU_SLCF(IQ2,NM),'(ES13.6,1X,ES13.6,1X,ES13.6)') STIME, SLICE_MIN_BOUND, SLICE_MAX_BOUND
CLOSE(LU_SLCF(IQ2,NM))
ENDIF
CLOSE(LU_SLCF(IQ,NM))
CLOSE(LU_SLCF(IQ+N_SLCF_MAX,NM))
ENDIF
ENDIF

Expand Down Expand Up @@ -10304,6 +10351,8 @@ SUBROUTINE DUMP_BNDF(T,DT,NM)
INTEGER :: NBF_DEBUG
INTEGER, INTENT(IN) :: NM
TYPE(PATCH_TYPE), POINTER :: PA
REAL(FB) BNDF_TIME, BNDF_VAL_MIN, BNDF_VAL_MAX
INTEGER :: CHANGE_BOUND, IERROR

IF (MESHES(NM)%N_PATCH==0 .AND. MESHES(NM)%N_INTERNAL_CFACE_CELLS==0) RETURN

Expand Down Expand Up @@ -10429,7 +10478,29 @@ SUBROUTINE DUMP_BNDF(T,DT,NM)
ENDIF

ENDDO PATCH_LOOP
WRITE(LU_BNDF(NF+N_BNDF,NM),'(ES13.6,1X,ES13.6,1X,ES13.6)')STIME,BOUND_MIN,BOUND_MAX
CHANGE_BOUND = 0
IF (REAL(T-T_BEGIN,FB)<TWO_EPSILON_FB) THEN
BNDF_VAL_MIN = BOUND_MIN
BNDF_VAL_MAX = BOUND_MAX
CHANGE_BOUND = 1
ELSE
OPEN(LU_BNDF(NF+N_BNDF,NM),FILE=FN_BNDF(NF+N_BNDF,NM),ACTION='READ')
READ(LU_BNDF(NF+N_BNDF,NM),FMT=*,IOSTAT=IERROR)BNDF_TIME, BNDF_VAL_MIN, BNDF_VAL_MAX
CLOSE(LU_BNDF(NF+N_BNDF,NM))
IF( IERROR /= 0 .OR. BOUND_MIN < BNDF_VAL_MIN) THEN
BNDF_VAL_MIN = BOUND_MIN
CHANGE_BOUND = 1
ENDIF
IF( IERROR /= 0 .OR. BOUND_MAX > BNDF_VAL_MAX) THEN
BNDF_VAL_MAX = BOUND_MAX
CHANGE_BOUND = 1
ENDIF
ENDIF
IF (CHANGE_BOUND == 1) THEN
OPEN(LU_BNDF(NF+N_BNDF,NM),FILE=FN_BNDF(NF+N_BNDF,NM),FORM='FORMATTED',STATUS='REPLACE')
WRITE(LU_BNDF(NF+N_BNDF,NM),'(ES13.6,1X,ES13.6,1X,ES13.6)')STIME, BNDF_VAL_MIN, BNDF_VAL_MAX
CLOSE(LU_BNDF(NF+N_BNDF,NM))
ENDIF

ENDDO FILE_LOOP

Expand All @@ -10441,24 +10512,41 @@ SUBROUTINE DUMP_BNDF(T,DT,NM)
NC = 0
I1=0; I2=-1; J1=0; J2=-1; K1=0; K2=-1; ! Just dummy numbers, not needed for INBOUND_FACES
! write geometry for slice file
CHANGE_BOUND = 0
IF (REAL(T-T_BEGIN,FB)<TWO_EPSILON_FB) THEN
OPEN(LU_BNDG(NF,NM), FILE=FN_BNDG(NF,NM), FORM='UNFORMATTED',STATUS='REPLACE')
OPEN(LU_BNDG(NF+N_BNDF,NM),FILE=FN_BNDG(NF+N_BNDF,NM),FORM='FORMATTED', STATUS='REPLACE')
CALL DUMP_SLICE_GEOM_DATA(LU_BNDG(NF,NM),LU_BNDG(NF+N_BNDF,NM), &
.FALSE.,.TRUE.,"INBOUND_FACES",1,STIME,I1,I2,J1,J2,K1,K2,BF%DEBUG, &
IND,0,BF%Y_INDEX,BF%Z_INDEX,BF%PART_INDEX,0,0,BF%PROP_INDEX,0,0,T,DT,NM)
!IND,BF%Y_INDEX,BF%Z_INDEX,BF%PART_INDEX,T,DT,NM)
CALL DUMP_SLICE_GEOM_DATA(LU_BNDG(NF,NM), &
.FALSE.,.TRUE.,"INBOUND_FACES",1,STIME,I1,I2,J1,J2,K1,K2,BF%DEBUG, &
IND,0,BF%Y_INDEX,BF%Z_INDEX,BF%PART_INDEX,0,0,BF%PROP_INDEX,0,0,T,DT,NM, &
BOUND_MIN, BOUND_MAX)
BNDF_VAL_MIN = BOUND_MIN
BNDF_VAL_MAX = BOUND_MAX
CHANGE_BOUND = 1
ELSE
! data file at subsequent time steps
OPEN(LU_BNDG(NF,NM), FILE=FN_BNDG(NF,NM), FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND')
OPEN(LU_BNDG(NF+N_BNDF,NM),FILE=FN_BNDG(NF+N_BNDF,NM),FORM='FORMATTED', STATUS='OLD',POSITION='APPEND')
CALL DUMP_SLICE_GEOM_DATA(LU_BNDG(NF,NM),LU_BNDG(NF+N_BNDF,NM), &
CALL DUMP_SLICE_GEOM_DATA(LU_BNDG(NF,NM), &
.FALSE.,.TRUE.,"INBOUND_FACES",0,STIME,I1,I2,J1,J2,K1,K2,BF%DEBUG, &
IND,0,BF%Y_INDEX,BF%Z_INDEX,BF%PART_INDEX,0,0,BF%PROP_INDEX,0,0,T,DT,NM)
!IND,BF%Y_INDEX,BF%Z_INDEX,BF%PART_INDEX,T,DT,NM)
IND,0,BF%Y_INDEX,BF%Z_INDEX,BF%PART_INDEX,0,0,BF%PROP_INDEX,0,0,T,DT,NM, &
BOUND_MIN, BOUND_MAX)
OPEN(LU_BNDG(NF+N_BNDF,NM),FILE=FN_BNDG(NF+N_BNDF,NM), ACTION='READ')
READ(LU_BNDG(NF+N_BNDF,NM),FMT=*,IOSTAT=IERROR)BNDF_TIME, BNDF_VAL_MIN, BNDF_VAL_MAX
CLOSE(LU_BNDG(NF+N_BNDF,NM))
IF (IERROR /= 0 .OR. BOUND_MIN < BNDF_VAL_MIN) THEN
BNDF_VAL_MIN = BOUND_MIN
CHANGE_BOUND = 1
ENDIF
IF (IERROR /= 0 .OR. BOUND_MAX > BNDF_VAL_MAX) THEN
BNDF_VAL_MAX = BOUND_MAX
CHANGE_BOUND = 1
ENDIF
ENDIF
IF (CHANGE_BOUND == 1) THEN
OPEN(LU_BNDG(NF+N_BNDF,NM),FILE=FN_BNDG(NF+N_BNDF,NM),FORM='FORMATTED',STATUS='REPLACE')
WRITE(LU_BNDG(NF+N_BNDF,NM),'(ES13.6,1X,ES13.6,1X,ES13.6)') STIME, BNDF_VAL_MIN, BNDF_VAL_MAX
CLOSE(LU_BNDG(NF+N_BNDF,NM))
ENDIF
CLOSE(LU_BNDG(NF,NM))
CLOSE(LU_BNDG(NF+N_BNDF,NM))
ENDDO FILE_LOOP2
ENDIF

Expand Down