1 c ===============================================================================
2 c This file is included by
7 c ==============================================================================
9 c These next include files will define
the macros that will define
the difference approximations
10 c The actual macro is called below
11 #Include "defineDiffOrder2f.h"
12 #Include "defineDiffOrder4f.h"
14 #Include "commonMacros.h"
16 #beginMacro loopse1(e1)
17 if( useWhereMask.ne.0 )then
37 #beginMacro loopse2(e1,e2)
38 if( useWhereMask.ne.0 )then
42 if(
mask(i1,i2,i3).
gt.0 )then
61 #beginMacro loopse3(e1,e2,e3)
62 if( useWhereMask.ne.0 )then
66 if(
mask(i1,i2,i3).
gt.0 )then
87 #beginMacro loopse4(e1,e2,e3,e4)
88 if( useWhereMask.ne.0 )then
92 if(
mask(i1,i2,i3).
gt.0 )then
115 #beginMacro loopse6(e1,e2,e3,e4,e5,e6)
116 if( useWhereMask.ne.0 )then
120 if(
mask(i1,i2,i3).
gt.0 )then
150 c Define
the artificial diffusion coefficients
151 c gt should be
R or C (
gridType is Rectangular or Curvilinear)
152 c tb should be blank or SA (SA=Spalart-Allamras turbulence model)
153 #beginMacro defineArtificialDiffusionCoefficients(dim,gt,tb)
155 cdmz=admz ##
gt ## tb(i1 ,i2 ,i3)
156 cdpz=admz
## gt ## tb(i1+1,i2 ,i3)
157 cdzm=adzm ##
gt ## tb(i1 ,i2 ,i3)
158 cdzp=adzm
## gt ## tb(i1 ,i2+1,i3)
159 cdDiag=cdmz+cdpz+cdzm+cdzp
160 ! write(*,
'(1x,''insdt:i1,i2,cdmz,cdzm='',2i3,2f9.3)') i1,i2,cdmz,cdzm
162 cdmzz=admzz ##
gt ## tb(i1 ,i2 ,i3 )
163 cdpzz=admzz
## gt ## tb(i1+1,i2 ,i3 )
164 cdzmz=adzmz ##
gt ## tb(i1 ,i2 ,i3 )
165 cdzpz=adzmz
## gt ## tb(i1 ,i2+1,i3 )
166 cdzzm=adzzm ##
gt ## tb(i1 ,i2 ,i3 )
167 cdzzp=adzzm
## gt ## tb(i1 ,i2 ,i3+1)
168 cdDiag=cdmzz+cdpzz+cdzmz+cdzpz+cdzzm+cdzzp
173 #beginMacro defineDerivativeMacros(DIM,ORDER,GRIDTYPE)
175 #defineMacro U(cc) u(i1,i2,i3,cc)
176 #defineMacro UU(cc) uu(i1,i2,i3,cc)
180 #If #GRIDTYPE == "rectangular"
181 #defineMacro UX(cc) ux22r(i1,i2,i3,cc)
182 #defineMacro UY(cc) uy22r(i1,i2,i3,cc)
183 #defineMacro UXX(cc) uxx22r(i1,i2,i3,cc)
184 #defineMacro UXY(cc) uxy22r(i1,i2,i3,cc)
185 #defineMacro UYY(cc) uyy22r(i1,i2,i3,cc)
186 #defineMacro ULAP(cc) ulaplacian22r(i1,i2,i3,cc)
188 #defineMacro UX(cc) ux22(i1,i2,i3,cc)
189 #defineMacro UY(cc) uy22(i1,i2,i3,cc)
190 #defineMacro UXX(cc) uxx22(i1,i2,i3,cc)
191 #defineMacro UXY(cc) uxy22(i1,i2,i3,cc)
192 #defineMacro UYY(cc) uyy22(i1,i2,i3,cc)
193 #defineMacro ULAP(cc) ulaplacian22(i1,i2,i3,cc)
196 #If #GRIDTYPE == "rectangular"
197 #defineMacro UX(cc) ux42r(i1,i2,i3,cc)
198 #defineMacro UY(cc) uy42r(i1,i2,i3,cc)
199 #defineMacro UXX(cc) uxx42r(i1,i2,i3,cc)
200 #defineMacro UXY(cc) uxy42r(i1,i2,i3,cc)
201 #defineMacro UYY(cc) uyy42r(i1,i2,i3,cc)
202 #defineMacro ULAP(cc) ulaplacian42r(i1,i2,i3,cc)
204 #defineMacro UX(cc) ux42(i1,i2,i3,cc)
205 #defineMacro UY(cc) uy42(i1,i2,i3,cc)
206 #defineMacro UXX(cc) uxx42(i1,i2,i3,cc)
207 #defineMacro UXY(cc) uxy42(i1,i2,i3,cc)
208 #defineMacro UYY(cc) uyy42(i1,i2,i3,cc)
209 #defineMacro ULAP(cc) ulaplacian42(i1,i2,i3,cc)
214 #If #GRIDTYPE == "rectangular"
215 #defineMacro UX(cc) ux23r(i1,i2,i3,cc)
216 #defineMacro UY(cc) uy23r(i1,i2,i3,cc)
217 #defineMacro UZ(cc) uz23r(i1,i2,i3,cc)
218 #defineMacro UXX(cc) uxx23r(i1,i2,i3,cc)
219 #defineMacro UXY(cc) uxy23r(i1,i2,i3,cc)
220 #defineMacro UXZ(cc) uxz23r(i1,i2,i3,cc)
221 #defineMacro UYY(cc) uyy23r(i1,i2,i3,cc)
222 #defineMacro UYZ(cc) uyz23r(i1,i2,i3,cc)
223 #defineMacro UZZ(cc) uzz23r(i1,i2,i3,cc)
224 #defineMacro ULAP(cc) ulaplacian23r(i1,i2,i3,cc)
226 #defineMacro UX(cc) ux23(i1,i2,i3,cc)
227 #defineMacro UY(cc) uy23(i1,i2,i3,cc)
228 #defineMacro UZ(cc) uz23(i1,i2,i3,cc)
229 #defineMacro UXX(cc) uxx23(i1,i2,i3,cc)
230 #defineMacro UXY(cc) uxy23(i1,i2,i3,cc)
231 #defineMacro UXZ(cc) uxz23(i1,i2,i3,cc)
232 #defineMacro UYY(cc) uyy23(i1,i2,i3,cc)
233 #defineMacro UYZ(cc) uyz23(i1,i2,i3,cc)
234 #defineMacro UZZ(cc) uzz23(i1,i2,i3,cc)
235 #defineMacro ULAP(cc) ulaplacian23(i1,i2,i3,cc)
240 #If #GRIDTYPE == "rectangular"
241 #defineMacro UX(cc) ux43r(i1,i2,i3,cc)
242 #defineMacro UY(cc) uy43r(i1,i2,i3,cc)
243 #defineMacro UZ(cc) uz43r(i1,i2,i3,cc)
244 #defineMacro UXX(cc) uxx43r(i1,i2,i3,cc)
245 #defineMacro UXY(cc) uxy43r(i1,i2,i3,cc)
246 #defineMacro UXZ(cc) uxz43r(i1,i2,i3,cc)
247 #defineMacro UYY(cc) uyy43r(i1,i2,i3,cc)
248 #defineMacro UYZ(cc) uyz43r(i1,i2,i3,cc)
249 #defineMacro UZZ(cc) uzz43r(i1,i2,i3,cc)
250 #defineMacro ULAP(cc) ulaplacian43r(i1,i2,i3,cc)
252 #defineMacro UX(cc) ux43(i1,i2,i3,cc)
253 #defineMacro UY(cc) uy43(i1,i2,i3,cc)
254 #defineMacro UZ(cc) uz43(i1,i2,i3,cc)
255 #defineMacro UXX(cc) uxx43(i1,i2,i3,cc)
256 #defineMacro UXY(cc) uxy43(i1,i2,i3,cc)
257 #defineMacro UXZ(cc) uxz43(i1,i2,i3,cc)
258 #defineMacro UYY(cc) uyy43(i1,i2,i3,cc)
259 #defineMacro UYZ(cc) uyz43(i1,i2,i3,cc)
260 #defineMacro UZZ(cc) uzz43(i1,i2,i3,cc)
261 #defineMacro ULAP(cc) ulaplacian43(i1,i2,i3,cc)
268 c =============================================================
269 c Compute derivatives of
u,
v,w
270 c =============================================================
271 #beginMacro setupDerivatives(DIM)
289 c***************************************************************
290 c Define
the equations
for EXPLICIT time stepping
294 c
GRIDTYPE: rectangular, curvilinear
296 c***************************************************************
297 #beginMacro fillEquations(DIM,ORDER,GRIDTYPE)
301 if( isAxisymmetric.eq.0 )then
303 if( gridIsImplicit.eq.0 )then
306 loopse1($buildEquations(EXPLICIT,NONE,DIM,
ORDER,
GRIDTYPE,NO))
308 else ! gridIsImplicit
309 ! ***** implicit *******
311 if( implicitOption .eq.computeImplicitTermsSeparately )then
312 loopse1($buildEquations(BOTH,NONE,DIM,ORDER,GRIDTYPE,NO))
313 else if( implicitOption.eq.doNotComputeImplicitTerms )then
314 loopse1($buildEquations(EXPLICIT_ONLY,NONE,DIM,ORDER,GRIDTYPE,NO))
316 write(*,*)'
insdt: Unknown implicitOption=',implicitOption
318 end
if ! end implicitOption
322 else if( isAxisymmetric.eq.1 )then
325 ! **** axisymmetric
case ****
326 if( gridIsImplicit.eq.0 )then
329 loopse1($buildEquations(EXPLICIT,NONE,DIM,ORDER,GRIDTYPE,YES))
331 else ! gridIsImplicit
332 ! ***** implicit *******
334 if( implicitOption .eq.computeImplicitTermsSeparately )then
335 loopse1($buildEquations(BOTH,NONE,DIM,ORDER,GRIDTYPE,YES))
336 else if( implicitOption.eq.doNotComputeImplicitTerms )then
337 loopse1($buildEquations(EXPLICIT_ONLY,NONE,DIM,ORDER,GRIDTYPE,YES))
339 write(*,*)'
insdt: Unknown implicitOption=',implicitOption
341 end
if ! end implicitOption
354 c====================================================================================
356 c====================================================================================
357 #beginMacro assignEquations(DIM,ORDER)
359 fillEquations(DIM,ORDER,rectangular)
361 fillEquations(DIM,ORDER,curvilinear)
368 c======================================================================================
369 c Define
the subroutine to compute du/dt
371 c======================================================================================
372 #beginMacro INSDT(NAME,DIM,ORDER)
373 subroutine NAME(nd,n1a,n1b,n2a,n2b,n3a,n3b,nd1a,nd1b,nd2a,nd2b,nd3a,nd3b,nd4a,nd4b,\
374 mask,xy,rsxy,radiusInverse, u,uu,
ut,uti,gv,
dw, bc, ipar, rpar, ierr )
375 c======================================================================
376 c Compute du/dt
for the incompressible NS on rectangular grids
377 c OPTIMIZED version
for rectangular grids.
378 c nd : number of
space dimensions
380 c gv : gridVelocity
for moving grids
381 c uu :
for moving grids uu is
a workspace to hold u-gv, otherwise uu==u
382 c
dw : distance to
the wall
for some turbulence models
383 c======================================================================
385 integer nd, n1a,n1b,n2a,n2b,n3a,n3b,nd1a,nd1b,nd2a,nd2b,nd3a,nd3b,nd4a,nd4b
387 real u(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
388 real uu(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
389 real
ut(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
390 real uti(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
391 real gv(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1)
392 real
dw(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
393 real xy(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1)
394 real rsxy(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1,0:nd-1)
395 real radiusInverse(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
397 integer
mask(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
398 integer bc(0:1,0:2),ierr
403 ! ---- local variables -----
405 integer gridIsImplicit,implicitOption,implicitMethod,isAxisymmetric,
use2ndOrderAD,use4thOrderAD
406 integer rc,pc,uc,vc,
wc,sc,
nc,
kc,
ec,
tc,
grid,
m,advectPassiveScalar,vsc
407 real nu,dt,nuPassiveScalar,adcPassiveScalar
408 real dxi,dyi,dzi,
dri,dsi,dti,dr2i,ds2i,dt2i
410 real ad21n,ad22n,ad41n,ad42n,cd22n,cd42n
414 integer rectangular,curvilinear
415 parameter( rectangular=0, curvilinear=1 )
417 integer turbulenceModel,noTurbulenceModel
418 integer baldwinLomax,spalartAllmaras,kEpsilon,kOmega,largeEddySimulation
419 parameter (noTurbulenceModel=0,baldwinLomax=1,kEpsilon=2,kOmega=3,spalartAllmaras=4,largeEddySimulation=5 )
421 integer pdeModel,standardModel,BoussinesqModel,viscoPlasticModel,twoPhaseFlowModel
422 parameter( standardModel=0,BoussinesqModel=1,viscoPlasticModel=2,twoPhaseFlowModel=3 )
424 integer computeAllTerms,\
425 doNotComputeImplicitTerms,\
426 computeImplicitTermsSeparately,\
427 computeAllWithWeightedImplicit
430 doNotComputeImplicitTerms=1,\
431 computeImplicitTermsSeparately=2,\
432 computeAllWithWeightedImplicit=3 )
435 real dr(0:2),
dx(0:2)
439 real
cb1,
cb2, cv1,
sigma,
sigmai,
kappa, cw1, cw2, cw3, cw3e6, cv1e3, cd0, cr0
440 real chi,chi3,fnu1,fnu2,
s,
r,g,fw,dKappaSq,nSqBydSq,dd
447 real k0,k0x,k0y,k0z, e0,e0x,e0y,e0z
449 real cMu,cEps1,cEps2,sigmaEpsI,sigmaKI
452 ! real nuVP,etaVP,yieldStressVP,exponentVP,epsVP
454 ! real u0xx,u0xy,u0xz,u0yy,u0yz,u0zz
455 ! real v0xx,v0xy,v0xz,v0yy,v0yz,v0zz
456 ! real w0xx,w0xy,w0xz,w0yy,w0yz,w0zz
458 real delta22,delta23,delta42,delta43
461 declareDifferenceOrder2(u,
RX)
464 declareDifferenceOrder4(u,
RX)
467 rx(i1,i2,i3)=rsxy(i1,i2,i3,0,0)
468 ry(i1,i2,i3)=rsxy(i1,i2,i3,0,1)
469 rz(i1,i2,i3)=rsxy(i1,i2,i3,0,2)
470 sx(i1,i2,i3)=rsxy(i1,i2,i3,1,0)
471 sy(i1,i2,i3)=rsxy(i1,i2,i3,1,1)
472 sz(i1,i2,i3)=rsxy(i1,i2,i3,1,2)
473 tx(i1,i2,i3)=rsxy(i1,i2,i3,2,0)
474 ty(i1,i2,i3)=rsxy(i1,i2,i3,2,1)
475 tz(i1,i2,i3)=rsxy(i1,i2,i3,2,2)
477 c The next macro call will define
the difference approximation statement
functions
479 defineDifferenceOrder2Components1(u,
RX)
482 defineDifferenceOrder4Components1(u,
RX)
485 c --- For 2nd
order 2
D artificial diffusion ---
486 delta22(c)= (
u(i1+1,i2,i3,c)-4.*
u(i1,i2,i3,c)+
u(i1-1,i2,i3,c) \
487 +
u(i1,i2+1,i3,c) +
u(i1,i2-1,i3,c))
488 c --- For 2nd
order 3
D artificial diffusion ---
490 (
u(i1+1,i2,i3,c)-6.*
u(i1,i2,i3,c)+
u(i1-1,i2,i3,c) \
491 +
u(i1,i2+1,i3,c) +
u(i1,i2-1,i3,c) \
492 +
u(i1,i2,i3+1,c) +
u(i1,i2,i3-1,c))
493 c ---For fourth-
order artificial diffusion in 2
D
495 ( -
u(i1+2,i2,i3,c)-
u(i1-2,i2,i3,c) \
496 -
u(i1,i2+2,i3,c)-
u(i1,i2-2,i3,c) \
497 +4.*(
u(i1+1,i2,i3,c)+
u(i1-1,i2,i3,c) \
498 +
u(i1,i2+1,i3,c)+
u(i1,i2-1,i3,c)) \
500 c ---For fourth-
order artificial diffusion in 3
D
502 ( -
u(i1+2,i2,i3,c)-
u(i1-2,i2,i3,c) \
503 -
u(i1,i2+2,i3,c)-
u(i1,i2-2,i3,c) \
504 -
u(i1,i2,i3+2,c)-
u(i1,i2,i3-2,c) \
505 +4.*(
u(i1+1,i2,i3,c)+
u(i1-1,i2,i3,c) \
506 +
u(i1,i2+1,i3,c)+
u(i1,i2-1,i3,c) \
507 +
u(i1,i2,i3+1,c)+
u(i1,i2,i3-1,c)) \
513 ! write(*,
'("Inside insdt: gridType=",i2)')
gridType
521 tc =ipar(6) ! **new**
523 orderOfAccuracy =ipar(8)
524 gridIsMoving =ipar(9)
525 useWhereMask =ipar(10)
526 gridIsImplicit =ipar(11)
527 implicitMethod =ipar(12)
528 implicitOption =ipar(13)
529 isAxisymmetric =ipar(14)
530 use2ndOrderAD =ipar(15)
531 use4thOrderAD =ipar(16)
532 advectPassiveScalar=ipar(17)
534 turbulenceModel =ipar(19)
550 nuPassiveScalar =rpar(11)
551 adcPassiveScalar =rpar(12)
557 ! nuVP =rpar(24) !
for visco-plastic
559 ! yieldStressVP =rpar(26)
560 ! exponentVP =rpar(27)
563 ! write(*,'("
insdt: eta,yield,exp,
eps=",4e10.2)') etaVP,yieldStressVP,exponentVP,epsVP
568 if( orderOfAccuracy.ne.2 .and. orderOfAccuracy.ne.4 )then
569 write(*,'("
insdt:ERROR orderOfAccuracy=",i6)') orderOfAccuracy
576 if( uc.lt.0 .or. vc.lt.0 .or. (nd.eq.3 .and. wc.lt.0) )then
577 write(*,'("
insdt:ERROR uc,vc,
ws=",3i6)') uc,vc,wc
581 c write(*,'("
insdt: turbulenceModel=",2i6)') turbulenceModel
582 c write(*,'("
insdt: nd,uc,vc,wc,kc=",2i6)') nd,uc,vc,wc,kc
584 if( turbulenceModel.eq.kEpsilon .and. (kc.lt.uc+nd .or. kc.
gt.1000) )then
585 write(*,'("
insdt:ERROR in kc: nd,uc,vc,wc,kc=",2i6)') nd,uc,vc,wc,kc
590 c ** these are needed by self-adjoint terms **fix**
601 if( turbulenceModel.eq.spalartAllmaras )then
602 call
getSpalartAllmarasParameters(cb1, cb2, cv1, sigma, sigmai, kappa, cw1, cw2, cw3, cw3e6, \
604 else if( turbulenceModel.eq.kEpsilon )then
606 ! write(*,'("
insdt:
k-epsilon: nc,kc,ec=",3i3)') nc,kc,ec
609 ! write(*,'("
insdt: cMu,cEps1,cEps2,sigmaEpsI,sigmaKI=",5f8.3)') cMu,cEps1,cEps2,sigmaEpsI,sigmaKI
611 else if( turbulenceModel.eq.largeEddySimulation )then
613 else if( turbulenceModel.ne.noTurbulenceModel )then
617 adc=adcPassiveScalar ! coefficient of linear artificial diffusion
621 c *********************************
622 c ********MAIN LOOPS***************
623 c *********************************
624 assignEquations(DIM,ORDER)
631 c : empty version
for linking when we
do not want an option
633 #beginMacro INSDT_NULL(NAME,DIM,ORDER)
634 subroutine NAME(nd,n1a,n1b,n2a,n2b,n3a,n3b,nd1a,nd1b,nd2a,nd2b,nd3a,nd3b,nd4a,nd4b,\
635 mask,xy,rsxy,radiusInverse, u,uu,
ut,uti,gv,
dw, bc, ipar, rpar, ierr )
636 c======================================================================
637 c EMPTY VERSION
for Linking without this Capability
639 c Compute du/dt
for the incompressible NS on rectangular grids
640 c OPTIMIZED version
for rectangular grids.
641 c nd : number of
space dimensions
643 c gv : gridVelocity
for moving grids
644 c uu :
for moving grids uu is
a workspace to hold u-gv, otherwise uu==u
645 c
dw : distance to
the wall
for some turbulence models
646 c======================================================================
648 integer nd, n1a,n1b,n2a,n2b,n3a,n3b,nd1a,nd1b,nd2a,nd2b,nd3a,nd3b,nd4a,nd4b
650 real u(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
651 real uu(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
652 real
ut(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
653 real uti(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
654 real gv(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1)
655 real
dw(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
656 real xy(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1)
657 real rsxy(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1,0:nd-1)
658 real radiusInverse(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
660 integer
mask(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
661 integer bc(0:1,0:2),ierr
666 write(*,'("ERROR: NULL version of subroutine NAME called")')
667 write(*,'(" You may have to turn on an option in
the Makefile.")')
676 #beginMacro buildFile(NAME,DIM,ORDER)
677 #beginFile src/NAME.f
678 INSDT(NAME,DIM,ORDER)
680 #beginFile src/NAME ## Null.f
681 INSDT_NULL(NAME,DIM,ORDER)