source: palm/trunk/SOURCE/lpm_extend_tails.f90 @ 1359

Last change on this file since 1359 was 1359, checked in by hoffmann, 10 years ago

new Lagrangian particle structure integrated

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