Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
convect.F90
Go to the documentation of this file.
1 !-----------------------------------------------------------------------
2 ! Stability limits:
3 ! AB3: .7236 w/safety (1.2): .603
4 ! RK3: 1.73 (sqrt 3) w/safety (1.2): 1.44
5 ! RK4: 2.828 w/safety (1.2): 2.36
6 ! SEM Safety factor: 1.52 for N=3
7 ! < 1.20 for N=16
8 ! ~ 1.16 for N=256
9 !-----------------------------------------------------------------------
10 #define INLINE_INTP
11 subroutine setup_convect(igeom)
12  use dealias, only : vxd, vyd, vzd
13  use input, only : param, ifchar, ifcons, ifpert
14  use soln, only : vx, vy, vz
15  implicit none
16 
17  integer, intent(in) :: igeom
18 
19  if (igeom == 1) return
20  if (param(99) < 0) return ! no dealiasing
21 
22  if (ifchar) then
23  write(*,*) "Oops: ifchar"
24 #if 0
25  nelc = nelv
26  if (ifmhd) nelc = max(nelv,nelfld(ifldmhd))
27  if (ifmhd) call exitti('no characteristics for mhd yet$',istep)
28 
29  ifnew = .true.
30  if (igeom > 2) ifnew = .false.
31  call set_conv_char(ct_vx,c_vx,vx,vy,vz,nelc,time,ifnew)
32 #endif
33 
34  else
35 
36  if ( .NOT. ifpert) then
37  if (ifcons) then
38 !max call set_convect_cons (vxd,vyd,vzd,vx,vy,vz)
39  else
40  call set_convect_new(vxd,vyd,vzd,vx,vy,vz)
41  endif
42  endif
43 
44  endif
45 
46  return
47 end subroutine setup_convect
48 !-----------------------------------------------------------------------
50 subroutine convect_new(bdu,u,ifuf,cx,cy,cz,ifcf)
51  use kinds, only : dp
52  use size_m, only : nelv
53  use size_m, only : lxd, lyd, lzd, ldim
54  use size_m, only : nx1, ny1, nz1, nxd, nyd, nzd
55  use input, only : if3d
56  use ctimer, only : tscn, dnekclock
57  use interp, only : jgl, jgt, dgl, dgt
58  use interp, only : get_int_ptr, get_dgl_ptr
59  implicit none
60 
61  real(DP) :: bdu(*),u(*),cx(*),cy(*),cz(*)
62  logical :: ifuf,ifcf ! u and/or c already on fine mesh?
63 
64  integer, parameter :: ltd=lxd*lyd*lzd
65  real(DP) :: ur(ltd), us(ltd), ut(ltd), tr(ltd,3), uf(ltd)
66 
67  integer :: e, iu, ic, ib, i, iptr, iptr2
68  integer :: nxyz1, nxyzd, nxyzu, nxyzc
69  real(DP) :: etime
70  real(DP) :: w((2*lxd)**ldim,2)
71  integer, parameter :: ldw = 2*(2*lxd)**ldim
72 
73  etime = dnekclock()
74 !max call set_dealias_rx()
75 
76  nxyz1 = nx1*ny1*nz1
77  nxyzd = nxd*nyd*nzd
78 
79  nxyzu = nxyz1
80  if (ifuf) nxyzu = nxyzd
81 
82  nxyzc = nxyz1
83  if (ifcf) nxyzc = nxyzd
84 
85  iu = 1 ! pointer to scalar field u
86  ic = 1 ! pointer to vector field C
87  ib = 1 ! pointer to scalar field Bdu
88 
89 #ifdef INLINE_INTP
90  call get_int_ptr(iptr, nx1,nxd)
91  call get_dgl_ptr(iptr2, nxd,nxd)
92 #endif
93 
94  do e=1,nelv
95 
96  if (ifcf) then
97  call copy(tr(1,1),cx(ic),nxyzd) ! already in rst form
98  call copy(tr(1,2),cy(ic),nxyzd)
99  if (if3d) call copy(tr(1,3),cz(ic),nxyzd)
100 
101  else ! map coarse velocity to fine mesh (C-->F)
102  write(*,*) "Oops: ifcf"
103 #if 0
104  call intp_rstd(fx,cx(ic),nx1,nxd,if3d,0) ! 0 --> forward
105  call intp_rstd(fy,cy(ic),nx1,nxd,if3d,0) ! 0 --> forward
106  if (if3d) call intp_rstd(fz,cz(ic),nx1,nxd,if3d,0) ! 0 --> forward
107 
108  if (if3d) then ! Convert convector F to r-s-t coordinates
109 
110  do i=1,nxyzd
111  tr(i,1)=rx(i,1,e)*fx(i)+rx(i,2,e)*fy(i)+rx(i,3,e)*fz(i)
112  tr(i,2)=rx(i,4,e)*fx(i)+rx(i,5,e)*fy(i)+rx(i,6,e)*fz(i)
113  tr(i,3)=rx(i,7,e)*fx(i)+rx(i,8,e)*fy(i)+rx(i,9,e)*fz(i)
114  enddo
115 
116  else
117 
118  do i=1,nxyzd
119  tr(i,1)=rx(i,1,e)*fx(i)+rx(i,2,e)*fy(i)
120  tr(i,2)=rx(i,3,e)*fx(i)+rx(i,4,e)*fy(i)
121  enddo
122 
123  endif
124 #endif
125  endif
126 
127 ! etime = etime - dnekclock()
128 #ifndef INLINE_INTP
129  if (ifuf) then
130  call grad_rst(ur,us,ut,u(iu),nxd,if3d)
131  else
132  call intp_rstd(uf,u(iu),nx1,nxd,if3d,0) ! 0 --> forward
133  call grad_rst(ur,us,ut,uf,nxd,if3d)
134  endif
135 #else
136  if (ifuf) then
137  call local_grad3(ur,us,ut,u(iu),nxd-1,1,dgl(iptr2),dgt(iptr2))
138  else
139  call specmpn(uf,nxd,u(iu),nx1,jgl(iptr),jgt(iptr),if3d,w,ldw)
140  call local_grad3(ur,us,ut,uf,nxd-1,1,dgl(iptr2),dgt(iptr2))
141  endif
142 #endif
143 ! etime = etime + dnekclock()
144 
145  if (if3d) then
146  do i=1,nxyzd ! mass matrix included, per DFM (4.8.5)
147  uf(i) = tr(i,1)*ur(i)+tr(i,2)*us(i)+tr(i,3)*ut(i)
148  enddo
149  else
150  do i=1,nxyzd ! mass matrix included, per DFM (4.8.5)
151  uf(i) = tr(i,1)*ur(i)+tr(i,2)*us(i)
152  enddo
153  endif
154 ! etime = etime - dnekclock()
155 #ifndef INLINE_INTP
156  call intp_rstd(bdu(ib),uf,nx1,nxd,if3d,1) ! Project back to coarse
157 #else
158  call specmpn(bdu(ib),nx1,uf,nxd,jgt(iptr),jgl(iptr),if3d,w,ldw)
159 #endif
160 ! etime = etime + dnekclock()
161 
162  ic = ic + nxyzc
163  iu = iu + nxyzu
164  ib = ib + nxyz1
165 
166  enddo
167  tscn = tscn + (dnekclock() - etime)
168 
169  return
170  end subroutine convect_new
171 
172 !-----------------------------------------------------------------------
175 subroutine set_convect_new(cr,cs,ct,ux,uy,uz)
176  use kinds, only : dp
177  use size_m, only : lx1, ly1, lz1, lxd, lyd, lzd, ldim
178  use size_m, only : nx1, ny1, nz1, nxd, nyd, nzd, nelv
179  use geom, only : rx
180  use input, only : if3d
181  use mesh, only : if_ortho
182  use ctimer, only : tscn, nscn, dnekclock
183  use interp, only : jgl, jgt
184  use interp, only : get_int_ptr
185 
186  implicit none
187 
188  integer, parameter :: lxy=lx1*ly1*lz1, ltd=lxd*lyd*lzd
189 
190  real(DP) :: cr(ltd,*),cs(ltd,*),ct(ltd,*)
191  real(DP) :: ux(lxy,*),uy(lxy,*),uz(lxy,*)
192 
193  real(DP) :: fx(ltd), fy(ltd), fz(ltd)!, ur, us, ut, tr, uf
194  real(DP) :: w((2*lxd)**ldim,2)
195  integer, parameter :: ldw = 2*(2*lxd)**ldim
196 
197  real(DP) :: etime
198 
199  integer :: e, nxyz1, nxyzd, ic, i, j, iptr
200  nscn = nscn + 1
201  etime = dnekclock()
202  call set_dealias_rx()
203 
204  nxyz1 = nx1*ny1*nz1
205  nxyzd = nxd*nyd*nzd
206 
207  ic = 1 ! pointer to vector field C
208 #ifdef INLINE_INTP
209  call get_int_ptr(iptr, nx1, nxd)
210 #endif
211 
212  do e=1,nelv
213 
214  ! Map coarse velocity to fine mesh (C-->F)
215 
216  !call specmpn(fx,nxd,ux(1,e),nx1,jgl(i),jgt(i),if3d,w,ldw)
217  !call specmpn(fy,nxd,uy(1,e),nx1,jgl(i),jgt(i),if3d,w,ldw)
218  !call specmpn(fz,nxd,uz(1,e),nx1,jgl(i),jgt(i),if3d,w,ldw)
219 ! etime = etime - dnekclock()
220 #ifdef INLINE_INTP
221  call specmpn(fx,nxd,ux(1,e),nx1,jgl(iptr),jgt(iptr),if3d,w,ldw)
222  call specmpn(fy,nxd,uy(1,e),nx1,jgl(iptr),jgt(iptr),if3d,w,ldw)
223  if (if3d) call specmpn(fz,nxd,uz(1,e),nx1,jgl(iptr),jgt(iptr),if3d,w,ldw)
224 #else
225  call intp_rstd(fx,ux(1,e),nx1,nxd,if3d,0) ! 0 --> forward
226  call intp_rstd(fy,uy(1,e),nx1,nxd,if3d,0) ! 0 --> forward
227  if (if3d) call intp_rstd(fz,uz(1,e),nx1,nxd,if3d,0) ! 0 --> forward
228 #endif
229 ! etime = etime + dnekclock()
230 
231  ! Convert convector F to r-s-t coordinates
232 
233  if (if3d) then
234 
235  if (if_ortho) then
236  do i=1,nxyzd
237  cr(i,e)=rx(i,1,e)*fx(i)
238  cs(i,e)=rx(i,2,e)*fy(i)
239  ct(i,e)=rx(i,3,e)*fz(i)
240  enddo
241  else
242  do i=1,nxyzd
243  cr(i,e)=rx(i,1,e)*fx(i)+rx(i,2,e)*fy(i)+rx(i,3,e)*fz(i)
244  cs(i,e)=rx(i,4,e)*fx(i)+rx(i,5,e)*fy(i)+rx(i,6,e)*fz(i)
245  ct(i,e)=rx(i,7,e)*fx(i)+rx(i,8,e)*fy(i)+rx(i,9,e)*fz(i)
246  enddo
247  endif
248  else
249 #if 0
250  do i=1,nxyzd
251  cr(i,e)=rx(i,1,e)*fx(i)+rx(i,2,e)*fy(i)
252  cs(i,e)=rx(i,3,e)*fx(i)+rx(i,4,e)*fy(i)
253  enddo
254 #endif
255  endif
256  enddo
257  tscn = tscn + (dnekclock() - etime)
258 
259  return
260 end subroutine set_convect_new
261 !-----------------------------------------------------------------------
Input parameters from preprocessors.
Definition: input_mod.F90:11
subroutine get_dgl_ptr(ip, mx, md)
Get pointer to GL-GL interpolation dgl() for pair (mx,md)
Definition: interp_mod.F90:65
Definition: soln_mod.F90:1
Module containing memoized interpolation matrices.
Definition: interp_mod.F90:5
subroutine get_int_ptr(ip, mx, md)
Get pointer to jgl() for interpolation pair (mx,md)
Definition: interp_mod.F90:32
subroutine set_convect_new(cr, cs, ct, ux, uy, uz)
Put vxd,vyd,vzd into rst form on fine mesh For rst form, see eq. (4.8.5) in Deville, Fischer, Mund (2002).
Definition: convect.F90:175
subroutine setup_convect(igeom)
Definition: convect.F90:11
subroutine set_dealias_rx
Eulerian scheme, add convection term to forcing function.
Definition: induct.F90:128
cleaned
Definition: mesh_mod.F90:2
real(dp) function dnekclock()
Definition: ctimer_mod.F90:103
subroutine copy(a, b, n)
Definition: math.F90:52
subroutine convect_new(bdu, u, ifuf, cx, cy, cz, ifcf)
Compute dealiased form: J^T Bf *JC .grad Ju w/ correct Jacobians.
Definition: convect.F90:50
Geometry arrays.
Definition: geom_mod.F90:2
subroutine exitti(stringi, idata)
Definition: comm_mpi.F90:328