Ignore:
Timestamp:
Nov 20, 2017 12:40:38 PM (6 years ago)
Author:
schwenkel
Message:

enable particle advection with grid stretching and some formatation changes in lpm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/lpm_exchange_horiz.f90

    r2606 r2628  
    2525! -----------------
    2626! $Id$
     27! Enabled particle advection with grid stretching. Furthermore, the CFL-
     28! criterion is checked for every particle at every time step.
     29!
     30! 2606 2017-11-10 10:36:31Z schwenkel
    2731! Changed particle box locations: center of particle box now coincides
    2832! with scalar grid point of same index.
     
    124128 
    125129    USE, INTRINSIC ::  ISO_C_BINDING
    126 
     130   
     131    USE arrays_3d,                                                             &
     132       ONLY:  zw
     133   
    127134    USE control_parameters,                                                    &
    128135        ONLY:  dz, message_string, simulated_time
     
    887894       jp = particle_array(n)%y * ddy
    888895       kp = particle_array(n)%z / dz + 1 + offset_ocean_nzt
     896!
     897!--    In case of grid stretching a particle might be above or below the 
     898!--    previously calculated particle grid box (indices).     
     899       DO WHILE( zw(kp) < particle_array(n)%z )
     900          kp = kp + 1
     901       ENDDO
     902
     903       DO WHILE( zw(kp-1) > particle_array(n)%z )
     904          kp = kp - 1
     905       ENDDO
    889906
    890907       IF ( ip >= nxl  .AND.  ip <= nxr  .AND.  jp >= nys  .AND.  jp <= nyn    &
     
    10221039!------------------------------------------------------------------------------!
    10231040 SUBROUTINE lpm_move_particle
    1024 
     1041 
    10251042    IMPLICIT NONE
    10261043
     
    10381055
    10391056    CALL cpu_log( log_point_s(41), 'lpm_move_particle', 'start' )
    1040 
     1057    CALL lpm_check_cfl
    10411058    DO  ip = nxl, nxr
    10421059       DO  jp = nys, nyn
     
    10501067                i = particles_before_move(n)%x * ddx
    10511068                j = particles_before_move(n)%y * ddy
    1052                 k = particles_before_move(n)%z / dz + 1 + offset_ocean_nzt
    1053 
     1069                k = kp
     1070!
     1071!--             Find correct vertical particle grid box (necessary in case of grid stretching)
     1072!--             Due to the CFL limitations only the neighbouring grid boxes are considered.
     1073                IF( zw(k)   < particles_before_move(n)%z ) k = k + 1
     1074                IF( zw(k-1) > particles_before_move(n)%z ) k = k - 1
     1075               
    10541076!--             For lpm_exchange_horiz to work properly particles need to be moved to the outermost gridboxes
    10551077!--             of the respective processor. If the particle index is inside the processor the following lines
     
    10591081                j = MIN ( j , nyn )
    10601082                j = MAX ( j , nys )
     1083               
    10611084                k = MIN ( k , nzt )
    10621085                k = MAX ( k , nzb+1 )
     1086               
    10631087!
    10641088!--             Check, if particle has moved to another grid cell.
     
    10921116
    10931117 END SUBROUTINE lpm_move_particle
    1094 
     1118 
     1119!------------------------------------------------------------------------------!
     1120! Description:
     1121! ------------
     1122!> Check CFL-criterion for each particle. If one particle violated the
     1123!> criterion the particle will be deleted and a warning message is given.
     1124!------------------------------------------------------------------------------!
     1125 SUBROUTINE lpm_check_cfl 
     1126       
     1127    IMPLICIT NONE
     1128   
     1129    INTEGER(iwp)  ::  i
     1130    INTEGER(iwp)  ::  j
     1131    INTEGER(iwp)  ::  k
     1132    INTEGER(iwp)  ::  n
     1133   
     1134    DO  i = nxl, nxr
     1135       DO  j = nys, nyn
     1136          DO  k = nzb+1, nzt
     1137             number_of_particles = prt_count(k,j,i)
     1138             IF ( number_of_particles <= 0 )  CYCLE
     1139             particles => grid_particles(k,j,i)%particles(1:number_of_particles)         
     1140             DO n = 1, number_of_particles
     1141   
     1142                IF(ABS(particles(n)%speed_x) >                                 &
     1143                   (dx/(particles(n)%age-particles(n)%age_m))  .OR.            &
     1144                   ABS(particles(n)%speed_y) >                                 &
     1145                   (dx/(particles(n)%age-particles(n)%age_m))  .OR.            &
     1146                   ABS(particles(n)%speed_z) >                                 &
     1147                   ((zw(k)-zw(k-1))/(particles(n)%age-particles(n)%age_m))) THEN
     1148                   WRITE( message_string, * ) 'PARTICLE VIOLATED CFL CRITERION'&
     1149                   ': particle with id ',particles(n)%id,' will be deleted!'   
     1150                   CALL message( 'lpm_check_cfl', 'PA0500', 0, 1, 0, 6, 0 )
     1151                   particles(n)%particle_mask= .FALSE.
     1152                ENDIF
     1153             ENDDO
     1154          ENDDO
     1155       ENDDO
     1156    ENDDO   
     1157
     1158 END SUBROUTINE lpm_check_cfl
     1159 
    10951160!------------------------------------------------------------------------------!
    10961161! Description:
Note: See TracChangeset for help on using the changeset viewer.