subroutine comp_temp ( u, v, temp, flag, work, imax, jmax, delt, & delx, dely, gamma, re, pr ) !******************************************************************************* ! !! COMP_TEMP computes the temperature field. ! ! Reference: ! ! Michael Griebel, Thomas Dornseifer, Tilman Neunhoeffer, ! Numerical Simulation in Fluid Dynamics, ! SIAM 1998. ! ! Parameters: ! ! Input, real U(0:IMAX+1,0:JMAX+1), V(0:IMAX+1,0:JMAX+1), ! the velocity field. ! ! Input/output, real TEMP(0:IMAX+1,0:JMAX+1), the temperature field. ! ! Input, integer FLAG(0:IMAX+1,0:JMAX+1), indicates the type of each cell. ! ! Workspace, real WORK(0:IMAX+1,0:JMAX+1). ! ! Input, integer IMAX, JMAX, the index of the last computational ! row and column of the grid. ! ! Input, real DELT, the time step. ! ! Input, real DELX, DELY, the width and height of one cell. ! ! Input, real GAMMA, the upwind differencing factor. ! ! Input, real RE, the Reynolds number. ! ! Input, real PR, the Prandtl number. ! use nrtype implicit none real ( rp ), intent ( in ) :: delt real ( rp ), intent ( in ) :: delx real ( rp ), intent ( in ) :: dely real ( rp ) :: dutdx real ( rp ) :: dvtdy integer ( i2b ), dimension(0:,0:), intent ( in ) :: flag real ( rp ), intent ( in ) :: gamma integer i integer, intent ( in ) :: imax real ( rp ) :: indelx2 real ( rp ) :: indely2 integer j integer, intent ( in ) :: jmax real ( rp ) :: laplt real ( rp ), intent ( in ) :: pr real ( rp ), intent ( in ) :: re real ( rp ), dimension(0:,0:), intent ( inout ) :: temp real ( rp ), dimension(0:,0:), intent ( in ) :: u real ( rp ), dimension(0:,0:), intent ( in ) :: v real ( rp ), dimension(0:,0:), intent ( out ) :: work include 'defs.h' indelx2 = 1.0 / ( delx * delx ) indely2 = 1.0 / ( dely * dely ) do i = 1, imax do j = 1, jmax if ( iand ( flag(i,j), c_f ) /= 0 .and. flag(i,j) < c_e ) then laplt = ( temp(i+1,j) - 2.0 * temp(i,j) + temp(i-1,j) ) * indelx2 & + ( temp(i,j+1) - 2.0 * temp(i,j) + temp(i,j-1) ) * indely2 dutdx = ( ( u(i,j) * 0.5 * ( temp(i,j) + temp(i+1,j) ) & - u(i-1,j) * 0.5 * ( temp(i-1,j) + temp(i,j) ) ) & + gamma * ( abs ( u(i,j) ) * 0.5 * ( temp(i,j) - temp(i+1,j) ) & - abs ( u(i-1,j) ) * 0.5 * ( temp(i-1,j) - temp(i,j) ) ) & ) / delx dvtdy = ( ( v(i,j) * 0.5 * ( temp(i,j) + temp(i,j+1) ) & - v(i,j-1) * 0.5 * ( temp(i,j-1) + temp(i,j) ))& + gamma * ( abs ( v(i,j) ) * 0.5 * (temp(i,j) -temp(i,j+1)) & - abs ( v(i,j-1) ) * 0.5 * (temp(i,j-1)-temp(i,j)))& ) / dely work(i,j) = temp(i,j) + delt * ( laplt / re / pr - dutdx - dvtdy ) end if end do end do do i = 1, imax do j = 1, jmax if ( iand ( flag(i,j), c_f ) /= 0 .and. flag(i,j) < c_e ) then temp(i,j) = work(i,j) end if end do end do return end subroutine comp_fg ( u, v, temp, f, g, flag, imax, jmax, delt, delx, dely, & gx, gy, gamma, re, beta ) !******************************************************************************* ! !! COMP_FG computes the F and G fields. ! ! Reference: ! ! Michael Griebel, Thomas Dornseifer, Tilman Neunhoeffer, ! Numerical Simulation in Fluid Dynamics, ! SIAM 1998. ! ! Parameters: ! ! Input, real U(0:IMAX+1,0:JMAX+1), V(0:IMAX+1,0:JMAX+1), ! TEMP(0:IMAX+1,0:JMAX+1), the velocity and temperature fields. ! ! Input, integer FLAG(0:IMAX+1,0:JMAX+1), indicates the type of each cell. ! ! Input, integer IMAX, JMAX, the index of the last computational ! row and column of the grid. ! ! Input, real DELT, the time step. ! ! Input, real DELX, DELY, the width and height of one cell. ! ! Input, real GX, GY, the X and Y components of a volume force. ! ! Input, real GAMMA, the upwind differencing factor. ! ! Input, real RE, the Reynolds number. ! ! Input, real BETA, the coefficient of volume expansion. ! use nrtype implicit none real ( rp ), intent ( in ) :: beta real ( rp ), intent ( in ) :: delt real ( rp ), intent ( in ) :: delx real ( rp ), intent ( in ) :: dely real ( rp ) :: du2dx real ( rp ) :: duvdx real ( rp ) :: duvdy real ( rp ) :: dv2dy real ( rp ), dimension(0:,0:), intent ( out ) :: f integer ( i2b ), dimension(0:,0:), intent ( in ) :: flag real ( rp ), dimension(0:,0:), intent ( out ) :: g real ( rp ), intent ( in ) :: gamma real ( rp ), intent ( in ) :: gx real ( rp ), intent ( in ) :: gy integer i integer, intent ( in ) :: imax integer j integer, intent ( in ) :: jmax real ( rp ) :: laplu real ( rp ) :: laplv real ( rp ), intent ( in ) :: re real ( rp ), dimension(0:,0:), intent ( in ) :: temp real ( rp ), dimension(0:,0:), intent ( in ) :: u real ( rp ), dimension(0:,0:), intent ( in ) :: v include 'defs.h' ! ! Compute flux field F ! ! Only if both adjacent cells are fluid cells. ! do i = 1, imax-1 do j = 1, jmax if ((( iand ( flag(i,j), c_f) /= 0) .and. flag(i,j) < c_e ) .and.& (( iand ( flag(i+1,j),c_f) /= 0) .and. flag(i+1,j) < c_e ) ) then du2dx = ((u(i,j)+u(i+1,j))*(u(i,j)+u(i+1,j)) & + gamma*abs ( u(i,j)+u(i+1,j))*(u(i,j)-u(i+1,j)) & - (u(i-1,j)+u(i,j))*(u(i-1,j)+u(i,j)) & - gamma*abs ( u(i-1,j)+u(i,j))*(u(i-1,j)-u(i,j))) & / (4.0*delx) duvdy = ((v(i,j)+v(i+1,j))*(u(i,j)+u(i,j+1)) & + gamma*abs ( v(i,j)+v(i+1,j))*(u(i,j)-u(i,j+1)) & - (v(i,j-1)+v(i+1,j-1))*(u(i,j-1)+u(i,j)) & - gamma*abs ( v(i,j-1)+v(i+1,j-1))*(u(i,j-1)-u(i,j))) & / ( 4.0 * dely ) laplu = ( u(i+1,j) - 2.0 * u(i,j) + u(i-1,j) ) / delx / delx & + ( u(i,j+1) - 2.0 * u(i,j) + u(i,j-1) ) / dely / dely f(i,j) = u(i,j) + delt * ( laplu / re - du2dx - duvdy + gx ) & - delt * beta * gx * ( temp(i,j) + temp(i+1,j) ) / 2.0 else f(i,j) = u(i,j) end if end do end do ! ! Compute flux field G ! ! Only if both adjacent cells are fluid cells ! do i = 1, imax do j = 1, jmax-1 if ((( iand ( flag(i,j), c_f)/=0).and.(flag(i,j) 0 ) .and. (flag(i, j) < c_e ) ) .and. & (( iand ( flag(i+1,j), c_f ) > 0 ) .and. (flag(i+1,j) < c_e ) )) then u(i,j) = f(i,j) - ( p(i+1,j) - p(i,j) ) * delt / delx end if end do end do do i = 1, imax do j = 1, jmax - 1 if ((( iand ( flag(i,j), c_f ) > 0 ) .and. (flag(i, j) < c_e ) ) .and.& (( iand ( flag(i,j+1),c_f ) > 0 ) .and. (flag(i,j+1) < c_e ) )) then v(i,j) = g(i,j) - ( p(i,j+1) - p(i,j) ) * delt / dely end if end do end do return end subroutine comp_delt ( delt, t, imax, jmax, delx, dely, u, v, re, pr, & tau, iwrite, del_trace, del_inj, del_streak, del_vec ) !******************************************************************************* ! !! COMP_DELT computes the adaptive time stepsize. ! ! Discussion: ! ! The adaptive time stepsize must satisfy the CFL stability criteria. ! ! The routine also sets the flag "write" if some data ! has to be written into a file. ! ! Reference: ! ! Michael Griebel, Thomas Dornseifer, Tilman Neunhoeffer, ! Numerical Simulation in Fluid Dynamics, ! SIAM 1998. ! ! Parameters: ! ! Output, real DELT, the time step. ! ! Input, real T, the current time. ! ! Input, integer IMAX, JMAX, the index of the last computational ! row and column of the grid. ! ! Input, real DELX, DELY, the width and height of one cell. ! ! Input, real U(0:IMAX+1,0:JMAX+1), V(0:IMAX+1,0:JMAX+1), ! the velocity field. ! ! Input, real RE, the Reynolds number. ! ! Input, real PR, the Prandtl number. ! ! Input, real TAU, the safety factor for timestep control. ! ! Input, integer IWRITE, ? ! ! Input, real DEL_TRACE, ? ! ! Input, real DEL_INJ, ? ! ! Input, real DEL_STREAK, ? ! ! Input, real DEL_VEC, ? ! use nrtype implicit none real ( rp ), intent ( in ) :: del_inj real ( rp ), intent ( in ) :: del_streak real ( rp ), intent ( in ) :: del_trace real ( rp ), intent ( in ) :: del_vec real ( rp ) :: deltrepr real ( rp ), intent ( out ) :: delt real ( rp ) :: deltu real ( rp ) :: deltv real ( rp ), intent ( in ) :: delx real ( rp ), intent ( in ) :: dely integer i integer, intent ( in ) :: imax integer, intent ( out ) :: iwrite integer j integer, intent ( in ) :: jmax real ( rp ), intent ( in ) :: pr real ( rp ), intent ( in ) :: re real ( rp ), intent ( in ) :: t real ( rp ) :: t_new real ( rp ), intent ( in ) :: tau real ( rp ), dimension(0:,0:), intent ( in ) :: u real ( rp ) :: umax real ( rp ), dimension(0:,0:), intent ( in ) :: v real ( rp ) :: vmax ! ! Satisfy the CFL conditions. ! ! If a very small TAU, then no time stepsize control. ! if ( 1.0e-10 <= tau ) then umax = 1.0e-10 vmax = 1.0e-10 do i = 0, imax+1 do j = 1, jmax+1 if ( umax < abs ( u(i,j) ) ) then umax = abs ( u(i,j) ) end if end do end do do i = 1, imax+1 do j = 0, jmax+1 if ( vmax < abs ( v(i,j) ) ) then vmax = abs ( v(i,j) ) end if end do end do deltu = delx / umax deltv = dely / vmax if ( pr < 1 ) then deltrepr = 1.0 / ( 1.0 / ( delx * delx ) & + 1.0 / ( dely * dely ) ) * re * pr / 2.0 else deltrepr = 1.0 / ( 1.0 / ( delx * delx ) & + 1.0 / ( dely * dely ) ) * re / 2.0 end if if ( deltu < deltv ) then if ( deltu < deltrepr ) then delt = deltu else delt = deltrepr end if else if ( deltv < deltrepr ) then delt = deltv else delt = deltrepr end if end if ! ! Multiply by safety factor. ! delt = tau * delt end if ! ! Look if some data has to be written to a file in the next time step. ! iwrite = 0 t_new = t + delt if ( int ( t / del_trace ) /= int ( t_new / del_trace ) ) then iwrite = iwrite + 1 end if if ( int ( t / del_inj ) /= int ( t_new / del_inj ) ) then iwrite = iwrite + 2 end if if ( int ( t / del_streak ) /= int ( t_new / del_streak ) ) then iwrite = iwrite + 4 end if if ( int ( t / del_vec ) /= int ( t_new / del_vec ) ) then iwrite = iwrite + 8 end if return end