114 dtlag, tlag, time_scheme, slag)
117 integer,
intent(in) :: lxd
118 type(
coef_t),
target :: coef
119 real(kind=
rp),
intent(in) :: ctarget
121 real(kind=
rp),
target,
intent(in) :: dtlag(10)
122 real(kind=
rp),
target,
intent(in) :: tlag(10)
125 integer :: nel, n_GL, n_GL_t, n, idx, idy, idz
126 real(kind=
rp) :: max_cfl_rk4
130 this%ntaubd =
max(int(ctarget/max_cfl_rk4),1)
132 call this%Xh_GL%init(
gl, lxd, lxd, lxd)
133 this%Xh_GLL => coef%Xh
134 this%coef_GLL => coef
135 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
137 call this%coef_GL%init(this%Xh_GL, coef%msh)
140 n_gl = nel*this%Xh_GL%lxyz
149 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
150 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
151 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
152 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
153 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
154 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
155 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
156 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
157 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
159 allocate(this%cx(n_gl))
160 allocate(this%cy(n_gl))
161 allocate(this%cz(n_gl))
162 allocate(this%c(n_gl_t, 3))
164 call this%dtime%init(1)
174 call this%GLL_to_GL%map(this%cx, this%ulag%f%x, nel, this%Xh_GL)
175 call this%GLL_to_GL%map(this%cy, this%vlag%f%x, nel, this%Xh_GL)
176 call this%GLL_to_GL%map(this%cz, this%wlag%f%x, nel, this%Xh_GL)
180 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
182 call this%GLL_to_GL%map(this%cx, this%ulag%lf(1)%x, nel, this%Xh_GL)
183 call this%GLL_to_GL%map(this%cy, this%vlag%lf(1)%x, nel, this%Xh_GL)
184 call this%GLL_to_GL%map(this%cz, this%wlag%lf(1)%x, nel, this%Xh_GL)
187 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
189 call this%GLL_to_GL%map(this%cx, this%ulag%lf(2)%x, nel, this%Xh_GL)
190 call this%GLL_to_GL%map(this%cy, this%vlag%lf(2)%x, nel, this%Xh_GL)
191 call this%GLL_to_GL%map(this%cz, this%wlag%lf(2)%x, nel, this%Xh_GL)
194 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
197 if (
present(slag))
then
250 type(
field_t),
intent(inout) :: u, v, w
251 integer :: i, nel, n_GL, n_GL_t, idx, idy, idz
253 nel = this%coef_GLL%msh%nelv
254 n_gl = nel*this%Xh_GL%lxyz
256 call copy(this%c(:,3), this%c(:,2), n_gl_t)
257 call copy(this%c(:,2), this%c(:,1), n_gl_t)
259 call this%GLL_to_GL%map(this%cx, u%x, nel, this%Xh_GL)
260 call this%GLL_to_GL%map(this%cy, v%x, nel, this%Xh_GL)
261 call this%GLL_to_GL%map(this%cz, w%x, nel, this%Xh_GL)
268 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
285 subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
288 type(
field_t),
intent(inout) :: vx, vy, vz
289 type(
field_t),
intent(inout) :: fx, fy, fz
290 type(
space_t),
intent(in) :: Xh
291 type(
coef_t),
intent(in) :: coef
292 integer,
intent(in) :: n
293 real(kind=
rp),
intent(in),
optional :: dt
295 real(kind=
rp) :: tau, tau1, th, dtau
296 integer :: i, ilag, itau, nel, n_GL, n_GL_t
297 real(kind=
rp),
dimension(3 * coef%msh%nelv * this%Xh_GL%lxyz) :: c_r1
298 real(kind=
rp),
dimension(3 * coef%msh%nelv * this%Xh_GL%lxyz) :: c_r23
299 real(kind=
rp),
dimension(3 * coef%msh%nelv * this%Xh_GL%lxyz) :: c_r4
300 real(kind=
rp),
parameter :: eps = 1e-10
303 n_gl = nel * this%Xh_GL%lxyz
306 associate(ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
307 ctlag => this%ctlag, dctlag => this%dctlag, dtime => this%dtime, &
308 oifs_scheme => this%oifs_scheme, ntaubd => this%ntaubd, c => this%c)
310 call dtime%init(oifs_scheme%ndiff)
312 tau = ctlag(oifs_scheme%ndiff)
318 call this%set_conv_velocity_fst(vx, vy, vz)
320 do ilag = oifs_scheme%ndiff, 1, -1
322 if (ilag .eq. 1)
then
324 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
325 oifs_scheme%diffusion_coeffs(2) &
326 * vx%x(i,1,1,1) * coef%B(i,1,1,1)
327 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
328 oifs_scheme%diffusion_coeffs(2) &
329 * vy%x(i,1,1,1) * coef%B(i,1,1,1)
330 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
331 oifs_scheme%diffusion_coeffs(2) &
332 * vz%x(i,1,1,1) * coef%B(i,1,1,1)
336 fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
337 oifs_scheme%diffusion_coeffs(ilag+1) &
338 * ulag%lf(ilag-1)%x(i,1,1,1) &
340 fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
341 oifs_scheme%diffusion_coeffs(ilag+1) &
342 * vlag%lf(ilag-1)%x(i,1,1,1) &
344 fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
345 oifs_scheme%diffusion_coeffs(ilag+1) &
346 * wlag%lf(ilag-1)%x(i,1,1,1) &
351 if (dctlag(ilag) .lt. eps)
then
352 dtau = dt/
real(ntaubd)
354 dtau = dctlag(ilag)/
real(ntaubd)
359 call dtime%interpolate_scalar(tau, c_r1, c, ctlag, n_gl_t)
360 call dtime%interpolate_scalar(th, c_r23, c, ctlag, n_gl_t)
361 call dtime%interpolate_scalar(tau1, c_r4, c, ctlag, n_gl_t)
362 call runge_kutta(fx%x, c_r1, c_r23, c_r4, xh, this%Xh_GL, coef, &
363 this%coef_GL, this%GLL_to_GL, &
364 tau, dtau, n, nel, n_gl)
365 call runge_kutta(fy%x, c_r1, c_r23, c_r4, xh, this%Xh_GL, coef, &
366 this%coef_GL, this%GLL_to_GL, &
367 tau, dtau, n, nel, n_gl)
368 call runge_kutta(fz%x, c_r1, c_r23, c_r4, xh, this%Xh_GL, coef, &
369 this%coef_GL, this%GLL_to_GL, &
370 tau, dtau, n, nel, n_gl)
392 type(field_t),
intent(inout) :: vx, vy, vz
393 type(field_t),
intent(inout) :: fs
394 type(field_t),
intent(inout) :: s
395 type(space_t),
intent(in) :: Xh
396 type(coef_t),
intent(in) :: coef
397 integer,
intent(in) :: n
398 real(kind=rp),
intent(in),
optional :: dt
399 real(kind=rp) :: tau, tau1, th, dtau
400 integer :: i, ilag, itau, nel, n_GL, n_GL_t
401 real(kind=rp),
dimension(3 * coef%msh%nelv * this%Xh_GL%lxyz) :: c_r1
402 real(kind=rp),
dimension(3 * coef%msh%nelv * this%Xh_GL%lxyz) :: c_r23
403 real(kind=rp),
dimension(3 * coef%msh%nelv * this%Xh_GL%lxyz) :: c_r4
404 real(kind=rp),
parameter :: eps = 1e-10
406 n_gl = nel * this%Xh_GL%lxyz
409 associate(slag => this%slag, ctlag => this%ctlag, &
410 dctlag => this%dctlag, dtime => this%dtime, &
411 oifs_scheme => this%oifs_scheme, ntaubd => this%ntaubd, c => this%c)
413 call dtime%init(oifs_scheme%ndiff)
415 tau = ctlag(oifs_scheme%ndiff)
419 call this%set_conv_velocity_fst(vx, vy, vz)
421 do ilag = oifs_scheme%ndiff, 1, -1
422 if (ilag .eq. 1)
then
424 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
425 oifs_scheme%diffusion_coeffs(2) &
426 * s%x(i,1,1,1) * coef%B(i,1,1,1)
430 fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
431 oifs_scheme%diffusion_coeffs(ilag+1) &
432 * slag%lf(ilag-1)%x(i,1,1,1) * coef%B(i,1,1,1)
436 if (dctlag(ilag) .lt. eps)
then
437 dtau = dt/
real(ntaubd)
439 dtau = dctlag(ilag)/
real(ntaubd)
444 call dtime%interpolate_scalar(tau, c_r1, c, ctlag, n_gl_t)
445 call dtime%interpolate_scalar(th, c_r23, c, ctlag, n_gl_t)
446 call dtime%interpolate_scalar(tau1, c_r4, c, ctlag, n_gl_t)
447 call runge_kutta(fs%x, c_r1, c_r23, c_r4, xh, this%Xh_GL, coef, &
448 this%coef_GL, this%GLL_to_GL, &
449 tau, dtau, n, nel, n_gl)