132 dtlag, tlag, time_scheme, slag)
135 integer,
intent(in) :: lxd
136 type(
coef_t),
target :: coef
137 real(kind=
rp),
intent(in) :: ctarget
139 real(kind=
rp),
target,
intent(in) :: dtlag(10)
140 real(kind=
rp),
target,
intent(in) :: tlag(10)
143 integer :: nel, n_GL, n, idx, idy, idz
144 real(kind=
rp) :: max_cfl_rk4
148 this%ntaubd =
max(int(ctarget/max_cfl_rk4),1)
150 call this%Xh_GL%init(
gl, lxd, lxd, lxd)
151 this%Xh_GLL => coef%Xh
152 this%coef_GLL => coef
153 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
155 call this%coef_GL%init(this%Xh_GL, coef%msh)
157 call this%cr_GL%init(coef%msh, this%Xh_GL)
158 call this%cs_GL%init(coef%msh, this%Xh_GL)
159 call this%ct_GL%init(coef%msh, this%Xh_GL)
162 n_gl = nel*this%Xh_GL%lxyz
165 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
166 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
167 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
168 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
169 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
170 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
171 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
172 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
173 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
176 allocate(this%cx(n_gl))
177 allocate(this%cy(n_gl))
178 allocate(this%cz(n_gl))
183 allocate(this%cr_k23)
184 allocate(this%cs_k23)
185 allocate(this%ct_k23)
191 call this%cr_k1%init(coef%msh, this%Xh_GL)
192 call this%cs_k1%init(coef%msh, this%Xh_GL)
193 call this%ct_k1%init(coef%msh, this%Xh_GL)
195 call this%cr_k23%init(coef%msh, this%Xh_GL)
196 call this%cs_k23%init(coef%msh, this%Xh_GL)
197 call this%ct_k23%init(coef%msh, this%Xh_GL)
199 call this%cr_k4%init(coef%msh, this%Xh_GL)
200 call this%cs_k4%init(coef%msh, this%Xh_GL)
201 call this%ct_k4%init(coef%msh, this%Xh_GL)
203 call this%conv_k1%init(3)
204 call this%conv_k23%init(3)
205 call this%conv_k4%init(3)
207 call this%conv_k1%assign(1, this%cr_k1)
208 call this%conv_k1%assign(2, this%cs_k1)
209 call this%conv_k1%assign(3, this%ct_k1)
211 call this%conv_k23%assign(1, this%cr_k23)
212 call this%conv_k23%assign(2, this%cs_k23)
213 call this%conv_k23%assign(3, this%ct_k23)
215 call this%conv_k4%assign(1, this%cr_k4)
216 call this%conv_k4%assign(2, this%cs_k4)
217 call this%conv_k4%assign(3, this%ct_k4)
219 call this%dtime%init(1)
235 call this%GLL_to_GL%map(this%cx, this%ulag%f%x, nel, this%Xh_GL)
236 call this%GLL_to_GL%map(this%cy, this%vlag%f%x, nel, this%Xh_GL)
237 call this%GLL_to_GL%map(this%cz, this%wlag%f%x, nel, this%Xh_GL)
241 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
244 call this%convr_GL%init(this%cr_GL, 3)
245 call this%convs_GL%init(this%cs_GL, 3)
246 call this%convt_GL%init(this%ct_GL, 3)
249 call this%GLL_to_GL%map(this%cx, this%ulag%lf(1)%x, nel, this%Xh_GL)
250 call this%GLL_to_GL%map(this%cy, this%vlag%lf(1)%x, nel, this%Xh_GL)
251 call this%GLL_to_GL%map(this%cz, this%wlag%lf(1)%x, nel, this%Xh_GL)
254 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
256 this%convr_GL%lf(1) = this%cr_GL
257 this%convs_GL%lf(1) = this%cs_GL
258 this%convt_GL%lf(1) = this%ct_GL
260 call this%GLL_to_GL%map(this%cx, this%ulag%lf(2)%x, nel, this%Xh_GL)
261 call this%GLL_to_GL%map(this%cy, this%vlag%lf(2)%x, nel, this%Xh_GL)
262 call this%GLL_to_GL%map(this%cz, this%wlag%lf(2)%x, nel, this%Xh_GL)
265 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
267 this%convr_GL%lf(2) = this%cr_GL
268 this%convs_GL%lf(2) = this%cs_GL
269 this%convt_GL%lf(2) = this%ct_GL
272 if (
present(slag))
then
416 subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
419 type(
field_t),
intent(inout) :: vx, vy, vz
420 type(
field_t),
intent(inout) :: fx, fy, fz
421 type(
space_t),
intent(in) :: Xh
422 type(
coef_t),
intent(in) :: coef
423 integer,
intent(in) :: n
424 real(kind=
rp),
intent(in),
optional :: dt
425 real(kind=
rp) :: tau, tau1, th, dtau
426 integer :: i, ilag, itau, nel, n_GL
429 n_gl = nel * this%Xh_GL%lxyz
431 associate(ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
432 ctlag => this%ctlag, dctlag => this%dctlag, dtime => this%dtime, &
433 xh_gl => this%Xh_GL, coef_gl => this%coef_GL, ntaubd => this%ntaubd, &
434 gll_to_gl => this%GLL_to_GL, oifs_scheme => this%oifs_scheme, &
435 cr_k1 => this%cr_K1, cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, &
436 cr_k23 => this%cr_K23, cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, &
437 cr_k4 => this%cr_K4, cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
438 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
439 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
440 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
442 call dtime%init(oifs_scheme%ndiff)
444 tau = ctlag(oifs_scheme%ndiff)
446 call this%set_conv_velocity_fst(vx, vy, vz)
458 do ilag = oifs_scheme%ndiff, 1, -1
460 if (ilag .eq. 1)
then
462 oifs_scheme%diffusion_coeffs%x(2), n)
464 oifs_scheme%diffusion_coeffs%x(2), n)
466 oifs_scheme%diffusion_coeffs%x(2), n)
469 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
471 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
473 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
476 if (ilag .eq. 1)
then
478 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
479 oifs_scheme%diffusion_coeffs%x(2) &
480 * vx%x(i,1,1,1) * coef%B(i,1,1,1)
481 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
482 oifs_scheme%diffusion_coeffs%x(2) &
483 * vy%x(i,1,1,1) * coef%B(i,1,1,1)
484 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
485 oifs_scheme%diffusion_coeffs%x(2) &
486 * vz%x(i,1,1,1) * coef%B(i,1,1,1)
490 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
491 oifs_scheme%diffusion_coeffs%x(ilag+1) &
492 * ulag%lf(ilag-1)%x(i,1,1,1) &
494 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
495 oifs_scheme%diffusion_coeffs%x(ilag+1) &
496 * vlag%lf(ilag-1)%x(i,1,1,1) &
498 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
499 oifs_scheme%diffusion_coeffs%x(ilag+1) &
500 * wlag%lf(ilag-1)%x(i,1,1,1) &
505 dtau = dctlag(ilag)/
real(ntaubd)
509 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
510 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
511 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
512 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
513 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
514 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
515 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
516 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
517 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
518 call runge_kutta(fx, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
519 coef, coef_gl, gll_to_gl, tau, dtau, &
521 call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
522 coef, coef_gl, gll_to_gl, tau, dtau, &
524 call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
525 coef, coef_gl, gll_to_gl, tau, dtau, &
549 type(field_t),
intent(inout) :: vx, vy, vz
550 type(field_t),
intent(inout) :: fs
551 type(field_t),
intent(inout) :: s
552 type(space_t),
intent(in) :: Xh
553 type(coef_t),
intent(in) :: coef
554 integer,
intent(in) :: n
555 real(kind=rp),
intent(in),
optional :: dt
556 real(kind=rp) :: tau, tau1, th, dtau
557 integer :: i, ilag, itau, nel, n_GL
559 n_gl = nel * this%Xh_GL%lxyz
561 associate(slag => this%slag, ctlag => this%ctlag, dctlag => this%dctlag, &
562 dtime => this%dtime, xh_gl => this%Xh_GL, coef_gl => this%coef_GL, &
563 ntaubd => this%ntaubd, gll_to_gl => this%GLL_to_GL, &
564 oifs_scheme => this%oifs_scheme, cr_k1 => this%cr_K1, &
565 cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, cr_k23 => this%cr_K23, &
566 cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, cr_k4 => this%cr_K4, &
567 cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
568 convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
569 convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
570 conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
572 call dtime%init(oifs_scheme%ndiff)
574 tau = ctlag(oifs_scheme%ndiff)
576 call this%set_conv_velocity_fst(vx, vy, vz)
578 if (neko_bcknd_device .eq. 1)
then
579 call device_rzero(fs%x_d,n)
584 do ilag = oifs_scheme%ndiff, 1, -1
585 if (neko_bcknd_device .eq. 1)
then
586 if (ilag .eq. 1)
then
587 call device_addcol3s2(fs%x_d, s%x_d, coef%B_d, &
588 oifs_scheme%diffusion_coeffs%x(2), n)
590 call device_addcol3s2(fs%x_d, slag%lf(ilag-1)%x_d, coef%B_d, &
591 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
594 if (ilag .eq. 1)
then
596 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
597 oifs_scheme%diffusion_coeffs%x(2) &
598 * s%x(i,1,1,1) * coef%B(i,1,1,1)
602 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
603 oifs_scheme%diffusion_coeffs%x(ilag+1) &
604 * slag%lf(ilag-1)%x(i,1,1,1) * coef%B(i,1,1,1)
608 dtau = dctlag(ilag)/
real(ntaubd)
612 call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
613 call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
614 call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
615 call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
616 call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
617 call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
618 call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
619 call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
620 call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
621 call runge_kutta(fs, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
622 coef, coef_gl, gll_to_gl, tau, dtau, &