Ignore:
Timestamp:
Nov 7, 2011 2:18:25 PM (10 years ago)
Author:
fricke
Message:

Modifications of the multigrid pressure solver

File:
1 edited

Legend:

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

    r708 r778  
    77! Current revisions:
    88! -----------------
    9 !
     9! Allocation of p3 changes when multigrid is used and the collected field on PE0
     10! has more grid points than the subdomain of an PE.
    1011!
    1112! Former revisions:
     
    7576    REAL    ::  maxerror, maximum_mgcycles, residual_norm
    7677
    77     REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ::  r
     78    REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ::  r 
    7879
    7980    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  p3
     
    8182
    8283    CALL cpu_log( log_point_s(29), 'poismg', 'start' )
    83 
    8484!
    8585!-- Initialize arrays and variables used in this subroutine
    86     ALLOCATE ( p3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
    87 
     86
     87!--    If the number of grid points of the gathered grid, which is collected
     88!--    on PE0, is larger than the number of grid points of an PE, than array
     89!--    p3 will be enlarged.
     90    IF ( gathered_size > subdomain_size )  THEN
     91       ALLOCATE( p3(nzb:nzt_mg(mg_switch_to_pe0_level)+1,nys_mg(         &
     92                    mg_switch_to_pe0_level)-1:nyn_mg(mg_switch_to_pe0_level)+1,   &
     93                    nxl_mg(mg_switch_to_pe0_level)-1:nxr_mg(                    &
     94                    mg_switch_to_pe0_level)+1) )
     95    ELSE
     96       ALLOCATE ( p3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
     97    ENDIF
    8898!
    8999!-- Ghost boundaries have to be added to divergence array.
     
    111121    DO WHILE ( residual_norm > residual_limit  .OR. &
    112122               mgcycles < maximum_mgcycles )
    113 
     123 
    114124       CALL next_mg_level( d, p_loc, p3, r)
    115        
     125
    116126!
    117127!--    Calculate the residual if the user has not preset the number of
     
    120130          CALL resid( d, p_loc, r )
    121131          maxerror = SUM( r(nzb+1:nzt,nys:nyn,nxl:nxr)**2 )
     132
    122133#if defined( __parallel )
    123134          IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    124           CALL MPI_ALLREDUCE( maxerror, residual_norm, 1, MPI_REAL, MPI_SUM, &
     135             CALL MPI_ALLREDUCE( maxerror, residual_norm, 1, MPI_REAL, MPI_SUM, &
    125136                              comm2d, ierr)
    126137#else
    127           residual_norm = maxerror
     138             residual_norm = maxerror
    128139#endif
    129140          residual_norm = SQRT( residual_norm )
     
    612623
    613624          IF ( .NOT. unroll )  THEN
     625
    614626             CALL cpu_log( log_point_s(36), 'redblack_no_unroll', 'start' )
    615627
     
    964976    CALL exchange_horiz( p_mg, 1)
    965977
     978
    966979 END SUBROUTINE redblack
    967980
     
    11071120    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  f2, f2_sub, p2, p2_sub
    11081121
     1122
    11091123!
    11101124!-- Restriction to the coarsest grid
     
    11151129!--    iterations in order to get a more accurate solution.
    11161130       ngsrb = 2 * ngsrb
     1131
    11171132       CALL redblack( f_mg, p_mg )
     1133
    11181134       ngsrb = ngsrb / 2
     1135
    11191136
    11201137    ELSEIF ( grid_level /= 1 )  THEN
     
    11371154       grid_level = grid_level - 1
    11381155       nxl = nxl_mg(grid_level)
     1156       nys = nys_mg(grid_level)
    11391157       nxr = nxr_mg(grid_level)
    1140        nys = nys_mg(grid_level)
    11411158       nyn = nyn_mg(grid_level)
    11421159       nzt = nzt_mg(grid_level)
     
    11501167
    11511168       IF ( grid_level == mg_switch_to_pe0_level )  THEN
     1169
    11521170!
    11531171!--       From this level on, calculations are done on PE0 only.
     
    11561174!--       in between (otherwise, the restrict routine would expect
    11571175!--       the gathered array)
     1176
    11581177          nxl_mg_save = nxl_mg(grid_level)
    11591178          nxr_mg_save = nxr_mg(grid_level)
     
    11901209          nyn = nyn_mg(grid_level)
    11911210          nzt = nzt_mg(grid_level)
    1192 
    11931211!
    11941212!--       Gather all arrays from the subdomains on PE0
     
    12311249
    12321250       ELSE
    1233 
    12341251          CALL restrict( f2, r )
    12351252
     
    13341351
    13351352       ELSE
    1336 
    13371353          CALL prolong( p2, p3 )
    13381354
     
    13601376    ENDIF
    13611377
     1378
    13621379!
    13631380!-- The following few lines serve the steering of the multigrid scheme
Note: See TracChangeset for help on using the changeset viewer.