[1682] | 1 | !> @file lpm_extend_tails.f90 |
---|
[1036] | 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 | ! |
---|
[1310] | 16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[849] | 19 | ! Current revisions: |
---|
| 20 | ! ------------------ |
---|
[1360] | 21 | ! |
---|
[1683] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: lpm_extend_tails.f90 1683 2015-10-07 23:57:51Z gronemeier $ |
---|
| 26 | ! |
---|
[1683] | 27 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 28 | ! Code annotations made doxygen readable |
---|
| 29 | ! |
---|
[1360] | 30 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 31 | ! New particle structure integrated. |
---|
| 32 | ! Kind definition added to all floating point numbers. |
---|
| 33 | ! |
---|
[1321] | 34 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 35 | ! ONLY-attribute added to USE-statements, |
---|
| 36 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 37 | ! kinds are defined in new module kinds, |
---|
| 38 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 39 | ! all variable declaration statements |
---|
[849] | 40 | ! |
---|
[1037] | 41 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 42 | ! code put under GPL (PALM 3.9) |
---|
| 43 | ! |
---|
[850] | 44 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 45 | ! initial revision (former part of advec_particles) |
---|
[849] | 46 | ! |
---|
[850] | 47 | ! |
---|
[849] | 48 | ! Description: |
---|
| 49 | ! ------------ |
---|
[1682] | 50 | !> Add the current particle positions to the particle tails. |
---|
[849] | 51 | !------------------------------------------------------------------------------! |
---|
[1682] | 52 | SUBROUTINE lpm_extend_tails |
---|
| 53 | |
---|
[849] | 54 | |
---|
[1320] | 55 | USE control_parameters, & |
---|
| 56 | ONLY: dt_3d |
---|
[849] | 57 | |
---|
[1320] | 58 | USE kinds |
---|
| 59 | |
---|
| 60 | USE particle_attributes, & |
---|
| 61 | ONLY: maximum_number_of_tailpoints, maximum_tailpoint_age, & |
---|
| 62 | minimum_tailpoint_distance, number_of_particles, particles, & |
---|
| 63 | particle_tail_coordinates |
---|
| 64 | |
---|
[849] | 65 | IMPLICIT NONE |
---|
| 66 | |
---|
[1682] | 67 | INTEGER(iwp) :: i !< |
---|
| 68 | INTEGER(iwp) :: n !< |
---|
| 69 | INTEGER(iwp) :: nn !< |
---|
[849] | 70 | |
---|
[1682] | 71 | REAL(wp) :: distance !< |
---|
[849] | 72 | |
---|
| 73 | |
---|
[1359] | 74 | distance = 0.0_wp |
---|
[849] | 75 | |
---|
| 76 | DO n = 1, number_of_particles |
---|
| 77 | |
---|
| 78 | nn = particles(n)%tail_id |
---|
| 79 | |
---|
| 80 | IF ( nn /= 0 ) THEN |
---|
| 81 | ! |
---|
| 82 | !-- Calculate the distance between the actual particle position and the |
---|
| 83 | !-- next tailpoint |
---|
[1359] | 84 | IF ( minimum_tailpoint_distance /= 0.0_wp ) THEN |
---|
[849] | 85 | distance = ( particle_tail_coordinates(1,1,nn) - & |
---|
| 86 | particle_tail_coordinates(2,1,nn) )**2 + & |
---|
| 87 | ( particle_tail_coordinates(1,2,nn) - & |
---|
| 88 | particle_tail_coordinates(2,2,nn) )**2 + & |
---|
| 89 | ( particle_tail_coordinates(1,3,nn) - & |
---|
| 90 | particle_tail_coordinates(2,3,nn) )**2 |
---|
| 91 | ENDIF |
---|
| 92 | |
---|
| 93 | ! |
---|
| 94 | !-- First, increase the index of all existings tailpoints by one |
---|
| 95 | IF ( distance >= minimum_tailpoint_distance ) THEN |
---|
| 96 | |
---|
| 97 | DO i = particles(n)%tailpoints, 1, -1 |
---|
| 98 | particle_tail_coordinates(i+1,:,nn) = & |
---|
| 99 | particle_tail_coordinates(i,:,nn) |
---|
| 100 | ENDDO |
---|
| 101 | ! |
---|
| 102 | !-- Increase the counter which contains the number of tailpoints. |
---|
| 103 | !-- This must always be smaller than the given maximum number of |
---|
| 104 | !-- tailpoints because otherwise the index bounds of |
---|
| 105 | !-- particle_tail_coordinates would be exceeded |
---|
| 106 | IF ( particles(n)%tailpoints < maximum_number_of_tailpoints-1 ) & |
---|
| 107 | THEN |
---|
| 108 | particles(n)%tailpoints = particles(n)%tailpoints + 1 |
---|
| 109 | ENDIF |
---|
| 110 | ENDIF |
---|
| 111 | ! |
---|
| 112 | !-- In any case, store the new point at the beginning of the tail |
---|
| 113 | particle_tail_coordinates(1,1,nn) = particles(n)%x |
---|
| 114 | particle_tail_coordinates(1,2,nn) = particles(n)%y |
---|
| 115 | particle_tail_coordinates(1,3,nn) = particles(n)%z |
---|
| 116 | particle_tail_coordinates(1,4,nn) = particles(n)%class |
---|
| 117 | ! |
---|
| 118 | !-- Increase the age of the tailpoints |
---|
[1359] | 119 | IF ( minimum_tailpoint_distance /= 0.0_wp ) THEN |
---|
[849] | 120 | particle_tail_coordinates(2:particles(n)%tailpoints,5,nn) = & |
---|
| 121 | particle_tail_coordinates(2:particles(n)%tailpoints,5,nn) + dt_3d |
---|
| 122 | ! |
---|
| 123 | !-- Delete the last tailpoint, if it has exceeded its maximum age |
---|
| 124 | IF ( particle_tail_coordinates(particles(n)%tailpoints,5,nn) > & |
---|
| 125 | maximum_tailpoint_age ) THEN |
---|
| 126 | particles(n)%tailpoints = particles(n)%tailpoints - 1 |
---|
| 127 | ENDIF |
---|
| 128 | ENDIF |
---|
| 129 | |
---|
| 130 | ENDIF |
---|
| 131 | |
---|
| 132 | ENDDO |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | END SUBROUTINE lpm_extend_tails |
---|