-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlip.f90
813 lines (680 loc) · 23.8 KB
/
lip.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
! ====================================================
! upen_int -> result, works in x(lines)
! can work in place, JJS 12/09
! ====================================================
! ===================================================================
! ADDS explicit viscous term in x --- orientation in x(lines)
! works in place
! Called by: rhsp.f90, JJS 12/09
! ===================================================================
!//////////////////// JSS MAY 2010 ///////
!interpyy() now works in place
!differzy() now works in place
!////////////////////////////////////////
!JSS: Also, apart of computing the viscous term the x convective term is computed.
! upen_int: for computing the convective terms
! upencil: for computing the viscous terms
!result: Result
! icon,econ --> convective [Ac]X' =[Bc]X == [icon]X'=[econ]X
! iconv,econv --> viscous [Av]X''=[Bv]X == [iconv]X'=[econv]X
!
! dcbx = Boundary coefficients for convective terms
! cofvbx= Boundary coefficients for viscous terms
! nlin=number of pencils
!d/dx: chv depending of 'v,w' or 'u' ------> For convective terms (chv for u=1, for v,w=2)
!d/dx: chv depending of (uv),(upen_int),(uw)
! vel=0: 'v,w'; vel.ne.0 u ------> For viscous terms
! rex=-1/Reynolds
!ie:
! ===========d/dX==========================
! differx(geni,result ,icon,dcbx,econ ,chv,jee)
! call differx(u_x ,result,dcxu,dcbx,cofcxu,1,ny+1)
! call differx(v_x ,result,dcxv,dcbx,cofcxv,2,ny)
! call differx(w_x ,result,dcxv,dcbx,cofcxv,2,ny+1)
! call differx (v,result,dcxu,dcbx,cofcxu,1,ny)
! call differx (w,result,dcxu,dcbx,cofcxu,1,ny+1)
!
! ===========d/dY==========================
! differzy(geni,result,icon,dcby,econ ,chv,npter1,fwb1,fwb2 ,jee)
! call differzy(u ,resultu,dcyv,dcby,cofcyv, 1, 1, 0, 1, ny+1)
! call differzy(w ,resultu,dcyv,dcby,cofcyv, 1, 1, 0, 1, ny+1)
! call differzy(u_y,rhsu,dcyu,dcby,cofcyu, 3, 1, -1, 0, ny+1)
! call differzy(v_y,rhsv,dcyv,dcby,cofcyv, 1, 1, 0, 1, ny )
! call differzy(w_y,rhsw,dcyu,dcby,cofcyu, 3, 1, -1, 0, ny+1)
!i.e: call difvisxx(wki1,resultu,wki1,dcxu,vixu,dcbx,cofcxu,cofvxu,cofvbx,1,mpu,1,rex)
subroutine difvisxx(upen_int,upencil,result,icon,iconv,dcbx,econ,econv,cofvbx,chv,nlin,vel,rex)
use ctesp
use temporal
use alloc_dns,only:idx
implicit none
include "mpif.h"
integer npter1,vel
real*8 icon(3,nx),econ(2,nx),iconv(3,1:nx),econv(3,1:nx)
real*8 dcbx(5,4),cofvbx(4,4),rex
real*8 result(nx,nlin),upen_int(nx,nlin),upencil(nx,nlin),bb(nx)
integer chv1,chv,i,j,k,l,nlin,ic
! For the convective terms
chv1 = chv+2
! For the viscous terms
if (vel==0) then
ic=1
else
ic=3
end if
if (mpiid2.eq.0) then
tm1 = MPI_WTIME()
endif
!===========Start computing the convective terms and copy it to result()
!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(k,i,bb)
!$OMP DO SCHEDULE(STATIC)
do k =1,nlin
!---------[A]du=[B]u Computing [B]u=[Bu]
do i = 2,nx-1
bb(i)=econ(1,i)*upen_int(i-1,k)+econ(2,i)*upen_int(i,k)
enddo
bb(1) = dcbx(chv,1)*upen_int(1,k)+ dcbx(chv,2)*upen_int(2,k)+ &
& dcbx(chv,3)*upen_int(3,k)+ dcbx(chv,4)*upen_int(4,k)
bb(nx) = dcbx(chv1,1)*upen_int(nx,k)+ dcbx(chv1,2)*upen_int(nx-1,k)+ &
& dcbx(chv1,3)*upen_int(nx-2,k)+ dcbx(chv1,4)*upen_int(nx-3,k)
!---------SOLVING [A]du=[Bu]----------------------
do j = 2,nx
bb(j) = bb(j) + icon(1,j)*bb(j-1)
enddo
bb(nx) = bb(nx)*icon(2,nx)
do j = nx-1,1,-1
bb(j) = (bb(j)-icon(3,j)*bb(j+1))*icon(2,j)
enddo
!-------------Pade of the convective terms DONE!
!IMPOSE outflow BC Uinf*du/dx for the last plane:
bb(nx)=Uinfinity*(upencil(nx,k)-upencil(nx-1,k))*idx
result(:,k)=bb !convective term saved in result() buffer
!===========Start computing the viscous terms and add it to result()
!---------[A]ddu=[B]u Computing [B]u=[Bu]
do i = 2,nx-1
bb(i) = econv(1,i)*upencil(i+1,k)+ econv(2,i)*upencil(i,k)+ &
& econv(3,i)*upencil(i-1,k)
enddo
bb(1) = cofvbx(ic,1)*upencil(1,k) + cofvbx(ic,2)*upencil(2,k) + &
& cofvbx(ic,3)*upencil(3,k) + cofvbx(ic,4)*upencil(4,k)
bb(nx) = cofvbx(ic+1,1)*upencil(nx,k) + cofvbx(ic+1,2)*upencil(nx-1,k)+ &
& cofvbx(ic+1,3)*upencil(nx-2,k) + cofvbx(ic+1,4)*upencil(nx-3,k)
!---------SOLVING [A]ddu=[Bu]----------------------
do i = 2,nx
bb(i) = bb(i) + iconv(1,i)*bb(i-1)
enddo
bb(nx) = bb(nx)*iconv(2,nx)
do i = nx-1,1,-1
bb(i) = (bb(i)-iconv(3,i)*bb(i+1))*iconv(2,i)
enddo
bb(nx)=0d0 !! IMPOSE inviscid output BC
result(:,k)=result(:,k)+rex*bb !convective + viscous terms
enddo
!$OMP END PARALLEL
if (mpiid2.eq.0) then
tm2 = MPI_WTIME()
tmp5 = tmp5 + abs(tm2-tm1)
endif
end subroutine difvisxx
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
!! used in the (zy) part of rhsp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
!JSS May 20th 2010
!differzy now works in place
!
subroutine differzy(geni,result,icon,dcby,econ,chv,npter1,fwb1,fwb2,jee)
use ctesp
use point
use temporal
implicit none
include "mpif.h"
integer jee,npter1,kk,k2
real*8 icon(3,npter1:jee),econ(2,1:ny)
real*8 dcby(4,4),tm1p,tm2p
real*8 result(0:2*nz2+1,ny+1),geni(0:2*nz2+1,jee)
real*8:: buf_top(0:2*nz2+1),buf_bottom(0:2*nz2+1) !in order to work in place
integer chv,fwb1,fwb2,i,j,k,l,cha
cha = chv + 1
if (mpiid2.eq.0) then
tm1p = MPI_WTIME()
endif
!$OMP DO SCHEDULE(STATIC)
do kk=0,2*nz2+1,blockl
k2=min(2*nz2+1,kk+blockl-1)
!at the boundaries
do k =kk,k2
buf_bottom(k) = (dcby(chv,1)*geni(k,1) + &
& dcby(chv,2)*geni(k,2) + &
& dcby(chv,3)*geni(k,3) + &
& dcby(chv,4)*geni(k,4))
buf_top(k) = (dcby(cha,1)*geni(k,ny) + &
& dcby(cha,2)*geni(k,ny-1) + &
& dcby(cha,3)*geni(k,ny-2) + &
& dcby(cha,4)*geni(k,ny-3))
enddo
if(fwb2.eq.1) then
do j = 2,jee-1
do k =kk,k2
result(k,j) = econ(2,j)*geni(k,j+fwb2)+ econ(1,j)*geni(k,j+fwb1)
enddo
enddo
elseif(fwb2.eq.0) then
do j = jee-1,2,-1
do k =kk,k2
result(k,j) = econ(2,j)*geni(k,j+fwb2)+ econ(1,j)*geni(k,j+fwb1)
enddo
enddo
endif
result(kk:k2,1) =buf_bottom(kk:k2)
result(kk:k2,jee)=buf_top(kk:k2)
! resolution of tridiagonal
do j = 2,jee
do k =kk,k2
result(k,j) = result(k,j) + icon(1,j)*result(k,j-1)
enddo
enddo
do k =kk,k2
result(k,jee) = result(k,jee)*icon(2,jee)
enddo
do j = jee-1,1,-1
do k =kk,k2
result(k,j) = (result(k,j)-icon(3,j)*result(k,j+1))*icon(2,j)
enddo
enddo
enddo
if (mpiid2.eq.0) then
tm2p = MPI_WTIME()
!$OMP CRITICAL
tmp8 = tmp8 + abs(tm2p-tm1p)/nthreads
!$OMP END CRITICAL
endif
end subroutine differzy
! ******************************************************************
!
! Interpolates the velocities u,v in x using a Pade scheme.
! Thus Au=b is solved where u is the interpolated velocity.
! gen ==> input velocity to be interpolated
! geni ==> output interpolated velocity.
! icon ==> coefficients of the lefthand side (above A)
! of the scheme
! econ ==> coefficient to calculate b in the above
! inbx ==> boundary scheme coefficients
! loguv = 1: 'u'. loguv=0: 'v,w'
!
! works in (x-lines). M.Simens 03, JJS 12/09
! *******************************************************************
subroutine interpxx(gen,geni,icon,econ,inbx,chi,nlin,loguv)
use ctesp
use temporal
use omp_lib
implicit none
include "mpif.h"
real*8 icon(3,nx),econ(2,nx),inbx(4,4)
real*8 gen (nx,nlin),geni(nx,nlin), bb(nx)
integer i,j,k,l,loguv,chi,chi2,nlin
if (loguv .eq. 1) then
chi2 = chi+1
else
chi2 = chi+3
endif
if (mpiid2.eq.0) then
tm1 = MPI_WTIME()
endif
!$OMP PARALLEL DO SCHEDULE(STATIC) DEFAULT(SHARED) PRIVATE(k,i,bb)
do k =1,nlin
do i = 2,nx-1
bb(i)=econ(1,i)*gen(i,k)+econ(2,i)*gen(i+1,k)
enddo
!boundary scheme.
bb(1) = inbx(chi2,1)*gen(1,k) + inbx(chi2,2)*gen(2,k) + &
& inbx(chi2,3)*gen(3,k) + inbx(chi2,4)*gen(4,k)
bb(nx)= inbx(chi,1)*gen(nx,k) + inbx(chi,2)*gen(nx-1,k) + &
& inbx(chi,3)*gen(nx-2,k)+ inbx(chi,4)*gen(nx-3,k)
! solving tridiagonal
do i = 2,nx
bb(i) = bb(i) + icon(1,i)*bb(i-1)
enddo
bb(nx) = bb(nx)*icon(2,nx)
do i = nx-1,1,-1
bb(i) = (bb(i)-icon(3,i)*bb(i+1))*icon(2,i)
enddo
geni(:,k)=bb
enddo
if (mpiid2.eq.0) then
tm2 = MPI_WTIME()
tmp6 = tmp6 + abs(tm2-tm1)
endif
end subroutine interpxx
! ====================================================
! u -> result, works in x(lines)
! can work in place, JJS 12/09
! ====================================================
subroutine differxx(u,result,icon,dcbx,econ,chv,nlin)
use ctesp
implicit none
integer npter1
real*8 icon(3,nx),econ(2,nx)
real*8 dcbx(5,4)
real*8 result(nx,nlin),u(nx,nlin),bb(nx)
integer chv1,chv,i,j,k,l,nlin
chv1 = chv+2
!$OMP PARALLEL DO SCHEDULE(STATIC) DEFAULT(SHARED) PRIVATE(j,k,i,bb)
do k =1,nlin
do i = 2,nx-1
bb(i)=econ(1,i)*u(i-1,k)+econ(2,i)*u(i,k)
enddo
bb(1) = dcbx(chv,1)*u(1,k)+ dcbx(chv,2)*u(2,k)+ &
& dcbx(chv,3)*u(3,k)+ dcbx(chv,4)*u(4,k)
bb(nx) = dcbx(chv1,1)*u(nx,k) + dcbx(chv1,2)*u(nx-1,k)+ &
& dcbx(chv1,3)*u(nx-2,k)+ dcbx(chv1,4)*u(nx-3,k)
do j = 2,nx
bb(j) = bb(j) + icon(1,j)*bb(j-1)
enddo
bb(nx) = bb(nx)*icon(2,nx)
do j = nx-1,1,-1
bb(j) = (bb(j)-icon(3,j)*bb(j+1))*icon(2,j)
enddo
result(:,k)=bb
enddo
end subroutine differxx
! *******************************************************************
!
! Interpolates the velocities u,v,w in y using a Pade scheme.
! Thus Au=b is solved where u is the final interpolated
! velocity.
! gen ==> input velocity to be interpolated
! geni ==> output interpolated velocity.
! icon ==> coefficients of the lefthand side (above A)
! of the scheme
! econ ==> coefficient to calculate b in the above
! inby ==> boundary scheme coefficients
!
! loguv = 0: 'u,w'. loguv=1: 'v'
! M.Simens 03
! *******************************************************************
!
!JSS May 20th 2010
!interpyy now works in place
subroutine interpyy(gen,geni,icon,econ,inby,jee,loguv,dim,m)
use ctesp
use point
use temporal
implicit none
include "mpif.h"
integer jee,i,j,k,l,loguv,m,dim,ii,i2
real*8 icon(3,1:ny),inby(4,4),econ(2,1:ny),gen(dim,1:jee), &
& geni(dim,1:ny+1),tm1p,tm2p
real*8:: buffer(dim) !in order to work in place
if (mpiid2.eq.0) then
tm1p = MPI_WTIME()
endif
if (loguv .eq. 0) then ! --- u & w
!$OMP DO SCHEDULE(STATIC)
do ii=1,m,blockl
i2=min(m,ii+blockl-1)
do k =ii,i2 ! boundary schemes.
geni(k,1) = 0d0 ! for no slip boundary conditions
buffer(k) = inby(1,1)*gen(k,ny+1) + inby(1,2)*gen(k,ny) + &
& inby(1,3)*gen(k,ny-1) + inby(1,4)*gen(k,ny-2)
enddo
do j = 2,ny-1
do k =ii,i2 ! calculating b
geni(k,j) = econ(1,j)*gen(k,j) + econ(2,j)*gen(k,j+1)
enddo
enddo
geni(ii:i2,ny)=buffer(ii:i2)
enddo
!$OMP END DO NOWAIT
else ! --- v
!$OMP DO SCHEDULE(STATIC)
do ii=1,m,blockl
i2=min(m,ii+blockl-1)
do k =ii,i2 ! boundary schemes.
buffer(k) = inby(3,1)*gen(k,1) + inby(3,2)*gen(k,2) + &
& inby(3,3)*gen(k,3) + inby(3,4)*gen(k,4)
geni(k,ny) = inby(4,1)*gen(k,ny) + inby(4,2)*gen(k,ny-1)+ &
& inby(4,3)*gen(k,ny-2)+inby(4,4)*gen(k,ny-3)
enddo
do j = ny-1,2,-1 !inverse loop order in order to work in place
do k =ii,i2 ! calculating b
geni(k,j) = econ(2,j)*gen(k,j)+econ(1,j)*gen(k,j-1)
enddo
enddo
geni(ii:i2,1 )=buffer(ii:i2)
enddo
!$OMP END DO NOWAIT
endif
! --- solve the tridiagonal ----
!$OMP DO SCHEDULE(STATIC)
do ii=1,m,blockl
i2=min(m,ii+blockl-1)
do j = 2,ny
do k =ii,i2
geni(k,j) = geni(k,j) + icon(1,j)*geni(k,j-1)
enddo
enddo
do k =ii,i2
geni(k,ny) = geni(k,ny)*icon(2,ny)
enddo
do j = ny-1,1,-1
do k =ii,i2
geni(k,j) = (geni(k,j)-icon(3,j)*geni(k,j+1))*icon(2,j)
enddo
enddo
enddo
if (mpiid2.eq.0) then
tm2p = MPI_WTIME()
!$OMP CRITICAL
tmp4 = tmp4 + abs(tm2p-tm1p)/nthreads
!$OMP END CRITICAL
endif
end subroutine interpyy
! ===================================================================
! compute explicit viscous term in y --- orientation in (zy)
! Called by: rhsp.f90, JJS 12/09
! ===================================================================
subroutine vistyy(u,result,icon,econ,cofvby,jee)
use ctesp
use point
use temporal
implicit none
include "mpif.h"
integer jee,ii,i2
real*8 icon(3,jee),econ(3,ny),cofvby(4,4)
real*8 u(nz1,jee),result(nz1,ny+1),tm1p,tm2p
integer i,j,k,ic
if (jee==ny) then
ic=1
else
ic=3
end if
if (mpiid2.eq.0) then
tm1p = MPI_WTIME()
endif
!----- right hand side ---------
!$OMP DO SCHEDULE(STATIC)
do ii=1,nz1,blockl
i2=min(nz1,ii+blockl-1)
do k =ii,i2
result(k,1)=cofvby(ic,1)*u(k,1)+cofvby(ic,2)*u(k,2) + cofvby(ic,3)*u(k,3)+cofvby(ic,4)*u(k,4)
enddo
do j = 2,jee-1
do k =ii,i2
result(k,j) = econ(1,j)*u(k,j+1)+econ(2,j)*u(k,j)+ econ(3,j)*u(k,j-1)
enddo
enddo
do k =ii,i2
result(k,jee)=cofvby(ic+1,1)*u(k,jee)+cofvby(ic+1,2)*u(k,jee-1)+ &
& cofvby(ic+1,3)*u(k,jee-2)+cofvby(ic+1,4)*u(k,jee-3)
enddo
!----- backsubstitution in place
do j = 2,jee
do k =ii,i2
result(k,j) = result(k,j) + icon(1,j)*result(k,j-1)
enddo
enddo
do k =ii,i2
result(k,jee) = result(k,jee)*icon(2,jee)
enddo
do j = jee-1,1,-1
do k =ii,i2
result(k,j) = (result(k,j)-icon(3,j)*result(k,j+1))*icon(2,j)
enddo
enddo
enddo
if (mpiid2.eq.0) then
tm2p = MPI_WTIME()
!$OMP CRITICAL
tmp7 = tmp7 + abs(tm2p-tm1p)/nthreads
!$OMP END CRITICAL
endif
end subroutine vistyy
! ===========================================================
! new version, works in zy
! icon ==> coefficients of the lefthand side (above A)
! of the scheme
! econ ==> coefficient to calculate b in the above
!
!res=input u=output
!
! ./rhsp.f90:284:call impl(u,wki1,vyui,cofvyu,kb,ke,ny+1,rex,dt,m,rkdv,1)
! ./rhsp.f90:285:call impl(w,wki3,vyui,cofvyu,kb,ke,ny+1,rex,dt,m,rkdv,3)
! ./rhsp.f90:286:call impl(v,wki2,vyvi,cofvyv,kb,ke,ny ,rex,dt,m,rkdv,0)
! ===========================================================
subroutine implzy(u,res,icon,econ,jee,var1)
use ctesp
use temporal
implicit none
include "mpif.h"
integer jee,kk,k2
real*8, dimension(0:2*nz2+1,jee):: u,res
real*8 icon(3,jee),econ(3,ny)
real*8 a1(ny+1),a2(ny+1),a3(ny+1),var1,d
integer i,j,m,k,l,vel
!!!!!!!!! hopefully, u already has the boundary conditions in j=1 and jee
if (mpiid2.eq.0) tm1 = MPI_WTIME()
!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(j,kk,k,k2)
!$OMP DO SCHEDULE(STATIC)
do j = 2,jee-1
u(:,j)=icon(1,j)*res(:,j-1)+icon(2,j)*res(:,j)+icon(3,j)*res(:,j+1)
a1(j) = icon(1,j) + var1*econ(3,j)
a2(j) = icon(2,j) + var1*econ(2,j)
a3(j) = icon(3,j) + var1*econ(1,j)
enddo
!$OMP WORKSHARE
u(:,2) = u(:,2) - a1(2)*u(:,1)
u(:,jee-1) = u(:,jee-1) - a3(jee-1)*u(:,jee)
a1(2) = 0d0
a3(jee-1) = 0d0
!$OMP END WORKSHARE
!$OMP SINGLE
do j=2+1,jee-1
d =1d0/a2(j-1)
a2(j-1)=d
a1(j )= -a1(j)*d
a2(j )=a2(j)+a1(j)*a3(j-1)
enddo
a2(jee-1)=1d0/a2(jee-1)
!$OMP END SINGLE
! backsubstitution
!$OMP DO SCHEDULE(STATIC)
do kk=0,2*nz2+1,blockl
k2=min(2*nz2+1,kk+blockl-1)
do j = 3,jee-1
do k=kk,k2
u(k,j) = u(k,j)+a1(j)*u(k,j-1)
enddo
enddo
do k=kk,k2
u(k,jee-1) = u(k,jee-1)*a2(jee-1)
enddo
do j = jee-2,2,-1
do k=kk,k2
u(k,j) = (u(k,j)-a3(j)*u(k,j+1))*a2(j)
enddo
enddo
enddo
!$OMP END PARALLEL
if (mpiid2.eq.0) then
tm2 = MPI_WTIME()
tmp9 = tmp9 + abs(tm2-tm1)
endif
end subroutine implzy
!==================================================================
!New subroutines to compute statistics (some of them do not shift
!half cell)
!JSS March 11
!==================================================================
!!4th order interpolator for the pressure
!JSS January 2011
!DOES NOT WORK IN PLACE
!dp/dn=nu*d2V/dy2 @th wall
subroutine interp_pressure(f,fi,n,v)
use ctesp
use alloc_dns, only: y,l_weight,ldyy,re
use point
implicit none
include "mpif.h"
integer:: n,j,k,kk,k2
real*8, dimension(nz1,n):: f,fi,v
real*8:: dvdy2
!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(j,kk,k,k2,dvdy2)
!$OMP DO SCHEDULE(STATIC)
do kk=1,nz1,blockl
k2=min(nz1,kk+blockl-1)
do k =kk,k2
dvdy2=sum(ldyy*v(k,1:5))/re
f(k,1)=(dvdy2-sum(l_weight(2:5,0)*f(k,2:5)))/l_weight(1,0);
enddo
do j=1,2
do k=kk,k2
fi(k,j)=sum(l_weight(1:5,j)*f(k,j:j+4))
enddo
enddo
do j=3,n-2
do k=kk,k2
fi(k,j)=sum(l_weight(1:5,j)*f(k,j-2:j+2))
enddo
enddo
do j=n-1,n
do k=kk,k2
fi(k,j)=sum(l_weight(1:5,j)*f(k,j-4:j))
enddo
enddo
enddo
!$OMP END PARALLEL
end subroutine interp_pressure
!===================================================================
! COMPACT FINITE DIFFERENCES SCHEMES. JSS MARCH 011
!
!! As in: "COMPACT FINITE DIFFERENCE SCHEMES ON NON-UNIFORM MESHES".
!! Gamet, Ducros, Nicoud, Poinsot)
!! (I am doing high order 6th order CFD...as costly as 4th)
!! Close to the wall, the order is improved using a bigger stencil
!! (Mark: 4 points stencils, Me: 4,5 point stencils)
!===================================================================
!Compute derivative in Y direction (at the same position)
!(does not work in place, use different buffers v_in,v_out)
subroutine diffy_inplace(v_in,v_out,c)
use ctesp
use point
implicit none
include "mpif.h"
real(8),intent(in):: c(8,ny)
real(8):: v_out(0:2*nz2+1,ny),v_in(0:2*nz2+1,ny)
integer i,j,k,l,kk,k2
!$OMP DO SCHEDULE(STATIC)
do kk=0,2*nz2+1,blockl
k2=min(2*nz2+1,kk+blockl-1)
!at the boundaries
do k =kk,k2
v_out(k,1) =sum(c(1:4,1 )*v_in(k,1:4))
v_out(k,2) =sum(c(1:4,2 )*v_in(k,1:4))
v_out(k,ny-1) =sum(c(1:4,ny-1)*v_in(k,ny-3:ny))
v_out(k,ny) =sum(c(1:4,ny) *v_in(k,ny-3:ny))
enddo
do j = 3,ny-2
do k =kk,k2
v_out(k,j) =sum(c(1:5,j)*v_in(k,j-2:j+2))
enddo
enddo
! resolution of tridiagonal: TDMA Algorithm. LU decomposition in Coeft
do j = 2,ny
v_out(kk:k2,j) = v_out(kk:k2,j)-c(6,j)*v_out(kk:k2,j-1)
enddo
v_out(kk:k2,ny)=v_out(kk:k2,ny)*c(7,ny)
do j = ny-1,1,-1
v_out(kk:k2,j) = (v_out(kk:k2,j)-c(8,j)*v_out(kk:k2,j+1))*c(7,j)
enddo
enddo
end subroutine diffy_inplace
!Compute derivative in X direction (at the same position)
!(does not work in place, use different buffers u_in,u_out)
subroutine diffx_inplace(u_in,u_out,c,nlin)
use ctesp
implicit none
real*8 u_out(nx,nlin),u_in(nx,nlin),c(8,nx)
integer i,j,k,l,nlin
!$OMP PARALLEL DO SCHEDULE(STATIC) DEFAULT(SHARED) PRIVATE(j,k,i)
do k =1,nlin
u_out(1,k) =sum(c(1:5,1 )*u_in(1:5,k)) !i=1
u_out(2,k) =sum(c(1:5,2 )*u_in(1:5,k)) !i=2
u_out(nx-1,k) =sum(c(1:5,nx-1)*u_in(nx-4:nx,k))!i=nx-1
u_out(nx,k) =sum(c(1:5,nx )*u_in(nx-4:nx,k))!i=nx
do i = 3,nx-2
u_out(i,k)=sum(c(1:5,3)*u_in(i-2:i+2,k)) !interior points
enddo
! resolution of tridiagonal: TDMA Algorithm. LU decomposition in Coeft
do j = 2,nx
u_out(j,k) =u_out(j,k)-c(6,j)*u_out(j-1,k)
enddo
u_out(nx,k)=u_out(nx,k)*c(7,nx)
do j = nx-1,1,-1
u_out(j,k) = (u_out(j,k)-c(8,j)*u_out(j+1,k))*c(7,j)
enddo
enddo
end subroutine diffx_inplace
!Compute interpolation in X direction (mid-point interpolation)
!(does not work in place, use different buffers u_in,u_out)
subroutine interpx_new(u_in,u_out,c,nlin)
use ctesp
implicit none
real*8 u_out(nx,nlin),u_in(nx,nlin),c(8,nx)
integer i,j,k,l,nlin
!$OMP PARALLEL DO SCHEDULE(STATIC) DEFAULT(SHARED) PRIVATE(j,k,i)
do k =1,nlin
u_out(1,k) =sum(c(1:4,1 )*u_in(1:4,k)) !i=1
u_out(nx-1,k) =sum(c(1:4,nx-1)*u_in(nx-3:nx,k))!i=nx-1
u_out(nx,k) =sum(c(1:4,nx )*u_in(nx-3:nx,k))!i=nx
do i = 2,nx-2
u_out(i,k)=sum(c(1:4,3)*u_in(i-1:i+2,k)) !interior points
enddo
! resolution of tridiagonal: TDMA Algorithm. LU decomposition in Coeft
do j = 2,nx
u_out(j,k) =u_out(j,k)-c(6,j)*u_out(j-1,k)
enddo
u_out(nx,k)=u_out(nx,k)*c(7,nx)
do j = nx-1,1,-1
u_out(j,k) = (u_out(j,k)-c(8,j)*u_out(j+1,k))*c(7,j)
enddo
enddo
end subroutine interpx_new
!Compute interpolation in Y direction (mid-point interpolation)
!(does not work in place, use different buffers u_in,u_out)
!tipo=0 for ny+1 input arrays. tipo=1 for ny input tipe arrays
subroutine interpy_new(u_in,u_out,c,tipo)
use ctesp
use point
implicit none
include "mpif.h"
integer i,j,k,l,kk,k2,tipo,ch
real(8),intent(in):: c(8,ny)
real(8):: u_out(0:2*nz2+1,ny),u_in(0:2*nz2+1,ny+1-tipo)
ch=1;if (tipo.eq.1) ch=0;
!$OMP DO SCHEDULE(STATIC)
do kk=0,2*nz2+1,blockl
k2=min(2*nz2+1,kk+blockl-1)
!at the boundaries
do k =kk,k2
u_out(k,1) =sum(c(1:4,1)*u_in(k,2:5)) !Pressure@wall
u_out(k,2) =sum(c(1:5,2)*u_in(k,2:6))
enddo
do j = 3,ny-2
do k =kk,k2
u_out(k,j) =sum(c(1:4,j)*u_in(k,j-1:j+2))
enddo
enddo
if (tipo.eq.0) u_out(kk:k2,1)=0d0 !@wall position velocity =0
do k =kk,k2
u_out(k,ny-1) =sum(c(1:3+ch,ny-1)*u_in(k,ny-2:ny+ch))
u_out(k,ny) =sum(c(1:3+ch,ny) *u_in(k,ny-2:ny+ch))
enddo
! resolution of tridiagonal, for u(2:ny), since u(1)=0
do j = 3,ny
u_out(kk:k2,j) = u_out(kk:k2,j)-c(6,j)*u_out(kk:k2,j-1)
enddo
u_out(kk:k2,ny)=u_out(kk:k2,ny)*c(7,ny)
do j = ny-1,2,-1
u_out(kk:k2,j) = (u_out(kk:k2,j)-c(8,j)*u_out(kk:k2,j+1))*c(7,j)
enddo
enddo
end subroutine interpy_new