1 ! ****************************************************************************************************
2 ! Define macros that are used to build
the full implicit matrices
for the INS, VP etc. equations
4 !
This file contains
generic macros that are used by
the different PDEs
10 ! ****************************************************************************************************
13 c --- See --- op/fortranCoeff/opcoeff.bf
14 c op/include/defineConservative.h
15 c --- See --- mx/src/interfaceMacros.bf <-- mixes different orders of accuracy
17 c -- define bpp macros
for coefficient
operators (from op/src/stencilCoeff.maple)
18 #Include opStencilCoeffOrder2.h
19 #Include opStencilCoeffOrder4.h
20 #Include opStencilCoeffOrder6.h
21 ! #Include opStencilCoeffOrder8.h
24 c These next include file will define
the macros that will define
the difference approximations (in op/src)
25 c Defines getDuDx2(
u,aj,ff), getDuDxx2(u,aj,ff), getDuDx3(u,aj,ff), ... etc.
26 #Include "derivMacroDefinitions.h"
29 c defineParametricDerivativeMacros(u,dr,
dx,DIM,
ORDER,COMPONENTS,MAXDERIV)
32 #Include "defineParametricDerivMacros.h"
35 ! defineParametricDerivativeMacros(u,dr,
dx,DIM,
ORDER,COMPONENTS,MAXDERIV)
37 ! defineParametricDerivativeMacros(u,dr,
dx,2,2,1,2)
38 defineParametricDerivativeMacros(rsxy,dr,
dx,3,2,2,2)
39 defineParametricDerivativeMacros(rsxy,dr,dx,3,4,2,2)
40 defineParametricDerivativeMacros(rsxy,dr,dx,3,6,2,2)
42 defineParametricDerivativeMacros(u,dr,dx,3,2,1,2)
43 defineParametricDerivativeMacros(ul,dr,dx,3,2,1,2)
46 ! Example to define orders 2,4,6:
47 ! defineParametricDerivativeMacros(u1,
dr1,
dx1,2,2,1,6)
48 ! defineParametricDerivativeMacros(u1,dr1,dx1,2,4,1,4)
49 ! defineParametricDerivativeMacros(u1,dr1,dx1,2,6,1,2)
53 ! defines getConservativeCoeff(
OPERATOR,
s,
coeff ), OPERATOR=divScalarGrad, ...
54 #Include "conservativeCoefficientMacros.h"
58 #beginMacro beginLoops()
65 #beginMacro endLoops()
72 #beginMacro beginLoopsNoMask()
78 #beginMacro endLoopsNoMask()
84 !
This loop will check
for mask>0 and
mask != interiorBoundaryPoint
85 #beginMacro beginLoopsMixedBoundary()
89 !
if( btest(
mask(i1,i2,i3),28) )then
90 ! write(*,
'("+++ Point i=(",3i5,") is an interiorBoundaryPoint")') i1,i2,i3
92 if(
mask(i1,i2,i3).
gt.0 .and. .not.btest(
mask(i1,i2,i3),28) )then
95 #beginMacro beginMatrixLoops(m1,m2,m3)
96 do m3=-halfWidth3,halfWidth3
97 do m2=-halfWidth,halfWidth
98 do m1=-halfWidth,halfWidth
101 #beginMacro endMatrixLoops()
107 ! ======================================================================================================
108 ! Add
the local matrix
operator opCoeff to
the global matrix coeff in equation
"e" and component
"c"
109 ! ======================================================================================================
110 #beginMacro addCoeff(c,e,coeff,opCoeff)
112 do m2=-halfWidth,halfWidth
113 do m1=-halfWidth,halfWidth
114 coeff(mce2(m1,m2,0,c,
e),i1,i2,i3)=
coeff(mce2(m1,m2,0,c,
e),i1,i2,i3)+(opCoeff(ma2(m1,m2,0)))
118 do m3=-halfWidth,halfWidth
119 do m2=-halfWidth,halfWidth
120 do m1=-halfWidth,halfWidth
121 coeff(mce3(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(mce3(m1,m2,m3,c,
e),
i1,
i2,
i3)+(opCoeff(ma3(m1,m2,m3)))
129 ! ======================================================================================================
130 ! Assign and add up to 10 different local matrix
operators to
the global matrix coeff
131 ! in equation
"e" and component
"c"
133 ! (Leave
final unused arguments empty)
134 ! ======================================================================================================
135 #beginMacro setCoeff10(c,e,coeff,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10)
136 do m3=-halfWidth3,halfWidth3
137 do m2=-halfWidth,halfWidth
138 do m1=-halfWidth,halfWidth
140 coeff(
MCE(m1,m2,m3,c,
e),i1,i2,i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
141 (op6(MA(m1,m2,m3)))+(op7(MA(m1,m2,m3)))+(op8(MA(m1,m2,m3)))+(op9(MA(m1,m2,m3)))+(op10(MA(m1,m2,m3)))
143 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
144 (op6(MA(m1,m2,m3)))+(op7(MA(m1,m2,m3)))+(op8(MA(m1,m2,m3)))+(op9(MA(m1,m2,m3)))
146 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
147 (op6(MA(m1,m2,m3)))+(op7(MA(m1,m2,m3)))+(op8(MA(m1,m2,m3)))
149 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
150 (op6(MA(m1,m2,m3)))+(op7(MA(m1,m2,m3)))
152 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
155 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))
157 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))
159 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))
161 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))
170 #beginMacro setCoeff9(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,op8,op9)
171 setCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,op8,op9,)
173 #beginMacro setCoeff8(c,e,coeff,op1,op2,op3,op4,op5,op6,op7,op8)
174 setCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,op8,,)
176 #beginMacro setCoeff7(c,e,coeff,op1,op2,op3,op4,op5,op6,op7)
177 setCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,,,)
179 #beginMacro setCoeff6(c,e,coeff,op1,op2,op3,op4,op5,op6)
180 setCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,,,,)
182 #beginMacro setCoeff5(c,e,coeff,op1,op2,op3,op4,op5)
183 setCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,,,,,)
185 #beginMacro setCoeff4(c,e,coeff,op1,op2,op3,op4)
186 setCoeff10(c,
e,coeff,op1,op2,op3,op4,,,,,,)
188 #beginMacro setCoeff3(c,e,coeff,op1,op2,op3)
189 setCoeff10(c,
e,coeff,op1,op2,op3,,,,,,,)
191 #beginMacro setCoeff2(c,e,coeff,op1,op2)
192 setCoeff10(c,
e,coeff,op1,op2,,,,,,,,)
194 #beginMacro setCoeff1(c,e,coeff,op1)
195 setCoeff10(c,
e,coeff,op1,,,,,,,,,)
199 ! ======================================================================================================
200 ! Add up to 10 different local matrix
operators to
the global matrix coeff
201 ! in equation
"e" and component
"c"
203 ! (Leave
final unused arguments empty)
204 ! ======================================================================================================
205 #beginMacro addCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10)
206 do m3=-halfWidth3,halfWidth3
207 do m2=-halfWidth,halfWidth
208 do m1=-halfWidth,halfWidth
210 coeff(
MCE(m1,m2,m3,c,
e),i1,i2,i3)=
coeff(
MCE(m1,m2,m3,c,
e),i1,i2,i3)+\
211 (op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
212 (op6(MA(m1,m2,m3)))+(op7(MA(m1,m2,m3)))+(op8(MA(m1,m2,m3)))+(op9(MA(m1,m2,m3)))+(op10(MA(m1,m2,m3)))
214 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+\
215 (op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
216 (op6(MA(m1,m2,m3)))+(op7(MA(m1,m2,m3)))+(op8(MA(m1,m2,m3)))+(op9(MA(m1,m2,m3)))
218 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+\
219 (op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
220 (op6(MA(m1,m2,m3)))+(op7(MA(m1,m2,m3)))+(op8(MA(m1,m2,m3)))
222 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+\
223 (op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
224 (op6(MA(m1,m2,m3)))+(op7(MA(m1,m2,m3)))
226 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+\
227 (op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))+\
230 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+\
231 (op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))+(op5(MA(m1,m2,m3)))
233 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+\
234 (op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))+(op4(MA(m1,m2,m3)))
236 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))+(op3(MA(m1,m2,m3)))
238 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+(op1(MA(m1,m2,m3)))+(op2(MA(m1,m2,m3)))
240 coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)=
coeff(
MCE(m1,m2,m3,c,
e),
i1,
i2,
i3)+(op1(MA(m1,m2,m3)))
247 #beginMacro addCoeff9(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,op8,op9)
248 addCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,op8,op9,)
250 #beginMacro addCoeff8(c,e,coeff,op1,op2,op3,op4,op5,op6,op7,op8)
251 addCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,op8,,)
253 #beginMacro addCoeff7(c,e,coeff,op1,op2,op3,op4,op5,op6,op7)
254 addCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,op7,,,)
256 #beginMacro addCoeff6(c,e,coeff,op1,op2,op3,op4,op5,op6)
257 addCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,op6,,,,)
259 #beginMacro addCoeff5(c,e,coeff,op1,op2,op3,op4,op5)
260 addCoeff10(c,
e,coeff,op1,op2,op3,op4,op5,,,,,)
262 #beginMacro addCoeff4(c,e,coeff,op1,op2,op3,op4)
263 addCoeff10(c,
e,coeff,op1,op2,op3,op4,,,,,,)
265 #beginMacro addCoeff3(c,e,coeff,op1,op2,op3)
266 addCoeff10(c,
e,coeff,op1,op2,op3,,,,,,,)
268 #beginMacro addCoeff2(c,e,coeff,op1,op2)
269 addCoeff10(c,
e,coeff,op1,op2,,,,,,,,)
271 #beginMacro addCoeff1(c,e,coeff,op1)
272 addCoeff10(c,
e,coeff,op1,,,,,,,,,)
279 ! ======================================================================================================
280 ! Set
the local matrix
operator opCoeff to
the global matrix coeff in equation
"e" and component
"c"
281 ! ======================================================================================================
282 #beginMacro setCoeff(c,e,coeff,opCoeff)
284 do m2=-halfWidth,halfWidth
285 do m1=-halfWidth,halfWidth
286 coeff(mce2(m1,m2,0,c,
e),i1,i2,i3)=opCoeff(ma2(m1,m2,0))
290 do m3=-halfWidth,halfWidth
291 do m2=-halfWidth,halfWidth
292 do m1=-halfWidth,halfWidth
293 coeff(mce3(m1,m2,m3,c,
e),i1,i2,i3)=opCoeff(ma3(m1,m2,m3))
300 ! ==========================================================================================
301 ! Evaluate
the Jacobian and its derivatives (parametric and spatial).
302 ! aj : prefix
for the name of
the resulting jacobian variables,
303 !
e.g. ajrx, ajsy, ajrxx, ajsxy, ...
304 ! MAXDER : number of derivatives to evaluate.
305 ! ==========================================================================================
306 #beginMacro opEvalJacobianDerivatives(aj,MAXDER)
308 #If $GRIDTYPE eq "curvilinear"
309 !
this next call will define
the jacobian and its derivatives (parameteric and spatial)
310 #peval evalJacobianDerivatives(rsxy,i1,i2,i3,aj,$DIM,$ORDER,MAXDER)
316 ! ==========================================================================================
317 ! Evaluate
the parametric derivatives of u.
318 ! u : evaluate derivatives of
this function.
319 !
uc : component to evaluate
320 ! uu : prefix
for the name of
the resulting derivatives,
e.g. uur, uus, uurr, ...
321 ! MAXDER : number of derivatives to evaluate.
322 ! ==========================================================================================
323 #beginMacro opEvalParametricDerivative(u,uc,uu,MAXDER)
324 #If $GRIDTYPE eq "curvilinear"
325 #peval evalParametricDerivativesComponents1(u,i1,i2,i3,uc, uu,$DIM,$ORDER,MAXDER)
327 uu=
u(i1,i2,i3,uc) ! in
the rectangular
case just eval
the solution
332 ! ==========================================================================================
333 ! Evaluate
a derivative. (assumes parametric derivatives have already been evaluated)
336 ! u : evaluate derivatives of
this function.
337 ! uc : component to evaluate
338 ! uu : prefix
for the name of
the resulting derivatives (same name used with opEvalParametricDerivative)
339 ! aj : prefix
for the name of
the jacobian variables.
340 ! ud :
derivative is assigned to
this variable.
341 ! ==========================================================================================
342 #beginMacro getOp(DERIV, u,uc,uu,aj,ud )
344 #If $GRIDTYPE eq "curvilinear"
345 #peval getDuD ## DERIV ## $DIM(uu,aj,ud) ! Note: The perl variables are evaluated when the macro is USED.
347 #peval ud = u ## DERIV ## $ORDER(i1,i2,i3,uc)
353 ! ==========================================================================================
354 ! Form
the local coefficient matrix
for an operator. (assumes parametric derivatives have already been evaluated)
355 ! DERIV : name of
the operator. One of
357 ! laplacian, rr,ss,tt, rrrr,ssss,tttt,
358 ! r2Dissipation=rr+ss[+tt]
359 ! r4Dissipation=rrrr+ssss[+tttt]
360 ! coeff : fill in
this (local) coefficient matrix
361 ! AJ : prefix
for the name of
the jacobian variables.
362 ! ==========================================================================================
363 #beginMacro getCoeff( DERIV, coeff, aj )
365 #If $GRIDTYPE eq "curvilinear" || #DERIV eq "identity" || #DERIV eq "r2Dissipation" || #DERIV eq "r4Dissipation"
366 #peval DERIV ## CoeffOrder$ORDER\Dim$DIM(coeff,aj) ! trouble if ## appears after a perl variable
368 #peval DERIV ## CoeffOrder$ORDER\Dim$DIM\Rectangular(coeff,aj)
375 ! ==============================================================================================================
377 ! ==============================================================================================================
378 #beginMacro fillCoeff(DERIV,coeff,c,e)
381 ! Evaluate
the jacobian derivatives used by
the coefficient and forward derivatives:
382 ! opEvalJacobianDerivatives(MAXDER) : MAXDER = max number of derivatives to precompute.
383 opEvalJacobianDerivatives(aj,1)
387 getCoeff(DERIV, xCoeff,aj)
389 addCoeff(
c,
e,coeff,xCoeff)
394 ! ==============================================================================================================
396 ! DERIV : divScalarGrad
397 ! ==============================================================================================================
398 #beginMacro fillCoeffConservative(DERIV,s,coeff,
c,
e)
401 getConservativeCoeff( DERIV,s,xCoeff )
403 addCoeff(
c,
e,coeff,xCoeff)
411 !=======================================================================================
412 ! /Description: Return
the equation number
for given indices
413 ! /
n (input): component number (
n=0,1,..,numberOfComponents-1 )
414 ! /i1,i2,i3 (input):
grid indices
415 ! /return value : The equation number.
416 !\end{SparseRepInclude.tex}
417 !=======================================================================================
418 #defineMacro indexToEquation( n,i1,i2,i3 ) (n+1+ \
419 numberOfComponentsForCoefficients*(i1-equationNumberBase1+\
420 equationNumberLength1*(i2-equationNumberBase2+\
421 equationNumberLength2*(i3-equationNumberBase3))) + equationOffset)
424 !===============================================================================================
426 ! Assign row and column numbers to entries in
a sparse matrix.
427 !
This routine is normally only used
for assign equation numbers on CompositeGrids
428 ! when
the equationNumber belongs to
a point on
a different MappedGrid.
429 ! Rows and columns in
the sparse matrix are numbered according to
the values of
431 ! where
n is
the component number and (I1,I2,
I3) are
the coordinate indicies on
the grid.
432 ! The component number
n runs from 0 to
the numberOfComponentsForCoefficients-1 and is used
433 ! when solving
a system of equations.
436 ! /na,I1a,I2a,I3a (input): defines
the row(s)
437 ! /equationNumber (input): defines an equation number
439 !\end{SparseRepInclude.tex}
440 !===============================================================================================
441 #beginMacro setEquationNumber(m, ni,i1,i2,i3, nj,j1,j2,j3 )
442 equationNumber(
m,i1,i2,i3)=indexToEquation( nj,j1,j2,j3)
447 !===============================================================================================
449 ! Specify
the classification
for a set of Index values
450 !\end{SparseRepInclude.tex}
451 !===============================================================================================
452 #beginMacro setClassify(n,i1,i2,i3, type)
453 classify(i1,i2,i3,
n)=type
456 ! =======================================================================
457 ! Macro to zero out
the matrix coefficients
for equations e1,e1+1,..,e2
458 ! =======================================================================
459 #beginMacro zeroMatrixCoefficients( coeff,e1,e2, i1,i2,i3 )
460 do m=ce(0,e1),ce(0,e2+1)-1
465 ! ===============================================================================================
466 ! Add an extrapolation equation to
the matrix
468 ! coeff : coefficient matrix to fill in.
469 !
c,
e : fill in equation
e, extrapolate component
c
470 !
i1,
i2,i3 : marks
the boundary point, ghost points will be assigned to
assign
471 ! orderOfExtrap : order of extrapolation
472 ! ghost : point line to extrapolate (ghost=1,2,..)
473 ! ===============================================================================================
474 #beginMacro fillMatrixExtrapolation(coeff, c,e,i1,i2,i3,orderOfExtrap,ghost)
475 if( orderOfExtrap.lt.1 .or. orderOfExtrap.gt.maxOrderOfExtrapolation )then
478 i1m=i1-is1*(ghost) ! ghost point
482 j1=i1m+is1*m ! m-th point moving inward from
the ghost point (i1,i2,i3)
486 coeff(mm,i1m,i2m,i3m)=extrapCoeff(m,orderOfExtrap) ! m=0,1,2,..
488 setEquationNumber(mm, e,i1m,i2m,i3m, c,j1,j2,j3 ) !macro to set equationNumber
490 setClassify(e,i1m,i2m,i3m, extrapolation) !macro to set classify
494 ! ===============================================================================================
495 ! Add
a Neumann or mixed BC to
the matrix
498 ! coeff : coefficient matrix to fill in.
499 ! c,e : fill in equation
e, extrapolate component c
500 !
i1,
i2,i3 : boundary point (will
assign equations on
the ghost point)
501 ! an(0:2) : holds
the outward
normal vector
502 !
a0,a1 : coefficients of
the mixed BC
503 ! ===============================================================================================
504 #beginMacro fillMatrixNeumann(coeff, c,e, i1,i2,i3, an,
a0,a1 )
506 ! Evaluate
the jacobian derivatives used by
the coefficient and forward derivatives:
507 ! opEvalJacobianDerivatives(MAXDER) : MAXDER = max number of derivatives to precompute.
508 opEvalJacobianDerivatives(aj,0)
511 ! getCoeff(identity, iCoeff,aj)
512 getCoeff(
x, xCoeff,aj)
513 getCoeff(y, yCoeff,aj)
514 getCoeff(identity, iCoeff,aj)
516 getCoeff(z, zCoeff,aj)
519 i1m=i1-is1 ! ghost point
523 beginMatrixLoops(m1,m2,m3)
528 coeff(mm,i1m,i2m,i3m)=a1*(an(0)*xCoeff(m)+an(1)*yCoeff(m))+
a0*iCoeff(m)
530 coeff(mm,i1m,i2m,i3m)=a1*(an(0)*xCoeff(m)+an(1)*yCoeff(m)+an(2)*zCoeff(m))\
534 ! The equation
for pt (e,i1m,i2m,i3m) is centered on (c,i1,i2,i3):
535 setEquationNumber(mm, e,i1m,i2m,i3m, c,i1+m1,i2+m2,i3+m3 ) !macro to set equationNumber
538 setClassify(e,i1m,i2m,i3m, ghost1) !macro to set classify
542 ! ===============================================================================================
543 ! Add
a Vector Symmetry BC to
the matrix
545 ! coeff : coefficient matrix to fill in.
546 ! cmpu,eqnu : fill in equations eqnu,...,eqnu+nd-1 and
components cmpu,...,cmpu+nd-1
547 ! i1,i2,i3 : boundary point, will
assign ghost point
550 ! E1:
n.u(-1) = -
n.u(1)
551 ! E2: t.u(-1) = t.u(1)
552 ! or -> [ u(-1) - (
n.u(-1))
n ] = [ u(1) - (
n.u(1))
n ]
554 ! [
n.u(-1) +
n.u(1)]
n + [ u(-1) - (
n.u(-1))
n ] - [ u(1) - (
n.u(1))
n ] = 0
556 ! u(-1) - u(1) + 2*(
n.u(1))
n = 0
557 ! ===============================================================================================
558 #beginMacro fillMatrixVectorSymmetry(coeff, cmpu,eqnu, i1,i2,i3, an )
560 ! write(*,
'(" VS: i1,i2=",2i2," normal=",2f5.2)') i1,i2,an(0),an(1)
562 i1m=i1-is1 ! ghost point
567 coeff(m,i1m,i2m,i3m)=0. !
init all elements to zero
576 mm=
MCE(mv(0),mv(1),mv(2),c,e) ! matrix index
for ghost pt
577 coeff(mm,i1m,i2m,i3m)=1. ! coeff of ghost point
578 setEquationNumber(mm, e,i1m,i2m,i3m, c,i1+mv(0),i2+mv(1),i3+mv(2) ) !macro to set equationNumber
581 mm=
MCE(mv(0),mv(1),mv(2),c,e) ! matrix index
for first pt inside
582 coeff(mm,i1m,i2m,i3m)=-1.
583 setEquationNumber(mm, e,i1m,i2m,i3m, c,i1+mv(0),i2+mv(1),i3+mv(2) ) !macro to set equationNumber
585 ! now add on
the term: 2*(
n.u(1))
n
587 mm=
MCE(mv(0),mv(1),mv(2),c,e) ! matrix index
for first pt inside
588 ! write(*,
'(" VS: mm,i1,i2,e,c=",5i2," n,n=",2f5.2)') mm,i1,i2,e,c,an(c-cmpu),an(e-eqnu)
589 coeff(mm,i1m,i2m,i3m)=coeff(mm,i1m,i2m,i3m) + 2.*an(c-cmpu)*an(e-eqnu)
590 setEquationNumber(mm, e,i1m,i2m,i3m, c,i1+mv(0),i2+mv(1),i3+mv(2) ) !macro to set equationNumber
593 setClassify(e,i1m,i2m,i3m, ghost1) !macro to set classify
597 ! ===============================================================================================
599 !
This macro does nothing on Cartesian grids.
600 ! ===============================================================================================
601 #beginMacro getNormalForCurvilinearGrid(
side,
axis,i1,i2,i3)
602 #If $GRIDTYPE ==
"curvilinear"
604 an(0)=rsxy(i1,i2,i3,
axis,0)
605 an(1)=rsxy(i1,i2,i3,
axis,1)
607 anNorm = (2*
side-1)/max( epsX, sqrt( an(0)**2 + an(1)**2 ) )
611 an(2)=rsxy(i1,i2,i3,
axis,2)
612 anNorm = (2*
side-1)/max( epsX, sqrt( an(0)**2 + an(1)**2 + an(2)**2 ) )
621 ! *************************************************************************************
624 ! ==============================================================================================================
625 ! Fill in
the coefficients
for an equation
626 ! ==============================================================================================================
627 #beginMacro fillCoeff()
629 #defineMacro
MCE(m1,m2,m3,c,e) mce2(m1,m2,m3,c,e)
630 #defineMacro MA(m1,m2,m3) ma2(m1,m2,m3)
632 #defineMacro
MCE(m1,m2,m3,c,e) mce3(m1,m2,m3,c,e)
633 #defineMacro MA(m1,m2,m3) ma3(m1,m2,m3)
636 !
the next macro is defined in insImpINS.bf, or insImpVP.bf, etc.
641 ! ======================================================================
642 ! Macro to fill in
the matrix with BC-s
645 ! Implicit parameters:
647 ! $GRIDTYPE :
"rectangular" or
"curvilinear"
648 ! ======================================================================
649 #beginMacro fillMatrixBoundaryConditions()
650 if( fillCoefficients.eq.1 .or. evalResidualForBoundaryConditions.eq.1 )then
653 #defineMacro
MCE(m1,m2,m3,c,e) mce2(m1,m2,m3,c,e)
654 #defineMacro MA(m1,m2,m3) ma2(m1,m2,m3)
656 #defineMacro
MCE(m1,m2,m3,c,e) mce3(m1,m2,m3,c,e)
657 #defineMacro MA(m1,m2,m3) ma3(m1,m2,m3)
686 #If $GRIDTYPE ==
"rectangular"
694 !
the next macro is defined in insImpINS.bf, or insImpVP.bf, etc.
695 fillMatrixBoundaryConditionsPDE()
696 getBoundaryResidualPDE()
700 !* fillMatrixBoundaryConditionsOnAFaceINS(normal00)
701 !* getBoundaryResidualINS(normal00)
703 !* fillMatrixBoundaryConditionsOnAFaceINS(normal10)
704 !* getBoundaryResidualINS(normal10)
706 !* fillMatrixBoundaryConditionsOnAFaceINS(normal01)
707 !* getBoundaryResidualINS(normal10)
709 !* fillMatrixBoundaryConditionsOnAFaceINS(normal11)
710 !* getBoundaryResidualINS(normal11)
712 !* fillMatrixBoundaryConditionsOnAFaceINS(normal02)
713 !* getBoundaryResidualINS(normal02)
715 !* fillMatrixBoundaryConditionsOnAFaceINS(normal12)
716 !* getBoundaryResidualINS(normal12)
723 n1a=indexRange(0,
axis)
724 n1b=indexRange(1,
axis)
726 n2a=indexRange(0,
axis)
727 n2b=indexRange(1,
axis)
729 n3a=indexRange(0,
axis)
730 n3b=indexRange(1,
axis)
739 ! ===================================================================================
740 ! Macro to evaluate
the RHS
741 ! ===================================================================================
742 #beginMacro assignRHS(PDE)
743 !
the next macro is defined in insImpINS.bf, or insImpVP.bf, etc.
748 ! ==============================================================================================================
749 ! Compute
the coefficient of
the artificial dissipation
750 ! ==============================================================================================================
762 #defineMacro uDiss22(u,
uc) (u(i1-1,i2,i3,
uc)+u(i1,i2-1,i3,
uc)+u(i1+1,i2,i3,
uc)+u(i1,i2+1,i3,
uc)-4.*u(i1,i2,i3,
uc))
763 #defineMacro uDiss23(u,
uc) (u(i1-1,i2,i3,
uc)+u(i1,i2-1,i3,
uc)+u(i1,i2,i3-1,
uc)+u(i1+1,i2,i3,
uc)+u(i1,i2+1,i3,
uc)+u(i1,i2,i3+1,
uc)-6.*u(i1,i2,i3,
uc))
766 #beginMacro INSIMP(NAME,PDE)
767 subroutine NAME(nd,nd1a,nd1b,nd2a,nd2b,nd3a,nd3b,nd4a,nd4b,\
768 mask,xy,rsxy,radiusInverse, u, ndc, coeff, fe,fi,ul, gv,gvl,
dw,
ndMatProp,matIndex,matValpc,matVal, bc, \
769 boundaryCondition, ndbcd1a,ndbcd1b,ndbcd2a,ndbcd2b,ndbcd3a,ndbcd3b,ndbcd4a,ndbcd4b,bcData,\
770 nde, equationNumber, classify, \
771 nr1a,nr1b,nr2a,nr2b,nr3a,nr3b, \
772 ipar, rpar, pdb, ierr )
773 c======================================================================
775 c Incompressible Navier Stokes IMPlicit
776 c -------------------------------------
778 c 1. Build
the coefficient matrix
for implicit methods
781 c nd : number of
space dimensions
782 c nd1a,nd1b,nd2a,nd2b,nd3a,nd3b : array dimensions
787 c coeff(m,i1,i2,i3) : array holding
the matrix coefficients
788 c u : holds
the current solution, used to
form the coeff matrix.
789 c fe : holds
the explicit part when evaluating
the RHS
790 c fi : holds
the implicit part when evaluating
the RHS
791 c ul : holds
the linearized solution, used when evaluating
the linearized operator and
RHS
792 c gv : gridVelocity
for moving grids
793 c
dw : distance to
the wall
for some turbulence models
795 c======================================================================
797 integer nd, ndc, n1a,n1b,n2a,n2b,n3a,n3b,
798 & nd1a,nd1b,nd2a,nd2b,nd3a,nd3b,nd4a,nd4b
799 integer nde,nr1a,nr1b,nr2a,nr2b,nr3a,nr3b
801 real u(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
803 real coeff(0:ndc-1,nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
805 real fe(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
806 real fi(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
808 real ul(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,nd4a:nd4b)
810 real gv(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1)
811 real gvl(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1)
812 real
dw(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
813 real xy(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1)
814 real rsxy(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:nd-1,0:nd-1)
815 real radiusInverse(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
817 integer
mask(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
820 integer ndbcd1a,ndbcd1b,ndbcd2a,ndbcd2b,ndbcd3a,ndbcd3b,ndbcd4a,ndbcd4b
821 real bcData(ndbcd1a:ndbcd1b,ndbcd2a:ndbcd2b,ndbcd3a:ndbcd3b,ndbcd4a:ndbcd4b)
823 integer equationNumber(0:nde-1,nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
824 integer classify(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:*)
829 double precision pdb ! pointer to
data base
831 ! -- arrays
for variable material properties --
832 integer constantMaterialProperties
833 integer piecewiseConstantMaterialProperties
835 parameter( constantMaterialProperties=0,\
836 piecewiseConstantMaterialProperties=1,\
839 integer matIndex(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b)
841 real matVal(nd1a:nd1b,nd2a:nd2b,nd3a:nd3b,0:*)
843 c ---- local variables -----
844 integer c,e,i1,i2,i3,m1,m2,m3,j1,j2,j3,ghostLine,
n,i1m,i2m,i3m,i1p,i2p,i3p,ndu
846 integer kd,kd3,
orderOfAccuracy,gridIsMoving,orderOfExtrap,orderOfExtrapolation,orderOfExtrapolationForOutflow
847 integer numberOfComponentsForCoefficients,stencilSize
848 integer gridIsImplicit,implicitOption,implicitMethod,
849 & isAxisymmetric,
use2ndOrderAD,use4thOrderAD,fillCoefficientsScalarSystem
850 integer
pc,
uc,
vc,
wc,sc,
nc,
kc,
ec,
tc,qc,vsc,rc,
grid,m,advectPassiveScalar
851 real nu,dt,nuPassiveScalar,adcPassiveScalar
853 real dxi,dyi,dzi,
dri,dsi,dti,dr2i,ds2i,dt2i
855 real ad21n,ad22n,ad41n,ad42n,cd22n,cd42n
857 real an(0:2),anNorm, advectionCoefficient
858 integer checkForInflowAtOutFlow, outflowOption
861 integer fillCoefficients,evalRightHandSide,evalResidual,evalResidualForBoundaryConditions
863 real ugv,vgv,wgv, ugvl,vgvl,wgvl
865 integer equationNumberBase1,equationNumberLength1,equationNumberBase2,equationNumberLength2,\
866 equationNumberBase3,equationNumberLength3,equationOffset
869 integer rectangular,curvilinear
870 parameter( rectangular=0, curvilinear=1 )
872 integer turbulenceModel,noTurbulenceModel
873 integer baldwinLomax,spalartAllmaras,kEpsilon,kOmega,largeEddySimulation
874 parameter (noTurbulenceModel=0,baldwinLomax=1,kEpsilon=2,kOmega=3,spalartAllmaras=4,largeEddySimulation=5 )
876 integer computeAllTerms,
877 & doNotComputeImplicitTerms,
878 & computeImplicitTermsSeparately,
879 & computeAllWithWeightedImplicit
882 & doNotComputeImplicitTerms=1,
883 & computeImplicitTermsSeparately=2,
884 & computeAllWithWeightedImplicit=3 )
888 real ulterm,vlterm,wlterm,qlterm
890 integer nonlinearTermsAreImplicit,evalLinearizedDerivatives
892 integer implicitVariation
893 integer implicitViscous, implicitAdvectionAndViscous, implicitFullLinearized
895 & implicitAdvectionAndViscous=1,
896 & implicitFullLinearized=2 )
898 integer pdeModel,standardModel,BoussinesqModel,viscoPlasticModel,twoPhaseFlowModel
899 parameter( standardModel=0,BoussinesqModel=1,viscoPlasticModel=2,twoPhaseFlowModel=3 )
912 interfaceBoundaryCondition,\
913 neumannBoundaryCondition
918 symmetry=11,axisymmetric=13,interfaceBoundaryCondition=17,neumannBoundaryCondition=101 )
920 ! classifyTypes from SparseRep.
h
922 integer interior,boundary,ghost1,ghost2,ghost3,ghost4,
interpolation,periodic,extrapolation,unused
934 !
the following define which component to fill
for a scalar coeff problem
935 integer fillCoeffU,fillCoeffV,fillCoeffW,fillCoeffT
936 parameter( fillCoeffU=1,fillCoeffV=2,fillCoeffW=3,fillCoeffT=4 )
940 real dr(0:2), dx(0:2)
942 integer ma2(-5:5,-5:5,0:0), ma3(-5:5,-5:5,-5:5)
945 integer
ncc,width,halfWidth,halfWidth3
947 integer maxWidth,maxWidthDim
948 parameter( maxWidth=5,maxWidthDim=maxWidth*maxWidth*maxWidth )
949 real iCoeff(0:maxWidthDim-1)
950 real xCoeff(0:maxWidthDim-1)
951 real yCoeff(0:maxWidthDim-1)
952 real zCoeff(0:maxWidthDim-1)
953 real lapCoeff(0:maxWidthDim-1)
954 real divSGradCoeff(0:maxWidthDim-1)
955 real dissCoeff(0:maxWidthDim-1)
958 real ulx,uly,ulz, vlx,vly,vlz, wlx,wly,wlz, plx,ply,plz, qlx,qly,qlz
959 real u0x,
u0y,
u0z,u0xx,u0xy,u0xz,u0yy,u0yz,u0zz
960 real
v0x,
v0y,
v0z,v0xx,v0xy,v0xz,v0yy,v0yz,v0zz
961 real
w0x,
w0y,w0z,w0xx,w0xy,w0xz,w0yy,w0yz,w0zz
962 real q0x,q0y,q0z,q0xx,q0xy,q0xz,q0yy,q0yz,q0zz
963 integer eqn,eqnu,eqnv,eqnw,eqnq,eqnk,eqne
964 integer cmp,cmpu,cmpv,cmpw,cmpq,cmpk,cmpe
966 ! temp variables
for coeff macros:
967 real cur,cus,cut,curr,curs,curt,cuss,cust,cutt
969 ! --- visco plastic variables ---
970 real dr0i,dr1i,dr0dr1,dr0dr2,dr1dr2
971 real divNuGradu,divNuGradv,divNuGradw,divNuGradul,divNuGradvl,divNuGradwl
972 real dxvsqi(0:2),dtImp
974 !
This include file (created in insImpINS.bf or insImpVP, ...) declares variables needed by each version
975 declareInsImpTemporaryVariables()
977 integer maxOrderOfExtrapolation
979 real extrapCoeff(0:maxOrderOfExtrapolation,1:maxOrderOfExtrapolation)
981 integer numberOfComponents
984 real rhopc,rhov, Cppc, Cpv, thermalKpc, thermalKv, Kx, Ky, Kz, Kr, Ks, Kt
987 rx(i1,i2,i3)=rsxy(i1,i2,i3,0,0)
988 ry(i1,i2,i3)=rsxy(i1,i2,i3,0,1)
989 rz(i1,i2,i3)=rsxy(i1,i2,i3,0,2)
990 sx(i1,i2,i3)=rsxy(i1,i2,i3,1,0)
991 sy(i1,i2,i3)=rsxy(i1,i2,i3,1,1)
992 sz(i1,i2,i3)=rsxy(i1,i2,i3,1,2)
993 tx(i1,i2,i3)=rsxy(i1,i2,i3,2,0)
994 ty(i1,i2,i3)=rsxy(i1,i2,i3,2,1)
995 tz(i1,i2,i3)=rsxy(i1,i2,i3,2,2)
997 ! c=component, e=equation
999 mce2(m1,m2,m3,c,e) = ma2(m1,m2,m3) + stencilSize*(c+
ncc*e)
1000 mce3(m1,m2,m3,c,e) = ma3(m1,m2,m3) + stencilSize*(c+
ncc*e)
1001 ce(c,e) = stencilSize*(c+
ncc*e)
1003 ! statement
functions to access coefficients of mixed-boundary conditions
1009 ! -- statement
functions for variable material properties
1011 rhopc(i1,i2,i3) = matValpc( 0, matIndex(i1,i2,i3))
1012 Cppc(i1,i2,i3) = matValpc( 1, matIndex(i1,i2,i3))
1013 thermalKpc(i1,i2,i3) = matValpc( 2, matIndex(i1,i2,i3))
1016 rhov(i1,i2,i3) = matVal(i1,i2,i3,0)
1017 Cpv(i1,i2,i3) = matVal(i1,i2,i3,1)
1018 thermalKv(i1,i2,i3) = matVal(i1,i2,i3,2)
1023 1.,-1.,0.,0.,0.,0.,0.,0.,0.,0., \
1024 1.,-2.,1.,0.,0.,0.,0.,0.,0.,0., \
1025 1.,-3.,3.,-1.,0.,0.,0.,0.,0.,0., \
1026 1.,-4.,6.,-4.,1.,0.,0.,0.,0.,0., \
1027 1.,-5.,10.,-10.,5.,-1.,0.,0.,0.,0., \
1028 1.,-6.,15.,-20.,15.,-6.,1.,0.,0.,0., \
1029 1.,-7.,21.,-35.,35.,-21.,7.,-1.,0.,0., \
1030 1.,-8.,28.,-56.,70.,-56.,28.,-8.,1.,0., \
1031 1.,-9.,36.,-84.,126.,-126.,84.,-36.,9.,-1./
1033 ! write(*,
'("Inside insdt: gridType=",i2)')
gridType
1051 gridIsMoving =ipar(15) ! *************
1053 implicitVariation =ipar(16) ! **new**
1055 fillCoefficients =ipar(17) ! new
1056 evalRightHandSide =ipar(18) ! new
1058 gridIsImplicit =ipar(19)
1059 implicitMethod =ipar(20)
1060 implicitOption =ipar(21)
1061 isAxisymmetric =ipar(22)
1063 use4thOrderAD =ipar(24)
1064 advectPassiveScalar=ipar(25)
1066 turbulenceModel =ipar(27)
1068 numberOfComponentsForCoefficients =ipar(29) ! number of
components for coefficients
1069 stencilSize =ipar(30)
1071 equationOffset = ipar(31)
1072 equationNumberBase1 = ipar(32)
1073 equationNumberLength1 = ipar(33)
1074 equationNumberBase2 = ipar(34)
1075 equationNumberLength2 = ipar(35)
1076 equationNumberBase3 = ipar(36)
1077 equationNumberLength3 = ipar(37)
1079 indexRange(0,0) =ipar(38)
1080 indexRange(1,0) =ipar(39)
1081 indexRange(0,1) =ipar(40)
1082 indexRange(1,1) =ipar(41)
1083 indexRange(0,2) =ipar(42)
1084 indexRange(1,2) =ipar(43)
1086 orderOfExtrapolation=ipar(44)
1087 orderOfExtrapolationForOutflow=ipar(45)
1089 evalResidual = ipar(46)
1090 evalResidualForBoundaryConditions=ipar(47)
1092 numberOfComponents= ipar(49)
1104 dt =rpar(6) ! **new**
1105 implicitFactor =rpar(7) ! **new**
1112 nuPassiveScalar =rpar(13)
1113 adcPassiveScalar =rpar(14)
1118 yEps =rpar(19) !
for axisymmetric
1120 gravity(0) =rpar(20)
1121 gravity(1) =rpar(21)
1122 gravity(2) =rpar(22)
1124 adcBoussinesq =rpar(24) ! coefficient of artificial diffusion
for Boussinesq
T equation
1127 epsX = 1.e-30 ! epsilon used to avoid division by zero in
the normal computation -- should be REAL_MIN*100 ??
1129 ncc=numberOfComponentsForCoefficients ! number of
components for coefficients
1131 ok =
getInt(pdb,
'checkForInflowAtOutFlow',checkForInflowAtOutFlow)
1133 write(*,
'("*** NAME:ERROR: checkForInflowAtOutFlow NOT FOUND")')
1135 if( debug.
gt.4 )then
1136 write(*,
'("*** NAME:checkForInflowAtOutFlow=",i6)') checkForInflowAtOutFlow
1139 ok =
getInt(pdb,
'outflowOption',outflowOption)
1141 write(*,
'("*** NAME:ERROR: outflowOption NOT FOUND")')
1143 if( debug.
gt.4 )then
1144 write(*,
'("*** NAME:outflowOption=",i6)') outflowOption
1148 ok = getReal(pdb,
'advectionCoefficient',advectionCoefficient)
1150 write(*,
'("*** NAME:ERROR: advectionCoefficient NOT FOUND")')
1152 if( debug.
gt.4 )then
1153 write(*,
'("*** NAME:advectionCoefficient=",f5.2)') advectionCoefficient
1160 write(*,
'("*** NAME:ERROR: vsc NOT FOUND")')
1163 ntdc = nd ! number of time dependent
components
1164 if( pdeModel.eq.BoussinesqModel .or. pdeModel.eq.viscoPlasticModel )then
1165 ntdc = ntdc+1 ! include Temperature
1171 ok =
getInt(pdb,
'fillCoefficientsScalarSystem',fillCoefficientsScalarSystem)
1173 write(*,
'("*** NAME:ERROR: fillCoefficientsScalarSystem NOT FOUND")')
1175 if( debug.
gt.4 )then
1176 write(*,
'("*** NAME:fillCoefficientsScalarSystem=",i6)') fillCoefficientsScalarSystem
1185 write(*,
'("NAME:ERROR gridType=",i6)')
gridType
1188 if(
uc.lt.0 .or.
vc.lt.0 .or. (nd.eq.3 .and.
wc.lt.0) )then
1189 write(*,
'("NAME:ERROR uc,vc,ws=",3i6)')
uc,
vc,
wc
1193 c write(*,
'("NAME: turbulenceModel=",2i6)') turbulenceModel
1194 c write(*,
'("NAME: nd,uc,vc,wc,kc=",2i6)') nd,
uc,
vc,
wc,
kc
1196 if( turbulenceModel.eq.kEpsilon .and. (
kc.lt.
uc+nd .or.
kc.
gt.1000) )then
1197 write(*,
'("NAME:ERROR in kc: nd,uc,vc,wc,kc=",2i6)') nd,
uc,
vc,
wc,
kc
1202 ! *****************************************************************************************************8
1203 ! ** it did not affect performance to use an array to index coeff ***
1205 width =
orderOfAccuracy+1 ! width of
the MATRIX stencil *********** fix this **********
1206 halfWidth = (width-1)/2
1210 do i2=-halfWidth,halfWidth
1211 do i1=-halfWidth,halfWidth
1212 ma2(i1,i2,0)=i1+halfWidth+width*(i2+halfWidth)
1216 halfWidth3=halfWidth
1217 do i3=-halfWidth,halfWidth
1218 do i2=-halfWidth,halfWidth
1219 do i1=-halfWidth,halfWidth
1220 ma3(i1,i2,i3)=i1+halfWidth+width*(i2+halfWidth+width*(i3+halfWidth))
1237 dxvsqi(m)=1./(dx(m)**2)
1241 if( debug .
gt.3 )then
1242 write(*,
'(" NAME: INFO: 2nd order art-diss is on: ad21,ad22=",2(e9.2,1x))')
ad21,
ad22
1248 cd22=
ad22/(nd**2) !
for 2nd-order artificial dissipation
1250 if( pdeModel.eq.BoussinesqModel )then
1251 if( debug .
gt.3 )then
1252 write(*,
'(" NAME: INFO: Boussinesq: kThermal,adcBoussinesq=",2(e9.2,1x))') kThermal,
adcBoussinesq
1257 ! *** define constants in
the implicit operator
1260 cmpu=
uc-
uc ! component number
for u in
the matrix
1264 cmpq=
tc-
uc ! temperature
1269 if( fillCoefficientsScalarSystem.ge.fillCoeffU .and. fillCoefficientsScalarSystem.le.fillCoeffW )then
1270 ! we are filling
a scalar matrix
for one component of
the velocity
1275 else if( fillCoefficientsScalarSystem.eq.fillCoeffT )then
1276 ! we are filling
a scalar matrix
for T
1283 eqnu=cmpu ! equation number
for u in
the matrix
1290 dtImp=dt*implicitFactor
1292 nuDt= nu*dt*implicitFactor ! matrix: coefficient of Laplacian in
the matrix
1293 kDt = kThermal*dt*implicitFactor !
for T equation
1294 aDt = dt*implicitFactor ! matrix: coefficient of advection terms in
the matrix
1295 bDt = dt*implicitFactor ! matrix: coefficient of extra zero-order linearized terms such as
u0.
x
1299 aImp=1. !
RHS: coeff of implicit advection terms
1300 bImp=1. !
RHS: coefficient of extra zero-order linearized terms such as
u0.
x
1302 ! aImp=(1.-implicitFactor) !
RHS: coeff of implicit advection terms
1303 ! aExp=0. ! advection terms are implicit
1305 ! **
NOTE: we force
the buoyancy terms to be explicit below **
1306 tImp=1. ! coefficient of
the implicit buoyancy term (set to zero
if not implicit)
1307 if( fillCoefficientsScalarSystem.ne.0 )then
1308 tImp=0. ! buoyancy term is not implicit when we
solve scalar systems
1312 nonlinearTermsAreImplicit=0
1313 if( implicitVariation.eq.implicitViscous )then
1314 aDt=0. ! matrix: advection terms are NOT implicit
1315 bDt=0. ! matrix: zero-order linearized terms are NOT implicit
1316 ! aExp=1. ! advection terms are explicit
1317 aImp=0. !
RHS: coeff of implicit advection terms
1319 tImp=0. ! Boussinesq terms are explicit
1320 else if( implicitVariation.eq.implicitAdvectionAndViscous )then
1321 nonlinearTermsAreImplicit=1
1325 else if( implicitVariation.eq.implicitFullLinearized )then
1326 nonlinearTermsAreImplicit=1
1331 write(*,
'(" NAME: ERROR: unexpected implicitVariation=",i6)') implicitVariation
1335 ! *** force
the buoyancy term to be explicit : (we could add this as an option)
1336 !
if the main balance in
the momentum is
grad(p) = - alpha*g*
T then we want both these
1337 ! terms to be explicit.
1342 ! The next macro is defined in insImpXX.bf and is used to look up parameters etc.
1343 initializePdeParameters()
1346 if( debug.
gt.3 )then
1347 if( evalRightHandSide.eq.1 )then
1348 write(*,
'("NAME: *EVAL RHS : implicitOption=",i2," (0=all,1=none,2=sep,3=all)")') implicitOption
1351 if( debug.
gt.7 )then
1352 if( evalRightHandSide.eq.1 )then
1353 write(*,
'("NAME: ******** EVAL RHS **********")')
1355 if( evalResidual.eq.1 )then
1356 write(*,
'("NAME: ******** EVAL RESIDUAL **********")')
1358 if( fillCoefficients.eq.1 )then
1359 write(*,
'("NAME: ******** FILL COEFF **********")')
1363 write(*,'(
"NAME: pdeModel,nonLinear,impVar=",3i4)
') pdeModel,nonlinearTermsAreImplicit,implicitVariation
1364 if( fillCoefficients.eq.1 )then
1365 write(*,'(
"NAME: stencilSize,ncc=",2i4)
') stencilSize,ncc
1367 write(*,'(
"NAME: aDt,bDt,nuDt=",3e10.2)
') aDt,bDt,nuDt
1368 write(*,'(
"NAME: implicitFactor,nuImp,aImp=",f4.2,1
x,3e10.2)
') implicitFactor,nuImp,aImp
1372 if( evalRightHandSide.eq.1 .and. (nonlinearTermsAreImplicit.eq.1 .or.
use2ndOrderAD.ne.0) )then
1373 evalLinearizedDerivatives = 1
1375 evalLinearizedDerivatives = 0
1380 ! Define operator parameters
1381 ! $DIM : number of spatial dimensions
1382 ! $ORDER : order of accuracy of an approximation
1383 ! $GRIDTYPE : rectangular or curvilinear
1384 ! $MATRIX_STENCIL_WIDTH :
space in
the global coeff matrix was allocated to hold this size stencil
1385 ! $STENCIL_WIDTH : stencil width of
the local coeff-matrix (such as xCoeff, yCoeff, lapCoeff, ...)
1386 #perl $ORDER=2; $MATRIX_STENCIL_WIDTH=3; $STENCIL_WIDTH=3;
1389 #perl $DIM=2; $GRIDTYPE="rectangular";
1391 ! fill
the coefficients:
1394 fillMatrixBoundaryConditions()
1398 #perl $DIM=2; $GRIDTYPE="curvilinear";
1400 ! fill
the coefficients:
1403 fillMatrixBoundaryConditions()
1408 #perl $DIM=3; $GRIDTYPE="rectangular";
1410 ! fill
the coefficients:
1413 fillMatrixBoundaryConditions()
1418 #perl $DIM=3; $GRIDTYPE="curvilinear";
1420 ! fill
the coefficients:
1423 fillMatrixBoundaryConditions()