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 :: 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 oifs_scheme%diffusion_coeffs%x(2), n)
509 oifs_scheme%diffusion_coeffs%x(2), n)
511 oifs_scheme%diffusion_coeffs%x(2), n)
513 call addcol3s2(fx%x, ulag%lf(ilag-1)%x, coef%B, &
514 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
515 call addcol3s2(fy%x, vlag%lf(ilag-1)%x, coef%B, &
516 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
517 call addcol3s2(fz%x, wlag%lf(ilag-1)%x, coef%B, &
518 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
521 dtau = dctlag(ilag)/
real(ntaubd)
525 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
526 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
527 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
528 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
529 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
530 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
531 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
532 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
533 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
534 call runge_kutta(fx, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
535 coef, coef_gl, gll_to_gl, tau, dtau, &
537 call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
538 coef, coef_gl, gll_to_gl, tau, dtau, &
540 call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
541 coef, coef_gl, gll_to_gl, tau, dtau, &
565 type(field_t),
intent(inout) :: vx, vy, vz
566 type(field_t),
intent(inout) :: fs
567 type(field_t),
intent(inout) :: s
568 type(space_t),
intent(in) :: Xh
569 type(coef_t),
intent(in) :: coef
570 integer,
intent(in) :: n
571 real(kind=rp),
intent(in),
optional :: dt
573 real(kind=dp) :: tau, tau1, th, dtau
574 integer :: ilag, itau, nel, n_GL
576 n_gl = nel * this%Xh_GL%lxyz
578 associate(slag => this%slag, ctlag => this%ctlag, dctlag => this%dctlag, &
579 dtime => this%dtime, xh_gl => this%Xh_GL, coef_gl => this%coef_GL, &
580 ntaubd => this%ntaubd, gll_to_gl => this%GLL_to_GL, &
581 oifs_scheme => this%oifs_scheme, cr_k1 => this%cr_K1, &
582 cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, cr_k23 => this%cr_K23, &
583 cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, cr_k4 => this%cr_K4, &
584 cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
585 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
586 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
587 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
589 call dtime%init(oifs_scheme%ndiff)
591 tau = ctlag(oifs_scheme%ndiff)
593 call this%set_conv_velocity_fst(vx, vy, vz)
595 if (neko_bcknd_device .eq. 1)
then
596 call device_rzero(fs%x_d,n)
601 do ilag = oifs_scheme%ndiff, 1, -1
602 if (neko_bcknd_device .eq. 1)
then
603 if (ilag .eq. 1)
then
604 call device_addcol3s2(fs%x_d, s%x_d, coef%B_d, &
605 oifs_scheme%diffusion_coeffs%x(2), n)
607 call device_addcol3s2(fs%x_d, slag%lf(ilag-1)%x_d, coef%B_d, &
608 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
611 if (ilag .eq. 1)
then
612 call addcol3s2(fs%x, s%x, coef%B, &
613 oifs_scheme%diffusion_coeffs%x(2), n)
615 call addcol3s2(fs%x, slag%lf(ilag-1)%x, coef%B, &
616 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
619 dtau = dctlag(ilag)/
real(ntaubd)
623 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
624 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
625 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
626 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
627 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
628 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
629 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
630 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
631 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
632 call runge_kutta(fs, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
633 coef, coef_gl, gll_to_gl, tau, dtau, &