127 dtlag, tlag, time_scheme, slag)
130 integer,
intent(in) :: lxd
131 type(
coef_t),
target :: coef
132 real(kind=
rp),
intent(in) :: ctarget
134 real(kind=
rp),
target,
intent(in) :: dtlag(10)
135 real(kind=
rp),
target,
intent(in) :: tlag(10)
138 integer :: nel, n_GL, n, idx, idy, idz
139 real(kind=
rp) :: max_cfl_rk4
143 this%ntaubd =
max(int(ctarget/max_cfl_rk4),1)
145 call this%Xh_GL%init(
gl, lxd, lxd, lxd)
146 this%Xh_GLL => coef%Xh
147 this%coef_GLL => coef
148 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
150 call this%coef_GL%init(this%Xh_GL, coef%msh)
152 call this%cr_GL%init(coef%msh, this%Xh_GL)
153 call this%cs_GL%init(coef%msh, this%Xh_GL)
154 call this%ct_GL%init(coef%msh, this%Xh_GL)
157 n_gl = nel*this%Xh_GL%lxyz
160 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
161 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
162 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
163 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
164 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
165 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
166 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
167 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
168 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
171 allocate(this%cx(n_gl))
172 allocate(this%cy(n_gl))
173 allocate(this%cz(n_gl))
178 allocate(this%cr_k23)
179 allocate(this%cs_k23)
180 allocate(this%ct_k23)
186 call this%cr_k1%init(coef%msh, this%Xh_GL)
187 call this%cs_k1%init(coef%msh, this%Xh_GL)
188 call this%ct_k1%init(coef%msh, this%Xh_GL)
190 call this%cr_k23%init(coef%msh, this%Xh_GL)
191 call this%cs_k23%init(coef%msh, this%Xh_GL)
192 call this%ct_k23%init(coef%msh, this%Xh_GL)
194 call this%cr_k4%init(coef%msh, this%Xh_GL)
195 call this%cs_k4%init(coef%msh, this%Xh_GL)
196 call this%ct_k4%init(coef%msh, this%Xh_GL)
198 call this%conv_k1%init(3)
199 call this%conv_k23%init(3)
200 call this%conv_k4%init(3)
202 call this%conv_k1%assign(1, this%cr_k1)
203 call this%conv_k1%assign(2, this%cs_k1)
204 call this%conv_k1%assign(3, this%ct_k1)
206 call this%conv_k23%assign(1, this%cr_k23)
207 call this%conv_k23%assign(2, this%cs_k23)
208 call this%conv_k23%assign(3, this%ct_k23)
210 call this%conv_k4%assign(1, this%cr_k4)
211 call this%conv_k4%assign(2, this%cs_k4)
212 call this%conv_k4%assign(3, this%ct_k4)
214 call this%dtime%init(1)
230 call this%GLL_to_GL%map(this%cx, this%ulag%f%x, nel, this%Xh_GL)
231 call this%GLL_to_GL%map(this%cy, this%vlag%f%x, nel, this%Xh_GL)
232 call this%GLL_to_GL%map(this%cz, this%wlag%f%x, nel, this%Xh_GL)
236 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
239 call this%convr_GL%init(this%cr_GL, 3)
240 call this%convs_GL%init(this%cs_GL, 3)
241 call this%convt_GL%init(this%ct_GL, 3)
244 call this%GLL_to_GL%map(this%cx, this%ulag%lf(1)%x, nel, this%Xh_GL)
245 call this%GLL_to_GL%map(this%cy, this%vlag%lf(1)%x, nel, this%Xh_GL)
246 call this%GLL_to_GL%map(this%cz, this%wlag%lf(1)%x, nel, this%Xh_GL)
249 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
251 this%convr_GL%lf(1) = this%cr_GL
252 this%convs_GL%lf(1) = this%cs_GL
253 this%convt_GL%lf(1) = this%ct_GL
255 call this%GLL_to_GL%map(this%cx, this%ulag%lf(2)%x, nel, this%Xh_GL)
256 call this%GLL_to_GL%map(this%cy, this%vlag%lf(2)%x, nel, this%Xh_GL)
257 call this%GLL_to_GL%map(this%cz, this%wlag%lf(2)%x, nel, this%Xh_GL)
260 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
262 this%convr_GL%lf(2) = this%cr_GL
263 this%convs_GL%lf(2) = this%cs_GL
264 this%convt_GL%lf(2) = this%ct_GL
267 if (
present(slag))
then
411 subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
414 type(
field_t),
intent(inout) :: vx, vy, vz
415 type(
field_t),
intent(inout) :: fx, fy, fz
416 type(
space_t),
intent(in) :: Xh
417 type(
coef_t),
intent(in) :: coef
418 integer,
intent(in) :: n
419 real(kind=
rp),
intent(in),
optional :: dt
420 real(kind=
rp) :: tau, tau1, th, dtau
421 integer :: i, ilag, itau, nel, n_GL
424 n_gl = nel * this%Xh_GL%lxyz
426 associate(ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
427 ctlag => this%ctlag, dctlag => this%dctlag, dtime => this%dtime, &
428 xh_gl => this%Xh_GL, coef_gl => this%coef_GL, ntaubd => this%ntaubd, &
429 gll_to_gl => this%GLL_to_GL, oifs_scheme => this%oifs_scheme, &
430 cr_k1 => this%cr_K1, cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, &
431 cr_k23 => this%cr_K23, cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, &
432 cr_k4 => this%cr_K4, cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
433 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
434 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
435 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
437 call dtime%init(oifs_scheme%ndiff)
439 tau = ctlag(oifs_scheme%ndiff)
441 call this%set_conv_velocity_fst(vx, vy, vz)
453 do ilag = oifs_scheme%ndiff, 1, -1
455 if (ilag .eq. 1)
then
457 oifs_scheme%diffusion_coeffs(2), n)
459 oifs_scheme%diffusion_coeffs(2), n)
461 oifs_scheme%diffusion_coeffs(2), n)
464 oifs_scheme%diffusion_coeffs(ilag+1), n)
466 oifs_scheme%diffusion_coeffs(ilag+1), n)
468 oifs_scheme%diffusion_coeffs(ilag+1), n)
471 if (ilag .eq. 1)
then
473 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
474 oifs_scheme%diffusion_coeffs(2) &
475 * vx%x(i,1,1,1) * coef%B(i,1,1,1)
476 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
477 oifs_scheme%diffusion_coeffs(2) &
478 * vy%x(i,1,1,1) * coef%B(i,1,1,1)
479 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
480 oifs_scheme%diffusion_coeffs(2) &
481 * vz%x(i,1,1,1) * coef%B(i,1,1,1)
485 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
486 oifs_scheme%diffusion_coeffs(ilag+1) &
487 * ulag%lf(ilag-1)%x(i,1,1,1) &
489 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
490 oifs_scheme%diffusion_coeffs(ilag+1) &
491 * vlag%lf(ilag-1)%x(i,1,1,1) &
493 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
494 oifs_scheme%diffusion_coeffs(ilag+1) &
495 * wlag%lf(ilag-1)%x(i,1,1,1) &
500 dtau = dctlag(ilag)/
real(ntaubd)
504 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
505 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
506 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
507 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
508 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
509 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
510 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
511 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
512 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
513 call runge_kutta(fx, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
514 coef, coef_gl, gll_to_gl, tau, dtau, &
516 call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
517 coef, coef_gl, gll_to_gl, tau, dtau, &
519 call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
520 coef, coef_gl, gll_to_gl, tau, dtau, &
544 type(field_t),
intent(inout) :: vx, vy, vz
545 type(field_t),
intent(inout) :: fs
546 type(field_t),
intent(inout) :: s
547 type(space_t),
intent(in) :: Xh
548 type(coef_t),
intent(in) :: coef
549 integer,
intent(in) :: n
550 real(kind=rp),
intent(in),
optional :: dt
551 real(kind=rp) :: tau, tau1, th, dtau
552 integer :: i, ilag, itau, nel, n_GL
554 n_gl = nel * this%Xh_GL%lxyz
556 associate(slag => this%slag, ctlag => this%ctlag, dctlag => this%dctlag, &
557 dtime => this%dtime, xh_gl => this%Xh_GL, coef_gl => this%coef_GL, &
558 ntaubd => this%ntaubd, gll_to_gl => this%GLL_to_GL, &
559 oifs_scheme => this%oifs_scheme, cr_k1 => this%cr_K1, &
560 cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, cr_k23 => this%cr_K23, &
561 cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, cr_k4 => this%cr_K4, &
562 cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
563 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
564 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
565 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
567 call dtime%init(oifs_scheme%ndiff)
569 tau = ctlag(oifs_scheme%ndiff)
571 call this%set_conv_velocity_fst(vx, vy, vz)
573 if (neko_bcknd_device .eq. 1)
then
574 call device_rzero(fs%x_d,n)
579 do ilag = oifs_scheme%ndiff, 1, -1
580 if (neko_bcknd_device .eq. 1)
then
581 if (ilag .eq. 1)
then
582 call device_addcol3s2(fs%x_d, s%x_d, coef%B_d, &
583 oifs_scheme%diffusion_coeffs(2), n)
585 call device_addcol3s2(fs%x_d, slag%lf(ilag-1)%x_d, coef%B_d, &
586 oifs_scheme%diffusion_coeffs(ilag+1), n)
589 if (ilag .eq. 1)
then
591 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
592 oifs_scheme%diffusion_coeffs(2) &
593 * s%x(i,1,1,1) * coef%B(i,1,1,1)
597 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
598 oifs_scheme%diffusion_coeffs(ilag+1) &
599 * slag%lf(ilag-1)%x(i,1,1,1) * coef%B(i,1,1,1)
603 dtau = dctlag(ilag)/
real(ntaubd)
607 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
608 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
609 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
610 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
611 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
612 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
613 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
614 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
615 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
616 call runge_kutta(fs, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
617 coef, coef_gl, gll_to_gl, tau, dtau, &