Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
conduct.F90
Go to the documentation of this file.
1 !-----------------------------------------------------------------------
3 subroutine cdscal (igeom)
4  use kinds, only : dp
5  use size_m, only : lx1, ly1, lz1, lelt, nx1, ny1, nz1, nfield, nid
6  use helmholtz, only : hsolve, approx_space
7  use input, only : ifmodel, ifkeps, ifaxis, ifaziv, iftran, iftmsh, ifprint
8  use geom, only : bintm1, binvm1
9  use soln, only : t, bq, tmask, tmult
10  use tstep, only : nelfld, ifield, nmxnl, imesh, tolht, nmxh
11  use ctimer, only : nheat2, theat2, dnekclock
12  implicit none
13 
14  integer, intent(in) :: igeom
15 
16  LOGICAL :: IFCONV
17 
18  real(DP), allocatable :: TA(:,:,:,:), TB(:,:,:,:)
19  real(DP), allocatable :: H1(:,:,:,:), H2(:,:,:,:)
20 
21  real(DP) :: etime
22 
23  type(approx_space), save :: apx
24  character(4) :: name4
25 
26  integer :: nel, ntot, nfldt, if1, isd, iter, intype
27 
28  nel = nelfld(ifield)
29  ntot = nx1*ny1*nz1*nel
30 
31  if (igeom == 1) then ! geometry at t^{n-1}
32  call makeq
33  call lagscal
34  else ! geometry at t^n
35 
36  IF (ifprint) THEN
37  IF (ifmodel .AND. ifkeps) THEN
38  nfldt = nfield - 1
39  IF (ifield == nfldt .AND. nid == 0) THEN
40  WRITE (6,*) ' Turbulence Model - k/epsilon solution'
41  ENDIF
42  ELSE
43  IF (ifield == 2 .AND. nid == 0) THEN
44  WRITE (6,*) ' Temperature/Passive scalar solution'
45  ENDIF
46  ENDIF
47  ENDIF
48  if1=ifield-1
49  write(name4,1) if1-1
50  1 format('PS',i2)
51  if(ifield == 2) write(name4,'(A4)') 'TEMP'
52 
53 
54  ! New geometry
55 
56  isd = 1
57  if (ifaxis .AND. ifaziv .AND. ifield == 2) isd = 2
58  ! if (ifaxis.and.ifmhd) isd = 2 !This is a problem if T is to be T!
59  etime = dnekclock()
60  nheat2 = nheat2 + 1
61  allocate(ta(lx1,ly1,lz1,lelt), tb(lx1,ly1,lz1,lelt))
62  allocate(h1(lx1,ly1,lz1,lelt), h2(lx1,ly1,lz1,lelt))
63  do iter=1,nmxnl ! iterate for nonlin. prob. (e.g. radiation b.c.)
64 
65  intype = 0
66  IF (iftran) intype = -1
67  CALL sethlm(h1,h2,intype)
68  CALL bcneusc(ta,-1)
69  h2 = h2 + ta
70  CALL bcdirsc(t(1,1,1,1,ifield-1))
71  etime = etime - dnekclock()
72  CALL axhelm(ta,t(1,1,1,1,ifield-1),h1,h2,imesh,isd)
73  etime = etime + dnekclock()
74  tb = bq(:,:,:,:,ifield-1) - ta
75  CALL bcneusc(ta,1)
76  tb = tb + ta
77 
78  ! CALL HMHOLTZ (name4,TA,TB,H1,H2
79  ! $ ,TMASK(1,1,1,1,IFIELD-1)
80  ! $ ,TMULT(1,1,1,1,IFIELD-1)
81  ! $ ,IMESH,TOLHT(IFIELD),NMXH,isd)
82 
83  etime = etime - dnekclock()
84  if(iftmsh(ifield)) then
85  call hsolve(name4,ta,tb,h1,h2 &
86  ,tmask(1,1,1,1,ifield-1) &
87  ,tmult(1,1,1,1,ifield-1) &
88  ,imesh,tolht(ifield),nmxh,1 &
89  ,apx,bintm1)
90  else
91  call hsolve(name4,ta,tb,h1,h2 &
92  ,tmask(1,1,1,1,ifield-1) &
93  ,tmult(1,1,1,1,ifield-1) &
94  ,imesh,tolht(ifield),nmxh,1 &
95  ,apx,binvm1)
96  endif
97  etime = etime + dnekclock()
98 
99  t(:,:,:,:,ifield-1) = t(:,:,:,:,ifield-1) + ta
100 
101  call cvgnlps(ifconv) ! Check convergence for nonlinear problem
102  if (ifconv) goto 2000
103 
104  ! Radiation case, smooth convergence, avoid flip-flop (ER).
105  t(:,:,:,:,ifield-1) = t(:,:,:,:,ifield-1) - 0.5_dp*ta
106 
107  END DO
108  2000 CONTINUE
109  deallocate(h1,h2,tb)
110  CALL bcneusc(ta,1)
111  bq(:,:,:,:,ifield-1) = bq(:,:,:,:,ifield-1) + ta ! no idea why... pf
112  deallocate(ta)
113  theat2 = theat2 + (dnekclock() - etime)
114  endif
115 
116  return
117 end subroutine cdscal
118 
119 !-----------------------------------------------------------------------
122 subroutine makeuq
123  use kinds, only : dp
124  use size_m, only : nx1, ny1, nz1
125  use geom, only : bm1
126  use soln, only : bq
127  use tstep, only : time, dt, ifield, nelfld
128  implicit none
129 
130  integer :: ntot
131 
132  ntot = nx1*ny1*nz1*nelfld(ifield)
133 
134  time = time-dt ! Set time to t^n-1 for user function
135 
136  bq(:,:,:,:,ifield-1) = 0._dp
137  call setqvol( bq(1,1,1,1,ifield-1) )
138  bq(:,:,:,:,ifield-1) = bq(:,:,:,:,ifield-1) * bm1
139 
140  time = time+dt ! Restore time
141 
142  return
143 end subroutine makeuq
144 
145 !-----------------------------------------------------------------------
147 subroutine setqvol(bql)
148  use kinds, only : dp
149  use size_m, only : lx1, ly1, lz1, lelt, nx1, ny1, nz1
150  use input, only : igroup, matype, cpgrp
151  use tstep, only : ifield, nelfld
152  implicit none
153 
154  real(DP) :: bql(lx1*ly1*lz1,lelt)
155  real(DP) :: cqvol
156  integer :: nel, nxyz1, ntot1, iel, igrp
157 
158 #ifndef MOAB
159  nel = nelfld(ifield)
160  nxyz1 = nx1*ny1*nz1
161  ntot1 = nxyz1*nel
162 
163  do iel=1,nel
164  igrp = igroup(iel)
165  if (matype(igrp,ifield) == 1) then ! constant source within a group
166  cqvol = cpgrp(igrp,ifield,3)
167  bql(:,iel) = cqvol
168  else ! pff 2/6/96 ............ default is to look at userq
169  call nekuq(bql,iel)
170  endif
171  enddo
172 
173 ! 101 FORMAT(' Wrong material type (',I3,') for group',I3,', field',I2
174 ! $ ,/,' Aborting in SETQVOL.')
175 #else
176 ! pulling in temperature right now, since we dont have anything else
177  call userq2(bql)
178 #endif
179 
180  return
181 end subroutine setqvol
182 
183 !------------------------------------------------------------------
185 !------------------------------------------------------------------
186 subroutine nekuq (bql,iel)
187  use kinds, only : dp
188  use size_m, only : lx1, ly1, lz1, lelt, nx1, ny1, nz1
189  use nekuse, only : qvol
190  use parallel, only : lglel
191  implicit none
192 
193  real(DP) :: bql(lx1,ly1,lz1,lelt)
194  integer :: iel
195 
196  integer :: ielg, k, j, i
197 
198  ielg = lglel(iel)
199  do k=1,nz1
200  do j=1,ny1
201  do i=1,nx1
202  call nekasgn(i,j,k,iel)
203  qvol = 0.0
204  call userq(i,j,k,ielg)
205  bql(i,j,k,iel) = qvol
206  enddo
207  enddo
208  END DO
209 
210  return
211 end subroutine nekuq
212 
213 !-----------------------------------------------------------------------
216 !---------------------------------------------------------------
217 subroutine convab()
218  use kinds, only : dp
219  use size_m, only : nx1, ny1, nz1, lx1, ly1, lz1, lelt
220  use geom, only : bm1
221  use soln, only : t, vtrans, bq
222  use tstep, only : ifield, nelfld
223  implicit none
224 
225  real(DP), allocatable :: TA (:,:,:,:)
226  integer :: nel, ntot1
227 
228  allocate(ta(lx1,ly1,lz1,lelt))
229 
230  nel = nelfld(ifield)
231  ntot1 = nx1*ny1*nz1*nel
232  CALL convop(ta,t(1,1,1,1,ifield-1))
233  bq(:,:,:,:,ifield-1) = bq(:,:,:,:,ifield-1) - bm1*ta *vtrans(:,:,:,:,ifield)
234 
235  return
236 end subroutine convab
237 
238 !-----------------------------------------------------------------------
240 subroutine makeabq
241  use kinds, only : dp
242  use size_m, only : nx1, ny1, nz1, lx1, ly1, lz1, lelt
243  use soln, only : vgradt1, vgradt2, bq
244  use tstep, only : ab, ifield, nelfld
245  implicit none
246 
247  real(DP), allocatable :: TA (:,:,:,:)
248  real(DP) :: ab0, ab1, ab2
249  integer :: nel, ntot1
250 
251  allocate(ta(lx1,ly1,lz1,lelt))
252 
253  ab0 = ab(1)
254  ab1 = ab(2)
255  ab2 = ab(3)
256  nel = nelfld(ifield)
257  ntot1 = nx1*ny1*nz1*nel
258 
259  ta = ab1*vgradt1(:,:,:,:,ifield-1) + ab2*vgradt2(:,:,:,:,ifield-1)
260  vgradt2(:,:,:,:,ifield-1) = vgradt1(:,:,:,:,ifield-1)
261  vgradt1(:,:,:,:,ifield-1) = bq(:,:,:,:,ifield-1)
262  bq(:,:,:,:,ifield-1) = ab0*bq(:,:,:,:,ifield-1) + ta
263 
264  return
265 end subroutine makeabq
266 
267 !-----------------------------------------------------------------------
269 !-----------------------------------------------------------------------
270 subroutine makebdq()
271  use kinds, only : dp
272  use size_m, only : lx1, ly1, lz1, lelt
273  use size_m, only : nx1, ny1, nz1
274  use geom, only : ifgeom
275  use geom, only : bm1, bm1lag
276  use soln, only : vtrans, t, tlag, bq
277  use tstep, only : ifield, nelfld, dt, bd, nbd
278  implicit none
279 
280  real(DP), allocatable :: TB(:,:,:,:)
281 
282  integer :: nel, ntot1, ilag
283 
284  allocate(tb(lx1,ly1,lz1,lelt))
285 
286  nel = nelfld(ifield)
287  ntot1 = nx1*ny1*nz1*nel
288 
289  tb = bd(2) * bm1 * t(:,:,:,:,ifield-1)
290 
291  DO ilag=2,nbd
292  IF (ifgeom) THEN
293  tb = tb + bd(ilag+1) * bm1lag(:,:,:,:,ilag-1) * tlag(:,:,:,:,ilag-1, ifield-1)
294  ELSE
295  tb = tb + bd(ilag+1) * bm1 * tlag(:,:,:,:,ilag-1,ifield-1)
296  ENDIF
297  END DO
298 
299  tb = (1./dt) * tb * vtrans(:,:,:,:,ifield)
300  bq(:,:,:,:,ifield-1) = bq(:,:,:,:,ifield-1) + tb
301 
302  return
303 end subroutine makebdq
304 
305 !-----------------------------------------------------------------------
307 !-----------------------------------------------------------------------
308 subroutine lagscal
309  use size_m, only : nx1, ny1, nz1
310  use soln, only : t, tlag
311  use tstep, only : ifield, nelfld, nbdinp
312  implicit none
313 
314  integer :: ntot1, ilag
315  ntot1 = nx1*ny1*nz1*nelfld(ifield)
316 
317  DO 100 ilag=nbdinp-1,2,-1
318  CALL copy(tlag(1,1,1,1,ilag ,ifield-1), &
319  tlag(1,1,1,1,ilag-1,ifield-1),ntot1)
320  100 END DO
321 
322  CALL copy(tlag(1,1,1,1,1,ifield-1),t(1,1,1,1,ifield-1),ntot1)
323 
324  return
325  end subroutine lagscal
326 
327 !-----------------------------------------------------------------------
cleaned
Definition: tstep_mod.F90:2
Input parameters from preprocessors.
Definition: input_mod.F90:11
subroutine bcneusc(S, ITYPE)
Apply Neumann boundary conditions to surface of scalar, S. Use IFIELD as a guide to which boundary co...
Definition: bdry.F90:840
Definition: soln_mod.F90:1
Type to hold the approximation space. Should not be modified outside this module, so more of a handle...
Definition: navier4.F90:25
subroutine makeq()
Generate forcing function for the solution of a passive scalar. !! NOTE: Do not change the content of...
Definition: makeq.F90:6
subroutine sethlm(h1, h2, intloc)
Set the variable property arrays H1 and H2 in the Helmholtz equation. (associated with variable IFIEL...
Definition: subs1.F90:694
subroutine axhelm(au, u, helm1, helm2, imesh, isd)
Compute the (Helmholtz) matrix-vector product, AU = helm1*[A]u + helm2*[B]u, for NEL elements...
Definition: hmholtz.F90:79
subroutine, public hsolve(name, u, r, h1, h2, vmk, vml, imsh, tol, maxit, isd, apx, bi)
Either std. Helmholtz solve, or a projection + Helmholtz solve.
Definition: navier4.F90:396
subroutine makeuq
Fill up user defined forcing function and collocate will the mass matrix on the Gauss-Lobatto mesh...
Definition: conduct.F90:122
real(dp) function dnekclock()
Definition: ctimer_mod.F90:103
subroutine makeabq
Sum up contributions to 3rd order Adams-Bashforth scheme.
Definition: conduct.F90:240
integer function lglel(iel)
subroutine copy(a, b, n)
Definition: math.F90:52
subroutine bcdirsc(S)
Apply Dirichlet boundary conditions to surface of scalar, S. Use IFIELD as a guide to which boundary ...
Definition: bdry.F90:748
subroutine cvgnlps(ifconv)
Check convergence for non-linear passisve scalar solver. Relevant for solving heat transport problems...
Definition: subs1.F90:135
cleaned
Definition: parallel_mod.F90:2
subroutine makebdq()
Add contributions to F from lagged BD terms.
Definition: conduct.F90:270
Geometry arrays.
Definition: geom_mod.F90:2
subroutine nekasgn(IX, IY, IZ, IEL)
Assign NEKTON variables for definition (by user) of boundary conditions at collocation point (IX...
Definition: bdry.F90:1014
subroutine lagscal
Keep old passive scalar field(s)
Definition: conduct.F90:308
subroutine nekuq(bql, iel)
Generate user-specified volumetric source term (temp./p.s.)
Definition: conduct.F90:186
subroutine setqvol(bql)
Set user specified volumetric forcing function (e.g. heat source).
Definition: conduct.F90:147
subroutine convab()
Eulerian scheme, add convection term to forcing function at current time step.
Definition: conduct.F90:217
cleaned
Definition: nekuse_mod.F90:2
subroutine cdscal(igeom)
Solve the convection-diffusion equation for passive scalar IPSCAL.
Definition: conduct.F90:3