KTH framework for Nek5000 toolboxes; testing version  0.0.1
plan5.f
Go to the documentation of this file.
1 c-----------------------------------------------------------------------
2  subroutine plan5(igeom)
3 
4 c Two-step Richardson Extrapolation.
5 c Operator splitting technique.
6 
7  include 'SIZE'
8  include 'TOTAL'
9 
10  common /scrns/ resv(lx1*ly1*lz1*lelv,3)
11 
12  n = lx1*ly1*lz1*nelv
13  n2 = lx2*ly2*lz2*nelv
14  dt2 = dt/2
15  dti = 1/dt
16 
17  if (igeom.eq.2) then
18 
19  if (ifmvbd) call opcopy
20  $ (wxlag(1,1,1,1,2),wylag(1,1,1,1,2),wzlag(1,1,1,1,2),xm1,ym1,zm1)
21 
22  do i=1,n
23  s = bm1(i,1,1,1)*vtrans(i,1,1,1,1)*dti ! Add density*mass/dt,
24  vxlag(i,1,1,1,2)=s*vx(i,1,1,1) ! equivalent to using
25  vylag(i,1,1,1,2)=s*vy(i,1,1,1) ! density*mass/(dt/2)
26  vzlag(i,1,1,1,2)=s*vz(i,1,1,1) ! in the first place...
27  enddo
28 
29  call midstep(vxlag,vylag,vzlag,prlag,0,dt) ! One step of Pn-Pn-2
30 
31  do i=1,n ! Add density*mass/dt,
32  bfx(i,1,1,1)=bfx(i,1,1,1)+vxlag(i,1,1,1,2) ! equivalent to using
33  bfy(i,1,1,1)=bfy(i,1,1,1)+vylag(i,1,1,1,2) ! density*mass/(dt/2)
34  bfz(i,1,1,1)=bfz(i,1,1,1)+vzlag(i,1,1,1,2) ! in the first place...
35  enddo
36 
37  if (ifmvbd) then
38  call opcopy
39  $ (xm1,ym1,zm1,wxlag(1,1,1,1,2),wylag(1,1,1,1,2),wzlag(1,1,1,1,2))
40  call geom_reset(0)
41  endif
42 
43  time = time-dt2
44  call midstep(vx,vy,vz,pr,1,dt2) ! One step of Pn-Pn-2, dt/2
45 
46  time = time+dt2
47  call setup_convect(2) ! Map vx --> vxd
48  call setprop
49 
50  call midstep(vx,vy,vz,pr,0,dt2) ! One step of Pn-Pn-2, dt/2
51 
52  do i=1,n
53  vx(i,1,1,1)=2*vx(i,1,1,1)-vxlag(i,1,1,1,1)
54  vy(i,1,1,1)=2*vy(i,1,1,1)-vylag(i,1,1,1,1)
55  vz(i,1,1,1)=2*vz(i,1,1,1)-vzlag(i,1,1,1,1)
56  enddo
57 
58  do i=1,n2
59  pr(i,1,1,1)=2*pr(i,1,1,1)-prlag(i,1,1,1,1)
60  enddo
61 
62  call ortho(pr)
63 
64  endif
65 
66  return
67  end
68 c-----------------------------------------------------------------------
69  subroutine midstep(ux,uy,uz,pu,iresv,dtl)
70  include 'SIZE'
71  include 'TOTAL'
72 
73  parameter(lv=lx1*ly1*lz1*lelt)
74  real ux(1),uy(1),uz(1),pu(1)
75 
76  common /p5var/ rhs2(lx1*ly1*lz1*lelv,3)
77 
78  common /scrns/ resv(lx1*ly1*lz1*lelv,3)
79  $ , dv1(lx1*ly1*lz1*lelv)
80  $ , dv2(lx1*ly1*lz1*lelv)
81  $ , dv3(lx1*ly1*lz1*lelv)
82  common /scrvh/ h1(lx1*ly1*lz1*lelv)
83  $ , h2(lx1*ly1*lz1*lelv)
84 
85 
86  if (lx1.eq.lx2)
87  $ call exitti('midstep requires lx2=lx1-2 in SIZE$',lx2)
88 
89  ifield = 1 ! Set field for velocity
90  n = lx1*ly1*lz1*nelv
91  n2 = lx2*ly2*lz2*nelv
92 
93  dti = 1/dtl
94  call copy (h1,vdiff ,n)
95  call cmult2 (h2,vtrans,dti,n)
96 
97  if (iresv.eq.0) then ! bfx etc is preserved if iresv=1
98 
99  call makeuf ! Initialize bfx, bfy, bfz
100  if (ifmvbd) call admeshv ! Add div(W.u_i)
101 
102  call convop(resv(1,1),vx)
103  call convop(resv(1,2),vy)
104  call convop(resv(1,3),vz)
105 
106  do i=1,n
107  b=vtrans(i,1,1,1,1)*bm1(i,1,1,1)
108  s=1./dtl
109  bfx(i,1,1,1)=bfx(i,1,1,1)+b*(s*vx(i,1,1,1)-resv(i,1))
110  bfy(i,1,1,1)=bfy(i,1,1,1)+b*(s*vy(i,1,1,1)-resv(i,2))
111  bfz(i,1,1,1)=bfz(i,1,1,1)+b*(s*vz(i,1,1,1)-resv(i,3))
112  enddo
113 
114  endif
115 
116  call adv_geom(dtl) ! Advance the geometry
117 
118  call opcopy (ux,uy,uz,vx,vy,vz)
119 
120  call bcdirvc (ux,uy,uz,v1mask,v2mask,v3mask) ! Don't forget bcneutr !
121  call ophx (resv(1,1),resv(1,2),resv(1,3),ux,uy,uz,h1,h2)
122 
123  call copy(rhs2,resv,lx1*ly1*lz1*lelv*3)
124 
125  do i=1,n
126  resv(i,1)=bfx(i,1,1,1)-resv(i,1) ! rhs = rhs - H*u
127  resv(i,2)=bfy(i,1,1,1)-resv(i,2)
128  resv(i,3)=bfz(i,1,1,1)-resv(i,3)
129  enddo
130 
131  tolhv = abs(param(22))
132  call ophinv(dv1,dv2,dv3
133  $ ,resv(1,1),resv(1,2),resv(1,3),h1,h2,tolhv,nmxv)
134 
135  call opadd2(ux,uy,uz,dv1,dv2,dv3)
136 
137  bd(1) = 1.0
138  call rzero(pu,n2)
139 
140  dt_old = dt
141  dt = dtl
142  call incomprn(ux,uy,uz,pu)
143  dt = dt_old
144 
145  return
146  end
147 c-----------------------------------------------------------------------
148  subroutine adv_geom(dtl) ! Advance the geometry
149  include 'SIZE'
150  include 'TOTAL'
151 
152  param(28) = 1 ! This forces Euler Forward for Mesh Update
153  ! Note: p28 must be set prior to call settime
154 
155  dt_tmp = dt ! Save "full" dt value
156  dt = dtl
157 
158  ifield = 1
159  call gengeom(2)
160  ifield = 1
161 
162  dt = dt_tmp ! Restore dt
163 
164  return
165  end
166 c-----------------------------------------------------------------------
subroutine bcdirvc(V1, V2, V3, mask1, mask2, mask3)
Definition: bdry.f:574
subroutine exitti(stringi, idata)
Definition: comm_mpi.f:535
subroutine setup_convect(igeom)
Definition: convect2.f:17
subroutine gengeom(igeom)
Definition: drive2.f:371
subroutine geom_reset(icall)
Definition: ic.f:1802
subroutine ophinv(o1, o2, o3, i1, i2, i3, h1, h2, tolh, nmxhi)
Definition: induct.f:1023
subroutine incomprn(ux, uy, uz, up)
Definition: induct.f:282
subroutine copy(a, b, n)
Definition: math.f:260
subroutine rzero(a, n)
Definition: math.f:208
subroutine admeshv
Definition: mvmesh.f:82
subroutine makeuf
Definition: navier1.f:1464
subroutine convop(conv, fi)
Definition: navier1.f:3139
subroutine ortho(respr)
Definition: navier1.f:224
subroutine opcopy(a1, a2, a3, b1, b2, b3)
Definition: navier1.f:2474
subroutine ophx(out1, out2, out3, inp1, inp2, inp3, h1, h2)
Definition: navier1.f:743
subroutine opadd2(a1, a2, a3, b1, b2, b3)
Definition: navier1.f:2350
subroutine midstep(ux, uy, uz, pu, iresv, dtl)
Definition: plan5.f:70
subroutine adv_geom(dtl)
Definition: plan5.f:149
subroutine plan5(igeom)
Definition: plan5.f:3
subroutine setprop
Definition: subs1.f:2618
subroutine cmult2(A, B, CONST, N)
Definition: subs2.f:341