source: palm/trunk/SOURCE/lpm_boundary_conds.f90 @ 1952

Last change on this file since 1952 was 1930, checked in by suehring, 8 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 24.0 KB
Line 
1!> @file lpm_boundary_conds.f90
2!--------------------------------------------------------------------------------!
3! This file is part of PALM.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms
6! of the GNU General Public License as published by the Free Software Foundation,
7! either version 3 of the License, or (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with
14! PALM. If not, see <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2016 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------!
18!
19! Current revisions:
20! -----------------
21!
22!
23! Former revisions:
24! -----------------
25! $Id: lpm_boundary_conds.f90 1930 2016-06-09 16:32:12Z suehring $
26!
27! 1929 2016-06-09 16:25:25Z suehring
28! Rewritten wall reflection
29!
30! 1822 2016-04-07 07:49:42Z hoffmann
31! Tails removed. Unused variables removed.
32!
33! 1682 2015-10-07 23:56:08Z knoop
34! Code annotations made doxygen readable
35!
36! 1359 2014-04-11 17:15:14Z hoffmann
37! New particle structure integrated.
38! Kind definition added to all floating point numbers.
39!
40! 1320 2014-03-20 08:40:49Z raasch
41! ONLY-attribute added to USE-statements,
42! kind-parameters added to all INTEGER and REAL declaration statements,
43! kinds are defined in new module kinds,
44! revision history before 2012 removed,
45! comment fields (!:) to be used for variable explanations added to
46! all variable declaration statements
47!
48! 1036 2012-10-22 13:43:42Z raasch
49! code put under GPL (PALM 3.9)
50!
51! 849 2012-03-15 10:35:09Z raasch
52! routine renamed lpm_boundary_conds, bottom and top boundary conditions
53! included (former part of advec_particles)
54!
55! 824 2012-02-17 09:09:57Z raasch
56! particle attributes speed_x|y|z_sgs renamed rvar1|2|3
57!
58! Initial version (2007/03/09)
59!
60! Description:
61! ------------
62!> Boundary conditions for the Lagrangian particles.
63!> The routine consists of two different parts. One handles the bottom (flat)
64!> and top boundary. In this part, also particles which exceeded their lifetime
65!> are deleted.
66!> The other part handles the reflection of particles from vertical walls.
67!> This part was developed by Jin Zhang during 2006-2007.
68!>
69!> To do: Code structure for finding the t_index values and for checking the
70!> -----  reflection conditions is basically the same for all four cases, so it
71!>        should be possible to further simplify/shorten it.
72!>
73!> THE WALLS PART OF THIS ROUTINE HAS NOT BEEN TESTED FOR OCEAN RUNS SO FAR!!!!
74!> (see offset_ocean_*)
75!------------------------------------------------------------------------------!
76 SUBROUTINE lpm_boundary_conds( range )
77 
78
79    USE arrays_3d,                                                             &
80        ONLY:  zu, zw
81
82    USE control_parameters,                                                    &
83        ONLY:  dz, message_string, particle_maximum_age
84
85    USE cpulog,                                                                &
86        ONLY:  cpu_log, log_point_s
87
88    USE grid_variables,                                                        &
89        ONLY:  ddx, dx, ddy, dy
90
91    USE indices,                                                               &
92        ONLY:  nxl, nxr, nyn, nys, nz, nzb_s_inner
93
94    USE kinds
95
96    USE particle_attributes,                                                   &
97        ONLY:  deleted_particles, ibc_par_b, ibc_par_t, number_of_particles,   &
98               particles, particle_type, offset_ocean_nzt_m1,                  &
99               use_sgs_for_particles
100
101    USE pegrid
102
103    IMPLICIT NONE
104
105    CHARACTER (LEN=*) ::  range     !<
106   
107    INTEGER(iwp) ::  inc            !< dummy for sorting algorithmus
108    INTEGER(iwp) ::  ir             !< dummy for sorting algorithmus
109    INTEGER(iwp) ::  i1             !< grid index (x) of old particle position
110    INTEGER(iwp) ::  i2             !< grid index (x) of current particle position
111    INTEGER(iwp) ::  i3             !< grid index (x) of intermediate particle position
112    INTEGER(iwp) ::  jr             !< dummy for sorting algorithmus
113    INTEGER(iwp) ::  j1             !< grid index (y) of old particle position
114    INTEGER(iwp) ::  j2             !< grid index (x) of current particle position
115    INTEGER(iwp) ::  j3             !< grid index (x) of intermediate particle position
116    INTEGER(iwp) ::  n              !< particle number
117    INTEGER(iwp) ::  t_index        !< running index for intermediate particle timesteps in reflection algorithmus
118    INTEGER(iwp) ::  t_index_number !< number of intermediate particle timesteps in reflection algorithmus
119    INTEGER(iwp) ::  tmp_x          !< dummy for sorting algorithmus
120    INTEGER(iwp) ::  tmp_y          !< dummy for sorting algorithmus
121
122    INTEGER(iwp), DIMENSION(0:10) :: x_ind(0:10) = 0 !< index array (x) of intermediate particle positions
123    INTEGER(iwp), DIMENSION(0:10) :: y_ind(0:10) = 0 !< index array (x) of intermediate particle positions
124   
125    LOGICAL  ::  cross_wall_x    !< flag to check if particle reflection along x is necessary
126    LOGICAL  ::  cross_wall_y    !< flag to check if particle reflection along y is necessary
127    LOGICAL  ::  downwards       !< flag to check if particle reflection along z is necessary (only if particle move downwards)
128    LOGICAL  ::  reflect_x       !< flag to check if particle is already reflected along x
129    LOGICAL  ::  reflect_y       !< flag to check if particle is already reflected along y
130    LOGICAL  ::  reflect_z       !< flag to check if particle is already reflected along z
131    LOGICAL  ::  tmp_reach_x     !< dummy for sorting algorithmus
132    LOGICAL  ::  tmp_reach_y     !< dummy for sorting algorithmus
133    LOGICAL  ::  tmp_reach_z     !< dummy for sorting algorithmus
134    LOGICAL  ::  x_wall_reached  !< flag to check if particle has already reached wall
135    LOGICAL  ::  y_wall_reached  !< flag to check if particle has already reached wall
136
137    LOGICAL, DIMENSION(0:10) ::  reach_x  !< flag to check if particle is at a yz-wall
138    LOGICAL, DIMENSION(0:10) ::  reach_y  !< flag to check if particle is at a xz-wall
139    LOGICAL, DIMENSION(0:10) ::  reach_z  !< flag to check if particle is at a xy-wall
140
141    REAL(wp) ::  dt_particle    !< particle timestep
142    REAL(wp) ::  dum            !< dummy argument
143    REAL(wp) ::  eps = 1E-10_wp !< security number to check if particle has reached a wall
144    REAL(wp) ::  pos_x          !< intermediate particle position (x)
145    REAL(wp) ::  pos_x_old      !< particle position (x) at previous particle timestep
146    REAL(wp) ::  pos_y          !< intermediate particle position (y)
147    REAL(wp) ::  pos_y_old      !< particle position (y) at previous particle timestep
148    REAL(wp) ::  pos_z          !< intermediate particle position (z)
149    REAL(wp) ::  pos_z_old      !< particle position (z) at previous particle timestep
150    REAL(wp) ::  prt_x          !< current particle position (x)
151    REAL(wp) ::  prt_y          !< current particle position (y)
152    REAL(wp) ::  prt_z          !< current particle position (z)
153    REAL(wp) ::  t_old          !< previous reflection time
154    REAL(wp) ::  tmp_t          !< dummy for sorting algorithmus
155    REAL(wp) ::  xwall          !< location of wall in x
156    REAL(wp) ::  ywall          !< location of wall in y
157    REAL(wp) ::  zwall1         !< location of wall in z (old grid box)
158    REAL(wp) ::  zwall2         !< location of wall in z (current grid box)
159    REAL(wp) ::  zwall3         !< location of wall in z (old y, current x)
160    REAL(wp) ::  zwall4         !< location of wall in z (current y, old x)
161
162    REAL(wp), DIMENSION(0:10) ::  t  !< reflection time
163
164
165    IF ( range == 'bottom/top' )  THEN
166
167!
168!--    Apply boundary conditions to those particles that have crossed the top or
169!--    bottom boundary and delete those particles, which are older than allowed
170       DO  n = 1, number_of_particles
171
172!
173!--       Stop if particles have moved further than the length of one
174!--       PE subdomain (newly released particles have age = age_m!)
175          IF ( particles(n)%age /= particles(n)%age_m )  THEN
176             IF ( ABS(particles(n)%speed_x) >                                  &
177                  ((nxr-nxl+2)*dx)/(particles(n)%age-particles(n)%age_m)  .OR. &
178                  ABS(particles(n)%speed_y) >                                  &
179                  ((nyn-nys+2)*dy)/(particles(n)%age-particles(n)%age_m) )  THEN
180
181                  WRITE( message_string, * )  'particle too fast.  n = ',  n 
182                  CALL message( 'lpm_boundary_conds', 'PA0148', 2, 2, -1, 6, 1 )
183             ENDIF
184          ENDIF
185
186          IF ( particles(n)%age > particle_maximum_age  .AND.  &
187               particles(n)%particle_mask )                              &
188          THEN
189             particles(n)%particle_mask  = .FALSE.
190             deleted_particles = deleted_particles + 1
191          ENDIF
192
193          IF ( particles(n)%z >= zu(nz)  .AND.  particles(n)%particle_mask )  THEN
194             IF ( ibc_par_t == 1 )  THEN
195!
196!--             Particle absorption
197                particles(n)%particle_mask  = .FALSE.
198                deleted_particles = deleted_particles + 1
199             ELSEIF ( ibc_par_t == 2 )  THEN
200!
201!--             Particle reflection
202                particles(n)%z       = 2.0_wp * zu(nz) - particles(n)%z
203                particles(n)%speed_z = -particles(n)%speed_z
204                IF ( use_sgs_for_particles  .AND. &
205                     particles(n)%rvar3 > 0.0_wp )  THEN
206                   particles(n)%rvar3 = -particles(n)%rvar3
207                ENDIF
208             ENDIF
209          ENDIF
210         
211          IF ( particles(n)%z < zw(0)  .AND.  particles(n)%particle_mask )  THEN
212             IF ( ibc_par_b == 1 )  THEN
213!
214!--             Particle absorption
215                particles(n)%particle_mask  = .FALSE.
216                deleted_particles = deleted_particles + 1
217             ELSEIF ( ibc_par_b == 2 )  THEN
218!
219!--             Particle reflection
220                particles(n)%z       = 2.0_wp * zw(0) - particles(n)%z
221                particles(n)%speed_z = -particles(n)%speed_z
222                IF ( use_sgs_for_particles  .AND. &
223                     particles(n)%rvar3 < 0.0_wp )  THEN
224                   particles(n)%rvar3 = -particles(n)%rvar3
225                ENDIF
226             ENDIF
227          ENDIF
228       ENDDO
229
230    ELSEIF ( range == 'walls' )  THEN
231
232
233       CALL cpu_log( log_point_s(48), 'lpm_wall_reflect', 'start' )
234
235       DO  n = 1, number_of_particles
236!
237!--       Recalculate particle timestep
238          dt_particle = particles(n)%age - particles(n)%age_m
239!
240!--       Obtain x/y indices for current particle position
241          i2 = ( particles(n)%x + 0.5_wp * dx ) * ddx
242          j2 = ( particles(n)%y + 0.5_wp * dy ) * ddy
243!
244!--       Save current particle positions
245          prt_x = particles(n)%x
246          prt_y = particles(n)%y
247          prt_z = particles(n)%z
248!
249!--       Recalculate old particle positions
250          pos_x_old = particles(n)%x - particles(n)%speed_x * dt_particle
251          pos_y_old = particles(n)%y - particles(n)%speed_y * dt_particle
252          pos_z_old = particles(n)%z - particles(n)%speed_z * dt_particle
253!
254!--       Obtain x/y indices for old particle positions
255          i1 = ( pos_x_old + 0.5_wp * dx ) * ddx
256          j1 = ( pos_y_old + 0.5_wp * dy ) * ddy
257!
258!--       Determine horizontal as well as vertical walls at which particle can
259!--       be potentially reflected.
260!--       Start with walls aligned in yz layer.
261!--       Wall to the right
262          IF ( prt_x > pos_x_old )  THEN
263             xwall = ( i1 + 0.5_wp ) * dx
264!
265!--       Wall to the left
266          ELSE
267             xwall = ( i1 - 0.5_wp ) * dx
268          ENDIF
269!
270!--       Walls aligned in xz layer
271!--       Wall to the north
272          IF ( prt_y > pos_y_old )  THEN
273             ywall = ( j1 + 0.5_wp ) * dy
274!--       Wall to the south
275          ELSE
276             ywall = ( j1 - 0.5_wp ) * dy
277          ENDIF
278!
279!--       Walls aligned in xy layer at which particle can be possiblly reflected
280          zwall1 = zw(nzb_s_inner(j2,i2))
281          zwall2 = zw(nzb_s_inner(j1,i1))
282          zwall3 = zw(nzb_s_inner(j1,i2))
283          zwall4 = zw(nzb_s_inner(j2,i1))
284!
285!--       Initialize flags to check if particle reflection is necessary
286          downwards    = .FALSE.
287          cross_wall_x = .FALSE.
288          cross_wall_y = .FALSE.
289!
290!--       Initialize flags to check if a wall is reached
291          reach_x      = .FALSE.
292          reach_y      = .FALSE.
293          reach_z      = .FALSE.
294!
295!--       Initialize flags to check if a particle was already reflected
296          reflect_x = .FALSE.
297          reflect_y = .FALSE.
298          reflect_z = .FALSE.
299!
300!--       Initialize flags to check if a vertical wall is already crossed.
301!--       ( Required to obtain correct indices. )
302          x_wall_reached = .FALSE.
303          y_wall_reached = .FALSE.
304!
305!--       Initialize time array
306          t     = 0.0_wp
307!
308!--       Check if particle can reach any wall. This case, calculate the
309!--       fractional time needed to reach this wall. Store this fractional
310!--       timestep in array t. Moreover, store indices for these grid
311!--       boxes where the respective wall belongs to. 
312!--       Start with x-direction.
313          t_index    = 1
314          t(t_index) = ( xwall - pos_x_old )                                   &
315                     / MERGE( MAX( prt_x - pos_x_old,  1E-30_wp ),             &
316                              MIN( prt_x - pos_x_old, -1E-30_wp ),             &
317                              prt_x > pos_x_old )
318          x_ind(t_index)   = i2
319          y_ind(t_index)   = j1
320          reach_x(t_index) = .TRUE.
321          reach_y(t_index) = .FALSE.
322          reach_z(t_index) = .FALSE.
323!
324!--       Store these values only if particle really reaches any wall. t must
325!--       be in a interval between [0:1].
326          IF ( t(t_index) <= 1.0_wp .AND. t(t_index) >= 0.0_wp )  THEN
327             t_index      = t_index + 1
328             cross_wall_x = .TRUE.
329          ENDIF
330!
331!--       y-direction
332          t(t_index) = ( ywall - pos_y_old )                                   &
333                     / MERGE( MAX( prt_y - pos_y_old,  1E-30_wp ),             &
334                              MIN( prt_y - pos_y_old, -1E-30_wp ),             &
335                              prt_y > pos_y_old )
336          x_ind(t_index)   = i1
337          y_ind(t_index)   = j2
338          reach_x(t_index) = .FALSE.
339          reach_y(t_index) = .TRUE.
340          reach_z(t_index) = .FALSE.
341          IF ( t(t_index) <= 1.0_wp .AND. t(t_index) >= 0.0_wp )  THEN
342             t_index      = t_index + 1
343             cross_wall_y = .TRUE.
344          ENDIF
345!
346!--       z-direction
347!--       At first, check if particle moves downwards. Only in this case a
348!--       particle can be reflected vertically.
349          IF ( prt_z < pos_z_old )  THEN
350
351             downwards = .TRUE.
352             dum       =  1.0_wp / MERGE( MAX( prt_z - pos_z_old,  1E-30_wp ), &
353                                          MIN( prt_z - pos_z_old, -1E-30_wp ), &
354                                          prt_z > pos_z_old )
355
356             t(t_index)       = ( zwall1 - pos_z_old ) * dum
357             x_ind(t_index)   = i2
358             y_ind(t_index)   = j2
359             reach_x(t_index) = .FALSE.
360             reach_y(t_index) = .FALSE.
361             reach_z(t_index) = .TRUE.
362             IF ( t(t_index) <= 1.0_wp .AND. t(t_index) >= 0.0_wp )            &
363                t_index = t_index + 1
364
365             reach_x(t_index) = .FALSE.
366             reach_y(t_index) = .FALSE.
367             reach_z(t_index) = .TRUE.
368             t(t_index)       = ( zwall2 - pos_z_old ) * dum
369             x_ind(t_index)   = i1
370             y_ind(t_index)   = j1
371             IF ( t(t_index) <= 1.0_wp .AND. t(t_index) >= 0.0_wp )            &
372                t_index = t_index + 1
373
374             reach_x(t_index) = .FALSE.
375             reach_y(t_index) = .FALSE.
376             reach_z(t_index) = .TRUE.
377             t(t_index)       = ( zwall3 - pos_z_old ) * dum
378             x_ind(t_index)   = i2
379             y_ind(t_index)   = j1
380             IF ( t(t_index) <= 1.0_wp .AND. t(t_index) >= 0.0_wp )            &
381                t_index = t_index + 1
382
383             reach_x(t_index) = .FALSE.
384             reach_y(t_index) = .FALSE.
385             reach_z(t_index) = .TRUE.
386             t(t_index)       = ( zwall4 - pos_z_old ) * dum
387             x_ind(t_index)   = i1
388             y_ind(t_index)   = j2
389             IF ( t(t_index) <= 1.0_wp .AND. t(t_index) >= 0.0_wp )            &
390                t_index = t_index + 1
391
392          END IF
393          t_index_number = t_index - 1
394!
395!--       Carry out reflection only if particle reaches any wall
396          IF ( cross_wall_x .OR. cross_wall_y .OR. downwards )  THEN
397!
398!--          Sort fractional timesteps in ascending order. Also sort the
399!--          corresponding indices and flag according to the time interval a 
400!--          particle reaches the respective wall.
401             inc = 1
402             jr  = 1
403             DO WHILE ( inc <= t_index_number )
404                inc = 3 * inc + 1
405             ENDDO
406
407             DO WHILE ( inc > 1 )
408                inc = inc / 3
409                DO  ir = inc+1, t_index_number
410                   tmp_t       = t(ir)
411                   tmp_x       = x_ind(ir)
412                   tmp_y       = y_ind(ir)
413                   tmp_reach_x = reach_x(ir)
414                   tmp_reach_y = reach_y(ir)
415                   tmp_reach_z = reach_z(ir)
416                   jr    = ir
417                   DO WHILE ( t(jr-inc) > tmp_t )
418                      t(jr)       = t(jr-inc)
419                      x_ind(jr)   = x_ind(jr-inc)
420                      y_ind(jr)   = y_ind(jr-inc)
421                      reach_x(jr) = reach_x(jr-inc)
422                      reach_y(jr) = reach_y(jr-inc)
423                      reach_z(jr) = reach_z(jr-inc)
424                      jr    = jr - inc
425                      IF ( jr <= inc )  EXIT
426                   ENDDO
427                   t(jr)       = tmp_t
428                   x_ind(jr)   = tmp_x
429                   y_ind(jr)   = tmp_y
430                   reach_x(jr) = tmp_reach_x
431                   reach_y(jr) = tmp_reach_y
432                   reach_z(jr) = tmp_reach_z
433                ENDDO
434             ENDDO
435!
436!--          Initialize temporary particle positions
437             pos_x = pos_x_old
438             pos_y = pos_y_old
439             pos_z = pos_z_old
440!
441!--          Loop over all times a particle possibly moves into a new grid box
442             t_old = 0.0_wp
443             DO t_index = 1, t_index_number 
444!           
445!--             Calculate intermediate particle position according to the
446!--             timesteps a particle reaches any wall.
447                pos_x = pos_x + ( t(t_index) - t_old ) * dt_particle           &
448                                                       * particles(n)%speed_x
449                pos_y = pos_y + ( t(t_index) - t_old ) * dt_particle           &
450                                                       * particles(n)%speed_y
451                pos_z = pos_z + ( t(t_index) - t_old ) * dt_particle           &
452                                                       * particles(n)%speed_z
453!
454!--             Obtain x/y grid indices for intermediate particle position from
455!--             sorted index array
456                i3 = x_ind(t_index)
457                j3 = y_ind(t_index)
458!
459!--             Check which wall is already reached
460                IF ( .NOT. x_wall_reached )  x_wall_reached = reach_x(t_index) 
461                IF ( .NOT. y_wall_reached )  y_wall_reached = reach_y(t_index) 
462!
463!--             Check if a particle needs to be reflected at any yz-wall. If
464!--             necessary, carry out reflection. Please note, a security
465!--             constant is required, as the particle position do not
466!--             necessarily exactly match the wall location due to rounding
467!--             errors.   
468                IF ( ABS( pos_x - xwall ) < eps      .AND.                     &
469                     pos_z <= zw(nzb_s_inner(j3,i3)) .AND.                     &
470                     reach_x(t_index)                .AND.                     &
471                     .NOT. reflect_x )  THEN
472!
473!--                Reflection in x-direction.
474!--                Ensure correct reflection by MIN/MAX functions, depending on
475!--                direction of particle transport.
476!--                Due to rounding errors pos_x do not exactly matches the wall
477!--                location, leading to erroneous reflection.             
478                   pos_x = MERGE( MIN( 2.0_wp * xwall - pos_x, xwall ),        &
479                                  MAX( 2.0_wp * xwall - pos_x, xwall ),        &
480                                  particles(n)%x > xwall )
481!
482!--                Change sign of particle speed                     
483                   particles(n)%speed_x = - particles(n)%speed_x
484!
485!--                Change also sign of subgrid-scale particle speed
486                   particles(n)%rvar1 = - particles(n)%rvar1
487!
488!--                Set flag that reflection along x is already done
489                   reflect_x          = .TRUE.
490!
491!--                As particle do not crosses any further yz-wall during
492!--                this timestep, set further x-indices to the current one.
493                   x_ind(t_index:t_index_number) = i1
494!
495!--             If particle already reached the wall but was not reflected,
496!--             set further x-indices to the new one.
497                ELSEIF ( x_wall_reached .AND. .NOT. reflect_x )  THEN
498                    x_ind(t_index:t_index_number) = i2
499                ENDIF
500!
501!--             Check if a particle needs to be reflected at any xz-wall. If
502!--             necessary, carry out reflection.
503                IF ( ABS( pos_y - ywall ) < eps      .AND.                     &
504                     pos_z <= zw(nzb_s_inner(j3,i3)) .AND.                     &
505                     reach_y(t_index)                .AND.                     &
506                     .NOT. reflect_y ) THEN
507
508                   pos_y = MERGE( MIN( 2.0_wp * ywall - pos_y, ywall ),        &
509                                  MAX( 2.0_wp * ywall - pos_y, ywall ),        &
510                                  particles(n)%y > ywall ) 
511
512                   particles(n)%speed_y = - particles(n)%speed_y     
513                   particles(n)%rvar2   = - particles(n)%rvar2       
514     
515                   reflect_y            = .TRUE.
516                   y_ind(t_index:t_index_number) = j1
517
518                ELSEIF ( y_wall_reached .AND. .NOT. reflect_y )  THEN
519                   y_ind(t_index:t_index_number) = j2
520                ENDIF
521!
522!--             Check if a particle needs to be reflected at any xy-wall. If
523!--             necessary, carry out reflection.
524                IF ( downwards .AND. reach_z(t_index) .AND.                    &
525                     .NOT. reflect_z )  THEN
526                   IF ( pos_z - zw(nzb_s_inner(j3,i3)) < eps ) THEN
527 
528                      pos_z = MAX( 2.0_wp * zw(nzb_s_inner(j3,i3)) - pos_z,    &
529                                   zw(nzb_s_inner(j3,i3)) )
530
531                      particles(n)%speed_z = - particles(n)%speed_z
532                      particles(n)%rvar3   = - particles(n)%rvar3
533
534                      reflect_z            = .TRUE.
535
536                   ENDIF
537
538                ENDIF
539!
540!--             Swap time
541                t_old = t(t_index)
542
543             ENDDO
544!
545!--          If a particle was reflected, calculate final position from last
546!--          intermediate position.
547             IF ( reflect_x .OR. reflect_y .OR. reflect_z )  THEN
548
549                particles(n)%x = pos_x + ( 1.0_wp - t_old ) * dt_particle      &
550                                                         * particles(n)%speed_x
551                particles(n)%y = pos_y + ( 1.0_wp - t_old ) * dt_particle      &
552                                                         * particles(n)%speed_y
553                particles(n)%z = pos_z + ( 1.0_wp - t_old ) * dt_particle      &
554                                                         * particles(n)%speed_z
555
556             ENDIF
557
558          ENDIF
559
560       ENDDO
561
562       CALL cpu_log( log_point_s(48), 'lpm_wall_reflect', 'stop' )
563
564    ENDIF
565
566 END SUBROUTINE lpm_boundary_conds
Note: See TracBrowser for help on using the repository browser.