MFIX  2016-1
calc_interp_weights.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! Subroutine: CALC_INTERP_WEIGHTS !
3 ! !
4 ! Purpose: Calculate weights used for interpolation. !
5 ! !
6 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
7  SUBROUTINE calc_interp_weights
8 
13 
14  SELECT CASE(des_interp_scheme_enum)
15  CASE(des_interp_dpvm); CALL calc_interp_weights1
16  CASE(des_interp_gauss); CALL calc_interp_weights1
18  END SELECT
19 
20  RETURN
21  END SUBROUTINE calc_interp_weights
22 
23 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
24 ! Subroutine: CALC_INTERP_WEIGHTS1 !
25 ! !
26 ! Purpose: Calculate weights used for interpolation. !
27 ! !
28 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
29  SUBROUTINE calc_interp_weights1
30 
31  use discretelement, only: max_pip
32  use discretelement, only: pijk
33  use discretelement, only: des_pos_new
34  use discretelement, only: xe, yn, zt
35  use particle_filter, only: filter_cell
37  use geometry, only: do_k
38 
39  use param1, only: zero, one
40 ! compar is needed by functions.inc
41  use compar
42 
43  IMPLICIT NONE
44 
45  INTEGER :: L, IDX
46  INTEGER :: IJK, IJKt
47 
48  INTEGER :: I, J, K
49  INTEGER :: IC, JC, KC
50  INTEGER :: Km, Kp
51 
52  DOUBLE PRECISION :: WEIGHT
53  DOUBLE PRECISION :: WEIGHT_I(-1:1)
54  DOUBLE PRECISION :: WEIGHT_J(-1:1)
55  DOUBLE PRECISION :: WEIGHT_K(-1:1)
56 
57 !$omp parallel default(none) private(L, WEIGHT_I, WEIGHT_J, WEIGHT_K, &
58 !$omp KM, KP, IDX, IJK, I, J, K, WEIGHT, IJKT) &
59 !$omp shared(MAX_PIP, PIJK, DES_POS_NEW, XE, YN, ZT, DO_K, &
60 !$omp FILTER_CELL, FILTER_WEIGHT)
61 !$omp do
62  DO l = 1, max_pip
63 
64  IF(.NOT.is_normal(l)) cycle
65 
66  i = pijk(l,1)
67  j = pijk(l,2)
68  k = pijk(l,3)
69 
70 ! Tentative weights for I indices to the West and East.
71  weight_i(-1) = calc_filter_weights(des_pos_new(l,1), xe(i-1))
72  weight_i( 1) = calc_filter_weights(xe(i), des_pos_new(l,1))
73  weight_i( 0) = one - weight_i(-1) - weight_i(1)
74 
75 ! Tentative weights for J indices to the South and North.
76  weight_j(-1) = calc_filter_weights(des_pos_new(l,2), yn(j-1))
77  weight_j( 1) = calc_filter_weights(yn(j), des_pos_new(l,2))
78  weight_j( 0) = one - weight_j(-1) - weight_j(1)
79 
80 ! Tentative weights for K indices to the Top and Bottom.
81  IF(do_k) THEN
82  km=-1; kp=1
83  weight_k(-1) = calc_filter_weights(des_pos_new(l,3),zt(k-1))
84  weight_k( 1) = calc_filter_weights(zt(k), des_pos_new(l,3))
85  weight_k( 0) = one - weight_k(-1) - weight_k(1)
86  ELSE
87  km= 0; kp=0
88  weight_k( 0) = one
89  ENDIF
90 
91 ! Set the default fluid cell index and loop counter.
92  ijk = pijk(l,4)
93  idx=0
94 
95 ! Calculate weights for ghost particles. Only store weights that the
96 ! current process owns.
97  DO kc=km,kp
98  DO ic=-1,+1
99  DO jc=-1,+1
100  idx=idx+1
101  weight = weight_i(ic)*weight_j(jc)*weight_k(kc)
102  IF(is_on_mype_plus2layers(i+ic,j+jc,k+kc)) THEN
103  ijkt = funijk(i+ic,j+jc,k+kc)
104  IF(fluid_at(ijkt) .OR. cyclic_at(ijkt)) THEN
105  filter_cell(idx,l) = ijkt
106  filter_weight(idx,l) = weight
107  ELSE
108  filter_cell(idx,l) = ijk
109  filter_weight(idx,l) = weight
110  ENDIF
111  ELSE
112  filter_cell(idx,l) = ijk
113  filter_weight(idx,l) = zero
114  ENDIF
115  ENDDO
116  ENDDO
117  ENDDO
118 
119  ENDDO
120 !$omp end do
121 !$omp end parallel
122 
123  CONTAINS
124 
125 !``````````````````````````````````````````````````````````````````````!
126 ! !
127 !``````````````````````````````````````````````````````````````````````!
128  DOUBLE PRECISION FUNCTION calc_filter_weights(POS1, POS2)
131  use particle_filter, only: oofilter_vol
133 
134  DOUBLE PRECISION, INTENT(IN) :: POS1, POS2
135  DOUBLE PRECISION :: OVERLAP, HEIGHT
136 
137  overlap = pos1 - pos2
138  IF(overlap < filter_width_interp) THEN
139  height = filter_width_interp - overlap
140  calc_filter_weights = height**2 * &
141  (filter_width_interpx3 - height)*oofilter_vol
142  ELSE
144  ENDIF
145 
146  END FUNCTION calc_filter_weights
147 
148  include 'functions.inc'
149 
150  END SUBROUTINE calc_interp_weights1
151 
152 
153 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
154 ! Subroutine: CALC_INTERP_WEIGHTS2 !
155 ! !
156 ! Purpose: Calculate weights used for interpolation. !
157 ! !
158 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
159  SUBROUTINE calc_interp_weights2
161  use discretelement, only: max_pip
162  use discretelement, only: pijk
163  use discretelement, only: des_pos_new
164  use discretelement, only: xe, yn, zt
165  use particle_filter, only: filter_cell
166  use particle_filter, only: filter_weight
167  use geometry, only: dx, dy, dz
168  use geometry, only: odx_e, ody_n, odz_t, do_k
169 
170  use param1, only: zero, half, one
171 
172  use compar, only: funijk_map_c
173 
174 
175  IMPLICIT NONE
176 
177  INTEGER :: L, IDX
178  INTEGER :: IJK, IJKt
179 
180  INTEGER :: I, J, K
181  INTEGER :: IC, JC, KC
182  INTEGER :: Km, Kp
183 
184  DOUBLE PRECISION :: XC, YC, ZC
185  DOUBLE PRECISION :: WEIGHT
186  DOUBLE PRECISION :: WEIGHT_I(-1:1)
187  DOUBLE PRECISION :: WEIGHT_J(-1:1)
188  DOUBLE PRECISION :: WEIGHT_K(-1:1)
189 
190 
191  DO l = 1, max_pip
192 
193  IF(.NOT.is_normal(l)) cycle
194 
195  i = pijk(l,1)
196  j = pijk(l,2)
197  k = pijk(l,3)
198 
199 ! Tentative weights for I indices to the West and East.
200  xc = xe(i-1) + half*dx(i)
201  IF(des_pos_new(l,1) < xe(i-1)+half*dx(i)) THEN
202  weight_i(-1) = (xc - des_pos_new(l,1))*odx_e(i-1)
203  weight_i( 0) = one - weight_i(-1)
204  weight_i( 1) = zero
205  ELSE
206  weight_i( 1) = (des_pos_new(l,1) - xc)*odx_e(i)
207  weight_i( 0) = one - weight_i(1)
208  weight_i(-1) = zero
209  ENDIF
210 
211 ! Tentative weights for J indices to the South and North.
212  yc = yn(j-1) + half*dy(j)
213  IF(des_pos_new(l,2) < yn(j-1)+half*dy(j)) THEN
214  weight_j(-1) = (yc - des_pos_new(l,2))*ody_n(j-1)
215  weight_j( 0) = one - weight_j(-1)
216  weight_j( 1) = zero
217  ELSE
218  weight_j( 1) = (des_pos_new(l,2) - yc)*ody_n(j)
219  weight_j( 0) = one - weight_j(1)
220  weight_j(-1) = zero
221  ENDIF
222 
223 ! Tentative weights for K indices to the Top and Bottom.
224  IF(do_k) THEN
225  km=-1; kp=1
226  zc = zt(k-1) + half*dz(k)
227  IF(des_pos_new(l,3) < zt(k-1)+half*dz(k)) THEN
228  weight_k(-1) = (zc - des_pos_new(l,3))*odz_t(k-1)
229  weight_k( 0) = one - weight_k(-1)
230  weight_k( 1) = zero
231  ELSE
232  weight_k( 1) = (des_pos_new(l,3) - zc)*odz_t(k)
233  weight_k( 0) = one - weight_k(1)
234  weight_k(-1) = zero
235  ENDIF
236  ELSE
237  km= 0; kp=0
238  weight_k( 0) = one
239  ENDIF
240 
241 ! Set the default fluid cell index and loop counter.
242  ijk = pijk(l,4)
243  idx=0
244 
245 ! Calculate weights for ghost particles. Only store weights that the
246 ! current process owns.
247  DO kc=km,kp
248  DO ic=-1,+1
249  DO jc=-1,+1
250  idx=idx+1
251  weight = weight_i(ic)*weight_j(jc)*weight_k(kc)
252  IF(is_on_mype_plus2layers(i+ic,j+jc,k+kc)) THEN
253  ijkt = funijk_map_c(i+ic,j+jc,k+kc)
254  IF(fluid_at(ijkt)) THEN
255  filter_cell(idx,l) = ijkt
256  filter_weight(idx,l) = weight
257  ELSE
258  filter_cell(idx,l) = ijk
259  filter_weight(idx,l) = weight
260  ENDIF
261  ELSE
262  filter_cell(idx,l) = ijk
263  filter_weight(idx,l) = zero
264  ENDIF
265  ENDDO
266  ENDDO
267  ENDDO
268 
269  ENDDO
270 
271  CONTAINS
272 
273  include 'functions.inc'
274 
275  END SUBROUTINE calc_interp_weights2
integer, parameter des_interp_gauss
double precision function calc_filter_weights(POS1, POS2)
integer, dimension(:,:), allocatable filter_cell
double precision, parameter one
Definition: param1_mod.f:29
double precision, dimension(0:dim_j) dy
Definition: geometry_mod.f:70
double precision, dimension(0:dim_k) dz
Definition: geometry_mod.f:72
subroutine calc_interp_weights1
double precision filter_width_interpx3
subroutine calc_interp_weights
integer, parameter des_interp_lhat
Definition: ic_mod.f:9
double precision, dimension(:), allocatable ody_n
Definition: geometry_mod.f:123
double precision, dimension(:,:), allocatable filter_weight
double precision, dimension(:), allocatable odx_e
Definition: geometry_mod.f:121
integer, parameter des_interp_dpvm
double precision, dimension(0:dim_i) dx
Definition: geometry_mod.f:68
double precision filter_width_interp
double precision, parameter half
Definition: param1_mod.f:28
double precision oofilter_vol
integer des_interp_scheme_enum
logical do_k
Definition: geometry_mod.f:30
subroutine calc_interp_weights2
double precision, dimension(:), allocatable odz_t
Definition: geometry_mod.f:125
double precision, parameter zero
Definition: param1_mod.f:27