Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
adv_oifs.f90
Go to the documentation of this file.
1! Copyright (c) 2024, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
35 use advection, only : advection_t
36 use num_types, only : rp, dp
37 use space, only : space_t, gl
38 use field, only : field_t
39 use coefs, only : coef_t
40 use math, only : copy, rzero
46 use field_list, only : field_list_t
48 use device, only : device_map, device_unmap
50 use, intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr
51 implicit none
52 private
53
54 !! Type encapsulating operator-integration-factor splitting advection
55 !! routines with dealiasing applied
56 !! Literature:
57 !! https://www.mcs.anl.gov/~fischer/nek5000/oifs.pdf
58 !! https://publications.anl.gov/anlpubs/2017/12/140626.pdf
59 !! https://dl.acm.org/doi/abs/10.1007/BF01063118
60 type, public, extends(advection_t) :: adv_oifs_t
62 integer :: ntaubd = 0
64 type(coef_t) :: coef_gl
66 type(coef_t), pointer :: coef_gll => null()
68 type(interpolator_t) :: gll_to_gl
70 type(space_t) :: xh_gl
72 type(space_t), pointer :: xh_gll => null()
74 type(time_interpolator_t) :: dtime
76 type(field_series_t), pointer :: ulag, vlag, wlag, slag => null()
78 real(kind=dp), pointer :: ctlag(:) => null()
80 real(kind=dp), pointer :: dctlag(:) => null()
82 type(time_scheme_controller_t), pointer :: oifs_scheme => null()
84 type(field_t) :: cr_gl, cs_gl, ct_gl
86 type(field_series_t) :: convr_gl, convs_gl, convt_gl
88 type(field_t), pointer :: cr_k1 => null(), cs_k1 => null(), &
89 ct_k1 => null()
90 type(field_t), pointer :: cr_k23 => null(), cs_k23 => null(), &
91 ct_k23 => null()
92 type(field_t), pointer :: cr_k4 => null(), cs_k4 => null(), &
93 ct_k4 => null()
95 type(field_list_t) :: conv_k1, conv_k23, conv_k4
97 real(kind=rp), allocatable :: cx(:), cy(:), cz(:)
99 type(c_ptr) :: cx_d = c_null_ptr, cy_d = c_null_ptr, cz_d = c_null_ptr
100
101 contains
104 procedure, pass(this) :: compute => adv_oifs_compute
107 procedure, pass(this) :: compute_scalar => adv_oifs_compute_scalar
109 procedure, pass(this) :: init => adv_oifs_init
111 procedure, pass(this) :: set_conv_velocity_fst
113 procedure, pass(this) :: free => adv_oifs_free
116 procedure, pass(this) :: compute_ale => adv_oifs_compute_ale
118 procedure, pass(this) :: recompute_metrics => recompute_metrics_oifs
119 end type adv_oifs_t
120
121contains
122
134 subroutine adv_oifs_init(this, lxd, coef, ctarget, ulag, vlag, wlag, &
135 dtlag, tlag, time_scheme, slag)
136 implicit none
137 class(adv_oifs_t), intent(inout) :: this
138 integer, intent(in) :: lxd
139 type(coef_t), target :: coef
140 real(kind=rp), intent(in) :: ctarget
141 type(field_series_t), target, intent(in) :: ulag, vlag, wlag
142 real(kind=dp), target, intent(in) :: dtlag(10)
143 real(kind=dp), target, intent(in) :: tlag(10)
144 type(time_scheme_controller_t), target, intent(in) :: time_scheme
145 type(field_series_t), target, optional :: slag
146 integer :: nel, n_GL, n, idx, idy, idz
147 real(kind=rp) :: max_cfl_rk4
148
149 call this%free()
150
151 ! stability limit for RK4 including safety factor
152 max_cfl_rk4 = 2.0
153 this%ntaubd = max(int(ctarget/max_cfl_rk4),1)
154
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)
159
160 call this%coef_GL%init(this%Xh_GL, coef%msh)
161
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)
165
166 nel = coef%msh%nelv
167 n_gl = nel*this%Xh_GL%lxyz
168 n = nel*coef%Xh%lxyz
169
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)
179
180
181 allocate(this%cx(n_gl))
182 allocate(this%cy(n_gl))
183 allocate(this%cz(n_gl))
184
185 allocate(this%cr_k1)
186 allocate(this%cs_k1)
187 allocate(this%ct_k1)
188 allocate(this%cr_k23)
189 allocate(this%cs_k23)
190 allocate(this%ct_k23)
191 allocate(this%cr_k4)
192 allocate(this%cs_k4)
193 allocate(this%ct_k4)
194
195
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)
199
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)
203
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)
207
208 call this%conv_k1%init(3)
209 call this%conv_k23%init(3)
210 call this%conv_k4%init(3)
211
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)
215
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)
219
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)
223
224 call this%dtime%init(1)
225 this%ulag => ulag
226 this%vlag => vlag
227 this%wlag => wlag
228 this%ctlag => tlag
229 this%dctlag => dtlag
230 this%oifs_scheme => time_scheme
231
232 if (neko_bcknd_device .eq. 1) then
233 call device_map(this%cx, this%cx_d, n_gl)
234 call device_map(this%cy, this%cy_d, n_gl)
235 call device_map(this%cz, this%cz_d, n_gl)
236 end if
237
238 ! Initializing the convecting fields
239 ! Map the velocity fields from GLL space to GL space
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)
243
244 ! Set the convecting field in the rst format
245 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
246 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
247
248 ! Set the convecting field series
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)
252
253 ! Repeat for previous time-steps
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)
257
258 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
259 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
260
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
264
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)
268
269 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
270 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
271
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
275
276 ! Initilize the lagged scalar field, if present.
277 if (present(slag)) then
278 this%slag => slag
279 end if
280
281 end subroutine adv_oifs_init
282
284 subroutine adv_oifs_free(this)
285 class(adv_oifs_t), intent(inout) :: this
286
287 call this%conv_k1%free()
288 call this%conv_k23%free()
289 call this%conv_k4%free()
290
291 if (associated(this%cr_k1)) then
292 call this%cr_k1%free()
293 deallocate(this%cr_k1)
294 end if
295 if (associated(this%cs_k1)) then
296 call this%cs_k1%free()
297 deallocate(this%cs_k1)
298 end if
299 if (associated(this%ct_k1)) then
300 call this%ct_k1%free()
301 deallocate(this%ct_k1)
302 end if
303 if (associated(this%cr_k23)) then
304 call this%cr_k23%free()
305 deallocate(this%cr_k23)
306 end if
307 if (associated(this%cs_k23)) then
308 call this%cs_k23%free()
309 deallocate(this%cs_k23)
310 end if
311 if (associated(this%ct_k23)) then
312 call this%ct_k23%free()
313 deallocate(this%ct_k23)
314 end if
315 if (associated(this%cr_k4)) then
316 call this%cr_k4%free()
317 deallocate(this%cr_k4)
318 end if
319 if (associated(this%cs_k4)) then
320 call this%cs_k4%free()
321 deallocate(this%cs_k4)
322 end if
323 if (associated(this%ct_k4)) then
324 call this%ct_k4%free()
325 deallocate(this%ct_k4)
326 end if
327
328 nullify(this%cr_k1)
329 nullify(this%cs_k1)
330 nullify(this%ct_k1)
331 nullify(this%cr_k23)
332 nullify(this%cs_k23)
333 nullify(this%ct_k23)
334 nullify(this%cr_k4)
335 nullify(this%cs_k4)
336 nullify(this%ct_k4)
337
338 call this%convr_GL%free()
339 call this%convs_GL%free()
340 call this%convt_GL%free()
341
342 call this%cr_GL%free()
343 call this%cs_GL%free()
344 call this%ct_GL%free()
345
346 if (allocated(this%cx)) then
347 if (neko_bcknd_device .eq. 1) then
348 call device_unmap(this%cx, this%cx_d)
349 end if
350 deallocate(this%cx)
351 end if
352 if (allocated(this%cy)) then
353 if (neko_bcknd_device .eq. 1) then
354 call device_unmap(this%cy, this%cy_d)
355 end if
356 deallocate(this%cy)
357 end if
358 if (allocated(this%cz)) then
359 if (neko_bcknd_device .eq. 1) then
360 call device_unmap(this%cz, this%cz_d)
361 end if
362 deallocate(this%cz)
363 end if
364
365 call this%dtime%free()
366 call this%GLL_to_GL%free()
367 call this%coef_GL%free()
368 call this%Xh_GL%free()
369
370 nullify(this%coef_GLL)
371 nullify(this%Xh_GLL)
372 nullify(this%ulag)
373 nullify(this%vlag)
374 nullify(this%wlag)
375 nullify(this%slag)
376 nullify(this%ctlag)
377 nullify(this%dctlag)
378 nullify(this%oifs_scheme)
379
380 this%ntaubd = 0
381
382 end subroutine adv_oifs_free
383
389 subroutine set_conv_velocity_fst(this, u, v, w)
390 implicit none
391 class(adv_oifs_t), intent(inout) :: this
392 type(field_t), intent(inout) :: u, v, w
393 integer :: i, nel, n_GL, idx, idy, idz
394
395 nel = this%coef_GLL%msh%nelv
396 n_gl = nel*this%Xh_GL%lxyz
397
398 call this%convr_GL%update()
399 call this%convs_GL%update()
400 call this%convt_GL%update()
401
402 call this%GLL_to_GL%map(this%cx, u%x, nel, this%Xh_GL)
403 call this%GLL_to_GL%map(this%cy, v%x, nel, this%Xh_GL)
404 call this%GLL_to_GL%map(this%cz, w%x, nel, this%Xh_GL)
405
406 call set_convect_rst(this%cr_GL, this%cs_GL, this%ct_GL, &
407 this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
408
409 this%convr_GL%f = this%cr_GL
410 this%convs_GL%f = this%cs_GL
411 this%convt_GL%f = this%ct_GL
412
413 end subroutine set_conv_velocity_fst
414
415
428 subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
429 implicit none
430 class(adv_oifs_t), intent(inout) :: this
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
439
440 nel = coef%msh%nelv
441 n_gl = nel * this%Xh_GL%lxyz
442
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)
453
454 call dtime%init(oifs_scheme%ndiff)
455
456 tau = ctlag(oifs_scheme%ndiff)
457
458 call this%set_conv_velocity_fst(vx, vy, vz)
459
460 if (neko_bcknd_device .eq. 1) then
461 call device_rzero(fx%x_d,n)
462 call device_rzero(fy%x_d,n)
463 call device_rzero(fz%x_d,n)
464 else
465 call rzero(fx%x,n)
466 call rzero(fy%x,n)
467 call rzero(fz%x,n)
468 end if
469
470 do ilag = oifs_scheme%ndiff, 1, -1
471 if (neko_bcknd_device .eq. 1) then
472 if (ilag .eq. 1) then
473 call device_addcol3s2(fx%x_d, vx%x_d, coef%B_d, &
474 oifs_scheme%diffusion_coeffs%x(2), n)
475 call device_addcol3s2(fy%x_d, vy%x_d, coef%B_d, &
476 oifs_scheme%diffusion_coeffs%x(2), n)
477 call device_addcol3s2(fz%x_d, vz%x_d, coef%B_d, &
478 oifs_scheme%diffusion_coeffs%x(2), n)
479 else
480 call device_addcol3s2(fx%x_d, ulag%lf(ilag-1)%x_d, coef%B_d, &
481 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
482 call device_addcol3s2(fy%x_d, vlag%lf(ilag-1)%x_d, coef%B_d, &
483 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
484 call device_addcol3s2(fz%x_d, wlag%lf(ilag-1)%x_d, coef%B_d, &
485 oifs_scheme%diffusion_coeffs%x(ilag+1), n)
486 end if
487 else
488 if (ilag .eq. 1) then
489 do i = 1, n
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)
499 end do
500 else
501 do i = 1, n
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) &
505 * coef%B(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) &
509 * coef%B(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) &
513 * coef%B(i,1,1,1)
514 end do
515 end if
516 end if
517 dtau = dctlag(ilag)/real(ntaubd)
518 do itau = 1, ntaubd
519 th = tau + dtau/2.
520 tau1 = tau + dtau
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, &
532 n, nel, n_gl)
533 call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
534 coef, coef_gl, gll_to_gl, tau, dtau, &
535 n, nel, n_gl)
536 call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
537 coef, coef_gl, gll_to_gl, tau, dtau, &
538 n, nel, n_gl)
539 tau = tau1
540 end do
541 end do
542
543 end associate
544
545 end subroutine adv_oifs_compute
558 subroutine adv_oifs_compute_scalar(this, vx, vy, vz, s, fs, Xh, coef, n, dt)
559 implicit none
560 class(adv_oifs_t), intent(inout) :: this
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
568
569 real(kind=dp) :: tau, tau1, th, dtau
570 integer :: i, ilag, itau, nel, n_GL
571 nel = coef%msh%nelv
572 n_gl = nel * this%Xh_GL%lxyz
573
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)
584
585 call dtime%init(oifs_scheme%ndiff)
586
587 tau = ctlag(oifs_scheme%ndiff)
588
589 call this%set_conv_velocity_fst(vx, vy, vz)
590
591 if (neko_bcknd_device .eq. 1) then
592 call device_rzero(fs%x_d,n)
593 else
594 call rzero(fs%x,n)
595 end if
596
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)
602 else
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)
605 end if
606 else
607 if (ilag .eq. 1) then
608 do i = 1, n
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)
612 end do
613 else
614 do i = 1, n
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)
618 end do
619 end if
620 end if
621 dtau = dctlag(ilag)/real(ntaubd)
622 do itau = 1, ntaubd
623 th = tau + dtau/2.
624 tau1 = tau + dtau
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, &
636 n, nel, n_gl)
637 tau = tau1
638 end do
639 end do
640
641 end associate
642
643 end subroutine adv_oifs_compute_scalar
644 subroutine recompute_metrics_oifs(this, coef, moving_boundary)
645 class(adv_oifs_t), intent(inout) :: this
646 type(coef_t), intent(in) :: coef
647 logical, intent(in) :: moving_boundary
648 ! no-op
649 end subroutine recompute_metrics_oifs
650
651
652 subroutine adv_oifs_compute_ale(this, vx, vy, vz, wm_x, wm_y, wm_z, &
653 fx, fy, fz, Xh, coef, n, dt)
654 class(adv_oifs_t), intent(inout) :: this
655 type(field_t), intent(inout) :: vx, vy, vz
656 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
657 type(field_t), intent(inout) :: fx, fy, fz
658 type(space_t), intent(in) :: Xh
659 type(coef_t), intent(in) :: coef
660 integer, intent(in) :: n
661 real(kind=rp), intent(in), optional :: dt
662 ! no-op
663 end subroutine adv_oifs_compute_ale
664end module adv_oifs
double real
Map a Fortran array to a device (allocate and associate)
Definition device.F90:83
Unmap a Fortran array from a device (deassociate and free)
Definition device.F90:89
Subroutines to add advection terms to the RHS of a transport equation.
Definition adv_oifs.f90:34
subroutine adv_oifs_compute_scalar(this, vx, vy, vz, s, fs, xh, coef, n, dt)
Add the advection term for a scalar, i.e. , to the RHS.
Definition adv_oifs.f90:559
subroutine adv_oifs_compute_ale(this, vx, vy, vz, wm_x, wm_y, wm_z, fx, fy, fz, xh, coef, n, dt)
Definition adv_oifs.f90:654
subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, xh, coef, n, dt)
Add the advection term for the fluid, i.e. , to the RHS using the OIFS method.
Definition adv_oifs.f90:429
subroutine recompute_metrics_oifs(this, coef, moving_boundary)
Definition adv_oifs.f90:645
subroutine set_conv_velocity_fst(this, u, v, w)
Mapping the velocity fields to GL space and transforming them to the rst format.
Definition adv_oifs.f90:390
subroutine adv_oifs_init(this, lxd, coef, ctarget, ulag, vlag, wlag, dtlag, tlag, time_scheme, slag)
Constructor.
Definition adv_oifs.f90:136
subroutine adv_oifs_free(this)
Destructor.
Definition adv_oifs.f90:285
Subroutines to add advection terms to the RHS of a transport equation.
Definition advection.f90:34
Coefficients.
Definition coef.f90:34
subroutine, public device_rzero(a_d, n, strm)
Zero a real vector.
subroutine, public device_addcol3s2(a_d, b_d, c_d, s, n, strm)
Returns .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
Contains the field_serties_t type.
Defines a field.
Definition field.f90:34
Routines to interpolate between different spaces.
Definition math.f90:60
subroutine, public copy(a, b, n)
Copy a vector .
Definition math.f90:294
subroutine, public rzero(a, n)
Zero a real vector.
Definition math.f90:238
Build configurations.
integer, parameter neko_bcknd_sx
integer, parameter neko_bcknd_device
integer, parameter neko_bcknd_xsmm
integer, parameter, public dp
Definition num_types.f90:10
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Operators.
Definition operators.f90:34
subroutine, public set_convect_rst(cr, cs, ct, cx, cy, cz, xh, coef)
Transforms the convecting velocity field to the rst form of the GL space.
subroutine, public runge_kutta(phi, conv_k1, conv_k23, conv_k4, xh_gll, xh_gl, coef, coef_gl, gll_to_gl, tau, dtau, n, nel, n_gl)
Compute one step of Runge Kutta time interpolation for OIFS scheme.
Defines a function space.
Definition space.f90:34
integer, parameter, public gl
Definition space.f90:50
Implements type time_interpolator_t.
Compound scheme for the advection and diffusion operators in a transport equation.
Base class for time integration schemes.
Base abstract type for computing the advection operator.
Definition advection.f90:46
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:93
field_list_t, To be able to group fields together
Stores a series (sequence) of fields, logically connected to a base field, and arranged according to ...
Interpolation between two space::space_t.
The function space for the SEM solution fields.
Definition space.f90:64
Provides a tool to perform interpolation in time.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...
#define max(a, b)
Definition tensor.cu:40