forked from xcompact3d/Incompact3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemes.f90
841 lines (776 loc) · 24.7 KB
/
schemes.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
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
!################################################################################
!This file is part of Incompact3d.
!
!Incompact3d
!Copyright (c) 2012 Eric Lamballais and Sylvain Laizet
!
! Incompact3d is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation.
!
! Incompact3d is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with the code. If not, see <http://www.gnu.org/licenses/>.
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! We kindly request that you cite Incompact3d in your publications and
! presentations. The following citations are suggested:
!
! 1-Laizet S. & Lamballais E., 2009, High-order compact schemes for
! incompressible flows: a simple and efficient method with the quasi-spectral
! accuracy, J. Comp. Phys., vol 228 (15), pp 5989-6015
!
! 2-Laizet S. & Li N., 2011, Incompact3d: a powerful tool to tackle turbulence
! problems with up to 0(10^5) computational cores, Int. J. of Numerical
! Methods in Fluids, vol 67 (11), pp 1735-1757
!################################################################################
!********************************************************************
!
subroutine schemes()
!
!********************************************************************
USE param
USE derivX
USE derivY
USE derivZ
USE variables
USE var
implicit none
#ifdef DEBG
if (nrank .eq. 0) print *,'# schemes start'
#endif
!Velocity
! First derivative
if (nclx1.eq.0.and.nclxn.eq.0) derx => derx_00
if (nclx1.eq.1.and.nclxn.eq.1) derx => derx_11
if (nclx1.eq.1.and.nclxn.eq.2) derx => derx_12
if (nclx1.eq.2.and.nclxn.eq.1) derx => derx_21
if (nclx1.eq.2.and.nclxn.eq.2) derx => derx_22
!
if (ncly1.eq.0.and.nclyn.eq.0) dery => dery_00
if (ncly1.eq.1.and.nclyn.eq.1) dery => dery_11
if (ncly1.eq.1.and.nclyn.eq.2) dery => dery_12
if (ncly1.eq.2.and.nclyn.eq.1) dery => dery_21
if (ncly1.eq.2.and.nclyn.eq.2) dery => dery_22
!
if (nclz1.eq.0.and.nclzn.eq.0) derz => derz_00
if (nclz1.eq.1.and.nclzn.eq.1) derz => derz_11
if (nclz1.eq.1.and.nclzn.eq.2) derz => derz_12
if (nclz1.eq.2.and.nclzn.eq.1) derz => derz_21
if (nclz1.eq.2.and.nclzn.eq.2) derz => derz_22
! Second derivative
if (jLES.eq.1) then !iLES
!x
if (nclx1.eq.0.and.nclxn.eq.0) derxx => derxx_iles_00
if (nclx1.eq.1.and.nclxn.eq.1) derxx => derxx_iles_11
if (nclx1.eq.1.and.nclxn.eq.2) derxx => derxx_iles_12
if (nclx1.eq.2.and.nclxn.eq.1) derxx => derxx_iles_21
if (nclx1.eq.2.and.nclxn.eq.2) derxx => derxx_iles_22
!y
if (ncly1.eq.0.and.nclyn.eq.0) deryy => deryy_iles_00
if (ncly1.eq.1.and.nclyn.eq.1) deryy => deryy_iles_11
if (ncly1.eq.1.and.nclyn.eq.2) deryy => deryy_iles_12
if (ncly1.eq.2.and.nclyn.eq.1) deryy => deryy_iles_21
if (ncly1.eq.2.and.nclyn.eq.2) deryy => deryy_iles_22
!z
if (nclz1.eq.0.and.nclzn.eq.0) derzz => derzz_iles_00
if (nclz1.eq.1.and.nclzn.eq.1) derzz => derzz_iles_11
if (nclz1.eq.1.and.nclzn.eq.2) derzz => derzz_iles_12
if (nclz1.eq.2.and.nclzn.eq.1) derzz => derzz_iles_21
if (nclz1.eq.2.and.nclzn.eq.2) derzz => derzz_iles_22
else
!x
if (nclx1.eq.0.and.nclxn.eq.0) derxx => derxx_dns_00
if (nclx1.eq.1.and.nclxn.eq.1) derxx => derxx_dns_11
if (nclx1.eq.1.and.nclxn.eq.2) derxx => derxx_dns_12
if (nclx1.eq.2.and.nclxn.eq.1) derxx => derxx_dns_21
if (nclx1.eq.2.and.nclxn.eq.2) derxx => derxx_dns_22
!y
if (ncly1.eq.0.and.nclyn.eq.0) deryy => deryy_dns_00
if (ncly1.eq.1.and.nclyn.eq.1) deryy => deryy_dns_11
if (ncly1.eq.1.and.nclyn.eq.2) deryy => deryy_dns_12
if (ncly1.eq.2.and.nclyn.eq.1) deryy => deryy_dns_21
if (ncly1.eq.2.and.nclyn.eq.2) deryy => deryy_dns_22
!z
if (nclz1.eq.0.and.nclzn.eq.0) derzz => derzz_dns_00
if (nclz1.eq.1.and.nclzn.eq.1) derzz => derzz_dns_11
if (nclz1.eq.1.and.nclzn.eq.2) derzz => derzz_dns_12
if (nclz1.eq.2.and.nclzn.eq.1) derzz => derzz_dns_21
if (nclz1.eq.2.and.nclzn.eq.2) derzz => derzz_dns_22
endif
call first_derivative(alfa1x,af1x,bf1x,cf1x,df1x,alfa2x,af2x,alfanx,afnx,bfnx,&
cfnx,dfnx,alfamx,afmx,alfaix,afix,bfix,&
ffx,fsx,fwx,ffxp,fsxp,fwxp,dx,nx,nclx1,nclxn)
call first_derivative(alfa1y,af1y,bf1y,cf1y,df1y,alfa2y,af2y,alfany,afny,bfny,&
cfny,dfny,alfamy,afmy,alfajy,afjy,bfjy,&
ffy,fsy,fwy,ffyp,fsyp,fwyp,dy,ny,ncly1,nclyn)
call first_derivative(alfa1z,af1z,bf1z,cf1z,df1z,alfa2z,af2z,alfanz,afnz,bfnz,&
cfnz,dfnz,alfamz,afmz,alfakz,afkz,bfkz,&
ffz,fsz,fwz,ffzp,fszp,fwzp,dz,nz,nclz1,nclzn)
call second_derivative(alsa1x,as1x,bs1x,&
cs1x,ds1x,alsa2x,as2x,alsanx,asnx,bsnx,csnx,dsnx,alsamx,&
asmx,alsa3x,as3x,bs3x,alsatx,astx,bstx,&
alsa4x,as4x,bs4x,cs4x,&
alsattx,asttx,bsttx,csttx,&
alsaix,asix,bsix,csix,dsix,&
sfx,ssx,swx,sfxp,ssxp,swxp,dx2,nx,nclx1,nclxn)
call second_derivative(alsa1y,as1y,bs1y,&
cs1y,ds1y,alsa2y,as2y,alsany,asny,bsny,csny,dsny,alsamy,&
asmy,alsa3y,as3y,bs3y,alsaty,asty,bsty,&
alsa4y,as4y,bs4y,cs4y,&
alsatty,astty,bstty,cstty,&
alsajy,asjy,bsjy,csjy,dsjy,&
sfy,ssy,swy,sfyp,ssyp,swyp,dy2,ny,ncly1,nclyn)
call second_derivative(alsa1z,as1z,bs1z,&
cs1z,ds1z,alsa2z,as2z,alsanz,asnz,bsnz,csnz,dsnz,alsamz,&
asmz,alsa3z,as3z,bs3z,alsatz,astz,bstz,&
alsa4z,as4z,bs4z,cs4z,&
alsattz,asttz,bsttz,csttz,&
alsakz,askz,bskz,cskz,dskz,&
sfz,ssz,swz,sfzp,sszp,swzp,dz2,nz,nclz1,nclzn)
if (iscalar.ne.0) then
!Scalar
! First derivative
if (nclxS1.eq.0.and.nclxSn.eq.0) derxS => derx_00
if (nclxS1.eq.1.and.nclxSn.eq.1) derxS => derx_11
if (nclxS1.eq.1.and.nclxSn.eq.2) derxS => derx_12
if (nclxS1.eq.2.and.nclxSn.eq.1) derxS => derx_21
if (nclxS1.eq.2.and.nclxSn.eq.2) derxS => derx_22
!
if (nclyS1.eq.0.and.nclySn.eq.0) deryS => dery_00
if (nclyS1.eq.1.and.nclySn.eq.1) deryS => dery_11
if (nclyS1.eq.1.and.nclySn.eq.2) deryS => dery_12
if (nclyS1.eq.2.and.nclySn.eq.1) deryS => dery_21
if (nclyS1.eq.2.and.nclySn.eq.2) deryS => dery_22
!
if (nclzS1.eq.0.and.nclzSn.eq.0) derzS => derz_00
if (nclzS1.eq.1.and.nclzSn.eq.1) derzS => derz_11
if (nclzS1.eq.1.and.nclzSn.eq.2) derzS => derz_12
if (nclzS1.eq.2.and.nclzSn.eq.1) derzS => derz_21
if (nclzS1.eq.2.and.nclzSn.eq.2) derzS => derz_22
! Second derivative
if (jLES.eq.1) then !iLES
!x
if (nclxS1.eq.0.and.nclxSn.eq.0) derxxS => derxx_iles_00
if (nclxS1.eq.1.and.nclxSn.eq.1) derxxS => derxx_iles_11
if (nclxS1.eq.1.and.nclxSn.eq.2) derxxS => derxx_iles_12
if (nclxS1.eq.2.and.nclxSn.eq.1) derxxS => derxx_iles_21
if (nclxS1.eq.2.and.nclxSn.eq.2) derxxS => derxx_iles_22
!y
if (nclyS1.eq.0.and.nclySn.eq.0) deryyS => deryy_iles_00
if (nclyS1.eq.1.and.nclySn.eq.1) deryyS => deryy_iles_11
if (nclyS1.eq.1.and.nclySn.eq.2) deryyS => deryy_iles_12
if (nclyS1.eq.2.and.nclySn.eq.1) deryyS => deryy_iles_21
if (nclyS1.eq.2.and.nclySn.eq.2) deryyS => deryy_iles_22
!z
if (nclzS1.eq.0.and.nclzSn.eq.0) derzzS => derzz_iles_00
if (nclzS1.eq.1.and.nclzSn.eq.1) derzzS => derzz_iles_11
if (nclzS1.eq.1.and.nclzSn.eq.2) derzzS => derzz_iles_12
if (nclzS1.eq.2.and.nclzSn.eq.1) derzzS => derzz_iles_21
if (nclzS1.eq.2.and.nclzSn.eq.2) derzzS => derzz_iles_22
else
!x
if (nclxS1.eq.0.and.nclxSn.eq.0) derxxS => derxx_dns_00
if (nclxS1.eq.1.and.nclxSn.eq.1) derxxS => derxx_dns_11
if (nclxS1.eq.1.and.nclxSn.eq.2) derxxS => derxx_dns_12
if (nclxS1.eq.2.and.nclxSn.eq.1) derxxS => derxx_dns_21
if (nclxS1.eq.2.and.nclxSn.eq.2) derxxS => derxx_dns_22
!y
if (nclyS1.eq.0.and.nclySn.eq.0) deryyS => deryy_dns_00
if (nclyS1.eq.1.and.nclySn.eq.1) deryyS => deryy_dns_11
if (nclyS1.eq.1.and.nclySn.eq.2) deryyS => deryy_dns_12
if (nclyS1.eq.2.and.nclySn.eq.1) deryyS => deryy_dns_21
if (nclyS1.eq.2.and.nclySn.eq.2) deryyS => deryy_dns_22
!z
if (nclzS1.eq.0.and.nclzSn.eq.0) derzzS => derzz_dns_00
if (nclzS1.eq.1.and.nclzSn.eq.1) derzzS => derzz_dns_11
if (nclzS1.eq.1.and.nclzSn.eq.2) derzzS => derzz_dns_12
if (nclzS1.eq.2.and.nclzSn.eq.1) derzzS => derzz_dns_21
if (nclzS1.eq.2.and.nclzSn.eq.2) derzzS => derzz_dns_22
endif
call first_derivative(alfa1x,af1x,bf1x,cf1x,df1x,alfa2x,af2x,alfanx,afnx,bfnx,&
cfnx,dfnx,alfamx,afmx,alfaix,afix,bfix,&
ffxS,fsxS,fwxS,ffxpS,fsxpS,fwxpS,dx,nx,nclxS1,nclxSn)
call first_derivative(alfa1y,af1y,bf1y,cf1y,df1y,alfa2y,af2y,alfany,afny,bfny,&
cfny,dfny,alfamy,afmy,alfajy,afjy,bfjy,&
ffyS,fsyS,fwyS,ffypS,fsypS,fwypS,dy,ny,nclyS1,nclySn)
call first_derivative(alfa1z,af1z,bf1z,cf1z,df1z,alfa2z,af2z,alfanz,afnz,bfnz,&
cfnz,dfnz,alfamz,afmz,alfakz,afkz,bfkz,&
ffzS,fszS,fwzS,ffzpS,fszpS,fwzpS,dz,nz,nclzS1,nclzSn)
call second_derivative(alsa1x,as1x,bs1x,&
cs1x,ds1x,alsa2x,as2x,alsanx,asnx,bsnx,csnx,dsnx,alsamx,&
asmx,alsa3x,as3x,bs3x,alsatx,astx,bstx,&
alsa4x,as4x,bs4x,cs4x,&
alsattx,asttx,bsttx,csttx,&
alsaix,asix,bsix,csix,dsix,&
sfxS,ssxS,swxS,sfxpS,ssxpS,swxpS,dx2,nx,nclxS1,nclxSn)
call second_derivative(alsa1y,as1y,bs1y,&
cs1y,ds1y,alsa2y,as2y,alsany,asny,bsny,csny,dsny,alsamy,&
asmy,alsa3y,as3y,bs3y,alsaty,asty,bsty,&
alsa4y,as4y,bs4y,cs4y,&
alsatty,astty,bstty,cstty,&
alsajy,asjy,bsjy,csjy,dsjy,&
sfyS,ssyS,swyS,sfypS,ssypS,swypS,dy2,ny,nclyS1,nclySn)
call second_derivative(alsa1z,as1z,bs1z,&
cs1z,ds1z,alsa2z,as2z,alsanz,asnz,bsnz,csnz,dsnz,alsamz,&
asmz,alsa3z,as3z,bs3z,alsatz,astz,bstz,&
alsa4z,as4z,bs4z,cs4z,&
alsattz,asttz,bsttz,csttz,&
alsakz,askz,bskz,cskz,dskz,&
sfzS,sszS,swzS,sfzpS,sszpS,swzpS,dz2,nz,nclzS1,nclzSn)
endif
call interpolation(dx,nxm,nx,nclx1,nclxn,&
alcaix6,acix6,bcix6,&
ailcaix6,aicix6,bicix6,cicix6,dicix6,&
cfx6,ccx6,cbx6,cfxp6,ciwxp6,csxp6,&
cwxp6,csx6,cwx6,cifx6,cicx6,cisx6,&
cibx6,cifxp6,cisxp6,ciwx6,&
cfi6,cci6,cbi6,cfip6,csip6,cwip6,csi6,&
cwi6,cifi6,cici6,cibi6,cifip6,&
cisip6,ciwip6,cisi6,ciwi6)
call interpolation(dy,nym,ny,ncly1,nclyn,&
alcaiy6,aciy6,bciy6,&
ailcaiy6,aiciy6,biciy6,ciciy6,diciy6,&
cfy6,ccy6,cby6,cfyp6,ciwyp6,csyp6,&
cwyp6,csy6,cwy6,cify6,cicy6,cisy6,&
ciby6,cifyp6,cisyp6,ciwy6,&
cfi6y,cci6y,cbi6y,cfip6y,csip6y,cwip6y,csi6y,&
cwi6y,cifi6y,cici6y,cibi6y,cifip6y,&
cisip6y,ciwip6y,cisi6y,ciwi6y)
call interpolation(dz,nzm,nz,nclz1,nclzn,&
alcaiz6,aciz6,bciz6,&
ailcaiz6,aiciz6,biciz6,ciciz6,diciz6,&
cfz6,ccz6,cbz6,cfzp6,ciwzp6,cszp6,&
cwzp6,csz6,cwz6,cifz6,cicz6,cisz6,&
cibz6,cifzp6,ciszp6,ciwz6,&
cfi6z,cci6z,cbi6z,cfip6z,csip6z,cwip6z,csi6z,&
cwi6z,cifi6z,cici6z,cibi6z,cifip6z,&
cisip6z,ciwip6z,cisi6z,ciwi6z)
#ifdef DEBG
if (nrank .eq. 0) print *,'# schemes end'
#endif
return
end subroutine schemes
!*******************************************************************
!
subroutine prepare (b,c,f,s,w,n)
!
!*******************************************************************
use decomp_2d, only : mytype
use param, only : one
implicit none
integer :: i,n
real(mytype), dimension(n) :: b,c,f,s,w
do i=1,n
w(i)=c(i)
enddo
do i=2,n
s(i)=b(i-1)/w(i-1)
w(i)=w(i)-f(i-1)*s(i)
enddo
do i=1,n
w(i)=one/w(i)
enddo
return
end subroutine prepare
!*******************************************************************
!
subroutine first_derivative(alfa1,af1,bf1,cf1,df1,alfa2,af2,alfan,afn,bfn,&
cfn,dfn,alfam,afm,alfai,afi,bfi,&
ff,fs,fw,ffp,fsp,fwp,d,n,ncl1,ncln)
!
!*******************************************************************
use decomp_2d, only : mytype
use param
implicit none
real(mytype),intent(in) :: d
integer,intent(in) :: n,ncl1,ncln
real(mytype),dimension(n),intent(out) :: ff,fs,fw,ffp,fsp,fwp
real(mytype),intent(out) :: alfa1,af1,bf1,cf1,df1,alfa2,af2,alfan,afn,bfn,&
cfn,dfn,alfam,afm,alfai,afi,bfi
integer :: i
real(mytype),dimension(n) :: fb,fc
ff=zero;fs=zero;fw=zero;ffp=zero;fsp=zero;fwp=zero
fb=zero;fc=zero
alfa1= two
af1 =-(five/two)/d
bf1 = (two)/d
cf1 = (half)/d
df1 = zero
alfa2= one/four
af2 = (three/four)/d
alfan= two
afn =-(five/two)/d
bfn = (two)/d
cfn = (half)/d
dfn = zero
alfam= one/four
afm = (three/four)/d
alfai= one/three
afi = (seven/nine)/d
bfi = (one/thirtysix)/d
if (ncl1.eq.0) then !Periodic
ff(1) =alfai
ff(2) =alfai
fc(1) =two
fc(2) =one
fb(1) =alfai
fb(2) =alfai
elseif (ncl1.eq.1) then !Free-slip
ff(1) =alfai+alfai
ff(2) =alfai
fc(1) =one
fc(2) =one
fb(1) =alfai
fb(2) =alfai
elseif (ncl1.eq.2) then !Dirichlet
ff(1) =alfa1
ff(2) =alfa2
fc(1) =one
fc(2) =one
fb(1) =alfa2
fb(2) =alfai
endif
if (ncln.eq.0) then !Periodic
ff(n-2)=alfai
ff(n-1)=alfai
ff(n) =zero
fc(n-2)=one
fc(n-1)=one
fc(n )=one+alfai*alfai
fb(n-2)=alfai
fb(n-1)=alfai
fb(n )=zero
elseif (ncln.eq.1) then !Free-slip
ff(n-2)=alfai
ff(n-1)=alfai
ff(n) =zero
fc(n-2)=one
fc(n-1)=one
fc(n )=one
fb(n-2)=alfai
fb(n-1)=alfai+alfai
fb(n )=zero
elseif (ncln.eq.2) then !Dirichlet
ff(n-2)=alfai
ff(n-1)=alfam
ff(n) =zero
fc(n-2)=one
fc(n-1)=one
fc(n )=one
fb(n-2)=alfam
fb(n-1)=alfan
fb(n )=zero
endif
do i=3,n-3
ff(i)=alfai
fc(i)=one
fb(i)=alfai
enddo
do i=1,n
ffp(i)=ff(i)
enddo
call prepare (fb,fc,ff ,fs ,fw ,n)
if (ncl1.eq.1) then
ffp(1)=zero
endif
if (ncln.eq.1) then
fb(n-1)=zero
endif
call prepare (fb,fc,ffp,fsp,fwp,n)
return
end subroutine first_derivative
!*******************************************************************
!
subroutine second_derivative(alsa1,as1,bs1,&
cs1,ds1,alsa2,as2,alsan,asn,bsn,csn,dsn,alsam,&
asm,alsa3,as3,bs3,alsat,ast,bst,&
alsa4,as4,bs4,cs4,&
alsatt,astt,bstt,cstt,&
alsai,asi,bsi,csi,dsi,&
sf,ss,sw,sfp,ssp,swp,d2,n,ncl1,ncln)
!
!*******************************************************************
use decomp_2d, only : mytype
use param
use variables, only : fpi2
implicit none
real(mytype),intent(in) :: d2
integer,intent(in) :: n,ncl1,ncln
real(mytype),dimension(n),intent(out) :: sf,ss,sw,sfp,ssp,swp
real(mytype),intent(out) :: alsa1,as1,bs1,&
cs1,ds1,alsa2,as2,alsan,asn,bsn,csn,dsn,alsam,&
asm,alsa3,as3,bs3,alsat,ast,bst,&
alsa4,as4,bs4,cs4,&
alsatt,astt,bstt,cstt,&
alsai,asi,bsi,csi,dsi
integer :: i
real(mytype),dimension(n) :: sb,sc
real(mytype) :: xxnu,dpis3,kppkc,kppkm,xnpi2,xmpi2
sf=zero;ss=zero;sw=zero;sfp=zero;ssp=zero;swp=zero
alsa1= eleven
as1 = (thirteen)/d2
bs1 =-(twentyseven)/d2
cs1 = (fifteen)/d2
ds1 =-(one)/d2
alsa2= zpone
as2 = (six/five)/d2
alsa3= two/eleven
as3 = (twelve/eleven)/d2
bs3 = (three/fortyfour)/d2
alsa4= two/eleven
as4 = (twelve/eleven)/d2
bs4 = (three/fortyfour)/d2
cs4 = zero
alsan= eleven
asn = (thirteen)/d2
bsn =-(twentyseven)/d2
csn = (fifteen)/d2
dsn =-(one)/d2
alsam= zpone
asm = (six/five)/d2
alsat= two/eleven
ast = (twelve/eleven)/d2
bst = (three/fortyfour)/d2
alsatt = two/eleven
astt = (twelve/eleven)/d2
bstt = (three/fortyfour)/d2
cstt = zero
!BASE LELE
!alsai= 2./11.
!asi = (12./11.)/d2
!bsi = (3./44. )/d2
!csi = 0.
!NUMERICAL DISSIPATION (see publications for help)
! fpi2=(48./7)/(pi*pi)
if (jLES.eq.1) then !iLES
xxnu=one/fpi2
dpis3=two*pi/three
kppkc=pi*pi/xxnu+pi*pi
kppkm=dpis3*dpis3*exp(-((pi-dpis3)/(zpthree*pi-dpis3))**two)/xxnu+dpis3*dpis3
xnpi2=kppkc
xmpi2=kppkm
alsai=(405._mytype*xnpi2 - 1280._mytype*xmpi2 + 2736._mytype)/&
(810._mytype*xnpi2 - 1280._mytype*xmpi2 + 288._mytype)
asi=-(4329._mytype*xnpi2 - 256._mytype*xmpi2 - 1120._mytype*xnpi2*xmpi2 + 2288._mytype)/&
(3240._mytype*xnpi2 - 5120._mytype*xmpi2 + 1152._mytype)
asi = asi / (d2)
bsi=(2115._mytype*xnpi2 - 1792._mytype*xmpi2 - 280._mytype*xnpi2*xmpi2 + 1328._mytype)/&
(405._mytype*xnpi2 - 640._mytype*xmpi2 + 144._mytype)
bsi = bsi / (four*d2)
csi=-(nine*(855._mytype*xnpi2 + 256._mytype*xmpi2 - 160._mytype*xnpi2*xmpi2 - 2288._mytype))/&
(eight*(405._mytype*xnpi2 - 640._mytype*xmpi2 + 144._mytype))
csi = csi / (nine*d2)
dsi=(198._mytype*xnpi2 + 128._mytype*xmpi2 - 40._mytype*xnpi2*xmpi2 - 736._mytype)/&
(405._mytype*xnpi2 - 640._mytype*xmpi2 + 144._mytype)
dsi = dsi / (16.*d2)
else
alsai=(45._mytype*fpi2*pi*pi-272._mytype)/(two*(45._mytype*fpi2*pi*pi-208._mytype))
asi =((six-nine*alsai)/four)/d2
bsi =((-three+twentyfour*alsai)/five)/(four*d2)
csi =((two-eleven*alsai)/twenty)/(nine*d2)
dsi = zero
alsa4= alsai
as4 = asi
bs4 = bsi
cs4 = csi
alsatt = alsai
astt = asi
bstt = bsi
cstt = csi
endif
if (ncl1.eq.0) then !Periodic
sf(1) =alsai
sf(2) =alsai
sf(3) =alsai
sf(4) =alsai
sc(1) =two
sc(2) =one
sc(3) =one
sc(4) =one
sb(1) =alsai
sb(2) =alsai
sb(3) =alsai
sb(4) =alsai
elseif (ncl1.eq.1) then !Free-slip
sf(1) =alsai+alsai
sf(2) =alsai
sf(3) =alsai
sf(4) =alsai
sc(1) =one
sc(2) =one
sc(3) =one
sc(4) =one
sb(1) =alsai
sb(2) =alsai
sb(3) =alsai
sb(4) =alsai
elseif (ncl1.eq.2) then !Dirichlet
sf(1) =alsa1
sf(2) =alsa2
sf(3) =alsa3
sf(4) =alsa4
sc(1) =one
sc(2) =one
sc(3) =one
sc(4) =one
sb(1) =alsa2
sb(2) =alsa3
sb(3) =alsa4
sb(4) =alsai
endif
if (ncln.eq.0) then !Periodic
sf(n-4)=alsai
sf(n-3)=alsai
sf(n-2)=alsai
sf(n-1)=alsai
sf(n) =zero
sc(n-4)=one
sc(n-3)=one
sc(n-2)=one
sc(n-1)=one
sc(n )=one+alsai*alsai
sb(n-4)=alsai
sb(n-3)=alsai
sb(n-2)=alsai
sb(n-1)=alsai
sb(n )=zero
elseif (ncln.eq.1) then !Free-slip
sf(n-4)=alsai
sf(n-3)=alsai
sf(n-2)=alsai
sf(n-1)=alsai
sf(n) =zero
sc(n-4)=one
sc(n-3)=one
sc(n-2)=one
sc(n-1)=one
sc(n )=one
sb(n-4)=alsai
sb(n-3)=alsai
sb(n-2)=alsai
sb(n-1)=alsai+alsai
sb(n )=zero
elseif (ncln.eq.2) then !Dirichlet
sf(n-4)=alsai
sf(n-3)=alsatt
sf(n-2)=alsat
sf(n-1)=alsam
sf(n) =zero
sc(n-4)=one
sc(n-3)=one
sc(n-2)=one
sc(n-1)=one
sc(n )=one
sb(n-4)=alsatt
sb(n-3)=alsat
sb(n-2)=alsam
sb(n-1)=alsan
sb(n )=zero
endif
do i=5,n-5
sf(i)=alsai
sc(i)=one
sb(i)=alsai
enddo
do i=1,n
sfp(i)=sf(i)
enddo
if (ncl1.eq.1) then
sf (1)=zero
endif
call prepare (sb,sc,sf ,ss ,sw ,n)
call prepare (sb,sc,sfp,ssp,swp,n)
if (ncln.eq.1) then
sb(n-1)=zero
call prepare (sb,sc,sf ,ss ,sw ,n)
endif
return
end subroutine second_derivative
!*******************************************************************
!
subroutine interpolation(dx,nxm,nx,nclx1,nclxn,&
alcaix6,acix6,bcix6,&
ailcaix6,aicix6,bicix6,cicix6,dicix6,&
cfx6,ccx6,cbx6,cfxp6,ciwxp6,csxp6,&
cwxp6,csx6,cwx6,cifx6,cicx6,cisx6,&
cibx6,cifxp6,cisxp6,ciwx6,&
cfi6,cci6,cbi6,cfip6,csip6,cwip6,csi6,&
cwi6,cifi6,cici6,cibi6,cifip6,&
cisip6,ciwip6,cisi6,ciwi6)
!
!*******************************************************************
use decomp_2d, only : mytype
use param, only : jLES
implicit none
real(mytype),intent(in) :: dx
integer,intent(in) :: nxm,nx,nclx1,nclxn
real(mytype) :: alcaix6,acix6,bcix6
real(mytype) :: ailcaix6,aicix6,bicix6,cicix6,dicix6
real(mytype),dimension(nxm) :: cfx6,ccx6,cbx6,cfxp6,ciwxp6,csxp6,&
cwxp6,csx6,cwx6,cifx6,cicx6,cisx6
real(mytype),dimension(nxm) :: cibx6,cifxp6,cisxp6,ciwx6
real(mytype),dimension(nx) :: cfi6,cci6,cbi6,cfip6,csip6,cwip6,csi6,&
cwi6,cifi6,cici6,cibi6,cifip6
real(mytype),dimension(nx) :: cisip6,ciwip6,cisi6,ciwi6
integer :: i
alcaix6=9./62.
acix6=(63./62.)/dx
bcix6=(17./62.)/3./dx
cfx6(1)=alcaix6
cfx6(2)=alcaix6
cfx6(nxm-2)=alcaix6
cfx6(nxm-1)=alcaix6
cfx6(nxm)=0.
if (nclx1==0) ccx6(1)=2.
if (nclx1==1) ccx6(1)=1. + alcaix6
if (nclx1==2) ccx6(1)=1. + alcaix6
ccx6(2)=1.
ccx6(nxm-2)=1.
ccx6(nxm-1)=1.
if (nclxn==0) ccx6(nxm)=1. + alcaix6*alcaix6
if (nclxn==1) ccx6(nxm)=1. + alcaix6
if (nclxn==2) ccx6(nxm)=1. + alcaix6
cbx6(1)=alcaix6
cbx6(2)=alcaix6
cbx6(nxm-2)=alcaix6
cbx6(nxm-1)=alcaix6
cbx6(nxm)=0.
do i=3,nxm-3
cfx6(i)=alcaix6
ccx6(i)=1.
cbx6(i)=alcaix6
enddo
cfi6(1)=alcaix6 + alcaix6
cfi6(2)=alcaix6
cfi6(nx-2)=alcaix6
cfi6(nx-1)=alcaix6
cfi6(nx)=0.
cci6(1)=1.
cci6(2)=1.
cci6(nx-2)=1.
cci6(nx-1)=1.
cci6(nx)=1.
cbi6(1)=alcaix6
cbi6(2)=alcaix6
cbi6(nx-2)=alcaix6
cbi6(nx-1)=alcaix6 + alcaix6
cbi6(nx)=0.
do i=3,nx-3
cfi6(i)=alcaix6
cci6(i)=1.
cbi6(i)=alcaix6
enddo
if (jLES.eq.1) then
!Spectral-like dx6 v1
ailcaix6=0.461658
dicix6=0.00293016
!ORDRE 6
aicix6=1./64.*(75.+70.*ailcaix6-320.*dicix6)
bicix6=1./128.*(126.*ailcaix6-25.+1152.*dicix6)
cicix6=1./128.*(-10.*ailcaix6+3.-640.*dicix6)
aicix6=aicix6/2.
bicix6=bicix6/2.
cicix6=cicix6/2.
dicix6=dicix6/2.
else
!Classic
!ailcaix6=3./10.
!dicix6=0.
!Crazy
ailcaix6=0.49
dicix6=0.
aicix6=1./128.*(75.+70.*ailcaix6)
bicix6=1./256.*(126.*ailcaix6-25.)
cicix6=1./256.*(-10.*ailcaix6+3.)
dicix6=dicix6/2.
endif
cifx6(1)=ailcaix6
cifx6(2)=ailcaix6
cifx6(nxm-2)=ailcaix6
cifx6(nxm-1)=ailcaix6
cifx6(nxm)=0.
if (nclx1==0) cicx6(1)=2.
if (nclx1==1) cicx6(1)=1. + ailcaix6
if (nclx1==2) cicx6(1)=1. + ailcaix6
cicx6(2)=1.
cicx6(nxm-2)=1.
cicx6(nxm-1)=1.
if (nclxn==0) cicx6(nxm)=1. + ailcaix6*ailcaix6
if (nclxn==1) cicx6(nxm)=1. + ailcaix6
if (nclxn==2) cicx6(nxm)=1. + ailcaix6
cibx6(1)=ailcaix6
cibx6(2)=ailcaix6
cibx6(nxm-2)=ailcaix6
cibx6(nxm-1)=ailcaix6
cibx6(nxm)=0.
do i=3,nxm-3
cifx6(i)=ailcaix6
cicx6(i)=1.
cibx6(i)=ailcaix6
enddo
cifi6(1)=ailcaix6 + ailcaix6
cifi6(2)=ailcaix6
cifi6(nx-2)=ailcaix6
cifi6(nx-1)=ailcaix6
cifi6(nx)=0.
cici6(1)=1.
cici6(2)=1.
cici6(nx-2)=1.
cici6(nx-1)=1.
cici6(nx)=1.
cibi6(1)=ailcaix6
cibi6(2)=ailcaix6
cibi6(nx-2)=ailcaix6
cibi6(nx-1)=ailcaix6 + ailcaix6
cibi6(nx)=0.
do i=3,nx-3
cifi6(i)=ailcaix6
cici6(i)=1.
cibi6(i)=ailcaix6
enddo
do i=1,nxm
cfxp6(i)=cfx6(i)
cifxp6(i)=cifx6(i)
enddo
do i=1,nx
cifip6(i)=cifi6(i)
cfip6(i)=cfi6(i)
enddo
cfxp6(1)=0.
cfip6(1)=0.
call prepare (cbx6,ccx6,cfx6 ,csx6 ,cwx6 ,nxm)
call prepare (cbx6,ccx6,cfxp6,csxp6,cwxp6,nxm)
call prepare (cibx6,cicx6,cifx6 ,cisx6 ,ciwx6 ,nxm)
call prepare (cibx6,cicx6,cifxp6,cisxp6,ciwxp6,nxm)
call prepare (cbi6,cci6,cfi6 ,csi6 ,cwi6 ,nx)
call prepare (cbi6,cci6,cfip6,csip6,cwip6,nx)
call prepare (cibi6,cici6,cifi6 ,cisi6 ,ciwi6 ,nx)
call prepare (cibi6,cici6,cifip6,cisip6,ciwip6,nx)
if (nclxn.eq.1) then
cbx6(nxm-1)=0.
cibx6(nxm)=0
cbi6(nx-1)=0.
cibi6(nx)=0
call prepare (cbx6,ccx6,cfxp6,csxp6,cwxp6,nxm)
call prepare (cibx6,cicx6,cifxp6,cisxp6,ciwxp6,nxm)
call prepare (cbi6,cci6,cfip6,csip6,cwip6,nx)
call prepare (cibi6,cici6,cifip6,cisip6,ciwip6,nx)
endif
if (nclxn.eq.2) then
cbx6(nxm-1)=0.
cibx6(nxm)=0.
cbi6(nx-1)=0.
cibi6(nx)=0.
call prepare (cbx6,ccx6,cfxp6,csxp6,cwxp6,nxm)
call prepare (cibx6,cicx6,cifxp6,cisxp6,ciwxp6,nxm)
call prepare (cbi6,cci6,cfip6,csip6,cwip6,nx)
call prepare (cibi6,cici6,cifip6,cisip6,ciwip6,nx)
endif
return
end subroutine interpolation