6 subroutine ax(w,x,h1,h2,n)
12 real(DP) :: w(n),x(n),h1(n),h2(n)
17 call
axhelm(w,x,h1,h2,imsh,isd)
19 w = w * reshape(pmask, (/ n /))
29 use size_m
, only : lx1, ly1, lz1, lx2, ly2, lz2, lelv, lgmres
30 use size_m
, only : nx1, ny1, nz1, nelv, nid
32 use input, only : param, ifmgrid, ifprint
33 use geom, only : volvm1
34 use soln, only : pmask, vmult
35 use tstep, only : tolps, istep
39 real(DP) :: res (lx1*ly1*lz1*lelv)
40 real(DP) :: h1 (lx1,ly1,lz1,lelv)
41 real(DP) :: h2 (lx1,ly1,lz1,lelv)
42 real(DP) :: wt (lx1*ly1*lz1*lelv)
45 real(DP),
allocatable :: x(:),r(:),w(:)
46 real(DP),
allocatable :: h(:,:),gamma(:)
47 real(DP),
allocatable :: c(:),s(:)
48 real(DP),
allocatable :: v(:,:)
49 real(DP),
allocatable :: z(:,:)
55 real(DP) :: wk1(lgmres)
57 real(DP) :: alpha, l, temp
60 logical,
save :: iflag = .false., if_hyb = .false.
61 real(DP),
save :: norm_fac
63 real(DP) :: etime1, etime2, etime_p
64 real(DP) :: rnorm, tolpss, div0, ratio
65 real(DP),
external :: glsc3, vlsc3
66 real(DP),
parameter :: one = 1._dp, zero = 0._dp, mone = -1._dp
69 integer :: i, j, k, iconv
76 allocate(h(lgmres,lgmres))
77 allocate(gamma(lgmres+1))
78 allocate(c(lgmres), s(lgmres))
80 allocate(v(lx2*ly2*lz2*lelv,lgmres))
81 allocate(z(lx2*ly2*lz2*lelv,lgmres))
88 h = 0._dp; gamma=0._dp; c = 0._dp; s = 0._dp
102 norm_fac = 1./sqrt(volvm1)
110 call
chktcg1(tolps,res,h1,h2,pmask,vmult,1,1)
111 if (param(21) > 0 .AND. tolps > abs(param(21))) &
112 tolps = abs(param(21))
113 if (istep == 0) tolps = 1.e-4
119 allocate(x(lx2*ly2*lz2*lelv)); x = 0._dp
120 allocate(w(lx2*ly2*lz2*lelv))
121 allocate(r(lx2*ly2*lz2*lelv))
122 do while (iconv == 0 .AND. iter < 50)
130 gmres_mop = gmres_mop + 5*n
131 gmres_flop = gmres_flop + n
143 gmres_mop = gmres_mop + 2*n
144 gmres_flop = gmres_flop + 3*n
146 gamma(1) =
sum(r*r*wt)
147 call
gop(gamma,wk1,
'+ ',1)
148 gamma(1) = sqrt(gamma(1))
150 gamma(1) = sqrt(glsc3(r,r,wt,n))
154 div0 = gamma(1)*norm_fac
155 if (param(21) < 0) tolpss=abs(param(21))*div0
160 if(gamma(1) == 0.) goto 9000
161 gmres_flop = gmres_flop + n
162 gmres_mop = gmres_mop + 2*n
186 write(*,*)
"Oops: ifmgrid"
189 if (param(100) == 2)
then
190 call h1_overlap_2(z(1,j),w,pmask)
193 (z(1,j),w,d,pmask,vmult,nelv,ktype(1,1,kfldfdm),wk)
195 call crs_solve_h1(wk,w)
196 call add2(z(1,j),wk,n)
200 gmres_flop = gmres_flop + 2*n
201 gmres_mop = gmres_mop + 3*n
209 call
ax(w,z(1,j),h1,h2,n)
213 gmres_mop = gmres_mop + 3*n + (j+1)*n
214 gmres_flop = gmres_flop + (2*n-1)*j + n
216 call dgemv(
'T', n, j, &
221 call
gop(h(1,j),wk1,
'+ ',j)
223 gmres_mop = gmres_mop + (j+2)*n
224 gmres_flop = gmres_flop + (j*3)*n
225 call dgemv(
'N', n, j, &
233 h(i ,j)= c(i)*temp + s(i)*h(i+1,j)
234 h(i+1,j)= -s(i)*temp + c(i)*h(i+1,j)
237 gmres_mop = gmres_mop + 2*n
238 gmres_flop = gmres_flop + 3*n
241 call
gop(alpha, wk1,
'+ ', 1)
244 alpha = sqrt(glsc3(w,w,wt,n))
247 if(alpha == 0.) goto 900
248 l = sqrt(h(j,j)*h(j,j)+alpha*alpha)
253 gamma(j+1) = -s(j) * gamma(j)
254 gamma(j) = c(j) * gamma(j)
255 rnorm = abs(gamma(j+1))*norm_fac
257 if (ifprint .AND. nid == 0) &
258 write (6,66) iter,tolpss,rnorm,div0,ratio,istep
259 66
format(i5,1p4e12.5,i8,
' Divergence')
262 if (rnorm < tolpss) goto 900
264 if (iter > param(151)-1) goto 900
266 if (j == m) goto 1000
268 gmres_mop = gmres_mop + 2*n
269 gmres_flop = gmres_flop + n
271 v(:,j+1) = w(:) * temp
283 temp = temp - h(k,i)*c(i)
288 gmres_flop = gmres_flop + 2*n * j
289 gmres_mop = gmres_mop + (j+2)*n
290 call dgemv(
'N', n, j, &
302 gmres_mop = gmres_mop + 2*n
305 gmres_flop = gmres_flop + 2*n
306 gmres_mop = gmres_mop + 3*n
310 if (nid == 0)
write(6,9999) istep,iter,divex,tolpss,div0,etime_p, &
313 9999
format(i9,
' PRES gmres:',i5,1p5e12.4,1x,l4)
315 if (outer <= 2) if_hyb = .false.
static double sum(struct xxt *data, double v, uint n, uint tag)
subroutine ax(w, x, h1, h2, n)
w = A*x for pressure iteration
subroutine dssum(u)
Direct stiffness sum.
subroutine axhelm(au, u, helm1, helm2, imesh, isd)
Compute the (Helmholtz) matrix-vector product, AU = helm1*[A]u + helm2*[B]u, for NEL elements...
subroutine ortho(respr)
Orthogonalize the residual in the pressure solver with respect to (1,1,...,1)T (only if all Dirichlet...
real(dp) function dnekclock()
subroutine, public h1mg_solve(z, rhs, if_hybrid)
Solve preconditioner: z = M rhs, where .
subroutine hmh_gmres(res, h1, h2, wt, iter)
Solve the Helmholtz equation by right-preconditioned GMRES iteration.
subroutine chktcg1(tol, res, h1, h2, mask, mult, imesh, isd)
Check that the tolerances are not too small for the CG-solver. Important when calling the CG-solver (...
subroutine gop(x, w, op, n)
Global vector commutative operation.