1 | SUBROUTINE lpm_extend_tails |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! ONLY-attribute added to USE-statements, |
---|
23 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
24 | ! kinds are defined in new module kinds, |
---|
25 | ! comment fields (!:) to be used for variable explanations added to |
---|
26 | ! all variable declaration statements |
---|
27 | ! |
---|
28 | ! Former revisions: |
---|
29 | ! ----------------- |
---|
30 | ! $Id: lpm_extend_tails.f90 1320 2014-03-20 08:40:49Z raasch $ |
---|
31 | ! |
---|
32 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
33 | ! code put under GPL (PALM 3.9) |
---|
34 | ! |
---|
35 | ! 849 2012-03-15 10:35:09Z raasch |
---|
36 | ! initial revision (former part of advec_particles) |
---|
37 | ! |
---|
38 | ! |
---|
39 | ! Description: |
---|
40 | ! ------------ |
---|
41 | ! Add the current particle positions to the particle tails. |
---|
42 | !------------------------------------------------------------------------------! |
---|
43 | |
---|
44 | USE control_parameters, & |
---|
45 | ONLY: dt_3d |
---|
46 | |
---|
47 | USE kinds |
---|
48 | |
---|
49 | USE particle_attributes, & |
---|
50 | ONLY: maximum_number_of_tailpoints, maximum_tailpoint_age, & |
---|
51 | minimum_tailpoint_distance, number_of_particles, particles, & |
---|
52 | particle_tail_coordinates |
---|
53 | |
---|
54 | IMPLICIT NONE |
---|
55 | |
---|
56 | INTEGER(iwp) :: i !: |
---|
57 | INTEGER(iwp) :: n !: |
---|
58 | INTEGER(iwp) :: nn !: |
---|
59 | |
---|
60 | REAL(wp) :: distance !: |
---|
61 | |
---|
62 | |
---|
63 | distance = 0.0 |
---|
64 | |
---|
65 | DO n = 1, number_of_particles |
---|
66 | |
---|
67 | nn = particles(n)%tail_id |
---|
68 | |
---|
69 | IF ( nn /= 0 ) THEN |
---|
70 | ! |
---|
71 | !-- Calculate the distance between the actual particle position and the |
---|
72 | !-- next tailpoint |
---|
73 | IF ( minimum_tailpoint_distance /= 0.0 ) THEN |
---|
74 | distance = ( particle_tail_coordinates(1,1,nn) - & |
---|
75 | particle_tail_coordinates(2,1,nn) )**2 + & |
---|
76 | ( particle_tail_coordinates(1,2,nn) - & |
---|
77 | particle_tail_coordinates(2,2,nn) )**2 + & |
---|
78 | ( particle_tail_coordinates(1,3,nn) - & |
---|
79 | particle_tail_coordinates(2,3,nn) )**2 |
---|
80 | ENDIF |
---|
81 | |
---|
82 | ! |
---|
83 | !-- First, increase the index of all existings tailpoints by one |
---|
84 | IF ( distance >= minimum_tailpoint_distance ) THEN |
---|
85 | |
---|
86 | DO i = particles(n)%tailpoints, 1, -1 |
---|
87 | particle_tail_coordinates(i+1,:,nn) = & |
---|
88 | particle_tail_coordinates(i,:,nn) |
---|
89 | ENDDO |
---|
90 | ! |
---|
91 | !-- Increase the counter which contains the number of tailpoints. |
---|
92 | !-- This must always be smaller than the given maximum number of |
---|
93 | !-- tailpoints because otherwise the index bounds of |
---|
94 | !-- particle_tail_coordinates would be exceeded |
---|
95 | IF ( particles(n)%tailpoints < maximum_number_of_tailpoints-1 ) & |
---|
96 | THEN |
---|
97 | particles(n)%tailpoints = particles(n)%tailpoints + 1 |
---|
98 | ENDIF |
---|
99 | ENDIF |
---|
100 | ! |
---|
101 | !-- In any case, store the new point at the beginning of the tail |
---|
102 | particle_tail_coordinates(1,1,nn) = particles(n)%x |
---|
103 | particle_tail_coordinates(1,2,nn) = particles(n)%y |
---|
104 | particle_tail_coordinates(1,3,nn) = particles(n)%z |
---|
105 | particle_tail_coordinates(1,4,nn) = particles(n)%class |
---|
106 | ! |
---|
107 | !-- Increase the age of the tailpoints |
---|
108 | IF ( minimum_tailpoint_distance /= 0.0 ) THEN |
---|
109 | particle_tail_coordinates(2:particles(n)%tailpoints,5,nn) = & |
---|
110 | particle_tail_coordinates(2:particles(n)%tailpoints,5,nn) + dt_3d |
---|
111 | ! |
---|
112 | !-- Delete the last tailpoint, if it has exceeded its maximum age |
---|
113 | IF ( particle_tail_coordinates(particles(n)%tailpoints,5,nn) > & |
---|
114 | maximum_tailpoint_age ) THEN |
---|
115 | particles(n)%tailpoints = particles(n)%tailpoints - 1 |
---|
116 | ENDIF |
---|
117 | ENDIF |
---|
118 | |
---|
119 | ENDIF |
---|
120 | |
---|
121 | ENDDO |
---|
122 | |
---|
123 | |
---|
124 | END SUBROUTINE lpm_extend_tails |
---|