137 dtlag, tlag, time_scheme, slag)
140 integer,
intent(in) :: lxd
141 type(
coef_t),
target :: coef
142 real(kind=
rp),
intent(in) :: ctarget
144 real(kind=
dp),
target,
intent(in) :: dtlag(10)
145 real(kind=
dp),
target,
intent(in) :: tlag(10)
148 integer :: nel, n_GL, n, idx, idy, idz
149 real(kind=
rp) :: max_cfl_rk4
155 this%ntaubd =
max(int(ctarget/max_cfl_rk4),1)
157 call this%Xh_GL%init(
gl, lxd, lxd, lxd)
158 this%Xh_GLL => coef%Xh
159 this%coef_GLL => coef
160 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
162 call this%coef_GL%init(this%Xh_GL, coef%msh)
164 call this%cr_GL%init(coef%msh, this%Xh_GL)
165 call this%cs_GL%init(coef%msh, this%Xh_GL)
166 call this%ct_GL%init(coef%msh, this%Xh_GL)
169 n_gl = nel*this%Xh_GL%lxyz
172 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
173 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
174 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
175 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
176 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
177 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
178 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
179 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
180 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
183 allocate(this%cx(n_gl))
184 allocate(this%cy(n_gl))
185 allocate(this%cz(n_gl))
190 allocate(this%cr_k23)
191 allocate(this%cs_k23)
192 allocate(this%ct_k23)
198 call this%cr_k1%init(coef%msh, this%Xh_GL)
199 call this%cs_k1%init(coef%msh, this%Xh_GL)
200 call this%ct_k1%init(coef%msh, this%Xh_GL)
202 call this%cr_k23%init(coef%msh, this%Xh_GL)
203 call this%cs_k23%init(coef%msh, this%Xh_GL)
204 call this%ct_k23%init(coef%msh, this%Xh_GL)
206 call this%cr_k4%init(coef%msh, this%Xh_GL)
207 call this%cs_k4%init(coef%msh, this%Xh_GL)
208 call this%ct_k4%init(coef%msh, this%Xh_GL)
210 call this%conv_k1%init(3)
211 call this%conv_k23%init(3)
212 call this%conv_k4%init(3)
214 call this%conv_k1%assign(1, this%cr_k1)
215 call this%conv_k1%assign(2, this%cs_k1)
216 call this%conv_k1%assign(3, this%ct_k1)
218 call this%conv_k23%assign(1, this%cr_k23)
219 call this%conv_k23%assign(2, this%cs_k23)
220 call this%conv_k23%assign(3, this%ct_k23)
222 call this%conv_k4%assign(1, this%cr_k4)
223 call this%conv_k4%assign(2, this%cs_k4)
224 call this%conv_k4%assign(3, this%ct_k4)
226 call this%dtime%init(1)
242 call this%GLL_to_GL%map(this%cx, this%ulag%f%x, nel, this%Xh_GL)
243 call this%GLL_to_GL%map(this%cy, this%vlag%f%x, nel, this%Xh_GL)
244 call this%GLL_to_GL%map(this%cz, this%wlag%f%x, nel, this%Xh_GL)
248 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
251 call this%convr_GL%init(this%cr_GL, 3)
252 call this%convs_GL%init(this%cs_GL, 3)
253 call this%convt_GL%init(this%ct_GL, 3)
256 call this%GLL_to_GL%map(this%cx, this%ulag%lf(1)%x, nel, this%Xh_GL)
257 call this%GLL_to_GL%map(this%cy, this%vlag%lf(1)%x, nel, this%Xh_GL)
258 call this%GLL_to_GL%map(this%cz, this%wlag%lf(1)%x, nel, this%Xh_GL)
261 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
263 this%convr_GL%lf(1) = this%cr_GL
264 this%convs_GL%lf(1) = this%cs_GL
265 this%convt_GL%lf(1) = this%ct_GL
267 call this%GLL_to_GL%map(this%cx, this%ulag%lf(2)%x, nel, this%Xh_GL)
268 call this%GLL_to_GL%map(this%cy, this%vlag%lf(2)%x, nel, this%Xh_GL)
269 call this%GLL_to_GL%map(this%cz, this%wlag%lf(2)%x, nel, this%Xh_GL)
272 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
274 this%convr_GL%lf(2) = this%cr_GL
275 this%convs_GL%lf(2) = this%cs_GL
276 this%convt_GL%lf(2) = this%ct_GL
279 if (
present(slag))
then
445 subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
448 type(
field_t),
intent(inout) :: vx, vy, vz
449 type(
field_t),
intent(inout) :: fx, fy, fz
450 type(
space_t),
intent(in) :: Xh
451 type(
coef_t),
intent(in) :: coef
452 integer,
intent(in) :: n
453 real(kind=
rp),
intent(in),
optional :: dt
454 real(kind=
dp) :: tau, tau1, th, dtau
455 integer :: i, ilag, itau, nel, n_GL
458 n_gl = nel * this%Xh_GL%lxyz
460 associate(ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
461 ctlag => this%ctlag, dctlag => this%dctlag, dtime => this%dtime, &
462 xh_gl => this%Xh_GL, coef_gl => this%coef_GL, ntaubd => this%ntaubd, &
463 gll_to_gl => this%GLL_to_GL, oifs_scheme => this%oifs_scheme, &
464 cr_k1 => this%cr_K1, cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, &
465 cr_k23 => this%cr_K23, cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, &
466 cr_k4 => this%cr_K4, cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
467 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
468 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
469 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
471 call dtime%init(oifs_scheme%ndiff)
473 tau = ctlag(oifs_scheme%ndiff)
475 call this%set_conv_velocity_fst(vx, vy, vz)
487 do ilag = oifs_scheme%ndiff, 1, -1
489 if (ilag .eq. 1)
then
491 oifs_scheme%diffusion_coeffs%x(2), n)
493 oifs_scheme%diffusion_coeffs%x(2), n)
495 oifs_scheme%diffusion_coeffs%x(2), n)
498 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
500 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
502 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
505 if (ilag .eq. 1)
then
507 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
508 oifs_scheme%diffusion_coeffs%x(2) &
509 * vx%x(i,1,1,1) * coef%B(i,1,1,1)
510 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
511 oifs_scheme%diffusion_coeffs%x(2) &
512 * vy%x(i,1,1,1) * coef%B(i,1,1,1)
513 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
514 oifs_scheme%diffusion_coeffs%x(2) &
515 * vz%x(i,1,1,1) * coef%B(i,1,1,1)
519 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
520 oifs_scheme%diffusion_coeffs%x(ilag+1) &
521 * ulag%lf(ilag-1)%x(i,1,1,1) &
523 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
524 oifs_scheme%diffusion_coeffs%x(ilag+1) &
525 * vlag%lf(ilag-1)%x(i,1,1,1) &
527 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
528 oifs_scheme%diffusion_coeffs%x(ilag+1) &
529 * wlag%lf(ilag-1)%x(i,1,1,1) &
534 dtau = dctlag(ilag)/
real(ntaubd)
538 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
539 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
540 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
541 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
542 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
543 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
544 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
545 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
546 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
547 call runge_kutta(fx, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
548 coef, coef_gl, gll_to_gl, tau, dtau, &
550 call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
551 coef, coef_gl, gll_to_gl, tau, dtau, &
553 call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
554 coef, coef_gl, gll_to_gl, tau, dtau, &
578 type(field_t),
intent(inout) :: vx, vy, vz
579 type(field_t),
intent(inout) :: fs
580 type(field_t),
intent(inout) :: s
581 type(space_t),
intent(in) :: Xh
582 type(coef_t),
intent(in) :: coef
583 integer,
intent(in) :: n
584 real(kind=rp),
intent(in),
optional :: dt
586 real(kind=dp) :: tau, tau1, th, dtau
587 integer :: i, ilag, itau, nel, n_GL
589 n_gl = nel * this%Xh_GL%lxyz
591 associate(slag => this%slag, ctlag => this%ctlag, dctlag => this%dctlag, &
592 dtime => this%dtime, xh_gl => this%Xh_GL, coef_gl => this%coef_GL, &
593 ntaubd => this%ntaubd, gll_to_gl => this%GLL_to_GL, &
594 oifs_scheme => this%oifs_scheme, cr_k1 => this%cr_K1, &
595 cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, cr_k23 => this%cr_K23, &
596 cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, cr_k4 => this%cr_K4, &
597 cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
598 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
599 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
600 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
602 call dtime%init(oifs_scheme%ndiff)
604 tau = ctlag(oifs_scheme%ndiff)
606 call this%set_conv_velocity_fst(vx, vy, vz)
608 if (neko_bcknd_device .eq. 1)
then
609 call device_rzero(fs%x_d,n)
614 do ilag = oifs_scheme%ndiff, 1, -1
615 if (neko_bcknd_device .eq. 1)
then
616 if (ilag .eq. 1)
then
617 call device_addcol3s2(fs%x_d, s%x_d, coef%B_d, &
618 oifs_scheme%diffusion_coeffs%x(2), n)
620 call device_addcol3s2(fs%x_d, slag%lf(ilag-1)%x_d, coef%B_d, &
621 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
624 if (ilag .eq. 1)
then
626 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
627 oifs_scheme%diffusion_coeffs%x(2) &
628 * s%x(i,1,1,1) * coef%B(i,1,1,1)
632 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
633 oifs_scheme%diffusion_coeffs%x(ilag+1) &
634 * slag%lf(ilag-1)%x(i,1,1,1) * coef%B(i,1,1,1)
638 dtau = dctlag(ilag)/
real(ntaubd)
642 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
643 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
644 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
645 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
646 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
647 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
648 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
649 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
650 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
651 call runge_kutta(fs, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
652 coef, coef_gl, gll_to_gl, tau, dtau, &