Skip to content

Commit

Permalink
FDS Source: Streamline CONNECTED_ZONES and PSUM, USUM, DSUM
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgratta committed Nov 12, 2024
1 parent 9625908 commit 3064b74
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 114 deletions.
4 changes: 2 additions & 2 deletions Source/cons.f90
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ MODULE GLOBAL_CONSTANTS

! Divergence Arrays

REAL(EB), ALLOCATABLE, DIMENSION(:,:) :: DSUM,USUM,PSUM
REAL(EB), ALLOCATABLE, DIMENSION(:) :: DSUM,USUM,PSUM

! Level Set vegetation fire spread

Expand Down Expand Up @@ -633,7 +633,7 @@ MODULE GLOBAL_CONSTANTS
! Number of initial value, pressure zone, and multiplier derived types

INTEGER :: N_INIT,N_ZONE,N_MULT,N_MOVE
LOGICAL, ALLOCATABLE, DIMENSION(:,:,:) :: CONNECTED_ZONES
LOGICAL, ALLOCATABLE, DIMENSION(:,:) :: CONNECTED_ZONES
INTEGER, ALLOCATABLE, DIMENSION(:,:) :: CONNECTED_ZONES_LOC
REAL(EB) :: MINIMUM_ZONE_VOLUME=0._EB
REAL(EB) :: PRESSURE_RELAX_TIME=1._EB
Expand Down
67 changes: 30 additions & 37 deletions Source/divg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ SUBROUTINE DIVERGENCE_PART_1(T,DT,NM)

! Determine if pressure ZONEs have merged

IF (N_ZONE>0) CALL MERGE_PRESSURE_ZONES(NM)
IF (N_ZONE>0) CALL MERGE_PRESSURE_ZONES

! Compute normal component of velocity at boundaries, U_NORMAL_S in the PREDICTOR step, U_NORMAL in the CORRECTOR.

Expand Down Expand Up @@ -712,10 +712,6 @@ SUBROUTINE DIVERGENCE_PART_1(T,DT,NM)

IF_PRESSURE_ZONES: IF (N_ZONE>0) THEN

USUM(1:N_ZONE,NM) = 0._EB
DSUM(1:N_ZONE,NM) = 0._EB
PSUM(1:N_ZONE,NM) = 0._EB

R_PFCT = 1._EB
DO K=1,KBAR
DO J=1,JBAR
Expand All @@ -726,18 +722,18 @@ SUBROUTINE DIVERGENCE_PART_1(T,DT,NM)
IF (IPZ<1) CYCLE
IF (CELL(CELL_INDEX(I,J,K))%SOLID) CYCLE
VC = DX(I)*RC(I)*VC1
DSUM(IPZ,NM) = DSUM(IPZ,NM) + VC*DP(I,J,K)
DSUM(IPZ) = DSUM(IPZ) + VC*DP(I,J,K)
IF (CC_IBM) THEN
R_PFCT = 1._EB
IF (CCVAR(I,J,K,CC_CGSC) == CC_SOLID) THEN
CYCLE
ELSEIF(CCVAR(I,J,K,CC_CGSC) == CC_CUTCFE) THEN
CALL ADD_CUTCELL_PSUM(I,J,K,PBAR_P(K,IPZ),PSUM(IPZ,NM)); CYCLE
CALL ADD_CUTCELL_PSUM(I,J,K,PBAR_P(K,IPZ),PSUM(IPZ)); CYCLE
ELSEIF(CCVAR(I,J,K,CC_UNKZ) > 0) THEN
CALL ADD_LINKEDCELL_PSUM(I,J,K,VC,PBAR_P(K,IPZ),RTRM(I,J,K),PSUM(IPZ,NM)); CYCLE
CALL ADD_LINKEDCELL_PSUM(I,J,K,VC,PBAR_P(K,IPZ),RTRM(I,J,K),PSUM(IPZ)); CYCLE
ENDIF
ENDIF
PSUM(IPZ,NM) = PSUM(IPZ,NM) + VC*(R_PBAR(K,IPZ)*R_PFCT-RTRM(I,J,K))
PSUM(IPZ) = PSUM(IPZ) + VC*(R_PBAR(K,IPZ)*R_PFCT-RTRM(I,J,K))
ENDDO
ENDDO
ENDDO
Expand All @@ -752,8 +748,8 @@ SUBROUTINE DIVERGENCE_PART_1(T,DT,NM)
IPZ = B1%PRESSURE_ZONE
IF (IPZ<1) CYCLE WALL_LOOP4
IF (WC%BOUNDARY_TYPE/=SOLID_BOUNDARY) CYCLE WALL_LOOP4
IF (PREDICTOR) USUM(IPZ,NM) = USUM(IPZ,NM) + B1%U_NORMAL_S*B1%AREA
IF (CORRECTOR) USUM(IPZ,NM) = USUM(IPZ,NM) + B1%U_NORMAL *B1%AREA
IF (PREDICTOR) USUM(IPZ) = USUM(IPZ) + B1%U_NORMAL_S*B1%AREA
IF (CORRECTOR) USUM(IPZ) = USUM(IPZ) + B1%U_NORMAL *B1%AREA
ENDDO WALL_LOOP4


Expand All @@ -763,8 +759,8 @@ SUBROUTINE DIVERGENCE_PART_1(T,DT,NM)
B1 => BOUNDARY_PROP1(CFA%B1_INDEX)
IPZ = B1%PRESSURE_ZONE
IF (IPZ<1) CYCLE CFACE_LOOP
IF (PREDICTOR) USUM(IPZ,NM) = USUM(IPZ,NM) + B1%U_NORMAL_S*B1%AREA
IF (CORRECTOR) USUM(IPZ,NM) = USUM(IPZ,NM) + B1%U_NORMAL *B1%AREA
IF (PREDICTOR) USUM(IPZ) = USUM(IPZ) + B1%U_NORMAL_S*B1%AREA
IF (CORRECTOR) USUM(IPZ) = USUM(IPZ) + B1%U_NORMAL *B1%AREA
ENDDO CFACE_LOOP


Expand Down Expand Up @@ -1104,15 +1100,12 @@ SUBROUTINE SPECIES_ADVECTION(N,U_DOT_DEL_RHO_Z)
END SUBROUTINE SPECIES_ADVECTION


SUBROUTINE MERGE_PRESSURE_ZONES(NM)
SUBROUTINE MERGE_PRESSURE_ZONES

INTEGER, INTENT(IN) :: NM
INTEGER :: IW,IPZ,IOPZ
TYPE(WALL_TYPE), POINTER :: WC
TYPE(BOUNDARY_COORD_TYPE), POINTER :: BC

CONNECTED_ZONES(:,:,NM) = .FALSE.

DO IW=1,N_EXTERNAL_WALL_CELLS+N_INTERNAL_WALL_CELLS
WC=>WALL(IW)
IF (WC%BOUNDARY_TYPE/=NULL_BOUNDARY .AND. WC%BOUNDARY_TYPE/=OPEN_BOUNDARY .AND. WC%BOUNDARY_TYPE/=INTERPOLATED_BOUNDARY) CYCLE
Expand All @@ -1121,15 +1114,15 @@ SUBROUTINE MERGE_PRESSURE_ZONES(NM)
IPZ = PRESSURE_ZONE(BC%IIG,BC%JJG,BC%KKG)
IOPZ = PRESSURE_ZONE(BC%II,BC%JJ,BC%KK)
IF (IW>N_EXTERNAL_WALL_CELLS .AND. IPZ/=IOPZ) THEN
CONNECTED_ZONES(IOPZ,IPZ,NM) = .TRUE.
CONNECTED_ZONES(IPZ,IOPZ,NM) = .TRUE.
CONNECTED_ZONES(IOPZ,IPZ) = .TRUE.
CONNECTED_ZONES(IPZ,IOPZ) = .TRUE.
ENDIF
IF (WC%BOUNDARY_TYPE==OPEN_BOUNDARY) THEN
CONNECTED_ZONES(0,IPZ,NM) = .TRUE.
CONNECTED_ZONES(IPZ,0,NM) = .TRUE.
CONNECTED_ZONES(0,IPZ) = .TRUE.
CONNECTED_ZONES(IPZ,0) = .TRUE.
ELSEIF (WC%BOUNDARY_TYPE==INTERPOLATED_BOUNDARY) THEN
CONNECTED_ZONES(IOPZ,IPZ,NM) = .TRUE.
CONNECTED_ZONES(IPZ,IOPZ,NM) = .TRUE.
CONNECTED_ZONES(IOPZ,IPZ) = .TRUE.
CONNECTED_ZONES(IPZ,IOPZ) = .TRUE.
ENDIF
ENDDO

Expand Down Expand Up @@ -1294,36 +1287,36 @@ SUBROUTINE DIVERGENCE_PART_2(DT,NM)
USUM_ADD = 0._EB

DO IPZ=1,N_ZONE
SUM_P_PSUM = PBAR_P(1,IPZ)*PSUM(IPZ,NM)
SUM_P_PSUM = PBAR_P(1,IPZ)*PSUM(IPZ)
OPEN_ZONE = .FALSE.
SUM_USUM = USUM(IPZ,NM)
SUM_DSUM = DSUM(IPZ,NM)
SUM_PSUM = PSUM(IPZ,NM)
SUM_USUM = USUM(IPZ)
SUM_DSUM = DSUM(IPZ)
SUM_PSUM = PSUM(IPZ)
DO IOPZ=N_ZONE,0,-1
IF (IOPZ==IPZ) CYCLE
IF (CONNECTED_ZONES(IPZ,IOPZ,NM)) THEN
IF (CONNECTED_ZONES(IPZ,IOPZ)) THEN
IF (IOPZ==0) THEN
OPEN_ZONE = .TRUE.
ELSE
SUM_P_PSUM = SUM_P_PSUM + PBAR_P(1,IOPZ)*PSUM(IOPZ,NM)
SUM_USUM = SUM_USUM + USUM(IOPZ,NM)
SUM_DSUM = SUM_DSUM + DSUM(IOPZ,NM)
SUM_PSUM = SUM_PSUM + PSUM(IOPZ,NM)
SUM_P_PSUM = SUM_P_PSUM + PBAR_P(1,IOPZ)*PSUM(IOPZ)
SUM_USUM = SUM_USUM + USUM(IOPZ)
SUM_DSUM = SUM_DSUM + DSUM(IOPZ)
SUM_PSUM = SUM_PSUM + PSUM(IOPZ)
ENDIF
ENDIF
ENDDO
IF (OPEN_ZONE) THEN
P_EQ = P_0(1)
USUM_ADD(IPZ) = PSUM(IPZ,NM)*(PBAR_P(1,IPZ)-P_EQ)/PRESSURE_RELAX_TIME + DSUM(IPZ,NM) - USUM(IPZ,NM)
USUM_ADD(IPZ) = PSUM(IPZ)*(PBAR_P(1,IPZ)-P_EQ)/PRESSURE_RELAX_TIME + DSUM(IPZ) - USUM(IPZ)
ELSE
P_EQ = SUM_P_PSUM/SUM_PSUM
USUM_ADD(IPZ) = PSUM(IPZ,NM)*(PBAR_P(1,IPZ)-P_EQ)/PRESSURE_RELAX_TIME + DSUM(IPZ,NM) - USUM(IPZ,NM) - &
PSUM(IPZ,NM)*(SUM_DSUM-SUM_USUM)/SUM_PSUM
USUM_ADD(IPZ) = PSUM(IPZ)*(PBAR_P(1,IPZ)-P_EQ)/PRESSURE_RELAX_TIME + DSUM(IPZ) - USUM(IPZ) - &
PSUM(IPZ)*(SUM_DSUM-SUM_USUM)/SUM_PSUM
ENDIF
ENDDO

DO IPZ=1,N_ZONE
USUM(IPZ,NM) = USUM(IPZ,NM) + USUM_ADD(IPZ)
USUM(IPZ) = USUM(IPZ) + USUM_ADD(IPZ)
ENDDO

! Compute dP/dt for each pressure ZONE
Expand All @@ -1336,7 +1329,7 @@ SUBROUTINE DIVERGENCE_PART_2(DT,NM)
! Compute change in background pressure

DO IPZ=1,N_ZONE
IF (ABS(PSUM(IPZ,NM)) > TWO_EPSILON_EB) D_PBAR_DT_P(IPZ) = (DSUM(IPZ,NM) - USUM(IPZ,NM))/PSUM(IPZ,NM)
IF (ABS(PSUM(IPZ)) > TWO_EPSILON_EB) D_PBAR_DT_P(IPZ) = (DSUM(IPZ) - USUM(IPZ))/PSUM(IPZ)
IF (CORRECTOR) P_ZONE(IPZ)%DPSTAR = D_PBAR_DT_P(IPZ)
ENDDO

Expand Down
8 changes: 4 additions & 4 deletions Source/hvac.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1870,10 +1870,10 @@ SUBROUTINE DPSTARCALC
PZ => P_ZONE(IPZ)
IF (PZ%N_DUCTNODES==0) CYCLE
DPSTAR(IPZ) = P_ZONE(IPZ)%DPSTAR * DT_HV
PSUM_TOT(IPZ) = PSUM(IPZ,1)
PSUM_TOT(IPZ) = PSUM(IPZ)
DO IOPZ = 1,N_ZONE
IF (IPZ==IOPZ) CYCLE
IF (CONNECTED_ZONES(IPZ,IOPZ,1)) PSUM_TOT(IPZ) = PSUM_TOT(IPZ) + PSUM(IOPZ,1)
IF (CONNECTED_ZONES(IPZ,IOPZ)) PSUM_TOT(IPZ) = PSUM_TOT(IPZ) + PSUM(IOPZ)
ENDDO
ENDDO

Expand All @@ -1888,7 +1888,7 @@ SUBROUTINE DPSTARCALC
DO IOPZ = 1, N_ZONE
IF (IPZ==IOPZ) CYCLE
IF (P_ZONE(IOPZ)%N_DUCTNODES==0) CYCLE
IF (CONNECTED_ZONES(IPZ,IOPZ,1)) THEN
IF (CONNECTED_ZONES(IPZ,IOPZ)) THEN
IF (P_ZONE(IOPZ)%N_DUCTNODES==0) CYCLE
DPSTAR(IOPZ) = DPSTAR(IOPZ) - DN%DIR(1) * DU%AREA * DU%VEL(OLD) * DT_HV/PSUM_TOT(IPZ)
IF (DU%FIXED) DPSTAR(IOPZ) = DPSTAR(IOPZ) + DN%DIR(1) * DU%AREA * DU%VEL(NEW) * DT_HV/PSUM_TOT(IPZ)
Expand Down Expand Up @@ -3049,7 +3049,7 @@ SUBROUTINE COLLAPSE_HVAC_BC(T)
WRITE(MESSAGE,'(A,A)') 'ERROR(552): Ductnode must lie with a single pressure zone. Node: ',TRIM(DUCTNODE(NN)%ID)
CALL SHUTDOWN(MESSAGE); RETURN
ENDIF
IF (ANY(CONNECTED_ZONES(0,DN%ZONE_INDEX,:))) DN%ZONE_INDEX = 0
IF (CONNECTED_ZONES(0,DN%ZONE_INDEX)) DN%ZONE_INDEX = 0
ENDIF

INTERNAL_NODE_IF: IF (((DN%VENT .OR. DN%LEAKAGE) .AND. .NOT. DN%AMBIENT) .OR. &
Expand Down
4 changes: 2 additions & 2 deletions Source/init.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ SUBROUTINE INITIALIZE_MESH_VARIABLES_2(NM)

IF (N_ZONE > 0) THEN
ZONE_LOOP: DO IPZ = 1,N_ZONE
PSUM(IPZ,NM) = 0._EB
PSUM(IPZ) = 0._EB
DO K=1,M%KBAR
DO J=1,M%JBAR
DO I=1,M%IBAR
Expand All @@ -1118,7 +1118,7 @@ SUBROUTINE INITIALIZE_MESH_VARIABLES_2(NM)
ZZ_GET(1:N_TRACKED_SPECIES) = M%ZZ(I,J,K,1:N_TRACKED_SPECIES)
CALL GET_SPECIFIC_HEAT(ZZ_GET,CP,M%TMP(I,J,K))
RTRM = M%RSUM(I,J,K)/(CP*M%PBAR(K,IPZ))
PSUM(IPZ,NM) = PSUM(IPZ,NM) + VC*(1._EB/M%PBAR(K,IPZ)-RTRM)
PSUM(IPZ) = PSUM(IPZ) + VC*(1._EB/M%PBAR(K,IPZ)-RTRM)
ENDDO
ENDDO
ENDDO
Expand Down
Loading

0 comments on commit 3064b74

Please sign in to comment.