135 dtlag, tlag, time_scheme, slag)
138 integer,
intent(in) :: lxd
139 type(
coef_t),
target :: coef
140 real(kind=
rp),
intent(in) :: ctarget
142 real(kind=
dp),
target,
intent(in) :: dtlag(10)
143 real(kind=
dp),
target,
intent(in) :: tlag(10)
146 integer :: nel, n_GL, n, idx, idy, idz
147 real(kind=
rp) :: max_cfl_rk4
153 this%ntaubd =
max(int(ctarget/max_cfl_rk4),1)
155 call this%Xh_GL%init(
gl, lxd, lxd, lxd)
156 this%Xh_GLL => coef%Xh
157 this%coef_GLL => coef
158 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
160 call this%coef_GL%init(this%Xh_GL, coef%msh)
162 call this%cr_GL%init(coef%msh, this%Xh_GL)
163 call this%cs_GL%init(coef%msh, this%Xh_GL)
164 call this%ct_GL%init(coef%msh, this%Xh_GL)
167 n_gl = nel*this%Xh_GL%lxyz
170 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
171 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
172 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
173 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
174 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
175 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
176 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
177 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
178 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
181 allocate(this%cx(n_gl))
182 allocate(this%cy(n_gl))
183 allocate(this%cz(n_gl))
188 allocate(this%cr_k23)
189 allocate(this%cs_k23)
190 allocate(this%ct_k23)
196 call this%cr_k1%init(coef%msh, this%Xh_GL)
197 call this%cs_k1%init(coef%msh, this%Xh_GL)
198 call this%ct_k1%init(coef%msh, this%Xh_GL)
200 call this%cr_k23%init(coef%msh, this%Xh_GL)
201 call this%cs_k23%init(coef%msh, this%Xh_GL)
202 call this%ct_k23%init(coef%msh, this%Xh_GL)
204 call this%cr_k4%init(coef%msh, this%Xh_GL)
205 call this%cs_k4%init(coef%msh, this%Xh_GL)
206 call this%ct_k4%init(coef%msh, this%Xh_GL)
208 call this%conv_k1%init(3)
209 call this%conv_k23%init(3)
210 call this%conv_k4%init(3)
212 call this%conv_k1%assign(1, this%cr_k1)
213 call this%conv_k1%assign(2, this%cs_k1)
214 call this%conv_k1%assign(3, this%ct_k1)
216 call this%conv_k23%assign(1, this%cr_k23)
217 call this%conv_k23%assign(2, this%cs_k23)
218 call this%conv_k23%assign(3, this%ct_k23)
220 call this%conv_k4%assign(1, this%cr_k4)
221 call this%conv_k4%assign(2, this%cs_k4)
222 call this%conv_k4%assign(3, this%ct_k4)
224 call this%dtime%init(1)
240 call this%GLL_to_GL%map(this%cx, this%ulag%f%x, nel, this%Xh_GL)
241 call this%GLL_to_GL%map(this%cy, this%vlag%f%x, nel, this%Xh_GL)
242 call this%GLL_to_GL%map(this%cz, this%wlag%f%x, nel, this%Xh_GL)
246 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
249 call this%convr_GL%init(this%cr_GL, 3)
250 call this%convs_GL%init(this%cs_GL, 3)
251 call this%convt_GL%init(this%ct_GL, 3)
254 call this%GLL_to_GL%map(this%cx, this%ulag%lf(1)%x, nel, this%Xh_GL)
255 call this%GLL_to_GL%map(this%cy, this%vlag%lf(1)%x, nel, this%Xh_GL)
256 call this%GLL_to_GL%map(this%cz, this%wlag%lf(1)%x, nel, this%Xh_GL)
259 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
261 this%convr_GL%lf(1) = this%cr_GL
262 this%convs_GL%lf(1) = this%cs_GL
263 this%convt_GL%lf(1) = this%ct_GL
265 call this%GLL_to_GL%map(this%cx, this%ulag%lf(2)%x, nel, this%Xh_GL)
266 call this%GLL_to_GL%map(this%cy, this%vlag%lf(2)%x, nel, this%Xh_GL)
267 call this%GLL_to_GL%map(this%cz, this%wlag%lf(2)%x, nel, this%Xh_GL)
270 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
272 this%convr_GL%lf(2) = this%cr_GL
273 this%convs_GL%lf(2) = this%cs_GL
274 this%convt_GL%lf(2) = this%ct_GL
277 if (
present(slag))
then
428 subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
431 type(
field_t),
intent(inout) :: vx, vy, vz
432 type(
field_t),
intent(inout) :: fx, fy, fz
433 type(
space_t),
intent(in) :: Xh
434 type(
coef_t),
intent(in) :: coef
435 integer,
intent(in) :: n
436 real(kind=
rp),
intent(in),
optional :: dt
437 real(kind=
dp) :: tau, tau1, th, dtau
438 integer :: i, ilag, itau, nel, n_GL
441 n_gl = nel * this%Xh_GL%lxyz
443 associate(ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
444 ctlag => this%ctlag, dctlag => this%dctlag, dtime => this%dtime, &
445 xh_gl => this%Xh_GL, coef_gl => this%coef_GL, ntaubd => this%ntaubd, &
446 gll_to_gl => this%GLL_to_GL, oifs_scheme => this%oifs_scheme, &
447 cr_k1 => this%cr_K1, cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, &
448 cr_k23 => this%cr_K23, cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, &
449 cr_k4 => this%cr_K4, cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
450 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
451 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
452 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
454 call dtime%init(oifs_scheme%ndiff)
456 tau = ctlag(oifs_scheme%ndiff)
458 call this%set_conv_velocity_fst(vx, vy, vz)
470 do ilag = oifs_scheme%ndiff, 1, -1
472 if (ilag .eq. 1)
then
474 oifs_scheme%diffusion_coeffs%x(2), n)
476 oifs_scheme%diffusion_coeffs%x(2), n)
478 oifs_scheme%diffusion_coeffs%x(2), n)
481 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
483 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
485 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
488 if (ilag .eq. 1)
then
490 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
491 oifs_scheme%diffusion_coeffs%x(2) &
492 * vx%x(i,1,1,1) * coef%B(i,1,1,1)
493 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
494 oifs_scheme%diffusion_coeffs%x(2) &
495 * vy%x(i,1,1,1) * coef%B(i,1,1,1)
496 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
497 oifs_scheme%diffusion_coeffs%x(2) &
498 * vz%x(i,1,1,1) * coef%B(i,1,1,1)
502 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
503 oifs_scheme%diffusion_coeffs%x(ilag+1) &
504 * ulag%lf(ilag-1)%x(i,1,1,1) &
506 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
507 oifs_scheme%diffusion_coeffs%x(ilag+1) &
508 * vlag%lf(ilag-1)%x(i,1,1,1) &
510 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
511 oifs_scheme%diffusion_coeffs%x(ilag+1) &
512 * wlag%lf(ilag-1)%x(i,1,1,1) &
517 dtau = dctlag(ilag)/
real(ntaubd)
521 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
522 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
523 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
524 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
525 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
526 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
527 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
528 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
529 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
530 call runge_kutta(fx, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
531 coef, coef_gl, gll_to_gl, tau, dtau, &
533 call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
534 coef, coef_gl, gll_to_gl, tau, dtau, &
536 call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
537 coef, coef_gl, gll_to_gl, tau, dtau, &
561 type(field_t),
intent(inout) :: vx, vy, vz
562 type(field_t),
intent(inout) :: fs
563 type(field_t),
intent(inout) :: s
564 type(space_t),
intent(in) :: Xh
565 type(coef_t),
intent(in) :: coef
566 integer,
intent(in) :: n
567 real(kind=rp),
intent(in),
optional :: dt
569 real(kind=dp) :: tau, tau1, th, dtau
570 integer :: i, ilag, itau, nel, n_GL
572 n_gl = nel * this%Xh_GL%lxyz
574 associate(slag => this%slag, ctlag => this%ctlag, dctlag => this%dctlag, &
575 dtime => this%dtime, xh_gl => this%Xh_GL, coef_gl => this%coef_GL, &
576 ntaubd => this%ntaubd, gll_to_gl => this%GLL_to_GL, &
577 oifs_scheme => this%oifs_scheme, cr_k1 => this%cr_K1, &
578 cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, cr_k23 => this%cr_K23, &
579 cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, cr_k4 => this%cr_K4, &
580 cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
581 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
582 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
583 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
585 call dtime%init(oifs_scheme%ndiff)
587 tau = ctlag(oifs_scheme%ndiff)
589 call this%set_conv_velocity_fst(vx, vy, vz)
591 if (neko_bcknd_device .eq. 1)
then
592 call device_rzero(fs%x_d,n)
597 do ilag = oifs_scheme%ndiff, 1, -1
598 if (neko_bcknd_device .eq. 1)
then
599 if (ilag .eq. 1)
then
600 call device_addcol3s2(fs%x_d, s%x_d, coef%B_d, &
601 oifs_scheme%diffusion_coeffs%x(2), n)
603 call device_addcol3s2(fs%x_d, slag%lf(ilag-1)%x_d, coef%B_d, &
604 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
607 if (ilag .eq. 1)
then
609 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
610 oifs_scheme%diffusion_coeffs%x(2) &
611 * s%x(i,1,1,1) * coef%B(i,1,1,1)
615 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
616 oifs_scheme%diffusion_coeffs%x(ilag+1) &
617 * slag%lf(ilag-1)%x(i,1,1,1) * coef%B(i,1,1,1)
621 dtau = dctlag(ilag)/
real(ntaubd)
625 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
626 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
627 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
628 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
629 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
630 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
631 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
632 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
633 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
634 call runge_kutta(fs, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
635 coef, coef_gl, gll_to_gl, tau, dtau, &