5 if(nio.eq.0)
write(6,*)
'ABORT: not compiled with CVODE support!'
14 if(nio.eq.0)
write(6,*)
'ABORT: not compiled with CVODE support!'
23 if(nio.eq.0)
write(6,*)
'ABORT: not compiled with CVODE support!'
45 cv_nlocal = cv_nlocal + ntot
50 if (cv_nlocal .gt. cv_lysize)
then
51 if(nio.eq.0)
write(6,*)
52 &
'ABORT cv_setsize(): workspace too small, check SIZE! '
57 cv_nglobal = i8glsum(cv_nlocal,1)
68 common /cvwrk1/ y0(cv_lysize)
71 common /cv_rout/ rout(6),rpar(1)
75 common /cv_iout/ iout(21),ipar(1),cvcomm
77 real cv_atol_(lx1,ly1,lz1,lelt,ldimt)
78 common /cv_ydot/ cv_atol_
83 character*15 txt_meth,txt_itask
91 if(nio.eq.0)
write(*,*)
'Initializing CVODE ...'
101 cv_dtmax = param(164)
104 cv_ipretype = param(167)
109 if (cv_iatol.eq.1)
then
110 cv_atol(1) = param(162)
111 else if (cv_iatol.eq.2)
then
114 ntot = nxyz*nelfld(i)
115 call cfill(cv_atol_(1,1,1,1,i-1),atol(i),ntot)
118 call cvpack(cv_atol,cv_atol_,.false.)
124 call fnvinitp(cvcomm, 1, cv_nlocal, cv_nglobal, ier)
126 call fnvinits(1, cv_nlocal, ier)
129 write(*,
'(a,i3)')
'ABORT cv_init(): fnvinitp ier=', ier
134 call cvpack(y0,t,.false.)
135 call fcvmalloc(time, y0, cv_meth, itmeth, cv_iatol,
136 & cv_rtol, cv_atol, iout, rout, ipar, rpar, ier)
138 write(*,
'(a,i3)')
'ABORT cv_init(): fcvmalloc ier=', ier
143 call fcvspgmr(cv_ipretype,igstype,cv_maxl,cv_delt,ier)
145 write(*,
'(a,i3)')
'ABORT cv_init(): fcvspgmr ier=', ier
150 if(cv_ipretype.gt.0)
call fcvspilssetprec(1, ier)
153 call fcvspilssetjac(1, ier)
158 if(cv_meth.eq.1) txt_meth=
'AM'
159 if(cv_meth.eq.2) txt_meth=
'BDF'
160 write(6,
'(A,A)')
' integration method : ',
162 if(cv_itask.eq.1) txt_itask=
'NORMAL'
163 if(cv_itask.eq.3) txt_itask=
'NORMAL_TSTOP'
164 write(6,
'(A,A)')
' integration mode : ',
166 write(6,
'(A,i10)')
' Nglobal : ',
168 write(6,
'(A,1pe8.1)')
' relative tolerance : ',
173 if (cv_iatol.eq.1)
then
176 ntot = nxyz*nelfld(i)
177 dd =
vlmax(cv_atol_(1,1,1,1,i-1),ntot)
181 1000
format(3x,
'absolute tolerance field ',i3,
' : ',1pe8.1)
185 write(6,
'(A,i3)')
' krylov dimension : ',
187 write(6,
'(A,f5.3)')
' ratio linear/non-linear tol : ',
189 write(6,
'(A,i3)')
' preconditioner : ',
191 write(6,
'(A,1pe8.1)')
' dt_max : ',
193 write(6,
'(A,f5.3)')
' increment factor DQJ : ',
195 write(6,
'(A,g15.3,A,/)')
' done :: initializing CVODE',
217 common /cvwrk1/ y(cv_lysize)
219 common /cvwrk2/ vx_(lx1,ly1,lz1,lelv)
220 & ,vy_(lx1,ly1,lz1,lelv)
221 & ,vz_(lx1,ly1,lz1,lelv)
222 & ,xm1_(lx1,ly1,lz1,lelv)
223 & ,ym1_(lx1,ly1,lz1,lelv)
224 & ,zm1_(lx1,ly1,lz1,lelv)
225 & ,wx_(lx1,ly1,lz1,lelv)
226 & ,wy_(lx1,ly1,lz1,lelv)
227 & ,wz_(lx1,ly1,lz1,lelv)
231 common /cv_iout/ iout(21),ipar(1),cvcomm
236 if (.not.ifcvodeinit)
then
237 write(6,*)
'ABORT: CVODE was not initialized!'
242 if (cv_itask.eq.1)
then
244 iout_save(i) = iout(i)
250 call copy(xm1_,xm1,ntot)
251 call copy(ym1_,ym1,ntot)
252 if (if3d)
call copy(zm1_,zm1,ntot)
253 call copy(wx_,wx,ntot)
254 call copy(wy_,wy,ntot)
255 if (if3d)
call copy(wz_,wz,ntot)
259 call copy(vx_,vx,ntot)
260 call copy(vy_,vy,ntot)
261 if (if3d)
call copy(vz_,vz,ntot)
265 call fcvsetrin(
'MAX_STEP',cv_dtmax,ier)
268 if (cv_itask.eq.3)
then
270 call cvpack(y,t,.false.)
271 call fcvreinit(timef,y,cv_iatol,cv_rtol,cv_atol,ier)
273 write(*,
'(a,i3)')
'ABORT: fcvsetrin ier=', ier
279 call fcvsetrin(
'STOP_TIME',time,ier)
282 call fcvode(time,tout,y,cv_itask,ier)
287 write(*,
'(a)')
' Restart integrator and try again ...'
289 call cvpack(y,t,.false.)
290 call fcvreinit(timef,y,cv_iatol,cv_rtol,cv_atol,ier)
293 call fcvode(time,tout,y,cv_itask,ier)
299 write(*,
'(a,i3)')
'ABORT: fcvode returned ier =', ier
304 cv_istep = cv_istep + 1
308 call copy(vx,vx_,ntot)
309 call copy(vy,vy_,ntot)
310 if (if3d)
call copy(vz,vz_,ntot)
315 call copy(xm1,xm1_,ntot)
316 call copy(ym1,ym1_,ntot)
317 if (if3d)
call copy(zm1,zm1_,ntot)
318 call copy(wx,wx_,ntot)
319 call copy(wy,wy_,ntot)
320 if (if3d)
call copy(wz,wz_,ntot)
340 common /cvwrk2/ vx_(lx1,ly1,lz1,lelv)
341 & ,vy_(lx1,ly1,lz1,lelv)
342 & ,vz_(lx1,ly1,lz1,lelv)
343 & ,xm1_(lx1,ly1,lz1,lelv)
344 & ,ym1_(lx1,ly1,lz1,lelv)
345 & ,zm1_(lx1,ly1,lz1,lelv)
346 & ,wx_(lx1,ly1,lz1,lelv)
347 & ,wy_(lx1,ly1,lz1,lelv)
348 & ,wz_(lx1,ly1,lz1,lelv)
350 ntot = lx1*ly1*lz1*nelv
352 call sumab(vx,vx_,vxlag,ntot,cv_ab,nbd)
353 call sumab(vy,vy_,vylag,ntot,cv_ab,nbd)
354 if(if3d)
call sumab(vz,vz_,vzlag,ntot,cv_ab,nbd)
367 common /cvwrk2/ vx_(lx1,ly1,lz1,lelv)
368 & ,vy_(lx1,ly1,lz1,lelv)
369 & ,vz_(lx1,ly1,lz1,lelv)
370 & ,xm1_(lx1,ly1,lz1,lelv)
371 & ,ym1_(lx1,ly1,lz1,lelv)
372 & ,zm1_(lx1,ly1,lz1,lelv)
373 & ,wx_(lx1,ly1,lz1,lelv)
374 & ,wy_(lx1,ly1,lz1,lelv)
375 & ,wz_(lx1,ly1,lz1,lelv)
377 ntot = lx1*ly1*lz1*nelv
379 call sumab(wx,wx_,wxlag,ntot,cv_ab,nbd)
380 call sumab(wy,wy_,wylag,ntot,cv_ab,nbd)
381 if(if3d)
call sumab(wz,wz_,wzlag,ntot,cv_ab,nbd)
395 common /cvwrk2/ vx_(lx1,ly1,lz1,lelv)
396 & ,vy_(lx1,ly1,lz1,lelv)
397 & ,vz_(lx1,ly1,lz1,lelv)
398 & ,xm1_(lx1,ly1,lz1,lelv)
399 & ,ym1_(lx1,ly1,lz1,lelv)
400 & ,zm1_(lx1,ly1,lz1,lelv)
401 & ,wx_(lx1,ly1,lz1,lelv)
402 & ,wy_(lx1,ly1,lz1,lelv)
403 & ,wz_(lx1,ly1,lz1,lelv)
405 COMMON /scrsf/ dtmp(lx1*ly1*lz1*lelv)
407 ntot = lx1*ly1*lz1*nelv
409 call sumab(dtmp,wx_,wxlag,ntot,cv_abmsh,nabmsh)
410 call add3 (xm1,xm1_,dtmp,ntot)
412 call sumab(dtmp,wy_,wylag,ntot,cv_abmsh,nabmsh)
413 call add3 (ym1,ym1_,dtmp,ntot)
416 call sumab(dtmp,wz_,wzlag,ntot,cv_abmsh,nabmsh)
417 call add3 (zm1,zm1_,dtmp,ntot)
423 subroutine fcvfun (time_, y, ydot, ipar, rpar, ier)
433 real time_,y(*),ydot(*),rpar(*)
436 real w1(lx1,ly1,lz1,lelt),
437 $ w2(lx1,ly1,lz1,lelt),
438 $ w3(lx1,ly1,lz1,lelt)
440 real ydott(lx1,ly1,lz1,lelt,ldimt)
441 common /cv_ydot/ ydott
449 if (time.ne.cv_timel)
then
452 if(nio.eq.0)
write(6,10) istep,time,time-cv_timel
453 10
format(4x,i7,2x,
't=',1pe14.7,
' stepsize=',1pe13.4)
456 call copy(w1,vx,ntotv)
457 call copy(w2,vy,ntotv)
458 if (if3d)
call copy(w3,vz,ntotv)
464 call sub2(vx,wx,ntotv)
465 call sub2(vy,wy,ntotv)
466 if (if3d)
call sub2(vz,wz,ntotv)
471 call copy(vx,w1,ntotv)
472 call copy(vy,w2,ntotv)
473 if (if3d)
call copy(vz,w3,ntotv)
480 if(nid.eq.0 .and. loglevel.gt.2)
write(6,*)
'fcvfun',
486 if (ifcvfld(ifield))
call vprops
490 if (ifcvfld(ifield))
then
491 ntot = nxyz*nelfld(ifield)
494 if (iftmsh(ifield))
then
495 call dssum(bq(1,1,1,1,ifield-1),lx1,ly1,lz1)
496 call col2(bq(1,1,1,1,ifield-1),bintm1,ntot)
498 call col3(w1,vtrans(1,1,1,1,ifield),bm1,ntot)
499 call dssum(w1,lx1,ly1,lz1)
500 call col2(w1,bintm1,ntot)
502 call copy(w1,vtrans(1,1,1,1,ifield),ntot)
505 call invcol3(ydott(1,1,1,1,ifield-1),bq(1,1,1,1,ifield-1),
510 if (ifgsh_fld_same)
then
511 istride = lx1*ly1*lz1*lelt
512 call nvec_dssum(ydott,istride,nfield-1,gsh_fld(1))
515 if (ifcvfld(ifield) .and. gsh_fld(ifield).ge.0)
then
516 if(.not.iftmsh(ifield))
517 &
call dssum(ydott(1,1,1,1,ifield-1),lx1,ly1,lz1)
523 if (ifcvfld(ifield))
then
524 ntot = nxyz*nelfld(ifield)
525 if (.not.iftmsh(ifield) .and. gsh_fld(ifield).ge.0)
then
526 call col2(ydott(1,1,1,1,ifield-1),binvm1,ntot)
531 call cvpack(ydot,ydott,.true.)
563 cv_dtnek = time - timef
565 cv_dtlag(1) = cv_dtnek
566 cv_dtlag(2) = dtlag(2)
567 cv_dtlag(3) = dtlag(3)
569 call rzero(cv_abmsh,3)
570 call setabbd(cv_abmsh,cv_dtlag,nabmsh,1)
572 cv_abmsh(i) = cv_dtnek*cv_abmsh(i)
576 call setabbd(cv_ab,cv_dtlag,nbd,nbd)
579 call setbd(cv_bd,cv_dtlag,nbd)
591 common /cv_iout/ iout(21),ipar(1),cvcomm
595 nstp = iout(3) - iout_save(3)
596 nfe = iout(4) - iout_save(4) + iout(20)-iout_save(20)
597 nni = iout(7) - iout_save(7)
598 nli = iout(20)- iout_save(20)
599 nli_nni = float(nli)/max(1,nni)
601 nfe_avg = (1.-1./cv_istep)*nfe_avg + nfe/cv_istep
602 nli_nni_avg = (1.-1./cv_istep)*nli_nni_avg + nli_nni/cv_istep
604 write(*,
'(13x,a8,i8,3x,a8,i8,3x,a10,f5.1)')
608 write(*,
'(13x,a8,i8,3x,a8,i8,3x,a10,f5.1)')
611 &
'<nli/nni>:', nli_nni_avg
612 write(*,
'(13x,a8,i8,3x,a8,i8,3x,a10,i5)')
613 &
'ncfn: ' ,iout(6)-iout_save(6),
614 &
'ncfl: ' ,iout(21)-iout_save(21),
615 &
'netf: ',iout(5)-iout_save(5)
subroutine create_comm(inewcomm)
real *8 function dnekclock()
real *8 function dnekclock_sync()
subroutine set_convect_new(cr, cs, ct, ux, uy, uz)
subroutine cvunpack(w1, y) c c copy the internal cvode vector y to nek array w1 c include 'SIZE' include 'TOTAL' include 'CVODE' real w1(lx1
subroutine fcvfun(time_, y, ydot, ipar, rpar, ier)
subroutine nvec_dssum(u, stride, n, gs_handle)
subroutine dssum(u, nx, ny, nz)
subroutine col3(a, b, c, n)
real function vlmax(vec, n)
subroutine add3(a, b, c, n)
subroutine cfill(a, b, n)
subroutine invcol3(a, b, c, n)
subroutine setbd(bd, dtbd, nbd)
subroutine setabbd(ab, dtlag, nab, nbd)
subroutine sumab(v, vv, vvlag, ntot, ab_, nab_)